本文整理汇总了Java中jdk.internal.org.xml.sax.Attributes类的典型用法代码示例。如果您正苦于以下问题:Java Attributes类的具体用法?Java Attributes怎么用?Java Attributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attributes类属于jdk.internal.org.xml.sax包,在下文中一共展示了Attributes类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startElement
import jdk.internal.org.xml.sax.Attributes; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException
{
if (rootElem < 2) {
rootElem++;
}
if (rootElm == null) {
fatalError(new SAXParseException("An XML properties document must contain"
+ " the DOCTYPE declaration as defined by java.util.Properties.", null));
}
if (rootElem == 1 && !rootElm.equals(qName)) {
fatalError(new SAXParseException("Document root element \"" + qName
+ "\", must match DOCTYPE root \"" + rootElm + "\"", null));
}
if (!ALLOWED_ELEMENTS.contains(qName)) {
fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
}
if (qName.equals(ELEMENT_ENTRY)) {
validEntry = true;
key = attributes.getValue(ATTR_KEY);
if (key == null) {
fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
}
} else if (qName.equals(ALLOWED_COMMENT)) {
if (sawComment) {
fatalError(new SAXParseException("Only one comment element may be allowed. "
+ "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
}
sawComment = true;
}
}
示例2: startElement
import jdk.internal.org.xml.sax.Attributes; //导入依赖的package包/类
/**
* Receive notification of the start of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each element (such as allocating a new tree node or writing
* output to a file).</p>
*
* @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @param qName The qualified name (with prefix), or the
* empty string if qualified names are not available.
* @param attributes The attributes attached to the element. If
* there are no attributes, it shall be an empty
* Attributes object.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ContentHandler#startElement
*/
public void startElement (String uri, String localName,
String qName, Attributes attributes)
throws SAXException
{
// no op
}