當前位置: 首頁>>代碼示例>>Java>>正文


Java LocatorImpl.setPublicId方法代碼示例

本文整理匯總了Java中org.xml.sax.helpers.LocatorImpl.setPublicId方法的典型用法代碼示例。如果您正苦於以下問題:Java LocatorImpl.setPublicId方法的具體用法?Java LocatorImpl.setPublicId怎麽用?Java LocatorImpl.setPublicId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xml.sax.helpers.LocatorImpl的用法示例。


在下文中一共展示了LocatorImpl.setPublicId方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseBindings

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:WsimportOptions.java

示例2: convertToSAXParseException

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:SchemaContentHandler.java

示例3: toLocation

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
private static Locator toLocation(XMLStreamReader xsr) {
    LocatorImpl loc = new LocatorImpl();
    Location in = xsr.getLocation();
    loc.setSystemId(in.getSystemId());
    loc.setPublicId(in.getPublicId());
    loc.setLineNumber(in.getLineNumber());
    loc.setColumnNumber(in.getColumnNumber());
    return loc;
}
 
開發者ID:ojdkbuild,項目名稱:lookaside_java-1.8.0-openjdk,代碼行數:10,代碼來源:LocatableWebServiceException.java

示例4: testSetPublicIdGetPublicId

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setPublicId",
        args = { String.class }
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "getPublicId",
        args = { }
    )
})
public void testSetPublicIdGetPublicId() {
    LocatorImpl l = new LocatorImpl();

    l.setPublicId(PUB);
    assertEquals(PUB, l.getPublicId());

    l.setPublicId(null);
    assertEquals(null, l.getPublicId());
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:22,代碼來源:LocatorImplTest.java

示例5: parseBindings

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(is);
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(is);
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:30,代碼來源:WsimportOptions.java

示例6: documentLocator

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
/**
 * The {@link org.xml.sax.Locator}is only really useful when parsing a
 * textual document as its main purpose is to identify the line and column
 * number. Since we are processing an in memory tree which will probably
 * have its line number information removed, we'll just use -1 for the line
 * and column numbers.
 * 
 * @param document
 *            DOCUMENT ME!
 * 
 * @throws SAXException
 *             DOCUMENT ME!
 */
protected void documentLocator(Document document) throws SAXException
{
    LocatorImpl locator = new LocatorImpl();

    String publicID = null;
    String systemID = null;
    DocumentType docType = document.getDocType();

    if (docType != null)
    {
        publicID = docType.getPublicID();
        systemID = docType.getSystemID();
    }

    if (publicID != null)
    {
        locator.setPublicId(publicID);
    }

    if (systemID != null)
    {
        locator.setSystemId(systemID);
    }

    locator.setLineNumber(-1);
    locator.setColumnNumber(-1);

    contentHandler.setDocumentLocator(locator);
}
 
開發者ID:iOffice1,項目名稱:iOffice,代碼行數:43,代碼來源:SAXWriter.java

示例7: toLocator

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
/**
 * Creates a locator from the given SAX parse exception.
 * @param ex The SAX Parse exception
 * @return the corresponding locator.
 */
private static Locator toLocator(SAXParseException ex) {
  LocatorImpl locator = new LocatorImpl();
  locator.setLineNumber(ex.getLineNumber());
  locator.setColumnNumber(ex.getColumnNumber());
  locator.setPublicId(ex.getPublicId());
  locator.setSystemId(ex.getSystemId());
  return locator;
}
 
開發者ID:pageseeder,項目名稱:berlioz,代碼行數:14,代碼來源:Errors.java

示例8: parse

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
@Override
public Document parse(InputSource source) throws SAXException, IOException {
    if (source == null) {
        throw new IllegalArgumentException("source == null");
    }

    String namespaceURI = null;
    String qualifiedName = null;
    DocumentType doctype = null;
    String inputEncoding = source.getEncoding();
    String systemId = source.getSystemId();
    DocumentImpl document = new DocumentImpl(
            dom, namespaceURI, qualifiedName, doctype, inputEncoding);
    document.setDocumentURI(systemId);

    KXmlParser parser = new KXmlParser();
    try {
        parser.keepNamespaceAttributes();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, namespaceAware);

        if (source.getByteStream() != null) {
            parser.setInput(source.getByteStream(), inputEncoding);
        } else if (source.getCharacterStream() != null) {
            parser.setInput(source.getCharacterStream());
        } else if (systemId != null) {
            URL url = new URL(systemId);
            URLConnection urlConnection = url.openConnection();
            urlConnection.connect();
            // TODO: if null, extract the inputEncoding from the Content-Type header?
            parser.setInput(urlConnection.getInputStream(), inputEncoding);
        } else {
            throw new SAXParseException("InputSource needs a stream, reader or URI", null);
        }

        if (parser.nextToken() == XmlPullParser.END_DOCUMENT) {
            throw new SAXParseException("Unexpected end of document", null);
        }

        parse(parser, document, document, XmlPullParser.END_DOCUMENT);

        parser.require(XmlPullParser.END_DOCUMENT, null, null);
    } catch (XmlPullParserException ex) {
        if (ex.getDetail() instanceof IOException) {
            throw (IOException) ex.getDetail();
        }
        if (ex.getDetail() instanceof RuntimeException) {
            throw (RuntimeException) ex.getDetail();
        }

        LocatorImpl locator = new LocatorImpl();

        locator.setPublicId(source.getPublicId());
        locator.setSystemId(systemId);
        locator.setLineNumber(ex.getLineNumber());
        locator.setColumnNumber(ex.getColumnNumber());

        SAXParseException newEx = new SAXParseException(ex.getMessage(), locator);

        if (errorHandler != null) {
            errorHandler.error(newEx);
        }

        throw newEx;
    } finally {
        IoUtils.closeQuietly(parser);
    }

    return document;
}
 
