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


Java SAXException类代码示例

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


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

示例1: endPrefixMapping

import org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Receive notification of the end of a Namespace mapping.
 *
 * <p>By default, do nothing.  Application writers may override this
 * method in a subclass to take specific actions at the end of
 * each prefix mapping.</p>
 *
 * @param prefix The Namespace prefix being declared.
 * @throws SAXException Any SAX exception, possibly
 *            wrapping another exception.
 * @see ContentHandler#endPrefixMapping
 */
public void endPrefixMapping(String prefix) throws SAXException
{
  if (DEBUG)
    System.out.println("endPrefixMapping: prefix: " + prefix);

  if(null == prefix)
    prefix = "";

  int index = m_contextIndexes.peek() - 1;

  do
  {
    index = m_prefixMappings.indexOf(prefix, ++index);
  } while ( (index >= 0) && ((index & 0x01) == 0x01) );


  if (index > -1)
  {
    m_prefixMappings.setElementAt("%@$#^@#", index);
    m_prefixMappings.setElementAt("%@$#^@#", index + 1);
  }

  // no op
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:SAX2DTM.java

示例2: childElement

import org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Receives the root element and determines how to start
 * unmarshalling.
 */
@Override
public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    Loader loader = state.getContext().selectRootLoader(state,ea);
    if(loader!=null) {
        state.loader = loader;
        state.receiver = this;
        return;
    }

    // the registry doesn't know about this element.
    // try its xsi:type
    JaxBeanInfo beanInfo = XsiTypeLoader.parseXsiType(state, ea, null);
    if(beanInfo==null) {
        // we don't even know its xsi:type
        reportUnexpectedChildElement(ea,false);
        return;
    }

    state.loader = beanInfo.getLoader(null,false);
    state.prev.backup = new JAXBElement<Object>(ea.createQName(),Object.class,null);
    state.receiver = this;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:UnmarshallingContext.java

示例3: generateWeather

import org.xml.sax.SAXException; //导入依赖的package包/类
private void generateWeather(String c) throws IOException, SAXException, TransformerException, ParserConfigurationException {
    city = c;

    // creating the URL
    String url = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "&mode=xml&appid=" + APIKey;

    // printing out XML
    URL urlString = new URL(url);
    URLConnection conn = urlString.openConnection();

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(conn.getInputStream());

    TransformerFactory transformer = TransformerFactory.newInstance();
    Transformer xform = transformer.newTransformer();

    xform.transform(new DOMSource(doc), new StreamResult(System.out));
}
 
开发者ID:beesenpai,项目名称:EVE,代码行数:20,代码来源:Weather.java

示例4: parse

import org.xml.sax.SAXException; //导入依赖的package包/类
private void parse()
{
	try
	{
		InputStream inputStream = getInputStream();
		if( inputStream != null )
		{
			parsedManifest = parser.parseManifest(inputStream);
		}
		else
		{
			parsedManifest = null;
		}
	}
	catch( ParserConfigurationException | SAXException | IOException | CoreException e )
	{
		parsedManifest = null;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:AbstractPluginModel.java

示例5: startElement

import org.xml.sax.SAXException; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, Attributes elementAttributes) throws SAXException {            
    tag = qName.trim();                
    if (ENTRY_ELEMENT_NAME.equals(qName)) {                        
        values = new HashMap<String, Object>();
        values.put(REVISION_ATTRIBUTE, elementAttributes.getValue(REVISION_ATTRIBUTE));            
    } else if (PATH_ELEMENT_NAME.equals(qName)) {                                
        List<Path> paths = getPathList();
        Path path = new Path();
        path.action = elementAttributes.getValue(ACTION_ATTRIBUTE).charAt(0);
        path.copyPath = elementAttributes.getValue("copyfrom-path");
        path.copyRev = elementAttributes.getValue("copyfrom-rev");
        paths.add(path);                
    } else if(values != null) {
        values.put(tag, "");
    }            
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:LogCommand.java

示例6: getMessageDateTime

import org.xml.sax.SAXException; //导入依赖的package包/类
public static Date getMessageDateTime(String tmcMessage) throws ParserConfigurationException, SAXException,
		IOException, ParseException {
	DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
	InputStream stream = new ByteArrayInputStream(tmcMessage.getBytes(StandardCharsets.UTF_8));
	Document doc = docBuilder.parse(stream);

	doc.getDocumentElement().normalize();
	String timeStamp = doc.getDocumentElement().getAttribute("FGT");

	// FGT="2014-05-01T15:06:00"
	SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
	formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
	
	return formatter.parse(timeStamp);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:17,代码来源:TrafficUtility.java

示例7: getSessionId

import org.xml.sax.SAXException; //导入依赖的package包/类
private String getSessionId() throws IOException, ParserConfigurationException, SAXException, NoSuchAlgorithmException {

    HttpURLConnection con = createConnection(SID_REQUEST_URL);

    handleResponseCode(con.getResponseCode());

    Document doc = xmlFactory.newDocumentBuilder().parse(con.getInputStream());
    logger.trace("response:\n{}", XmlUtils.docToString(doc, true));
    if (doc == null) {
      throw new IOException("SessionInfo element not available");
    }
    String sid = XmlUtils.getValue(doc.getDocumentElement(), "SID");

    if (EMPTY_SID.equals(sid)) {
      String challenge = XmlUtils.getValue(doc.getDocumentElement(), "Challenge");
      sid = getSessionId(challenge);
    }

    if (sid == null || EMPTY_SID.equals(sid)) {
      throw new IOException("sid request failed: " + sid);
    }
    return sid;

  }
 
开发者ID:comtel2000,项目名称:fritz-home-skill,代码行数:25,代码来源:SwitchService.java

示例8: reconcileID

import org.xml.sax.SAXException; //导入依赖的package包/类
void reconcileID() throws SAXException {
    // find objects that were not a part of the object graph
    idReferencedObjects.removeAll(objectsWithId);

    for( Object idObj : idReferencedObjects ) {
        try {
            String id = getIdFromObject(idObj);
            reportError( new NotIdentifiableEventImpl(
                ValidationEvent.ERROR,
                Messages.DANGLING_IDREF.format(id),
                new ValidationEventLocatorImpl(idObj) ) );
        } catch (JAXBException e) {
            // this error should have been reported already. just ignore here.
        }
    }

    // clear the garbage
    idReferencedObjects.clear();
    objectsWithId.clear();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:XMLSerializer.java

示例9: joinByEnterElement

import org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Joins all the child receivers.
 *
 * <p>
 * This method is called by a child receiver when it sees
 * something that it cannot handle, or by this object itself
 * when it sees an event that it can't process.
 *
 * <p>
 * This method forces children to move to its final state,
 * then revert to the parent.
 *
 * @param source
 *      If this method is called by one of the child receivers,
 *      the receiver object. If this method is called by itself,
 *      null.
 */
public void joinByEnterElement( NGCCEventReceiver source,
    String uri, String local, String qname, Attributes atts ) throws SAXException {

    if(isJoining)   return; // we are already in the process of joining. ignore.
    isJoining = true;

    // send special token to the rest of the branches.
    // these branches don't understand this token, so they will
    // try to move to a final state and send the token back to us,
    // which this object will ignore (because isJoining==true)
    // Otherwise branches will find an error.
    for( int i=0; i<_receivers.length; i++ )
        if( _receivers[i]!=source )
            _receivers[i].enterElement(uri,local,qname,atts);

    // revert to the parent
    _parent._source.replace(this,_parent);
    _parent.onChildCompleted(null,_cookie,true);
    // send this event to the parent
    _parent.enterElement(uri,local,qname,atts);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:NGCCInterleaveFilter.java

示例10: handleCompileSingle

import org.xml.sax.SAXException; //导入依赖的package包/类
/**
 * Implementation of Compile File.
 */
private void handleCompileSingle(Lookup context) throws IOException, SAXException {
    // XXX could also try copy + mod from build.xml? but less likely to have <compile> in an accessible place...
    if (!alert(NbBundle.getMessage(JavaActions.class, "ACTION_compile.single"), FILE_SCRIPT_PATH)) {
        return;
    }
    Document doc = readCustomScript(FILE_SCRIPT_PATH);
    ensurePropertiesCopied(doc.getDocumentElement());
    Comment comm = doc.createComment(" " + NbBundle.getMessage(JavaActions.class, "COMMENT_edit_target") + " ");
    doc.getDocumentElement().appendChild(comm);
    comm = doc.createComment(" " + NbBundle.getMessage(JavaActions.class, "COMMENT_more_info_x.single") + " ");
    doc.getDocumentElement().appendChild(comm);
    String propertyName = "files"; // NOI18N
    AntLocation root = findPackageRoot(context);
    assert root != null : context;
    Element target = createCompileSingleTarget(doc, context, propertyName, root);
    doc.getDocumentElement().appendChild(target);
    writeCustomScript(doc, FILE_SCRIPT_PATH);
    // XXX #53622: support also folders (i.e. just files w/o ext??):
    String targetName = target.getAttribute("name");
    addBinding(ActionProvider.COMMAND_COMPILE_SINGLE, FILE_SCRIPT_PATH, targetName, propertyName, root.virtual, JAVA_FILE_PATTERN, "relative-path", ","); // NOI18N
    jumpToBinding(ActionProvider.COMMAND_COMPILE_SINGLE);
    jumpToBuildScript(FILE_SCRIPT_PATH, targetName);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JavaActions.java

示例11: text

import org.xml.sax.SAXException; //导入依赖的package包/类
public void text(String $value) throws SAXException {
    int $ai;
    switch($_ngcc_current_state) {
    case 0:
        {
            revertToParentFromText(makeResult(), super._cookie, $value);
        }
        break;
    case 1:
        {
            v = $value;
            $_ngcc_current_state = 0;
        }
        break;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ersSet.java

示例12: maybeReadAttribute

import org.xml.sax.SAXException; //导入依赖的package包/类
private String maybeReadAttribute(String name, boolean must)
        throws IOException, SAXException {

    // [24] VersionInfo ::= S 'version' Eq \'|\" versionNum \'|\"
    // [80] EncodingDecl ::= S 'encoding' Eq \'|\" EncName \'|\"
    // [32] SDDecl ::=  S 'standalone' Eq \'|\" ... \'|\"
    if (!maybeWhitespace()) {
        if (!must) {
            return null;
        }
        fatal("P-024", new Object[]{name});
        // NOTREACHED
    }

    if (!peek(name)) {
        if (must) {
            fatal("P-024", new Object[]{name});
        } else {
            // To ensure that the whitespace is there so that when we
            // check for the next attribute we assure that the
            // whitespace still exists.
            ungetc();
            return null;
        }
    }

    // [25] Eq ::= S? '=' S?
    maybeWhitespace();
    nextChar('=', "F-023", null);
    maybeWhitespace();

    return getQuotedString("F-035", name);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:DTDParser.java

示例13: parse

import org.xml.sax.SAXException; //导入依赖的package包/类
public static void parse(DefaultHandler handler, String file) throws SAXException, IOException {
	XMLReader xreader = XMLReaderFactory.createXMLReader();
	xreader.setContentHandler(handler);
	xreader.setErrorHandler(handler);
	FileReader reader = new FileReader(file);
    xreader.parse(new InputSource(reader));			
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:8,代码来源:SAXUtilities.java

示例14: test

import org.xml.sax.SAXException; //导入依赖的package包/类
@Test
public void test() {
    try {
        File dir = new File(Bug6975265Test.class.getResource("Bug6975265").getPath());
        File files[] = dir.listFiles();
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        for (int i = 0; i < files.length; i++) {
            try {
                System.out.println(files[i].getName());
                Schema schema = schemaFactory.newSchema(new StreamSource(files[i]));
                Assert.fail("should report error");
            } catch (org.xml.sax.SAXParseException spe) {
                System.out.println(spe.getMessage());
                continue;
            }
        }
    } catch (SAXException e) {
        e.printStackTrace();

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

示例15: getCoTTypeMap

import org.xml.sax.SAXException; //导入依赖的package包/类
public static ArrayList<CoTTypeDef> getCoTTypeMap(InputStream mapInputStream) throws ParserConfigurationException, SAXException, IOException
{

	ArrayList<CoTTypeDef> types = null;

	String content = getStringFromFile(mapInputStream);


	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder db = dbf.newDocumentBuilder();
	InputSource source = new InputSource();
	source.setCharacterStream(new StringReader(content));
	Document doc = db.parse(source);
	NodeList nodeList = doc.getElementsByTagName("types");
	types = typeBreakdown(nodeList.item(0));
	return types;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:18,代码来源:CoTUtilities.java


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