当前位置: 首页>>代码示例>>Java>>正文


Java Grammar类代码示例

本文整理汇总了Java中com.sun.org.apache.xerces.internal.xni.grammars.Grammar的典型用法代码示例。如果您正苦于以下问题:Java Grammar类的具体用法?Java Grammar怎么用?Java Grammar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Grammar类属于com.sun.org.apache.xerces.internal.xni.grammars包,在下文中一共展示了Grammar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preparseGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = (XMLGrammarLoader)fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:XMLGrammarPreparser.java

示例2: getGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Returns the grammar associated to the specified grammar description.
 * Currently, the root element name is used as the key for DTD grammars
 * and the target namespace  is used as the key for Schema grammars.
 *
 * @param desc The Grammar Description.
 */
public Grammar getGrammar(XMLGrammarDescription desc) {
    synchronized (fGrammars) {
        clean();
        int hash = hashCode(desc);
        int index = (hash & 0x7FFFFFFF) % fGrammars.length;
        for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
            Grammar tempGrammar = (Grammar) entry.grammar.get();
            /** If the soft reference has been cleared, remove this entry from the pool. */
            if (tempGrammar == null) {
                removeEntry(entry);
            }
            else if ((entry.hash == hash) && equals(entry.desc, desc)) {
                return tempGrammar;
            }
        }
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SoftReferenceGrammarPool.java

示例3: containsGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Returns true if the grammar pool contains a grammar associated
 * to the specified grammar description. Currently, the root element name
 * is used as the key for DTD grammars and the target namespace  is used
 * as the key for Schema grammars.
 *
 * @param desc The Grammar Description.
 */
public boolean containsGrammar(XMLGrammarDescription desc) {
    synchronized (fGrammars) {
        clean();
        int hash = hashCode(desc);
        int index = (hash & 0x7FFFFFFF) % fGrammars.length;
        for (Entry entry = fGrammars[index]; entry != null ; entry = entry.next) {
            Grammar tempGrammar = (Grammar) entry.grammar.get();
            /** If the soft reference has been cleared, remove this entry from the pool. */
            if (tempGrammar == null) {
                removeEntry(entry);
            }
            else if ((entry.hash == hash) && equals(entry.desc, desc)) {
                return true;
            }
        }
        return false;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:SoftReferenceGrammarPool.java

示例4: retrieveInitialGrammarSet

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
public Grammar [] retrieveInitialGrammarSet (String grammarType) {
    synchronized (fGrammars) {
        int grammarSize = fGrammars.length ;
        Grammar [] tempGrammars = new Grammar[fGrammarCount];
        int pos = 0;
        for (int i = 0; i < grammarSize; i++) {
            for (Entry e = fGrammars[i]; e != null; e = e.next) {
                if (e.desc.getGrammarType().equals(grammarType)) {
                    tempGrammars[pos++] = e.grammar;
                }
            }
        }
        Grammar[] toReturn = new Grammar[pos];
        System.arraycopy(tempGrammars, 0, toReturn, 0, pos);
        return toReturn;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:XMLGrammarPoolImpl.java

示例5: removeGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Removes the grammar associated to the specified grammar description from the
 * grammar pool and returns the removed grammar. Currently, the root element name
 * is used as the key for DTD grammars and the target namespace  is used
 * as the key for Schema grammars.
 *
 * @param desc The Grammar Description.
 * @return     The removed grammar.
 */
public Grammar removeGrammar(XMLGrammarDescription desc) {
    synchronized (fGrammars) {
        int hash = hashCode(desc);
    int index = (hash & 0x7FFFFFFF) % fGrammars.length;
    for (Entry entry = fGrammars[index], prev = null ; entry != null ; prev = entry, entry = entry.next) {
        if ((entry.hash == hash) && equals(entry.desc, desc)) {
            if (prev != null) {
                    prev.next = entry.next;
        }
        else {
            fGrammars[index] = entry.next;
        }
            Grammar tempGrammar = entry.grammar;
            entry.grammar = null;
            fGrammarCount--;
            return tempGrammar;
        }
    }
    return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:XMLGrammarPoolImpl.java

示例6: initGrammarBucket

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
private void initGrammarBucket(){
    if(fGrammarPool != null) {
        Grammar [] initialGrammars = fGrammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
        for (int i = 0; i < initialGrammars.length; i++) {
            // put this grammar into the bucket, along with grammars
            // imported by it (directly or indirectly)
            if (!fGrammarBucket.putGrammar((SchemaGrammar)(initialGrammars[i]), true)) {
                // REVISIT: a conflict between new grammar(s) and grammars
                // in the bucket. What to do? A warning? An exception?
                fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                        "GrammarConflict", null,
                        XMLErrorReporter.SEVERITY_WARNING);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:XMLSchemaLoader.java

示例7: preparseGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Parse a grammar from a location identified by an
 * XMLInputSource.
 * This method also adds this grammar to the XMLGrammarPool
 *
 * @param type The type of the grammar to be constructed
 * @param is The XMLInputSource containing this grammar's
 * information
 * <strong>If a URI is included in the systemId field, the parser will not expand this URI or make it
 * available to the EntityResolver</strong>
 * @return The newly created <code>Grammar</code>.
 * @exception XNIException thrown on an error in grammar
 * construction
 * @exception IOException thrown if an error is encountered
 * in reading the file
 */
public Grammar preparseGrammar(String type, XMLInputSource
            is) throws XNIException, IOException {
    if(fLoaders.containsKey(type)) {
        XMLGrammarLoader gl = fLoaders.get(type);
        // make sure gl's been set up with all the "basic" properties:
        gl.setProperty(SYMBOL_TABLE, fSymbolTable);
        gl.setProperty(ENTITY_RESOLVER, fEntityResolver);
        gl.setProperty(ERROR_REPORTER, fErrorReporter);
        // potentially, not all will support this one...
        if(fGrammarPool != null) {
            try {
                gl.setProperty(GRAMMAR_POOL, fGrammarPool);
            } catch(Exception e) {
                // too bad...
            }
        }
        return gl.loadGrammar(is);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:XMLGrammarPreparser.java

示例8: parseDTD

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
DTDGrammar parseDTD(XMLInputSource is)
            throws IOException {
    XMLEntityResolver resolver = getEntityResolver();
    if(resolver != null) {
        fDTDLoader.setEntityResolver(resolver);
    }
    fDTDLoader.setProperty(ERROR_REPORTER, fErrorReporter);

    // Should check whether the grammar with this namespace is already in
    // the grammar resolver. But since we don't know the target namespace
    // of the document here, we leave such check to the application...
    DTDGrammar grammar = (DTDGrammar)fDTDLoader.loadGrammar(is);
    // by default, hand it off to the grammar pool
    if (grammar != null) {
        fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_DTD,
                                  new Grammar[]{grammar});
    }

    return grammar;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:XMLGrammarCachingConfiguration.java

示例9: getGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Returns the grammar associated to the specified description.
 *
 * @param desc The description of the grammar.
 */
public Grammar getGrammar(XMLGrammarDescription desc) {

    if (super.containsGrammar(desc)) {
        return super.getGrammar(desc);
    }
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:CachingParserPool.java

示例10: parseXMLSchema

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
SchemaGrammar parseXMLSchema(XMLInputSource is)
            throws IOException {
    XMLEntityResolver resolver = getEntityResolver();
    if(resolver != null) {
        fSchemaLoader.setEntityResolver(resolver);
    }
    if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
        fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
    }
    fSchemaLoader.setProperty(ERROR_REPORTER, fErrorReporter);

    String propPrefix = Constants.XERCES_PROPERTY_PREFIX;
    String propName = propPrefix + Constants.SCHEMA_LOCATION;
    fSchemaLoader.setProperty(propName, getProperty(propName));
    propName = propPrefix + Constants.SCHEMA_NONS_LOCATION;
    fSchemaLoader.setProperty(propName, getProperty(propName));
    propName = Constants.JAXP_PROPERTY_PREFIX+Constants.SCHEMA_SOURCE;
    fSchemaLoader.setProperty(propName, getProperty(propName));
    fSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, getFeature(SCHEMA_FULL_CHECKING));

    // Should check whether the grammar with this namespace is already in
    // the grammar resolver. But since we don't know the target namespace
    // of the document here, we leave such check to XSDHandler
    SchemaGrammar grammar = (SchemaGrammar)fSchemaLoader.loadGrammar(is);
    // by default, hand it off to the grammar pool
    if (grammar != null) {
        fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA,
                                  new Grammar[]{grammar});
    }

    return grammar;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:XMLGrammarCachingConfiguration.java

示例11: retrieveInitialGrammarSet

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
public Grammar [] retrieveInitialGrammarSet (String grammarType) {
    synchronized (fGrammars) {
        clean();
        // Return no grammars. This allows the garbage collector to sift
        // out grammars which are not in use when memory demand is high.
        // It also allows the pool to return the "right" schema grammar
        // based on schema locations.
        return ZERO_LENGTH_GRAMMAR_ARRAY;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:SoftReferenceGrammarPool.java

示例12: cacheGrammars

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
public void cacheGrammars(String grammarType, Grammar[] grammars) {
    if (!fPoolIsLocked) {
        for (int i = 0; i < grammars.length; ++i) {
            putGrammar(grammars[i]);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:SoftReferenceGrammarPool.java

示例13: removeGrammar

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Removes the grammar associated to the specified grammar description from the
 * grammar pool and returns the removed grammar. Currently, the root element name
 * is used as the key for DTD grammars and the target namespace  is used
 * as the key for Schema grammars.
 *
 * @param desc The Grammar Description.
 * @return     The removed grammar.
 */
public Grammar removeGrammar(XMLGrammarDescription desc) {
    synchronized (fGrammars) {
        clean();
        int hash = hashCode(desc);
        int index = (hash & 0x7FFFFFFF) % fGrammars.length;
        for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
            if ((entry.hash == hash) && equals(entry.desc, desc)) {
                return removeEntry(entry);
            }
        }
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SoftReferenceGrammarPool.java

示例14: removeEntry

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
/**
 * Removes the given entry from the pool
 *
 * @param entry the entry to remove
 * @return The grammar attached to this entry
 */
private Grammar removeEntry(Entry entry) {
    if (entry.prev != null) {
        entry.prev.next = entry.next;
    }
    else {
        fGrammars[entry.bucket] = entry.next;
    }
    if (entry.next != null) {
        entry.next.prev = entry.prev;
    }
    --fGrammarCount;
    entry.grammar.entry = null;
    return (Grammar) entry.grammar.get();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:SoftReferenceGrammarPool.java

示例15: Entry

import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; //导入依赖的package包/类
protected Entry(int hash, int bucket, XMLGrammarDescription desc, Grammar grammar, Entry next, ReferenceQueue queue) {
    this.hash = hash;
    this.bucket = bucket;
    this.prev = null;
    this.next = next;
    if (next != null) {
        next.prev = this;
    }
    this.desc = desc;
    this.grammar = new SoftGrammarReference(this, grammar, queue);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:SoftReferenceGrammarPool.java


注:本文中的com.sun.org.apache.xerces.internal.xni.grammars.Grammar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。