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


Java LSInput.getStringData方法代码示例

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


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

示例1: resolveEntity

import org.w3c.dom.ls.LSInput; //导入方法依赖的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

示例2: resolveEntity

import org.w3c.dom.ls.LSInput; //导入方法依赖的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(sysId, baseSystemId) : sysId);

            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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:ValidatorHandlerImpl.java

示例3: dom2xmlInputSource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
XMLInputSource dom2xmlInputSource(LSInput is) {
    // need to wrap the LSInput with an XMLInputSource
    XMLInputSource xis = null;

    /**
     * An LSParser looks at inputs specified in LSInput in
     * the following order: characterStream, byteStream,
     * stringData, systemId, publicId. For consistency
     * have the same behaviour for XSLoader.
     */

    // check whether there is a Reader
    // according to DOM, we need to treat such reader as "UTF-16".
    if (is.getCharacterStream() != null) {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI(), is.getCharacterStream(),
        "UTF-16");
    }
    // check whether there is an InputStream
    else if (is.getByteStream() != null) {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI(), is.getByteStream(),
                is.getEncoding());
    }
    // if there is a string data, use a StringReader
    // according to DOM, we need to treat such data as "UTF-16".
    else if (is.getStringData() != null && is.getStringData().length() != 0) {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI(), new StringReader(is.getStringData()),
        "UTF-16");
    }
    // otherwise, just use the public/system/base Ids
    else {
        xis = new XMLInputSource(is.getPublicId(), is.getSystemId(),
                is.getBaseURI());
    }

    return xis;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:40,代码来源:XMLSchemaLoader.java

示例4: resolveEntity

import org.w3c.dom.ls.LSInput; //导入方法依赖的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(sysId, baseSystemId) : sysId);
            
            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:AaronZhangL,项目名称:SplitCharater,代码行数:44,代码来源:ValidatorHandlerImpl.java

示例5: resolveEntity

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId);

            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

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

示例6: resolveEntity

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId, true);

            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

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

示例7: dom2xmlInputSource

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
 * NON-DOM: convert LSInput to XNIInputSource
 *
 * @param is
 * @return
 */
XMLInputSource dom2xmlInputSource (LSInput is) {
    // need to wrap the LSInput with an XMLInputSource
    XMLInputSource xis = null;
    // check whether there is a Reader
    // according to DOM, we need to treat such reader as "UTF-16".
    if (is.getCharacterStream () != null) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI (), is.getCharacterStream (),
        "UTF-16");
    }
    // check whether there is an InputStream
    else if (is.getByteStream () != null) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI (), is.getByteStream (),
        is.getEncoding ());
    }
    // if there is a string data, use a StringReader
    // according to DOM, we need to treat such data as "UTF-16".
    else if (is.getStringData () != null && is.getStringData().length() > 0) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI (), new StringReader (is.getStringData ()),
        "UTF-16");
    }
    // otherwise, just use the public/system/base Ids
    else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
        (is.getPublicId() != null && is.getPublicId().length() > 0)) {
        xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
        is.getBaseURI ());
    }
    else {
        // all inputs are null
        if (fErrorHandler != null) {
            DOMErrorImpl error = new DOMErrorImpl();
            error.fType = "no-input-specified";
            error.fMessage = "no-input-specified";
            error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
            fErrorHandler.getErrorHandler().handleError(error);
        }
        throw new LSException(LSException.PARSE_ERR, "no-input-specified");
    }
    return xis;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:49,代码来源:DOMParserImpl.java

示例8: createResolver

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
public static Resolver createResolver(final LSResourceResolver resourceResolver) {
  return new AbstractResolver() {
    public void resolve(Identifier id, Input input) throws IOException, ResolverException {
      if (input.isResolved())
        return;
      String base = id.getBase();
      String publicId = null;
      String type = null;
      if (id instanceof ExternalIdentifier) {
        publicId = ((ExternalIdentifier)id).getPublicId();
        type = XML_TYPE;
      }
      else if (id instanceof XMLDocumentIdentifier)
        type = ((XMLDocumentIdentifier)id).getNamespaceUri();
      if (type == null) {
        String mediaType = id.getMediaType();
        if (mediaType.indexOf('*') < 0)
          type = IANA_MEDIA_TYPE_URI + mediaType;
      }
      String targetNamespace = null;
      if (id instanceof TargetNamespaceIdentifier)
        targetNamespace = ((TargetNamespaceIdentifier)id).getTargetNamespace();
      LSInput lsInput = resourceResolver.resolveResource(type, targetNamespace, publicId, id.getUriReference(), base);
      if (lsInput == null)
        return;
      input.setEncoding(lsInput.getEncoding());
      input.setUri(lsInput.getSystemId());
      final Reader characterStream = lsInput.getCharacterStream();
      if (characterStream != null) {
        input.setCharacterStream(characterStream);
        return;
      }
      final InputStream byteStream = lsInput.getByteStream();
      if (byteStream != null) {
        input.setByteStream(byteStream);
        return;
      }
      final String stringData = lsInput.getStringData();
      if (stringData != null) {
        input.setCharacterStream(new StringReader(stringData));
        return;
      }
      // we don't support redirecting to a public ID
    }
  };
}
 
开发者ID:relaxng,项目名称:jing-trang,代码行数:47,代码来源:LS.java

示例9: resolveEntity

import org.w3c.dom.ls.LSInput; //导入方法依赖的package包/类
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier	description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */          
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId);
            
            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:65,代码来源:DOMEntityResolverWrapper.java


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