📄 abstractbeanwriter.java
字号:
public String getQName(int index) {
if (index == idIndex) {
return idAttributeName;
}
return super.getQName(index);
}
public String getType(int index) {
if (index == idIndex) {
return "ID";
}
return super.getType(index);
}
public String getType(String uri, String localName) {
return getType(getIndex(uri, localName));
}
public String getType(String qName) {
return getType(getIndex(qName));
}
public String getURI(int index) {
//TODO: this is probably wrong
// probably need to move ID management into introspection
// before we can handle this namespace bit correctly
if (index == idIndex) {
return "";
}
return super.getURI(index);
}
public String getValue(int index) {
if (index == idIndex) {
return idValue;
}
return super.getValue(index);
}
public String getValue(String uri, String localName) {
return getValue(getIndex(uri, localName));
}
public String getValue(String qName) {
return getValue(getIndex(qName));
}
}
// OLD API (DEPRECATED)
// --------------------------------------------------------------------------------------
/**
* Get the indentation for the current element.
* Used for pretty priting.
*
* @return the amount that the current element is indented
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected int getIndentLevel() {
return 0;
}
// Expression methods
//-------------------------------------------------------------------------
/**
* Express an element tag start using given qualified name.
*
* @param qualifiedName the qualified name of the element to be expressed
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressElementStart(String qualifiedName)
throws IOException, SAXException {
// do nothing
}
/**
* Express an element tag start using given qualified name.
*
* @param uri the namespace uri
* @param localName the local name for this element
* @param qualifiedName the qualified name of the element to be expressed
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressElementStart(String uri, String localName, String qualifiedName)
throws IOException, SAXException {
expressElementStart( qualifiedName );
}
/**
* Express a closing tag.
*
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressTagClose() throws IOException, SAXException {}
/**
* Express an element end tag (with given name)
*
* @param qualifiedName the qualified name for the element to be closed
*
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressElementEnd(String qualifiedName)
throws IOException, SAXException {
// do nothing
}
/**
* Express an element end tag (with given name)
*
* @param uri the namespace uri of the element close tag
* @param localName the local name of the element close tag
* @param qualifiedName the qualified name for the element to be closed
*
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressElementEnd(
String uri,
String localName,
String qualifiedName)
throws
IOException,
SAXException {
expressElementEnd(qualifiedName);
}
/**
* Express an empty element end.
*
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressElementEnd() throws IOException, SAXException {}
/**
* Express body text
*
* @param text the string to write out as the body of the current element
*
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressBodyText(String text) throws IOException, SAXException {}
/**
* Express an attribute
*
* @param qualifiedName the qualified name of the attribute
* @param value the attribute value
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressAttribute(
String qualifiedName,
String value)
throws
IOException,
SAXException {
// Do nothing
}
/**
* Express an attribute
*
* @param namespaceUri the namespace uri
* @param localName the local name
* @param qualifiedName the qualified name of the attribute
* @param value the attribute value
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void expressAttribute(
String namespaceUri,
String localName,
String qualifiedName,
String value)
throws
IOException,
SAXException {
expressAttribute(qualifiedName, value);
}
/**
* Writes the given element
*
* @param qualifiedName qualified name to use for the element
* @param elementDescriptor the <code>ElementDescriptor</code> describing the element
* @param context the <code>Context</code> to use to evaluate the bean expressions
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @throws IntrospectionException if a java beans introspection problem occurs
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void write(
String qualifiedName,
ElementDescriptor elementDescriptor,
Context context )
throws
IOException,
SAXException,
IntrospectionException {
writeElement( "", qualifiedName, qualifiedName, elementDescriptor, context );
}
/**
* Writes the given element adding an ID attribute
*
* @param qualifiedName qualified name to use for the element
* @param elementDescriptor the <code>ElementDescriptor</code> describing the element
* @param context the <code>Context</code> to use to evaluate the bean expressions
* @param idAttribute the qualified name of the <code>ID</code> attribute
* @param idValue the value for the <code>ID</code> attribute
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @throws IntrospectionException if a java beans introspection problem occurs
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void write(
String qualifiedName,
ElementDescriptor elementDescriptor,
Context context,
String idAttribute,
String idValue )
throws
IOException,
SAXException,
IntrospectionException {
writeElement(
"",
qualifiedName,
qualifiedName,
elementDescriptor,
context,
idAttribute,
idValue );
}
/**
* Write attributes, child elements and element end
*
* @param qualifiedName qualified name to use for the element
* @param elementDescriptor the <code>ElementDescriptor</code> describing the element
* @param context the <code>Context</code> to use to evaluate the bean expressions
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @throws IntrospectionException if a java beans introspection problem occurs
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void writeRestOfElement(
String qualifiedName,
ElementDescriptor elementDescriptor,
Context context )
throws
IOException,
SAXException,
IntrospectionException {
writeRestOfElement( "", qualifiedName, qualifiedName, elementDescriptor, context );
}
/**
* Writes an element with a <code>IDREF</code> attribute
*
* @param qualifiedName of the element with <code>IDREF</code> attribute
* @param idrefAttributeName the qualified name of the <code>IDREF</code> attribute
* @param idrefAttributeValue the value for the <code>IDREF</code> attribute
* @throws IOException if an IO problem occurs during writing
* @throws SAXException if an SAX problem occurs during writing
* @throws IntrospectionException if a java beans introspection problem occurs
* @deprecated 0.5 replaced by new SAX inspired API
*/
protected void writeIDREFElement(
String qualifiedName,
String idrefAttributeName,
String idrefAttributeValue )
throws
IOException,
SAXException,
IntrospectionException {
// deprecated
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(
"",
idrefAttributeName,
idrefAttributeName,
"IDREF",
idrefAttributeValue);
startElement( "", qualifiedName, qualifiedName, attributes);
endElement( "", qualifiedName, qualifiedName );
}
/**
* Writes the element content.
*
* @param elementDescriptor the <code>ElementDescriptor</code> to write as xml
* @param context the <code>Context</code> to use to evaluate the bean expressions
* @return true if so
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -