org.apache.cayenne.util.Util.createXmlReader()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中org.apache.cayenne.util.Util.createXmlReader()方法的一些代码示例,展示了Util.createXmlReader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createXmlReader()方法的具体详情如下:
包路径:org.apache.cayenne.util.Util
类名称:Util
方法名:createXmlReader

Util.createXmlReader介绍

[英]Creates an XMLReader with default feature set. Note that all Cayenne internal XML parsers should probably use XMLReader obtained via this method for consistency sake, and can customize feature sets as needed.
[中]使用默认功能集创建XMLReader。请注意,为了保持一致性,所有Cayenne内部XML解析器可能都应该使用通过此方法获得的XMLReader,并且可以根据需要自定义功能集。

代码示例

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Creates new DriverDataSourceFactory.
 */
public DriverDataSourceFactory() throws Exception {
  this.parser = Util.createXmlReader();
}

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/** Creates new ConfigLoader. */
public ConfigLoader(ConfigLoaderDelegate delegate) throws Exception {
  if (delegate == null) {
    throw new IllegalArgumentException("Delegate must not be null.");
  }
  this.delegate = delegate;
  parser = Util.createXmlReader();
}

代码示例来源:origin: org.apache.cayenne/cayenne-project

public DataSourceInfo load(Resource configurationResource) throws Exception {
  if (configurationResource == null) {
    throw new NullPointerException("Null configurationResource");
  }
  DataSourceInfo dataSourceDescriptor = new DataSourceInfo();
  XMLReader parser = Util.createXmlReader();
  DriverHandler handler = new DriverHandler(dataSourceDescriptor, parser);
  parser.setContentHandler(handler);
  parser.setErrorHandler(handler);
  parser.parse(new InputSource(configurationResource.getURL().openStream()));
  return dataSourceDescriptor;
}

代码示例来源:origin: org.apache.cayenne/cayenne-project

List<DataChannelDescriptor> load(Resource configurationSource) throws ConfigurationException {
  if (configurationSource == null) {
    throw new NullPointerException("Null configurationSource");
  }
  URL configurationURL = configurationSource.getURL();
  List<DataChannelDescriptor> domains = new ArrayList<>();
  try (InputStream in = configurationURL.openStream();) {
    XMLReader parser = Util.createXmlReader();
    DomainsHandler rootHandler = new DomainsHandler(configurationSource, domains, parser);
    parser.setContentHandler(rootHandler);
    parser.setErrorHandler(rootHandler);
    parser.parse(new InputSource(in));
  } catch (Exception e) {
    throw new ConfigurationException("Error loading configuration from %s", e, configurationURL);
  }
  return domains;
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

/**
 * Creates new TypesHandler loading configuration info from the XML file
 * specified as <code>typesConfigPath</code> parameter.
 * 
 * @since 1.1
 */
public TypesHandler(URL typesConfig) {
  try (InputStream in = typesConfig.openStream();) {
    XMLReader parser = Util.createXmlReader();
    TypesParseHandler ph = new TypesParseHandler();
    parser.setContentHandler(ph);
    parser.setErrorHandler(ph);
    parser.parse(new InputSource(in));
    typesMap = ph.getTypes();
  } catch (Exception ex) {
    throw new CayenneRuntimeException("Error creating TypesHandler '" + typesConfig + "'.", ex);
  }
}

代码示例来源:origin: org.apache.cayenne/cayenne-project

/**
 * A default method for quick extraction of the project version from an XML
 * file.
 */
protected String loadProjectVersion() {
  RootTagHandler rootHandler = new RootTagHandler();
  URL url = projectSource.getURL();
  try (InputStream in = url.openStream();) {
    XMLReader parser = Util.createXmlReader();
    parser.setContentHandler(rootHandler);
    parser.setErrorHandler(rootHandler);
    parser.parse(new InputSource(in));
  } catch (SAXException e) {
    // expected ... handler will terminate as soon as it finds a root
    // tag.
  } catch (Exception e) {
    throw new ConfigurationException("Error reading configuration from %s", e, url);
  }
  return rootHandler.projectVersion != null ? rootHandler.projectVersion : UNKNOWN_VERSION;
}

代码示例来源:origin: org.apache.cayenne/cayenne-project

XMLReader parser = Util.createXmlReader();

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

XMLReader parser = Util.createXmlReader();
TypesParseHandler ph = new TypesParseHandler();
parser.setContentHandler(ph);

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Loads a DataMap from XML input source.
 */
public synchronized DataMap loadDataMap(InputSource src)
    throws CayenneRuntimeException {
  if (src == null) {
    throw new NullPointerException("Null InputSource.");
  }
  try {
    String mapName = mapNameFromLocation(src.getSystemId());
    dataMap = new DataMap(mapName);
    XMLReader parser = Util.createXmlReader();
    parser.setContentHandler(this);
    parser.setErrorHandler(this);
    parser.parse(src);
  }
  catch (SAXException e) {
    dataMap = null;
    throw new CayenneRuntimeException(
        "Wrong DataMap format, last processed tag: <" + currentTag,
        Util.unwindException(e));
  }
  catch (Exception e) {
    dataMap = null;
    throw new CayenneRuntimeException(
        "Error loading DataMap, last processed tag: <" + currentTag,
        Util.unwindException(e));
  }
  return dataMap;
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

XMLReader parser = Util.createXmlReader();

代码示例来源:origin: org.apache.cayenne/cayenne-server

/**
 * Loads a DataMap from XML input source.
 */
public synchronized DataMap loadDataMap(InputSource src) throws CayenneRuntimeException {
  if (src == null) {
    throw new NullPointerException("Null InputSource.");
  }
  try {
    String mapName = mapNameFromLocation(src.getSystemId());
    dataMap = new DataMap(mapName);
    XMLReader parser = Util.createXmlReader();
    parser.setContentHandler(this);
    parser.setErrorHandler(this);
    parser.parse(src);
  } catch (SAXException e) {
    dataMap = null;
    throw new CayenneRuntimeException("Wrong DataMap format, last processed tag: "
        + constructCurrentStateString(), Util.unwindException(e));
  } catch (Exception e) {
    dataMap = null;
    throw new CayenneRuntimeException("Error loading DataMap, last processed tag: "
        + constructCurrentStateString(), Util.unwindException(e));
  }
  return dataMap;
}

相关文章