Examples of TypeIncubator


Examples of com.sun.msv.datatype.xsd.TypeIncubator

   * @param xsdRestriction DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  private XSDatatype deriveSimpleType(XSDatatype baseType,
                                      Element xsdRestriction) {
    TypeIncubator incubator = new TypeIncubator(baseType);
    ValidationContext context = null;

    try {
      for (Iterator iter = xsdRestriction.elementIterator(); iter
          .hasNext();) {
        Element element = (Element) iter.next();
        String name = element.getName();
        String value = element.attributeValue("value");
        boolean fixed = AttributeHelper.booleanValue(element, "fixed");

        // add facet
        incubator.addFacet(name, value, fixed, context);
      }

      // derive a new type by those facets
      String newTypeName = null;

      return incubator.derive("", newTypeName);
    } catch (DatatypeException e) {
      onSchemaError("Invalid restriction: " + e.getMessage()
          + " when trying to build restriction: " + xsdRestriction);

      return null;
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

       
        return new XSDatatypeExp(nsUri,localName,reader,new XSDatatypeExp.Renderer(){
            public XSDatatype render( XSDatatypeExp.RenderingContext context )
                    throws DatatypeException {
               
                TypeIncubator ti = new TypeIncubator( baseType.getType(context) );
               
                Iterator itr = facets.iterator();
                for( int i=0; i<facetSize; i++ ) {
                    Facet f = (Facet)itr.next();
                    ti.addFacet( f.name, f.value, f.fixed, f.context );
                }
                return ti.derive(nsUri,localName);
            }
        });
    }
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

        if( isLateBind() )
            return new LazyTypeIncubator(this,ownerState.reader);
       
        // normal incubator
        return new XSTypeIncubator() {
            private final TypeIncubator core = new TypeIncubator(dt);
           
            public void addFacet( String name, String value, boolean fixed, ValidationContext context ) throws DatatypeException {
                core.addFacet(name,value,fixed,context);
            }
            public XSDatatypeExp derive(String uri,String localName) throws DatatypeException {
                return new XSDatatypeExp( core.derive(uri,localName), pool );
            }
        };
    }
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

   
    final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
   
    // TypeIncubator is used to "incubate" a type by adding facets.
    // constructor accepts the base type instance.
    TypeIncubator incubator = new TypeIncubator(StringType.theInstance);
   
    while(true)
    {
      try
      {
        System.out.print("-->");
        String s = in.readLine();
        StringTokenizer tokens = new StringTokenizer(s);
     
        String cmd = tokens.nextToken();
     
        if( cmd.equals("base") )
        {
          String typeName = tokens.nextToken();
         
          // to obtain a type by name, call this method.
          XSDatatype dt = DatatypeFactory.getTypeByName(typeName);
          if(dt==null)
          {// if the name is not recognized, null is returned.
            System.out.println("no such type");
            continue;
          }
          incubator = new TypeIncubator(dt);
          continue;
        }
        if( cmd.equals("add") )
        {
          String facetName = tokens.nextToken();
          String facetValue = tokens.nextToken();
          // to add a facet, call add method.
          // you MUST supply a valid ValidationContextProvider,
          // although this example omits one.
          incubator.addFacet( facetName, facetValue, false, null );
          continue;
        }
        if( cmd.equals("test") )
        {
          String value = tokens.nextToken();
                   
          // a type can be derived by derive method.
          // the new type contains all facets that were added.
          XSDatatype dt = incubator.derive("","anonymous");
         
          // check validity.
          if( dt.isValid(value,null) )
            // verify method returns true if the value is valid.
            System.out.println("valid value");
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

class DatatypeBuilderImpl implements DatatypeBuilder {
   
    private TypeIncubator incubator;
       
    DatatypeBuilderImpl( XSDatatype baseType ) {
        incubator = new TypeIncubator(baseType);
    }
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

       
        if( name.equals(XSDatatype.FACET_PATTERN) )
            // if the pattern facet is specified, we have to
            // derive a new type so that multiple pattern facets can
            // work as ANDing.
            incubator = new TypeIncubator(incubator.derive(null,null));
    }
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

     *
     * @return DOCUMENT ME!
     */
    private XSDatatype deriveSimpleType(XSDatatype baseType,
            Element xsdRestriction) {
        TypeIncubator incubator = new TypeIncubator(baseType);
        ValidationContext context = null;

        try {
            for (Iterator iter = xsdRestriction.elementIterator(); iter
                    .hasNext();) {
                Element element = (Element) iter.next();
                String name = element.getName();
                String value = element.attributeValue("value");
                boolean fixed = AttributeHelper.booleanValue(element, "fixed");

                // add facet
                incubator.addFacet(name, value, fixed, context);
            }

            // derive a new type by those facets
            String newTypeName = null;

            return incubator.derive("", newTypeName);
        } catch (DatatypeException e) {
            onSchemaError("Invalid restriction: " + e.getMessage()
                    + " when trying to build restriction: " + xsdRestriction);

            return null;
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

/* 443 */     return null;
/*     */   }
/*     */
/*     */   private XSDatatype deriveSimpleType(XSDatatype baseType, Element xsdRestriction)
/*     */   {
/* 458 */     TypeIncubator incubator = new TypeIncubator(baseType);
/* 459 */     ValidationContext context = null;
/*     */     try
/*     */     {
/* 462 */       Iterator iter = xsdRestriction.elementIterator();
/* 463 */       while (iter.hasNext()) {
/* 464 */         Element element = (Element)iter.next();
/* 465 */         String name = element.getName();
/* 466 */         String value = element.attributeValue("value");
/* 467 */         boolean fixed = AttributeHelper.booleanValue(element, "fixed");
/*     */
/* 470 */         incubator.addFacet(name, value, fixed, context);
/*     */       }
/*     */
/* 474 */       String newTypeName = null;
/*     */
/* 476 */       return incubator.derive("", newTypeName);
/*     */     } catch (DatatypeException e) {
/* 478 */       onSchemaError("Invalid restriction: " + e.getMessage() + " when trying to build restriction: " + xsdRestriction);
/*     */     }
/*     */
/* 481 */     return null;
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

        while(true)
        {
            if((cnt%500)==0 && cnt!=0 )    out.print("\r"+cnt+"    ");
           
            if( !pattern.hasMore() )    break;
            final TypeIncubator ti = new TypeIncubator(baseType);
            String answer;
           
            try
            {
                answer = TestPatternGenerator.merge( baseAnswer, pattern.get(ti), true );
            }
            catch( DatatypeException bte )
            {// ignore this error
                pattern.next();
                continue;
            }
           
            // derive a type with test facets.
            XSDatatype typeObj=null;
            try
            {
                typeObj = ti.derive("anonymousURI","anonymousLocal");
            }
            catch( DatatypeException bte )
            {
                err.reportTestCaseError(baseType,ti,bte);
            }
View Full Code Here

Examples of com.sun.msv.datatype.xsd.TypeIncubator

       
        return new XSDatatypeExp(nsUri,localName,reader,new XSDatatypeExp.Renderer(){
            public XSDatatype render( XSDatatypeExp.RenderingContext context )
                    throws DatatypeException {
               
                TypeIncubator ti = new TypeIncubator( baseType.getType(context) );
               
                Iterator itr = facets.iterator();
                for( int i=0; i<facetSize; i++ ) {
                    Facet f = (Facet)itr.next();
                    ti.addFacet( f.name, f.value, f.fixed, f.context );
                }
                return ti.derive(nsUri,localName);
            }
        });
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.