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


Java InputSource.setByteStream方法代码示例

本文整理汇总了Java中org.xml.sax.InputSource.setByteStream方法的典型用法代码示例。如果您正苦于以下问题:Java InputSource.setByteStream方法的具体用法?Java InputSource.setByteStream怎么用?Java InputSource.setByteStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xml.sax.InputSource的用法示例。


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

示例1: parse

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Converts to InputSource and pass it.
 */    
protected TreeDocumentRoot parse(FileObject fo) throws IOException, TreeException{
    
    try {
        URL url = fo.getURL();
        InputSource in = new InputSource(url.toExternalForm());  //!!! we could try ti get encoding from MIME content type
        in.setByteStream(fo.getInputStream());
        return parse(in);
        
    } catch (IOException ex) {
        ErrorManager emgr = ErrorManager.getDefault();
        emgr.annotate(ex, Util.THIS.getString("MSG_can_not_create_URL"));
        emgr.notify(ex);
    }           
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ParsingSupport.java

示例2: create

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public MutableXMLStreamBuffer create(XMLReader reader, InputStream in, String systemId) throws IOException, SAXException {
    if (_buffer == null) {
        createBuffer();
    }
    _buffer.setSystemId(systemId);
    reader.setContentHandler(this);
    reader.setProperty(Properties.LEXICAL_HANDLER_PROPERTY, this);

    try {
        setHasInternedStrings(reader.getFeature(Features.STRING_INTERNING_FEATURE));
    } catch (SAXException e) {
    }


    if (systemId != null) {
        InputSource s = new InputSource(systemId);
        s.setByteStream(in);
        reader.parse(s);
    } else {
        reader.parse(new InputSource(in));
    }

    return getXMLStreamBuffer();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SAXBufferCreator.java

示例3: sourceToInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Attempt to obtain a SAX InputSource object from a Source
 * object.
 *
 * @param source Must be a non-null Source reference.
 *
 * @return An InputSource, or null if Source can not be converted.
 */
public static InputSource sourceToInputSource(Source source) {

    if (source instanceof SAXSource) {
        return ((SAXSource) source).getInputSource();
    } else if (source instanceof StreamSource) {
        StreamSource ss      = (StreamSource) source;
        InputSource  isource = new InputSource(ss.getSystemId());

        isource.setByteStream(ss.getInputStream());
        isource.setCharacterStream(ss.getReader());
        isource.setPublicId(ss.getPublicId());

        return isource;
    } else {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SAXSource.java

示例4: parseXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Parses content as XML.
 * @throws IOException see {@link #connection} for subtype description; also thrown in case of malformed XML
 */
public Document parseXML() throws IOException {
    URLConnection c = connection();
    InputSource source = new InputSource(url.toString());
    source.setByteStream(c.getInputStream());
    try {
        return XMLUtil.parse(source, false, false, XMLUtil.defaultErrorHandler(), null);
    } catch (SAXException x) {
        throw new IOException(x);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ConnectionBuilder.java

示例5: scan

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Override
public void scan(JarURLConnection jarConn) throws IOException {

    URL url = jarConn.getURL();
    URL resourceURL = jarConn.getJarFileURL();
    Jar jar = null;
    InputStream is = null;
    WebXml fragment = new WebXml();

    try {
        jar = JarFactory.newInstance(url);
        if (parseRequired || context.getXmlValidation()) {
            is = jar.getInputStream(FRAGMENT_LOCATION);
        }

        if (is == null) {
            // If there is no web-fragment.xml to process there is no
            // impact on distributable
            fragment.setDistributable(true);
        } else {
            InputSource source = new InputSource(
                    "jar:" + resourceURL.toString() + "!/" +
                    FRAGMENT_LOCATION);
            source.setByteStream(is);
            parseWebXml(source, fragment, true);
        }
    } finally {
        if (jar != null) {
            jar.close();
        }
        fragment.setURL(url);
        if (fragment.getName() == null) {
            fragment.setName(fragment.getURL().toString());
        }
        fragment.setJarName(extractJarFileName(url));
        fragments.put(fragment.getName(), fragment);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:39,代码来源:ContextConfig.java

示例6: _readRegionMetadata

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static void _readRegionMetadata(
  RegionMetadata bean, InputStream in, String publicId)
{
  if (_LOG.isFiner())
  {
    _LOG.finer("Loading region-metadata from file:{0}", publicId);
  }
  try
  {
    InputSource input = new InputSource();
    input.setByteStream(in);
    input.setPublicId(publicId);

    DefaultHandler handler = new Handler(bean);
    _SAX_PARSER_FACTORY.newSAXParser().parse(input, handler);
  }
  catch (IOException ioe)
  {
    _error(publicId, ioe);
  }
  catch (ParserConfigurationException pce)
  {
    _error(publicId, pce);
  }
  catch (SAXException saxe)
  {
    _error(publicId, saxe);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:30,代码来源:RegionMetadata.java

示例7: loadXSD

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private void loadXSD(String resource, FieldDefinition detailsDef )
{
	try
	{
		InputStream is = getClass().getClassLoader().getResourceAsStream(resource);
		InputSource source = new InputSource();
		source.setByteStream(is);
		CoTDetailsDeff.parseXSD( source, detailsDef);
	}catch(Exception ex)
	{
		ex.printStackTrace();
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:14,代码来源:CoTAdapterService.java

示例8: streamSourceToInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static InputSource streamSourceToInputSource( StreamSource ss ) {
    InputSource is = new InputSource();
    is.setSystemId( ss.getSystemId() );
    is.setByteStream( ss.getInputStream() );
    is.setCharacterStream( ss.getReader() );

    return is;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:AbstractUnmarshallerImpl.java

示例9: resolveEntity

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * returned into an <code>InputSource</code>.
 */
public InputSource resolveEntity(String name, String publicId,
        String baseURI, String systemId) throws SAXException, IOException {
    if (fEntityResolver != null) {
        LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
        if (lsInput != null) {
            final String pubId = lsInput.getPublicId();
            final String sysId = lsInput.getSystemId();
            final String baseSystemId = lsInput.getBaseURI();
            final Reader charStream = lsInput.getCharacterStream();
            final InputStream byteStream = lsInput.getByteStream();
            final String data = lsInput.getStringData();
            final String encoding = lsInput.getEncoding();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId. For consistency
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:ValidatorHandlerImpl.java

示例10: resolveEntity

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/** SAX resolveEntity API. */
public InputSource resolveEntity (String publicId, String systemId) {
  String resolved = null;

  if (systemId != null && systemMap.containsKey(systemId)) {
    resolved = (String) systemMap.get(systemId);
  } else if (publicId != null && publicMap.containsKey(publicId)) {
    resolved = (String) publicMap.get(publicId);
  }

  if (resolved != null) {
    try {
      InputSource iSource = new InputSource(resolved);
      iSource.setPublicId(publicId);

      // Ideally this method would not attempt to open the
      // InputStream, but there is a bug (in Xerces, at least)
      // that causes the parser to mistakenly open the wrong
      // system identifier if the returned InputSource does
      // not have a byteStream.
      //
      // It could be argued that we still shouldn't do this here,
      // but since the purpose of calling the entityResolver is
      // almost certainly to open the input stream, it seems to
      // do little harm.
      //
      URL url = new URL(resolved);
      InputStream iStream = url.openStream();
      iSource.setByteStream(iStream);

      return iSource;
    } catch (Exception e) {
      // FIXME: silently fail?
      return null;
    }
  }

  return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:BootstrapResolver.java

示例11: resolveEntity

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Implements the <code>resolveEntity</code> method
 * for the SAX interface, using an underlying CatalogResolver
 * to do the real work.
 */
public InputSource resolveEntity (String publicId, String systemId) {
  allowXMLCatalogPI = false;
  String resolved = catalogResolver.getResolvedEntity(publicId, systemId);

  if (resolved == null && piCatalogResolver != null) {
    resolved = piCatalogResolver.getResolvedEntity(publicId, systemId);
  }

  if (resolved != null) {
    try {
      InputSource iSource = new InputSource(resolved);
      iSource.setPublicId(publicId);

      // Ideally this method would not attempt to open the
      // InputStream, but there is a bug (in Xerces, at least)
      // that causes the parser to mistakenly open the wrong
      // system identifier if the returned InputSource does
      // not have a byteStream.
      //
      // It could be argued that we still shouldn't do this here,
      // but since the purpose of calling the entityResolver is
      // almost certainly to open the input stream, it seems to
      // do little harm.
      //
      URL url = new URL(resolved);
      InputStream iStream = url.openStream();
      iSource.setByteStream(iStream);

      return iSource;
    } catch (Exception e) {
      catalogManager.debug.message(1, "Failed to create InputSource", resolved);
      return null;
    }
  } else {
    return null;
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:ResolvingXMLFilter.java

示例12: resolveEntity

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Implements the <code>resolveEntity</code> method
 * for the SAX interface.
 *
 * <p>Presented with an optional public identifier and a system
 * identifier, this function attempts to locate a mapping in the
 * catalogs.</p>
 *
 * <p>If such a mapping is found, the resolver attempts to open
 * the mapped value as an InputSource and return it. Exceptions are
 * ignored and null is returned if the mapped value cannot be opened
 * as an input source.</p>
 *
 * <p>If no mapping is found (or an error occurs attempting to open
 * the mapped value as an input source), null is returned and the system
 * will use the specified system identifier as if no entityResolver
 * was specified.</p>
 *
 * @param publicId  The public identifier for the entity in question.
 * This may be null.
 *
 * @param systemId  The system identifier for the entity in question.
 * XML requires a system identifier on all external entities, so this
 * value is always specified.
 *
 * @return An InputSource for the mapped identifier, or null.
 */
public InputSource resolveEntity (String publicId, String systemId) {
  String resolved = getResolvedEntity(publicId, systemId);

  if (resolved != null) {
    try {
      InputSource iSource = new InputSource(resolved);
      iSource.setPublicId(publicId);

      // Ideally this method would not attempt to open the
      // InputStream, but there is a bug (in Xerces, at least)
      // that causes the parser to mistakenly open the wrong
      // system identifier if the returned InputSource does
      // not have a byteStream.
      //
      // It could be argued that we still shouldn't do this here,
      // but since the purpose of calling the entityResolver is
      // almost certainly to open the input stream, it seems to
      // do little harm.
      //
      URL url = new URL(resolved);
      InputStream iStream = url.openStream();
      iSource.setByteStream(iStream);

      return iSource;
    } catch (Exception e) {
      catalogManager.debug.message(1, "Failed to create InputSource", resolved);
      return null;
    }
  }

  return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:60,代码来源:CatalogResolver.java

示例13: toInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static InputSource toInputSource(StreamSource src) {
    InputSource is = new InputSource();
    is.setByteStream(src.getInputStream());
    is.setCharacterStream(src.getReader());
    is.setPublicId(src.getPublicId());
    is.setSystemId(src.getSystemId());
    return is;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:XmlUtil.java


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