Java Code Examples for org.xml.sax.helpers.AttributesImpl#addAttribute()
The following examples show how to use
org.xml.sax.helpers.AttributesImpl#addAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAXModuleAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
@Override public void visitOpen(String packaze, int access, String... modules) { AttributesImpl att = new AttributesImpl(); StringBuilder sb = new StringBuilder(); SAXClassAdapter.appendAccess(access | SAXClassAdapter.ACCESS_MODULE, sb); att.addAttribute("", "name", "name", "", packaze); att.addAttribute("", "access", "access", "", sb.toString()); sa.addStart("opens", att); if (modules != null && modules.length > 0) { for (String to : modules) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "module", "module", "", to); sa.addElement("to", atts); } } sa.addEnd("opens"); }
Example 2
Source File: CacheXmlGenerator.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Generates XML for a <code>MembershipAttributes</code> */ private void generate(MembershipAttributes ra) throws SAXException { Set roles = ra.getRequiredRoles(); String laction = ra.getLossAction().toString().toLowerCase().replace('_', '-'); String raction = ra.getResumptionAction().toString().toLowerCase().replace('_', '-'); AttributesImpl raAtts = new AttributesImpl(); raAtts.addAttribute("", "", LOSS_ACTION, "", laction); raAtts.addAttribute("", "", RESUMPTION_ACTION, "", raction); handler.startElement("", MEMBERSHIP_ATTRIBUTES, MEMBERSHIP_ATTRIBUTES, raAtts); for (Iterator iter = roles.iterator(); iter.hasNext();) { Role role = (Role) iter.next(); AttributesImpl roleAtts = new AttributesImpl(); roleAtts.addAttribute("", "", NAME, "", role.getName()); handler.startElement("", REQUIRED_ROLE, REQUIRED_ROLE, roleAtts); handler.endElement("", REQUIRED_ROLE, REQUIRED_ROLE); } handler.endElement("", MEMBERSHIP_ATTRIBUTES, MEMBERSHIP_ATTRIBUTES); }
Example 3
Source File: XMLTransferReportWriter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void writeParentAssoc(ChildAssociationRef assoc) throws SAXException { if(assoc != null) { AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "from", "from", "String", assoc.getParentRef().toString()); attributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "type", "type", "String", formatQName(assoc.getTypeQName())); attributes.addAttribute(TransferModel.TRANSFER_MODEL_1_0_URI, "type", "isPrimary", "Boolean", assoc.isPrimary()?"true":"false"); writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOC, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOC, attributes); String name= formatQName(assoc.getQName()); writer.characters(name.toCharArray(), 0, name.length()); assoc.isPrimary(); writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOC, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOC); } }
Example 4
Source File: CacheXmlGenerator.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Generates XML for a <code>MembershipAttributes</code> */ private void generate(MembershipAttributes ra) throws SAXException { Set roles = ra.getRequiredRoles(); String laction = ra.getLossAction().toString().toLowerCase().replace('_', '-'); String raction = ra.getResumptionAction().toString().toLowerCase().replace('_', '-'); AttributesImpl raAtts = new AttributesImpl(); raAtts.addAttribute("", "", LOSS_ACTION, "", laction); raAtts.addAttribute("", "", RESUMPTION_ACTION, "", raction); handler.startElement("", MEMBERSHIP_ATTRIBUTES, MEMBERSHIP_ATTRIBUTES, raAtts); for (Iterator iter = roles.iterator(); iter.hasNext();) { Role role = (Role) iter.next(); AttributesImpl roleAtts = new AttributesImpl(); roleAtts.addAttribute("", "", NAME, "", role.getName()); handler.startElement("", REQUIRED_ROLE, REQUIRED_ROLE, roleAtts); handler.endElement("", REQUIRED_ROLE, REQUIRED_ROLE); } handler.endElement("", MEMBERSHIP_ATTRIBUTES, MEMBERSHIP_ATTRIBUTES); }
Example 5
Source File: IvyArtifactReport.java From ant-ivy with Apache License 2.0 | 6 votes |
private void writeOriginLocationIfPresent(RepositoryCacheManager cache, TransformerHandler saxHandler, ArtifactDownloadReport artifact) throws SAXException { ArtifactOrigin origin = artifact.getArtifactOrigin(); if (!ArtifactOrigin.isUnknown(origin)) { String originName = origin.getLocation(); boolean isOriginLocal = origin.isLocal(); String originLocation; AttributesImpl originLocationAttrs = new AttributesImpl(); if (isOriginLocal) { originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "true"); originLocation = originName.replace('\\', '/'); } else { originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "false"); originLocation = originName; } saxHandler .startElement(null, "origin-location", "origin-location", originLocationAttrs); char[] originLocationAsChars = originLocation.toCharArray(); saxHandler.characters(originLocationAsChars, 0, originLocationAsChars.length); saxHandler.endElement(null, "origin-location", "origin-location"); } }
Example 6
Source File: AttrImplTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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"); }
Example 7
Source File: SAXClassAdapter.java From tajo with Apache License 2.0 | 6 votes |
@Override public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) { StringBuffer sb = new StringBuffer(); appendAccess(access | ACCESS_FIELD, sb); AttributesImpl att = new AttributesImpl(); att.addAttribute("", "access", "access", "", sb.toString()); att.addAttribute("", "name", "name", "", name); att.addAttribute("", "desc", "desc", "", desc); if (signature != null) { att.addAttribute("", "signature", "signature", "", encode(signature)); } if (value != null) { att.addAttribute("", "value", "value", "", encode(value.toString())); } return new SAXFieldAdapter(sa, att); }
Example 8
Source File: CreoleXmlUpperCaseFilter.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
/** * Process the start of an element. If the element is a standard * creole.xml element then it and all its attributes have their names * converted to upper case. Other elements are passed through * untouched. */ @Override public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { String upperCaseName = localName.toUpperCase(); if(knownElements.contains(upperCaseName)) { AttributesImpl newAtts = new AttributesImpl(); for(int i = 0; i < atts.getLength(); i++) { String upperCaseAttrName = atts.getLocalName(i).toUpperCase(); String attrQName = atts.getQName(i); newAtts.addAttribute(atts.getURI(i), upperCaseAttrName, attrQName .substring(0, attrQName.indexOf(':') + 1) + upperCaseAttrName, atts.getType(i), atts.getValue(i)); } super.startElement(uri, upperCaseName, name.substring(0, name .indexOf(':') + 1) + upperCaseName, newAtts); } else { super.startElement(uri, localName, name, atts); } }
Example 9
Source File: JSonConfigReader.java From tomee with Apache License 2.0 | 6 votes |
private static AttributesImpl toAttributes(final Map<String, String> map, final String... ignored) { map.remove(COMMENT_KEY); final AttributesImpl attributes = new AttributesImpl(); for (final Map.Entry<String, String> entry : map.entrySet()) { final String key = entry.getKey(); boolean add = true; for (final String i : ignored) { if (key.equals(i)) { add = false; break; } } if (add) { attributes.addAttribute(null, key, key, null, entry.getValue()); } } return attributes; }
Example 10
Source File: AttributeSource.java From ramus with GNU General Public License v3.0 | 5 votes |
@Override public void save(ChartSaveXMLReader reader) throws SAXException { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", ATTRIBUTE_ID, ATTRIBUTE_ID, "CDATA", Long .toString(attribute.getId())); reader.startElement(SOURCE, attrs); reader.endElement(SOURCE); }
Example 11
Source File: SAXCodeAdapter.java From jtransc with Apache License 2.0 | 5 votes |
@Override public final void visitIincInsn(final int var, final int increment) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "var", "var", "", Integer.toString(var)); attrs.addAttribute("", "inc", "inc", "", Integer.toString(increment)); sa.addElement(Printer.OPCODES[Opcodes.IINC], attrs); }
Example 12
Source File: XMLTransferEventFormatterFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public AttributesImpl getAttributes(TransferEvent event) { TransferEventError s = (TransferEventError)event; AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(event.getTime())); return attributes; }
Example 13
Source File: XMLStreamReaderToContentHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Get the attributes associated with the given START_ELEMENT or ATTRIBUTE * StAXevent. * * @return the StAX attributes converted to an org.xml.sax.Attributes */ private Attributes getAttributes() { AttributesImpl attrs = new AttributesImpl(); int eventType = staxStreamReader.getEventType(); if (eventType != XMLStreamConstants.ATTRIBUTE && eventType != XMLStreamConstants.START_ELEMENT) { throw new InternalError( "getAttributes() attempting to process: " + eventType); } // in SAX, namespace declarations are not part of attributes by default. // (there's a property to control that, but as far as we are concerned // we don't use it.) So don't add xmlns:* to attributes. // gather non-namespace attrs for (int i = 0; i < staxStreamReader.getAttributeCount(); i++) { String uri = staxStreamReader.getAttributeNamespace(i); if(uri==null) uri=""; String localName = staxStreamReader.getAttributeLocalName(i); String prefix = staxStreamReader.getAttributePrefix(i); String qName; if(prefix==null || prefix.length()==0) qName = localName; else qName = prefix + ':' + localName; String type = staxStreamReader.getAttributeType(i); String value = staxStreamReader.getAttributeValue(i); attrs.addAttribute(uri, localName, qName, type, value); } return attrs; }
Example 14
Source File: XMLTransferDestinationReportWriter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void writeComment(String comment) { try { AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(TransferReportModel.TRANSFER_REPORT_MODEL_1_0_URI, "date", "date", "dateTime", ISO8601DateFormat.format(new Date())); writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT, attributes); writer.characters(comment.toCharArray(), 0, comment.length()); writer.endElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT, PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_COMMENT); } catch(SAXException se) { } }
Example 15
Source File: SAXCodeAdapter.java From jtransc with Apache License 2.0 | 5 votes |
@Override public void visitParameter(String name, int access) { AttributesImpl attrs = new AttributesImpl(); if (name != null) { attrs.addAttribute("", "name", "name", "", name); } StringBuilder sb = new StringBuilder(); SAXClassAdapter.appendAccess(access, sb); attrs.addAttribute("", "access", "access", "", sb.toString()); sa.addElement("parameter", attrs); }
Example 16
Source File: SAXClassAdapter.java From tajo with Apache License 2.0 | 5 votes |
@Override public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { StringBuffer sb = new StringBuffer(); appendAccess(access | ACCESS_CLASS, sb); AttributesImpl att = new AttributesImpl(); att.addAttribute("", "access", "access", "", sb.toString()); if (name != null) { att.addAttribute("", "name", "name", "", name); } if (signature != null) { att.addAttribute("", "signature", "signature", "", encode(signature)); } if (superName != null) { att.addAttribute("", "parent", "parent", "", superName); } att.addAttribute("", "major", "major", "", Integer.toString(version & 0xFFFF)); att.addAttribute("", "minor", "minor", "", Integer.toString(version >>> 16)); sa.addStart("class", att); sa.addStart("interfaces", new AttributesImpl()); if (interfaces != null && interfaces.length > 0) { for (String anInterface : interfaces) { AttributesImpl att2 = new AttributesImpl(); att2.addAttribute("", "name", "name", "", anInterface); sa.addElement("interface", att2); } } sa.addEnd("interfaces"); }
Example 17
Source File: SAXCodeAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
private void appendFrameTypes(final boolean local, final int n, final Object[] types) { for (int i = 0; i < n; ++i) { Object type = types[i]; AttributesImpl attrs = new AttributesImpl(); if (type instanceof String) { attrs.addAttribute("", "type", "type", "", (String) type); } else if (type instanceof Integer) { attrs.addAttribute("", "type", "type", "", TYPES[((Integer) type).intValue()]); } else { attrs.addAttribute("", "type", "type", "", "uninitialized"); attrs.addAttribute("", "label", "label", "", getLabel((Label) type)); } sa.addElement(local ? "local" : "stack", attrs); } }
Example 18
Source File: PeakListSaveHandler.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
/** * Add the row information into the XML document * * @param row * @param element * @throws IOException */ private void fillRowElement(PeakListRow row, TransformerHandler hd) throws SAXException, IOException { // <PEAK_IDENTITY> PeakIdentity preferredIdentity = row.getPreferredPeakIdentity(); PeakIdentity[] identities = row.getPeakIdentities(); AttributesImpl atts = new AttributesImpl(); for (int i = 0; i < identities.length; i++) { if (canceled) return; atts.addAttribute("", "", PeakListElementName.ID.getElementName(), "CDATA", String.valueOf(i)); atts.addAttribute("", "", PeakListElementName.PREFERRED.getElementName(), "CDATA", String.valueOf(identities[i] == preferredIdentity)); hd.startElement("", "", PeakListElementName.PEAK_IDENTITY.getElementName(), atts); fillIdentityElement(identities[i], hd); hd.endElement("", "", PeakListElementName.PEAK_IDENTITY.getElementName()); } // <PEAK_INFORMATION> // atts.clear(); if (canceled) return; // atts.addAttribute("", "", PeakListElementName.ID.getElementName(), // "CDATA", "INFORMATION"); hd.startElement("", "", PeakListElementName.PEAK_INFORMATION.getElementName(), atts); fillInformationElement(row.getPeakInformation(), hd); hd.endElement("", "", PeakListElementName.PEAK_INFORMATION.getElementName()); // <PEAK> Feature[] peaks = row.getPeaks(); for (Feature p : peaks) { if (canceled) return; atts.clear(); String dataFileID = dataFilesIDMap.get(p.getDataFile()); atts.addAttribute("", "", PeakListElementName.COLUMN.getElementName(), "CDATA", dataFileID); atts.addAttribute("", "", PeakListElementName.MZ.getElementName(), "CDATA", String.valueOf(p.getMZ())); // In the project file, retention time is represented in seconds, // for historical reasons double rt = p.getRT() * 60d; atts.addAttribute("", "", PeakListElementName.RT.getElementName(), "CDATA", String.valueOf(rt)); atts.addAttribute("", "", PeakListElementName.HEIGHT.getElementName(), "CDATA", String.valueOf(p.getHeight())); atts.addAttribute("", "", PeakListElementName.AREA.getElementName(), "CDATA", String.valueOf(p.getArea())); atts.addAttribute("", "", PeakListElementName.STATUS.getElementName(), "CDATA", p.getFeatureStatus().toString()); atts.addAttribute("", "", PeakListElementName.CHARGE.getElementName(), "CDATA", String.valueOf(p.getCharge())); atts.addAttribute("", "", PeakListElementName.PARENT_CHROMATOGRAM_ROW_ID.getElementName(), "CDATA", p.getParentChromatogramRowID() != null ? String.valueOf(p.getParentChromatogramRowID()) : ""); hd.startElement("", "", PeakListElementName.PEAK.getElementName(), atts); fillPeakElement(p, hd); hd.endElement("", "", PeakListElementName.PEAK.getElementName()); } }
Example 19
Source File: DotCorpusSerializer.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Writes the <code>DotCorpus</code> instance to the given <code>OutputStream</code>. * * @param dotCorpus * the {@link DotCorpus} object to serialize. * @param out * - the stream to write the current <code>DotCorpus</code> instance. * @throws CoreException - */ public static void serialize(DotCorpus dotCorpus, OutputStream out) throws CoreException { XMLSerializer xmlSerializer = new XMLSerializer(out, true); ContentHandler xmlSerHandler = xmlSerializer.getContentHandler(); try { xmlSerHandler.startDocument(); xmlSerHandler.startElement("", CONFIG_ELEMENT, CONFIG_ELEMENT, new AttributesImpl()); for (String corpusFolder : dotCorpus.getCorpusFolderNameList()) { AttributesImpl corpusFolderAttributes = new AttributesImpl(); corpusFolderAttributes.addAttribute("", "", CORPUS_FOLDER_ATTRIBUTE, "", corpusFolder); xmlSerHandler.startElement("", CORPUS_ELEMENT, CORPUS_ELEMENT, corpusFolderAttributes); xmlSerHandler.endElement("", CORPUS_ELEMENT, CORPUS_ELEMENT); } for (AnnotationStyle style : dotCorpus.getAnnotationStyles()) { AttributesImpl styleAttributes = new AttributesImpl(); styleAttributes.addAttribute("", "", STYLE_TYPE_ATTRIBUTE, "", style.getAnnotation()); styleAttributes.addAttribute("", "", STYLE_STYLE_ATTRIBUTE, "", style.getStyle().name()); Color color = style.getColor(); int colorInt = new Color(color.getRed(), color.getGreen(), color.getBlue()).getRGB(); styleAttributes.addAttribute("", "", STYLE_COLOR_ATTRIBUTE, "", Integer.toString(colorInt)); styleAttributes.addAttribute("", "", STYLE_LAYER_ATTRIBUTE, "", Integer.toString(style .getLayer())); if (style.getConfiguration() != null) { styleAttributes.addAttribute("", "", STYLE_CONFIG_ATTRIBUTE, "", style .getConfiguration()); } xmlSerHandler.startElement("", STYLE_ELEMENT, STYLE_ELEMENT, styleAttributes); xmlSerHandler.endElement("", STYLE_ELEMENT, STYLE_ELEMENT); } for (String type : dotCorpus.getShownTypes()) { AttributesImpl shownAttributes = new AttributesImpl(); shownAttributes.addAttribute("", "", SHOWN_TYPE_ATTRIBUTE, "", type); shownAttributes.addAttribute("", "", SHOWN_IS_VISISBLE_ATTRIBUTE, "", "true"); xmlSerHandler.startElement("", SHOWN_ELEMENT, SHOWN_ELEMENT, shownAttributes); xmlSerHandler.endElement("", SHOWN_ELEMENT, SHOWN_ELEMENT); } if (dotCorpus.getTypeSystemFileName() != null) { AttributesImpl typeSystemFileAttributes = new AttributesImpl(); typeSystemFileAttributes.addAttribute("", "", TYPESYTEM_FILE_ATTRIBUTE, "", dotCorpus .getTypeSystemFileName()); xmlSerHandler.startElement("", TYPESYSTEM_ELEMENT, TYPESYSTEM_ELEMENT, typeSystemFileAttributes); xmlSerHandler.endElement("", TYPESYSTEM_ELEMENT, TYPESYSTEM_ELEMENT); } for (String folder : dotCorpus.getCasProcessorFolderNames()) { AttributesImpl taggerConfigAttributes = new AttributesImpl(); taggerConfigAttributes.addAttribute("", "", CAS_PROCESSOR_FOLDER_ATTRIBUTE, "", folder); xmlSerHandler.startElement("", CAS_PROCESSOR_ELEMENT, CAS_PROCESSOR_ELEMENT, taggerConfigAttributes); xmlSerHandler.endElement("", CAS_PROCESSOR_ELEMENT, CAS_PROCESSOR_ELEMENT); } if (dotCorpus.getEditorLineLengthHint() != DotCorpus.EDITOR_LINE_LENGTH_HINT_DEFAULT) { AttributesImpl editorLineLengthHintAttributes = new AttributesImpl(); editorLineLengthHintAttributes.addAttribute("", "", EDITOR_LINE_LENGTH_ATTRIBUTE, "", Integer.toString(dotCorpus.getEditorLineLengthHint())); xmlSerHandler.startElement("", EDITOR_ELEMENT, EDITOR_ELEMENT, editorLineLengthHintAttributes); xmlSerHandler.endElement("", EDITOR_ELEMENT, EDITOR_ELEMENT); } xmlSerHandler.endElement("", CONFIG_ELEMENT, CONFIG_ELEMENT); xmlSerHandler.endDocument(); } catch (SAXException e) { String message = e.getMessage() != null ? e.getMessage() : ""; IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e); throw new CoreException(s); } }
Example 20
Source File: CacheXmlGenerator.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Generates XML for the given disk store * * @since prPersistSprint2 */ private void generate(DiskStore ds) throws SAXException { if (this.version.compareTo(VERSION_6_5) < 0) { return; } AttributesImpl atts = new AttributesImpl(); try { atts.addAttribute("", "", NAME, "", ds.getName()); if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasAutoCompact())) { if (generateDefaults() || ds.getAutoCompact() != DiskStoreFactory.DEFAULT_AUTO_COMPACT) atts.addAttribute("", "", AUTO_COMPACT, "", String.valueOf(ds.getAutoCompact())); } if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasAllowForceCompaction())) { if (generateDefaults() || ds.getAllowForceCompaction() != DiskStoreFactory.DEFAULT_ALLOW_FORCE_COMPACTION) atts.addAttribute("", "", ALLOW_FORCE_COMPACTION, "", String.valueOf(ds.getAllowForceCompaction())); } if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasCompactionThreshold())) { if (generateDefaults() || ds.getCompactionThreshold() != DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD) atts.addAttribute("", "", COMPACTION_THRESHOLD, "", String.valueOf(ds.getCompactionThreshold())); } if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasMaxOplogSize())) { if (generateDefaults() || ds.getMaxOplogSize() != DiskStoreFactory.DEFAULT_MAX_OPLOG_SIZE) atts.addAttribute("", "", MAX_OPLOG_SIZE, "", String.valueOf(ds.getMaxOplogSize())); } if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasTimeInterval())) { if (generateDefaults() || ds.getTimeInterval() != DiskStoreFactory.DEFAULT_TIME_INTERVAL) atts.addAttribute("", "", TIME_INTERVAL, "", String.valueOf(ds.getTimeInterval())); } if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasWriteBufferSize())) { if (generateDefaults() || ds.getWriteBufferSize() != DiskStoreFactory.DEFAULT_WRITE_BUFFER_SIZE) atts.addAttribute("", "", WRITE_BUFFER_SIZE, "", String.valueOf(ds.getWriteBufferSize())); } if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasQueueSize())) { if (generateDefaults() || ds.getQueueSize() != DiskStoreFactory.DEFAULT_QUEUE_SIZE) atts.addAttribute("", "", QUEUE_SIZE, "", String.valueOf(ds.getQueueSize())); } } finally { handler.startElement("", DISK_STORE, DISK_STORE, atts); if ((!(ds instanceof DiskStoreAttributesCreation) || ((DiskStoreAttributesCreation) ds).hasDiskDirs())) { File[] diskDirs = ds.getDiskDirs(); int[] diskSizes = ds.getDiskDirSizes(); if (diskDirs != null && diskDirs.length > 0) { if (generateDefaults() || !Arrays.equals(diskDirs, DiskStoreFactory.DEFAULT_DISK_DIRS) || !Arrays.equals(diskSizes, DiskStoreFactory.DEFAULT_DISK_DIR_SIZES)) { handler.startElement("", DISK_DIRS, DISK_DIRS, EMPTY); for (int i = 0; i < diskDirs.length; i++) { AttributesImpl diskAtts = new AttributesImpl(); if (diskSizes[i] != DiskStoreFactory.DEFAULT_DISK_DIR_SIZE) { diskAtts.addAttribute("", "", DIR_SIZE, "", String .valueOf(diskSizes[i])); } handler.startElement("", DISK_DIR, DISK_DIR, diskAtts); File dir = diskDirs[i]; String name = generateDefaults() ? dir.getAbsolutePath() : dir.getPath(); handler.characters(name.toCharArray(), 0, name.length()); handler.endElement("", DISK_DIR, DISK_DIR); } handler.endElement("", DISK_DIRS, DISK_DIRS); } } } handler.endElement("", "", DISK_STORE); } }