開發者ID:thahn0720,項目名稱:agui_framework,代碼行數:70,代碼來源:DocumentBuilderImpl.java

示例9: parse

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
@Override
public Document parse(InputSource source) throws SAXException, IOException {
    if (source == null) {
        throw new IllegalArgumentException();
    }

    String namespaceURI = null;
    String qualifiedName = null;
    DocumentType doctype = null;
    String inputEncoding = source.getEncoding();
    String systemId = source.getSystemId();
    DocumentImpl document = new DocumentImpl(
            dom, namespaceURI, qualifiedName, doctype, inputEncoding);
    document.setDocumentURI(systemId);

    try {
        KXmlParser parser = new KXmlParser();
        parser.keepNamespaceAttributes();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, namespaceAware);

        if (source.getByteStream() != null) {
            parser.setInput(source.getByteStream(), inputEncoding);
        } else if (source.getCharacterStream() != null) {
            parser.setInput(source.getCharacterStream());
        } else if (systemId != null) {
            URL url = new URL(systemId);
            URLConnection urlConnection = url.openConnection();
            urlConnection.connect();
            // TODO: if null, extract the inputEncoding from the Content-Type header?
            parser.setInput(urlConnection.getInputStream(), inputEncoding);
        } else {
            throw new SAXParseException(
                    "InputSource needs a stream, reader or URI", null);
        }

        if(parser.nextToken() == XmlPullParser.END_DOCUMENT) {
            throw new SAXParseException(
                    "Unexpected end of document", null);
        }

        parse(parser, document, document, XmlPullParser.END_DOCUMENT);

        parser.require(XmlPullParser.END_DOCUMENT, null, null);
    } catch (XmlPullParserException ex) {
        if(ex.getDetail() instanceof IOException) {
            throw (IOException)ex.getDetail();
        }
        if(ex.getDetail() instanceof RuntimeException) {
            throw (RuntimeException)ex.getDetail();
        }

        LocatorImpl locator = new LocatorImpl();

        locator.setPublicId(source.getPublicId());
        locator.setSystemId(systemId);
        locator.setLineNumber(ex.getLineNumber());
        locator.setColumnNumber(ex.getColumnNumber());

        SAXParseException newEx = new SAXParseException(ex.getMessage(),
                locator);

        if (errorHandler != null) {
            errorHandler.error(newEx);
        }

        throw newEx;
    }

    return document;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:71,代碼來源:DocumentBuilderImpl.java

示例10: testSAXParseException_String_Locator

import org.xml.sax.helpers.LocatorImpl; //導入方法依賴的package包/類
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "SAXParseException",
    args = { String.class, Locator.class }
)
public void testSAXParseException_String_Locator() {
    LocatorImpl l = new LocatorImpl();
    l.setPublicId(PUB);
    l.setSystemId(SYS);
    l.setLineNumber(ROW);
    l.setColumnNumber(COL);

    // Ordinary case
    SAXParseException e = new SAXParseException(ERR, l);

    assertEquals(ERR, e.getMessage());
    assertNull(e.getException());

    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());

    // No message
    e = new SAXParseException(null, l);

    assertNull(e.getMessage());
    assertNull(e.getException());

    assertEquals(PUB, e.getPublicId());
    assertEquals(SYS, e.getSystemId());
    assertEquals(ROW, e.getLineNumber());
    assertEquals(COL, e.getColumnNumber());

    // No locator
    e = new SAXParseException(ERR, null);

    assertEquals(ERR, e.getMessage());
    assertNull(e.getException());

    assertNull(e.getPublicId());
    assertNull(e.getSystemId());
    assertEquals(-1, e.getLineNumber());
    assertEquals(-1, e.getColumnNumber());

}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:47,代碼來源:SAXParseExceptionTest.java


注:本文中的org.xml.sax.helpers.LocatorImpl.setPublicId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。