本文整理匯總了Java中org.xml.sax.helpers.AttributesImpl.addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributesImpl.addAttribute方法的具體用法?Java AttributesImpl.addAttribute怎麽用?Java AttributesImpl.addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xml.sax.helpers.AttributesImpl
的用法示例。
在下文中一共展示了AttributesImpl.addAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addInclude
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
private void addInclude(Node parent, List files) throws SAXException {
if (files != null) {
Iterator iter = files.iterator();
while (iter.hasNext()) {
String file = (String)iter.next();
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "file", "file", "CDATA", file);
// Create a dummy Include directive node
Node includeDir =
new Node.IncludeDirective(attrs, null, // XXX
parent);
processIncludeDirective(file, includeDir);
}
}
}
示例2: visitInnerClass
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
@Override
public final void visitInnerClass(final String name,
final String outerName, final String innerName, final int access) {
StringBuilder sb = new StringBuilder();
appendAccess(access | ACCESS_INNER, sb);
AttributesImpl att = new AttributesImpl();
att.addAttribute("", "access", "access", "", sb.toString());
if (name != null) {
att.addAttribute("", "name", "name", "", name);
}
if (outerName != null) {
att.addAttribute("", "outerName", "outerName", "", outerName);
}
if (innerName != null) {
att.addAttribute("", "innerName", "innerName", "", innerName);
}
sa.addElement("innerclass", att);
}
示例3: testcase07
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
/**
* Basic test for setLocalName(int, String), setQName(int, String),
* setType(int, String), setValue(int, String) and setURI(int, String).
*/
@Test
public void testcase07() {
AttributesImpl attr = new AttributesImpl();
attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE);
attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE,
JEEP_VALUE);
attr.setLocalName(1, "speclead");
attr.setQName(1, "megi");
attr.setType(1, "sax");
attr.setValue(1, "SAX01");
attr.setURI(1, "www.megginson.com/sax/sax01");
assertEquals(attr.getLocalName(1), "speclead");
assertEquals(attr.getQName(1), "megi");
assertEquals(attr.getType(1), "sax");
assertEquals(attr.getType("megi"), "sax");
assertEquals(attr.getURI(1), "www.megginson.com/sax/sax01");
}
示例4: addInclude
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
/**
* Add a list of files. This is used for implementing include-prelude and
* include-coda of jsp-config element in web.xml
*/
private void addInclude(Node parent, List<String> files) throws JasperException {
if (files != null) {
Iterator<String> iter = files.iterator();
while (iter.hasNext()) {
String file = iter.next();
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "file", "file", "CDATA", file);
// Create a dummy Include directive node
Node includeNode = new Node.IncludeDirective(attrs, reader
.mark(), parent);
processIncludeDirective(file, includeNode);
}
}
}
示例5: writeCategory
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void writeCategory (NodeRef nodeRef, ManifestCategory value) throws SAXException
{
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "path", "path", "String",
value.getPath());
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_CATEGORY, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_CATEGORY, attributes);
writeValue(nodeRef);
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_CATEGORY, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_CATEGORY);
}
示例6: writeMLValue
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
private void writeMLValue(Locale locale, Serializable value) throws SAXException
{
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "locale", "locale", "String",
locale.toString());
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_MLVALUE, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_MLVALUE, attributes);
if (value != null)
{
String strValue = (String) DefaultTypeConverter.INSTANCE.convert(String.class, value);
boolean oldValue = format.isTrimText();
format.setTrimText(false);
try
{
writer.characters(strValue.toCharArray(), 0, strValue.length());
}
finally
{
format.setTrimText(oldValue);
}
}
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_MLVALUE, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_MLVALUE);
}
示例7: visitMaxs
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
@Override
public final void visitMaxs(final int maxStack, final int maxLocals) {
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "maxStack", "maxStack", "",
Integer.toString(maxStack));
attrs.addAttribute("", "maxLocals", "maxLocals", "",
Integer.toString(maxLocals));
sa.addElement("Max", attrs);
sa.addEnd("code");
}
示例8: visitTryCatchBlock
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
@Override
public final void visitTryCatchBlock(final Label start, final Label end,
final Label handler, final String type) {
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "start", "start", "", getLabel(start));
attrs.addAttribute("", "end", "end", "", getLabel(end));
attrs.addAttribute("", "handler", "handler", "", getLabel(handler));
if (type != null) {
attrs.addAttribute("", "type", "type", "", type);
}
sa.addElement("TryCatch", attrs);
}
示例9: writeTarget
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
/**
* Write the target to the report
*/
public void writeTarget(TransferTarget target) throws SAXException
{
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, "name", "name", "String", target.getName());
attributes.addAttribute(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, "endpointHost", "endpointHost", "String", target.getEndpointHost());
attributes.addAttribute(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, "endpointPort", "endpointPort", "int", String.valueOf(target.getEndpointPort()));
writer.startElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_TARGET, PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_TARGET, attributes);
writer.endElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_TARGET, PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_TARGET);
}
示例10: getAttributes
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
@Override
public AttributesImpl getAttributes(TransferEvent event)
{
TransferEventEndState s = (TransferEventEndState)event;
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(event.getTime()));
attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "state", "state", "string", s.getTransferState().toString());
return attributes;
}
示例11: getAttributes
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
/**
* Gets the Attributes that are not namesapce declarations
* @param attrs
* @return
*/
private AttributesImpl getAttributes(NamedNodeMap attrs) {
AttributesImpl atts = new AttributesImpl();
if(attrs == null)
return EMPTY_ATTS;
for(int i=0; i < attrs.getLength();i++) {
Attr a = (Attr)attrs.item(i);
//check if attr is ns declaration
if("xmlns".equals(a.getPrefix()) || "xmlns".equals(a.getLocalName())) {
continue;
}
atts.addAttribute(fixNull(a.getNamespaceURI()),a.getLocalName(),a.getName(),a.getSchemaTypeInfo().getTypeName(),a.getValue());
}
return atts;
}
示例12: testcase06
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
/**
* Basic test for getLocalName(int), getQName(int), getType(int),
* getType(String) and getURI(int).
*/
@Test
public void testcase06() {
AttributesImpl attr = new AttributesImpl();
attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE);
attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE,
JEEP_VALUE);
attr.setAttribute(1, "www.megginson.com", "author", "meg", "s", "SAX2");
assertEquals(attr.getLocalName(1), "author");
assertEquals(attr.getQName(1), "meg");
assertEquals(attr.getType(1), "s");
assertEquals(attr.getType("meg"), "s");
assertEquals(attr.getURI(1), "www.megginson.com");
}
示例13: getConstantAttribute
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
private static AttributesImpl getConstantAttribute(final Object cst) {
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "cst", "cst", "",
SAXClassAdapter.encode(cst.toString()));
attrs.addAttribute("", "desc", "desc", "",
Type.getDescriptor(cst.getClass()));
return attrs;
}
示例14: writeProperty
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void writeProperty(QName propertyName, Serializable value) throws SAXException
{
{
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "name", "name", "String",
formatQName(propertyName));
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_PROPERTY, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_PROPERTY, attributes);
}
if (value == null)
{
writeNullValue();
}
else if (value instanceof ContentData)
{
ContentData data = (ContentData) value;
AttributesImpl dataAttributes = new AttributesImpl();
dataAttributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "contentURL",
"contentURL", "String", data.getContentUrl());
dataAttributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "mimetype",
"mimetype", "String", data.getMimetype());
dataAttributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "size", "size",
"String", Long.toString(data.getSize()));
dataAttributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "encoding",
"encoding", "String", data.getEncoding());
dataAttributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "locale", "locale",
"String", data.getLocale().toString());
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_CONTENT_HEADER, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_CONTENT_HEADER,
dataAttributes);
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_CONTENT_HEADER, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_CONTENT_HEADER);
}
else if (value instanceof Collection)
{
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_VALUES, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_VALUES, EMPTY_ATTRIBUTES);
int index = 0;
for (Object valueInCollection : (Collection) value)
{
writeValue((Serializable) valueInCollection);
index++;
}
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_VALUES, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_VALUES);
}
else if (value instanceof MLText)
{
MLText mltext = (MLText) value;
for (Entry<Locale, String> entry : mltext.entrySet())
{
writeMLValue(entry.getKey(), entry.getValue());
}
}
else
{
writeValue(value);
}
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI,
ManifestModel.LOCALNAME_ELEMENT_PROPERTY, PREFIX + ":"
+ ManifestModel.LOCALNAME_ELEMENT_PROPERTY);
}
示例15: generateSSL
import org.xml.sax.helpers.AttributesImpl; //導入方法依賴的package包/類
/**
* Generates XML for the SSL configuration of the distributed system.
*/
private void generateSSL() throws SAXException {
DistributedSystemConfig config = this.system.getConfig();
boolean sslEnabled = config.isSSLEnabled();
if (!sslEnabled) {
return;
}
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "", AUTHENTICATION_REQUIRED, "",
String.valueOf(config.isSSLAuthenticationRequired()));
handler.startElement("", SSL, SSL, atts);
String protocols = config.getSSLProtocols();
if (protocols != null) {
handler.startElement("", PROTOCOLS, PROTOCOLS, EMPTY);
handler.characters(protocols.toCharArray(), 0, protocols.length());
handler.endElement("", PROTOCOLS, PROTOCOLS);
}
String ciphers = config.getSSLCiphers();
if (ciphers != null) {
handler.startElement("", CIPHERS, CIPHERS, EMPTY);
handler.characters(ciphers.toCharArray(), 0, ciphers.length());
handler.endElement("", CIPHERS, CIPHERS);
}
Properties sslProps = config.getSSLProperties();
for (Iterator iter = sslProps.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
handler.startElement("", PROPERTY, PROPERTY, EMPTY);
handler.startElement("", KEY, KEY, EMPTY);
handler.characters(key.toCharArray(), 0, key.length());
handler.endElement("", KEY, KEY);
handler.startElement("", VALUE, VALUE, EMPTY);
handler.characters(value.toCharArray(), 0, value.length());
handler.endElement("", VALUE, VALUE);
handler.endElement("", PROPERTY, PROPERTY);
}
handler.endElement("", SSL, SSL);
}