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


Java Parser类代码示例

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


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

示例1: parseTheme

import org.xml.sax.Parser; //导入依赖的package包/类
private void parseTheme(){
    try{
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setValidating(false);
        factory.setNamespaceAware(false);

        Parser p = new XMLReaderAdapter(factory.newSAXParser().getXMLReader());
        p.setDocumentHandler(this);
        String externalForm = themeURL.toExternalForm();
        InputSource is = new InputSource(externalForm);
        p.parse(is);
        activeThemes=null;  //dispose of now useless hashtable
        locator = null;
    }
    catch(java.io.IOException ie){
        System.err.println ("IO exception reading theme file"); //NOI18N
    } catch(org.xml.sax.SAXException se){
        System.err.println ("Error parsing theme file " + (locator != null ? "line " + locator.getLineNumber() : "")); //NOI18N
    } catch (ParserConfigurationException e) {
        System.err.println ("Couldn't create XML parser for theme file"); //NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:NbTheme.java

示例2: parse

import org.xml.sax.Parser; //导入依赖的package包/类
private synchronized AnnotationType parse() {
      if (annotationType == null) {
          AnnotationType at = new AnnotationType();
          Handler h = new Handler(at);

          try {
Parser xp;
              SAXParserFactory factory = SAXParserFactory.newInstance ();
              factory.setValidating (false);
              factory.setNamespaceAware(false);
              xp = factory.newSAXParser ().getParser ();
              xp.setEntityResolver(h);
              xp.setDocumentHandler(h);
              xp.setErrorHandler(h);
              xp.parse(new InputSource(xmlDataObject.getInputStream()));
              at.putProp(AnnotationType.PROP_FILE, xmlDataObject);
              annotationType = at;
          } catch (Exception e) { 
              LOG.warning("Corrupted xmlDataObject " + xmlDataObject.getPath());
              Exceptions.printStackTrace(e);
          }

      }
      return annotationType;
  }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AnnotationTypeProcessor.java

示例3: setup

import org.xml.sax.Parser; //导入依赖的package包/类
/**
 * Internal setup method.
 *
 * @param parser The embedded parser.
 * @exception java.lang.NullPointerException If the parser parameter
 *            is null.
 */
private void setup (Parser parser)
{
    if (parser == null) {
        throw new
            NullPointerException("Parser argument must not be null");
    }
    this.parser = parser;
    atts = new AttributesImpl();
    nsSupport = new NamespaceSupport();
    attAdapter = new AttributeListAdapter();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ParserAdapter.java

示例4: parse

import org.xml.sax.Parser; //导入依赖的package包/类
/**
 * Parse the specified input source, reporting SAX1 events to the
 * given handler.
 * Prefer the SAX2 version of this method, since the HandlerBase class is
 * now deprecated.
 * @param is the SAX input source
 * @param hb the SAX1 handler
 * @exception IllegalArgumentException if the input source is null
 * @see #parse(org.xml.sax.InputSource,org.xml.sax.helpers.DefaultHandler)
 */
public void parse(InputSource is, HandlerBase hb)
  throws SAXException, IOException
{
  if (is == null)
    {
      throw new IllegalArgumentException("input source is null");
    }
  Parser parser = getParser();
  parser.setDocumentHandler(hb);
  parser.setDTDHandler(hb);
  parser.setEntityResolver(hb);
  parser.setErrorHandler(hb);
  parser.parse(is);
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:SAXParser.java

示例5: setup

import org.xml.sax.Parser; //导入依赖的package包/类
/**
    * Internal setup method.
    *
    * @param parser The embedded parser.
    * @exception java.lang.NullPointerException If the parser parameter
    *            is null.
    */
   private void setup (Parser parser)
   {
if (parser == null) {
    throw new
	NullPointerException("Parser argument must not be null");
}
this.parser = parser;
atts = new AttributesImpl();
nsSupport = new NamespaceSupport();
attAdapter = new AttributeListAdapter();
   }
 
开发者ID:vilie,项目名称:javify,代码行数:19,代码来源:ParserAdapter.java

示例6: parse

import org.xml.sax.Parser; //导入依赖的package包/类
/**
 * Parse the specified input source, reporting SAX1 events to the
 * given handler.
 * Prefer the SAX2 version of this method, since the HandlerBase class is
 * now deprecated.
 * @param is the SAX input source
 * @param hb the SAX1 handler
 * @exception IllegalArgumentException if the input source is null
 * @see #parse(org.xml.sax.InputSource,org.xml.sax.helpers.DefaultHandler)
 */
public void parse(InputSource is, HandlerBase hb) 
  throws SAXException, IOException
{
  if (is == null)
    {
      throw new IllegalArgumentException("input source is null");
    }
  Parser parser = getParser();
  parser.setDocumentHandler(hb);
  parser.setDTDHandler(hb);
  parser.setEntityResolver(hb);
  parser.setErrorHandler(hb);
  parser.parse(is);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:25,代码来源:SAXParser.java

示例7: setup

import org.xml.sax.Parser; //导入依赖的package包/类
/**
 * Internal setup method.
 *
 * @param parser The embedded parser.
 * @exception java.lang.NullPointerException If the parser parameter
 *            is null.
 */
private void setup (Parser parser)
{
if (parser == null) {
    throw new
    NullPointerException("Parser argument must not be null");
}
this.parser = parser;
atts = new AttributesImpl();
nsSupport = new NamespaceSupport();
attAdapter = new AttributeListAdapter();
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:19,代码来源:ParserAdapter.java

示例8: testGetParser

import org.xml.sax.Parser; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "getParser",
    args = { }
)
public void testGetParser() {
    spf = SAXParserFactory.newInstance();
    try {
        Parser parser = spf.newSAXParser().getParser();
        assertNotNull(parser);
    } catch (Exception e) {
        throw new RuntimeException("Unexpected exception", e);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:15,代码来源:SAXParserTest.java

示例9: getParser

import org.xml.sax.Parser; //导入依赖的package包/类
public Parser getParser() throws SAXException {
    // Xerces2 AbstractSAXParser implements SAX1 Parser
    // assert(xmlReader instanceof Parser);
    return (Parser) xmlReader;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:SAXParserImpl.java

示例10: parse

import org.xml.sax.Parser; //导入依赖的package包/类
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:SAXParser.java

示例11: makeParser

import org.xml.sax.Parser; //导入依赖的package包/类
/**
    * Create a new SAX parser using the `org.xml.sax.parser' system property.
    *
    * <p>The named class must exist and must implement the
    * {@link org.xml.sax.Parser Parser} interface.</p>
    *
    * @exception java.lang.NullPointerException There is no value
    *            for the `org.xml.sax.parser' system property.
    * @exception java.lang.ClassNotFoundException The SAX parser
    *            class was not found (check your CLASSPATH).
    * @exception IllegalAccessException The SAX parser class was
    *            found, but you do not have permission to load
    *            it.
    * @exception InstantiationException The SAX parser class was
    *            found but could not be instantiated.
    * @exception java.lang.ClassCastException The SAX parser class
    *            was found and instantiated, but does not implement
    *            org.xml.sax.Parser.
    * @see #makeParser(java.lang.String)
    * @see org.xml.sax.Parser
    */
   public static Parser makeParser ()
throws ClassNotFoundException,
IllegalAccessException, 
InstantiationException,
NullPointerException,
ClassCastException
   {
String className = System.getProperty("org.xml.sax.parser");
if (className == null) {
    throw new NullPointerException("No value for sax.parser property");
} else {
    return makeParser(className);
}
   }
 
开发者ID:vilie,项目名称:javify,代码行数:36,代码来源:ParserFactory.java

示例12: getParser

import org.xml.sax.Parser; //导入依赖的package包/类
public Parser getParser()
  throws SAXException
{
  return null;
}
 
开发者ID:vilie,项目名称:javify,代码行数:6,代码来源:SAXParser.java

示例13: getParser

import org.xml.sax.Parser; //导入依赖的package包/类
public Parser getParser ()
  throws SAXException
{
  throw new SAXNotSupportedException ("SAX version 1 not supported");
}
 
开发者ID:vilie,项目名称:javify,代码行数:6,代码来源:GnomeSAXParser.java

示例14: getParser

import org.xml.sax.Parser; //导入依赖的package包/类
/**
 * Delegates to the wrapped SAXParser's implementation of the method.
 */
public Parser getParser() throws SAXException {
    return parser.getParser();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:7,代码来源:UnescapingSaxParser.java

示例15: getParser

import org.xml.sax.Parser; //导入依赖的package包/类
@Override
public Parser getParser() throws SAXException {
    return null;
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:5,代码来源:StubSAXParser.java


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