Range Validation in Java

Hi,
I am having a doubt in Range Validation
I having the following as input, i will maintain a Default Values,
StartId, EndId as Constant in my program
Example :
StartID= "0000000" Format will be "XXXXXXX"
EndID = "0000100" Format will be "XXXXXXX"
From the UI, i will have the option to enter a text. If the User has to enter the same Format "XXXXXXX", the format validation I performed using reg Expression,
I need to perform the Range validation here, if the user Enters value say
"0000700" < it is not within the StartId & EndId Range, then i need to say Error.
How can i perform Range Validation in java.?
Any Ideas please..

It can be done with regexp but it's probably easier to parse the start and end ids and the entered value into integers and perform the validation using a normal if statement.

Similar Messages

  • Threadinar13 - Double Range, Length & Long Range Validator Components

    Hi All,
    This is the thirteenth in the Threadinar series. See the Components Threadinar Index at http://forum.sun.com/jive/thread.jspa?threadID=103424 for the complete list to date.
    This Threadinar will discuss the 3 components in the "Components Palette: Validator Section" of the Creator Component Catalog.
    The components we will focus on today are
    "Double Range Validator", "Length Validator" & "Long Range Validator" Components.
    Let us begin our discussion with the "Double Range Validator" Component.
    [b]What Is a Validator?
    If your application collects information from users, for example a login and a password, then it is important that you verify the user data. The IDE provides a set of components for validating user input. These validators, which you access from the Validators section of the Components Palette, are as follows:
    [b]Double Range Validator Component
    A Double Range validator is typically used to validate that the value of a component does not exceed the standard range of the Java double data type. This data type represents a double floating-point number that ranges from �439E-324 to �1.7976931348623157E+308. Typically, the way you add a validator to a JavaServer Faces component is to edit the component's validator property, which provides a drop-down list from which you can select a validator.
    Use a Double Range validator to test whether the user has entered a double data type value within the range defined by the specified minimum and maximum values. The value must be floating-point or convertible to floating-point.
    [b]Length Validator Component
    A Length validator is used to validate that the length of text entered for a component is no shorter or longer than the values you specify for the validator's min and max properties. The validation occurs after the page is submitted. Typically, the way you add a validator to a JavaServer Faces component is to edit the component's validator property, which provides a drop-down list from which you can select a validator.
    Use a Length validator to test whether user has entered a string of a length defined by the specified minimum and maximum values. The value must be a java.lang.String.
    [b]Long Range Validator Component
    A Long Range validator is used to validate that the value of a component does not exceed the standard range of the Java long data type. This data type is a signed integer that ranges from -263 to 263-1, or
    -9223372036854775808 to 9223372036854775807. Typically, the way you add a validator to a JavaServer Faces component is to edit the component's validator property, which provides a drop-down list from which you can select a validator.
    Use a Long Range validator to test whether user has entered an integer of a size defined by the specified minimum and maximum values. The value must be any numeric type or String that can be converted to a long.
    You can use more than one validator on an input component to validate for different criteria. When you use a validator, your component also needs a message component to indicate when the validation fails.
    [b]See Also
    For more details on
    "Using Validators", Please see the tutorial at
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/validators_converters.html
    Customizing a Standard Validator Message
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/custommessage.html
    and
    Adding Your Own Validation Handler
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/customvalidator.html
    Please share your comments, experiences, additional information, questions, feedback, etc. on these components.

    .

  • How to write validation in java sript item should not allow more than 20 ch

    HI,
    I need to write validation in java script for a item it should not allow more than 20 characters.
    Thanks
    Nr

    If this answers your question, please mark your question as answered (so everyone knows it is answered) and assign points where you see fit..
    Thank you,
    Tony Miller
    Webster, TX

  • Range validations in web dynpro

    Hi experts,
    can you please tell me How to perform Range validations in web dynpro applications ?
    Advance Thanks,
    Namrata.

    Hi Namrata,
    Create a Simple Type (Local Dictonary -> DataTypes -> SimpleTypes). Enter either Length constraints / value constraints in the simple type. Bind this simple type to the context attribute. Whenever you are performing an action framework generated error message will be displayed based on the constraints you designed in simple type.
    Thanks
    Madhu

  • DOM validation using Java is extremely slow

    I have a large XML file ~8MB. When I do validation on it using java api, takes ~5 hours to process it.
    I have narrowed down the problem to xs:unique rules in the schema file. When I remove these rules, validation takes ~1 min.
    I have tried using MSXML parser with unique rules and it take about 30 min.
    My question is how could I speed up the validation in Java with these unique rules in the schema.
    Any help will be greatly appreciated.
    Thanks.

    Basically, you are saying removing the unique elements
    from schema and do the checking myself. This means
    everytime the schema is updated with new unique rules,
    I will have to modify the code to check for unique
    elements.
    Is there any other way to tackle this problem?You can choose what processing is done with the XML parser, and what is done within java, if you control the schema. Uniqueness is one that I have preferred to perform in java, since I often perform other validations in java anyway, and it works well. Just my opinion.
    If you post some XML/XSD code and list the parser you are using, someone that uses xs:unique may find something they can help you with.
    -Scott

  • DB procedure validation versus JAVA method validation

    Hi ,
    We have an application that is developed with Oracle Forms as well as Java (ADF )
    Now since ADF is the newer application, it was told to reduce the development time but provide efficient code. Now with Forms each field validation called a procedure and returned an error.
    For example if Name is validated, They have a procedure VALIDATE_NAME proc. Why they have separated this is cause based on different customers and different products, the name validation differs. So the in parameters are Field val, Product, customertype... etc. Like this, there are 20 VALIDATE_FIELD procedures for respective fields.
    Now to reduce duplication, I can call each procedure on each field. but that would means 20 DB additional calls for each procedure. If I write this logic in java it means I increase development time and probably increase probability of error.
    Which is the best practice for VALIDATION.

    Hi,
    you already mentioned the pros and cons of the approaches. I don't think that it is good practice to directly call the PLSQL validation from Java as it means you wont be able to change it easily in the future. I would look for an abstraction layer that initially (for the time being) accesses the database for validation (maybe caching some validation policies upon application instance start) and later then can be changed to use pure Java validation rules. One thing coming to my mind would be something like a rules engine that reads the validation conditions from the database and that is accessed from Java. If your manager says you should reduce development time then my impression is that the choice is not yours and you will have to use the database (though it feels wrong).
    Frank

  • Validation of Java Version

    Hello,
    I'm building a program that before it runs the program need to verify the version of Java.
    If the version is less that version 1.4, the program won't start.
    How I make the validation of Java version ?
    tks

    Ok.
    But, this command return a value String.
    In general, the version is like 1.4.2_03.
    Then, How I compare whith others versions ?
    Example,
    My program will run only in the Java version bigger than 1.3.
    The command getProperty return the string 1.4.2_03.
    It's my problem ...
    Tks

  • Range validation

    Hi all,
    What would be better way if I need to do a range validation.
    Lets say, I have a lv_range with value 'X01','X02','X03'.........until 'X50'.
    Now I want to do a checking like this: -
    IF lv_range is 'X01' to 'X10'.
    DO ABC.
    ELSEIF  lv_range is 'X11' to 'X20'.
    DO ABC1.
    ELSEIF  lv_range is 'X21' to 'X30'.
    DO ABC2.
    ELSE.
    DO ABC3.
    ENDIF.
    Thanks in advance.

    Other than using
    IF lv_range GE  'X01' AND lv_range LE 'X10'.
    it looks fine to me.
    matt

  • Flex validation in Java

    I am using a product called Crystal Xcelsius to design and
    develop dashboards for banking customers. The product using Flex
    controls with an Excel spreadsheet to show data. It then supports
    data connections to refresh or update that data. After setting all
    this up, it compiles it down to a Flash (SWF) file that can be
    delivered to our client.
    On the client's machine, the SWF file is loaded into a
    database and then served up to the users as needed. Also loaded
    into the database are the SQL queries which will be used to provide
    the data needed to refresh the connections.
    These SWF files and queries can be provided by us, but we
    also let our clients use Xcelsius to create their own and then
    upload them into our application. What I am looking for is a way to
    validate the SWF file as part of the import process. Specifically,
    since they are providing an SWF and a set of queries with
    connection names and range names, I want to parse the SWF file and
    make sure that the data connections in the SWF file match the
    queries that they have provided with the SWF file. I want to make
    sure that all connections in the SWF file have queries provided,
    and that there are no queries that were provided which don't map to
    connections in the SWF file.
    I can take care of the mapping, the part I don't know about
    is getting the list of connections specified in the SWF file. Since
    the server that is importing these files is running Java, are there
    any Java components or libraries I can use to look into a SWF file
    and get the list of data connections in the file?
    Any help, thoughts, or suggestions would be appreciated.
    -Benjamin

    James,
    If you want client-side validation you must use vbscript or preferrable javascript.
    To do client-side validation in your get or post method use java to validate the incoming paramters.
    By the way if you move to a jsps/struts/jsf environment you'll get more help from the system in dealing with these kinds of problems. Developing sizable applications using only servlets will be very difficult.

  • Problem with XSD validation in Java 5

    Hi everyone,
    my application creates in memory schema using JDOM. In Java 6 validation runs fine, but in Java 5 (which is the target platform currently) it fails.
    I tried a second test with just parsing an existing XSD document (not created using JDOM) and that works.
    The textual representation of both (file and JDOM generated) are identical. If I replace the XSD file with the JDOM output, the "file test" runs fine, too.
    Here's the test code:
        protected void assertXsdValid(Source xsdSource, InputSource xmlInputSource) throws SAXException, ParserConfigurationException, IOException {
            isValid = true;
            SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            sf.setErrorHandler(myErrorHandler);
            Schema schema = sf.newSchema(xsdSource); // <<--------- THIS LINE FAILS IN JAVA 5
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            dbf.setSchema(schema);
            DocumentBuilder db = dbf.newDocumentBuilder();
            db.setErrorHandler(myErrorHandler);
            db.parse(xmlInputSource);
            assertTrue(isValid);
        }This is the XSD:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://some.org/metamodel" elementFormDefault="qualified">
      <xs:element name="system">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string" />
            <xs:element name="vendor" type="xs:string" />
            <xs:element name="version" type="xs:decimal" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>This is the error message I get:
    ERROR: org.xml.sax.SAXParseException: s4s-att-invalid-value: Invalid attribute value for 'type' in element 'element'. Recorded reason: UndeclaredPrefix: Cannot resolve 'xs:string' as a QName: the prefix 'xs' is not declared.
    This is how I call the test code in the JDOM test:
            assertXsdValid(new JDOMSource(xsdDoc), new JDOMSource(xmlDoc).getInputSource());If I change the code to parsing not the JDOMSource, but a StreamSource reading the textual representation of the XSD, it works fine!
            assertXsdValid(new StreamSource(new ByteArrayInputStream(new XMLOutputter().outputString(xsdDoc).getBytes())), new JDOMSource(xmlDoc).getInputSource());But this is not what I want (I expect suboptimal performance with large XSD documents). So, if it works with Java 6, then why doesn't it work with Java 5?
    How can I use the Java 6 JAXP in Java 5?
    Thank you.

    A new user name?
    I can think of ways round your problem but can you first provide a reference that indicates that byte 0x80 is the MS936 encoding for the Euro?
    P.S. This is a forum and the vast majority of participants, including me, have no direct relationship with Oracle so getting definitive answers from Oracle via this forum is unlikely. If you think you have found a bug in 1.5 and/or 1.6, and I am not convinced you have, you need to report it via the bug database. If it is a bug then the response time for a fix is likely to be months rather than days.
    P.P.S No I can't explain why it works in 1.7!

  • Xml vs schema validation by java multimapping: ParserException

    Hello guys,
    I was looking for an answer everywhere, but with no succes.
    Problem:
    I am using SAP NetWeaver BI 7.0
    My interface mapping looks like this:
    1 XML INPUT ---> JAVA MAPPING ---> n XML OUTPUTS
    O found out, tha by setting occurence to "0..onbounded", causes, that also input is comming as "0..onbounded" xml. That I don't understant, but OK, can live with that. In runtime it looks that on the output, my xml root element is wrapped to this structure:
    <b>Messages
    |__Message1
        |__SDS_XSD_ZPPM_POB</b>
    What is frustrated problem for me, that I need to validate on the output in my Java Mapping the xml document against the schema but I always get this error:
    <i>Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    ERRORS :
    cvc-element : element information item '/:Messages[1]' is not associated with element declaration and do not has an attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is type.</i>
    This is the begin of the xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <Messages xmlns="http://xxx.sk/is_xx">
       <Message1>
          <SDS_XSD_ZPPM_POB>
    This is the begin of the schema definition:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="http://sap.com/xi/XI/SplitAndMerge" xmlns:p0="http://xxx.sk/is_xx"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://sap.com/xi/XI/SplitAndMerge">
       <xsd:element name="Messages" xmlns:p0="http://xxx.sk/is_xx">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element name="Message1" form="qualified">
                   <xsd:complexType>
                      <xsd:sequence>
                         <xsd:element ref="SDS_XSD_ZPPM_POB" minOccurs="0" maxOccurs="unbounded"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
                      </xsd:sequence>
                   </xsd:complexType>
                </xsd:element>
             </xsd:sequence>
          </xsd:complexType>
       </xsd:element>
    Without validation everything works perfect.
    CAN ANYBODY HELP WITH SOME CLUE?
    Thanks a lot
    Rasto
    Message was edited by:
            Peter Guzik

    No I didn't.
    Here is the result of my fixes:
    <b>XML:</b>
    <?xml version="1.0" encoding="UTF-8"?>
    <Messages xmlns="http://sap.com/xi/XI/SplitAndMerge">
       <Message1>
          <SDS_XSD_ZPPM_POB>
             <pob>010</pob>
    <b>XSD:</b>
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="http://sap.com/xi/XI/SplitAndMerge" xmlns:p0="http://xxx.sk/is_sds"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://sap.com/xi/XI/SplitAndMerge">
       <xsd:element name="Messages">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element name="Message1" form="qualified">
                   <xsd:complexType>
                      <xsd:sequence>
                         <xsd:element ref="SDS_XSD_ZPPM_POB" minOccurs="0" maxOccurs="unbounded"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
                      </xsd:sequence>
    <b>RESULT EXCEPTION:</b>
    Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    ERRORS :
    cvc-element : element information item '/:Messages[1]/:Message1[1]/:SDS_XSD_ZPPM_POB[1]/:pob[1]' is not associated with element declaration and do not has an attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is type.
    cvc-element : element information item '/:Messages[1]/:Message1[1]/:SDS_XSD_ZPPM_POB[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:Messages[1]/:Message1[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:Messages[1]' is not valid with respect to it's complex type definition..
    If there is an error in xml, according this message it is impossible to find it..

  • Date range validity evaluation in BRM table

    Lectori salutem, Gurus salutem,
    I'm using 7.3 sp03. I would like to achieve the following with BRM (bit simplified):
    a parameter, ABC, is passed to a ruleSetService, and needs to be evaluated.
    The table is as follows:
    ABC startDate endDate Value
    1 01-01-2011 31-12-2011 A
    1 01-01-2012 31-12-2012 B
    2 01-01-2011 31-12-2011 X
    4 01-01-2012 31-12-2012 Y
    When ABC-value '1' is passed to the ruleSetService in the table the first row needs to be selected. CurrentDate (24-11-2011) is in between 01-01-2011 and 31-12-2011, making this the valid row. The value that should be returned is A.
    Beginning of next year it should change to B.
    How should I set this up in BRM?
    Thanks in advance!
    Martijn.

    Hi Martijn,
    Appreciate that you've simplifiied the scenario... but do you have any idea how many of these entries you are likely to have in total as that may change the answer.
    You have a couple of choices that might work here...
    1. You could a decision table... to hold your values (i.e. ABC and date range as conditions, value as action) and use the rule that evaluates the decision table to pick up the current date for the comparison. e.g.  date conditions would be "greater than than 01-01-2011", "less than 31-12-2011", etc.
    2. Alternatively, if the plan is to have a simple end of year change over,  you could use Effectivities (in the Project Resources of the rules project) to determine which values  are selected and use a decision table or even just a rule script to determine the value.
    But the thing is... HOW you organise your rule is going to depend a lot on:
    a) How many entries in total do you expect
    b) Is there a nice neat cutover of all ABC values at the same time or do effective date ranges vary a lot between different ABC values
    c) Who's responsible for maintaining these and if multiiple people are responsible do you need to organise your rule to cater for that? E.g. Are different people responsible for different ABC entries
    Does that help at all?
    Regards,
    Jocelyn

  • XML Validation using java for SQL Injection and script validation

    I have an input coming from xml file.
    I have to read that input and validate the input against sql injections and scripts.
    I require help now how to read this xml data and validate against the above two options.
    I am a java developer.
    in this context what is marshelling?

    http://www.ibm.com/developerworks/library/x-javaxmlvalidapi.html?ca=dgr-lnxw07Java-XML-Val
    http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/package-summary.html
    The following code validates the xml against a xml schema
    // define the type of schema - we use W3C:
    String schemaLang = "http://www.w3.org/2001/XMLSchema";
    SchemaFactory factory = SchemaFactory.newInstance(schemaLang);
    Schema schema = factory.newSchema(new StreamSource("sample.xsd"));
    Validator validator = schema.newValidator();
    // at last perform validation:
    validator.validate(new StreamSource("sample.xml"));Message was edited by:
    haishai

  • Trigger validations MDM JAVA API

    Hi all,
    I got an issue trying to invoke the validations in the MDM Web Dynpro using the JAVA API; first of al I m creating the record before the user can edit it; in that first moment, the record is checked out and the validations are not executed, that is right, but later, when the user is editing the record, we want to force the user to type all the information using only a specific event (Save button) but even if the record is correct, the validations messages are still showing in the user interface.
    try {
        ModifyRecordCommand cmd = new ModifyRecordCommand(connectionPool);
        cmd.setRecord(material);
        cmd.setSession(usrSessionIdAdm);
        cmd.execute();
    } catch (ValidationException e) {
        RetrieveValidationsCommand valComm = new RetrieveValidationsCommand(connectionPool);
        valComm.setSession(usrSessionIdAdm);
        valComm.setTupleDefinitionId(tdIdTuple);
        valComm.execute();
        ValidationPropertiesResult valResult = valComm.getValidationPropertiesResult();
        ValidationProperties[] valProp = valResult.getValidations();
    Any idea about how to do it?
    Thank you!
    Claudia
    Edited by: Claudia Gómez on Mar 6, 2012 7:24 PM

    HI,
    are you using MDM Webdynpro component?
    you can call validation via the item detail interface,  no need to call via this command.
    Best regards,
    John

  • [INS-08109]Unexpected error validating input-java.lang.NulpointerException

    RAC 11gR2 Grid installation:
    ================
    I got java.lang.NullpointerException during RAC 11gR2 cluster installation.
    [INS-08109] Unexpected error occurred while validating inputs at state QuickInstallUI'.
    Summary:java.lang.NullpointerException
    Are you sure you want to continue ?
    If you click yes it goes back to where to started and the same error would occurs again if you try again. If you click no it will just exit the installer.
    Any help is appreciated. Thanks.
    I cannot go ahead with this error.
    Please find attached screenshot.
    Before starting ./runInstaller i have done with all prerequisite checks and also run
    ./runcluvfy.sh stage -pre crsinst -n isvm-lnx-brm03,isvm-lnx-brm04 -verbose
    Thanks,

    Very stupid installer !
    I've omitted my email, then pressed no in the next message, it passed that step!

Maybe you are looking for

  • Help with Script created to check log files.

    Hi, I have a program we use in our organization on multiple workstations that connect to a MS SQL 2005 database on a Virtual Microsoft 2008 r2 Server. The program is quite old and programmed around the days when serial connections were the most effic

  • File to multiple files scenario

    Hi there, I will try to explain my scenario. I pick up a file with several lines and I need to create one output file per line - <RECORD> + <LINE_ITEM> + <LINE_ITEM> + <LINE_ITEM> -</RECORD> I set up message mapping and interface mapping target to un

  • Video looks all "squished" and 16:9 creates boarder all around

    Hey, Thought I had this problem fixed. I am trying to export a clip I captured in FCP 5.1. I shot this footage in 24p Advanced with the DVX100. Well it looks squished and it creates a boarder all around instead of creating black bars at the top and b

  • Problems with 2 fact tables

    Hi. I use cmw2_ procedures to create dimensions and cubes. My cube has three dimensions. I have 2 fact views - one includes 3 dimensions, another - 2 dimensions. I tried to map measures to these fact tables - error: exact fetch return more than reque

  • Approval procedure to check and pop up alert when Inventory transfer

    HI Experts, I want to do an approval procedure to check and pop up alert when Inventory transfer To warehouse 01 by Query.how to query for the following statement in Approval Procedure? Regards,