Package com.sun.msv.util

Examples of com.sun.msv.util.StringPair


     *         <li>it's in the 'base" name class and
     *         <li>it's not one of those excluded names
     */
    public LaxDefaultNameClass( NameClass _base ) {
        this.base = _base;
        names.add( new StringPair(NAMESPACE_WILDCARD,LOCALNAME_WILDCARD) );
    }
View Full Code Here


     */
    protected NameClass equivalentNameClass;
   
    public boolean accepts( String namespaceURI, String localName ) {
        return base.accepts(namespaceURI,localName) &&
                !names.contains( new StringPair(namespaceURI,localName) );
    }
View Full Code Here

   
    /**
     * add a name so that this name will be rejected by the accepts method.
     */
    public void addName( String namespaceURI, String localName ) {
        names.add( new StringPair(namespaceURI,localName) );
        names.add( new StringPair(namespaceURI,LOCALNAME_WILDCARD) );
        names.add( new StringPair(NAMESPACE_WILDCARD,localName) );
    }
View Full Code Here

       
        Set uris = new java.util.HashSet();
       
        Iterator itr = possibleNames.iterator();
        while( itr.hasNext() ) {
            StringPair name = (StringPair)itr.next();
            if( name.localName!=MAGIC ) {
                // a simple name.
                if( nc.accepts(name)==nc.accepts( name.namespaceURI, MAGIC ) ) {
                    itr.remove();
                    continue;
                }
            } else
            if( name.namespaceURI!=MAGIC ) {
                // a ns name
                if( nc.accepts(name)==nc.accepts(MAGIC,MAGIC) ) {
                    itr.remove();
                    continue;
                }
            }
           
            // collect the remainig namespace URIs.
            if( name.namespaceURI!=MAGIC )
                uris.add(name.namespaceURI);
        }
       
        if( !nc.accepts(MAGIC,MAGIC) )
            possibleNames.remove( new StringPair(MAGIC,MAGIC) );
       
        NameClass result = null;
        Iterator jtr = uris.iterator();
        while( jtr.hasNext() ) {
            final String uri = (String)jtr.next();
           
            NameClass local = null;
            itr = possibleNames.iterator();
            while( itr.hasNext() ) {
                final StringPair name = (StringPair)itr.next();
               
                if(!name.namespaceURI.equals(uri))        continue;
                if(name.localName==MAGIC)                continue;
               
                if(local==null)    local = new SimpleNameClass(name);
                else            local = new ChoiceNameClass(local,new SimpleNameClass(name));
            }
            if(possibleNames.contains(new StringPair(uri,MAGIC))) {
                if(local==null)
                    local = new NamespaceNameClass(uri);
                else
                    local = new DifferenceNameClass(new NamespaceNameClass(uri),local);
            }
View Full Code Here

            throws SAXException {
       
        // create Datatype that validates attribute value.
        Datatype dt = createDatatype(attributeType);
       
        StringPair str = new StringPair("",attributeType);
       
        if(enums!=null) {
            Expression exp = Expression.nullSet;
            for( int i=0; i<enums.length; i++ )
                exp = grammar.pool.createChoice( exp,
View Full Code Here

        final RELAXNGReader reader = (RELAXNGReader)this.reader;
        String typeName = startTag.getCollapsedAttribute("type");
       
        Datatype type;
       
        StringPair typeFullName;
       
        if(typeName==null) {
            try {
                // defaults to built-in token type.
                type = reader.resolveDataTypeLibrary("").createDatatype("token");
                typeFullName = new StringPair("","token");
            } catch( DatatypeException e ) {
                // since token is the built-in datatype,
                // this can't happen
                e.printStackTrace();
                throw new InternalError();
            }
        } else {
            type = reader.resolveDataType(typeName);
            typeFullName = new StringPair(reader.datatypeLibURI,typeName);
        }
       
        Object value = type.createValue(text.toString(),reader);
        if( value==null ) {
            // this is not a good value for this type.
View Full Code Here

        if( fixed!=null )
            // TODO: is this 'fixed' value should be added through enumeration facet?
            // TODO: check if content model is a simpleType.
            contentType = reader.pool.createValue(
                com.sun.msv.datatype.xsd.TokenType.theInstance,
                new StringPair("","token"), fixed ); // emulate RELAX NG built-in token type
       
       
        ElementDeclExp decl;
        if( isGlobal() ) {
            decl = reader.currentSchema.elementDecls.getOrCreate(name);
View Full Code Here

 
  public StringPair generate( NameClass nc ) {
    if( nc instanceof SimpleNameClass ) {
      // 90% is SimpleNameClass. So this check makes
      // the computation faster.
      return new StringPair(
        ((SimpleNameClass)nc).namespaceURI,
        ((SimpleNameClass)nc).localName );
        }
   
    final String MAGIC = ".";
    final Set possibleNames = new java.util.HashSet();
   
    // collect possible names
    nc.visit( new NameClassVisitor(){
      public Object onNsName( NamespaceNameClass nc ) {
        possibleNames.add( new StringPair(nc.namespaceURI, MAGIC) );
        return null;
      }
 
      public Object onSimple( SimpleNameClass nc ) {
        possibleNames.add( new StringPair(nc.namespaceURI, nc.localName) );
        return null;
      }
 
      public Object onAnyName( AnyNameClass nc ){
        possibleNames.add( new StringPair(MAGIC, MAGIC) );
        return null;
      }
 
      public Object onChoice( ChoiceNameClass nc ) {
        nc.nc1.visit(this);
        nc.nc2.visit(this);
        return null;
      }
 
      public Object onNot( NotNameClass nc ) {
        possibleNames.add( new StringPair(MAGIC, MAGIC) );
        nc.child.visit(this);
        return null;
      }
 
      public Object onDifference( DifferenceNameClass nc ) {
        nc.nc1.visit(this);
        nc.nc2.visit(this);
        return null;
      }
    });
   
    // remove failed items
    Iterator itr = possibleNames.iterator();
    while( itr.hasNext() ) {
      StringPair p = (StringPair)itr.next();
      if( !nc.accepts( p.namespaceURI, p.localName ) )
        itr.remove();
    }
   
    if( possibleNames.size()==0 )
      throw new Error("name class that accepts nothing");
   
    // randomly pick one.
    StringPair model = (StringPair)
      possibleNames.toArray()[ random.nextInt(possibleNames.size()) ];
   
    StringPair answer;
    do {
      // expand wild card
      answer = new StringPair(
        model.namespaceURI==MAGIC?getRandomURI():model.namespaceURI,
        model.localName==MAGIC?getRandomName():model.localName );
    }while( !nc.accepts(answer.namespaceURI,answer.localName) );
   
    return answer;
View Full Code Here

        return new ExpressionPair(content, continuation);
    }

    /** computes a combined child content pattern and (,if possible,) its continuation. */
    public ExpressionPair get(Expression combinedPattern, StartTagInfo info) {
        StringPair sp = null;

        // check the cache
        if (combinedPattern.verifierTag != null) {
            OptimizationTag ot = (OptimizationTag)combinedPattern.verifierTag;
            sp = new StringPair(info.namespaceURI, info.localName);
            OptimizationTag.OwnerAndCont cache = (OptimizationTag.OwnerAndCont)ot.transitions.get(sp);

            if (cache != null) {
                // cache hit
                numElements = 1;
                result[0] = cache.owner;
                return new ExpressionPair(cache.owner.contentModel.getExpandedExp(pool), cache.continuation);
            }
        }

        ExpressionPair r = (ExpressionPair)get(combinedPattern, info, true);

        if (numElements == 1) {
            // only one element matchs this tag name. cache this result
            OptimizationTag ot = (OptimizationTag)combinedPattern.verifierTag;
            if (ot == null)
                combinedPattern.verifierTag = ot = new OptimizationTag();

            if (sp == null)
                sp = new StringPair(info.namespaceURI, info.localName);

            ot.transitions.put(sp, new OptimizationTag.OwnerAndCont(result[0], r.continuation));
        }
        return r;
    }
View Full Code Here

            if( args[i].equals("-root") ) {
                String root = args[++i];
                int idx = root.indexOf('}');
                if(idx<0)
                    // short form XXX
                    rootName = new StringPair( "", root );
                else
                    // full form {XXX}YYY
                    rootName = new StringPair( root.substring(1,idx), root.substring(idx+1) );
            }
            else
      if( args[i].equalsIgnoreCase("-encoding") )
        encoding = args[++i];
      else
View Full Code Here

TOP

Related Classes of com.sun.msv.util.StringPair

Copyright © 2018 www.massapicom. 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.