本文整理了Java中org.jdom2.Element.addContent()
方法的一些代码示例,展示了Element.addContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addContent()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:addContent
[英]Inserts the content in a collection into the content list at the given index. In event of an exception the original content will be unchanged and the objects in the supplied collection will be unaltered.
[中]将集合中的内容插入到给定索引处的内容列表中。发生异常时,原始内容将保持不变,所提供集合中的对象将保持不变。
代码示例来源:origin: gocd/gocd
private void addBreakers(Element element) {
Element messages = new Element("messages");
Element message = new Element("message");
String breakerNames = StringUtils.join(breakers, ", ");
message.setAttribute("text", breakerNames);
message.setAttribute("kind", "Breakers");
messages.addContent(message);
element.addContent(messages);
}
代码示例来源:origin: simpligility/android-maven-plugin
@SuppressWarnings( "unchecked" )
private void appendElement( Element source, Element target )
{
for ( Iterator<Attribute> itr = source.getAttributes().iterator(); itr.hasNext(); )
{
Attribute a = itr.next();
itr.remove();
Attribute mergedAtt = target.getAttribute( a.getName(), a.getNamespace() );
if ( mergedAtt == null )
{
target.setAttribute( a );
}
}
for ( Iterator<Element> itr = source.getChildren().iterator(); itr.hasNext(); )
{
Content n = itr.next();
itr.remove();
target.addContent( n );
}
}
代码示例来源:origin: geotools/geotools
public Element createRootTree() {
final Element rootElement = new Element(GeoTiffConstants.GEOTIFF_IIO_ROOT_ELEMENT_NAME);
rootElement.addContent(createIFD());
return rootElement;
}
代码示例来源:origin: geotools/geotools
private Element createIFD() {
Element ifd = new Element(GeoTiffConstants.GEOTIFF_IFD_TAG);
ifd.setAttribute(
GeoTiffConstants.GEOTIFF_TAGSETS_ATT_NAME,
BaselineTIFFTagSet.class.getName() + "," + GeoTIFFTagSet.class.getName());
if (modelPixelScale.isSet()) {
ifd.addContent(createModelPixelScaleElement());
}
if (isModelTiePointsSet()) {
ifd.addContent(createModelTiePointsElement());
} else if (isModelTransformationSet()) {
ifd.addContent(createModelTransformationElement());
}
if (getNumGeoKeyEntries() > 1) {
ifd.addContent(createGeoKeyDirectoryElement());
}
if (numGeoTiffDoubleParams > 0) {
ifd.addContent(createGeoDoubleParamsElement());
}
if (numGeoTiffAsciiParams > 0) {
ifd.addContent(createGeoAsciiParamsElement());
}
if (isNodataSet) {
ifd.addContent(createNoDataElement());
}
if (isMetadataSet) {
createMetadataElement(ifd);
}
return ifd;
}
代码示例来源:origin: geotools/geotools
private Element createGeoAsciiParamsElement() {
Element field = createFieldElement(getGeoAsciiParamsTag());
Element data = new Element(GeoTiffConstants.GEOTIFF_ASCIIS_TAG);
field.addContent(data);
data.addContent(createAsciiElement(geoTiffAsciiParams.toString()));
return field;
}
代码示例来源:origin: org.jdom/jdom
/**
* Read an Element off the ObjectInputStream.
*
* @see #writeObject(ObjectOutputStream)
* @param in where to read the Element from.
* @throws IOException if there is a reading problem.
* @throws ClassNotFoundException when a class cannot be found
*/
private void readObject(final ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
content = new ContentList(this);
int nss = in.readInt();
while (--nss >= 0) {
addNamespaceDeclaration((Namespace)in.readObject());
}
int ats = in.readInt();
while (--ats >= 0) {
setAttribute((Attribute)in.readObject());
}
int cs = in.readInt();
while (--cs >= 0) {
addContent((Content)in.readObject());
}
}
代码示例来源:origin: edu.ucar/cdm
private void addCoord(Element tableElem, String name, String kind) {
if (name != null) {
Element elem = new Element("coordinate").setAttribute("kind", kind);
elem.addContent(name);
tableElem.addContent(elem);
}
}
代码示例来源:origin: geotools/geotools
private Element createNoDataElement() {
Element field = createFieldElement(getNoDataTag());
Element data = new Element(GeoTiffConstants.GEOTIFF_ASCIIS_TAG);
field.addContent(data);
data.addContent(createAsciiElement(Double.toString(noData)));
return field;
}
代码示例来源:origin: geotools/geotools
public void assignTo(Element element) {
if (!element.getName().equals(GeoTiffConstants.GEOTIFF_IIO_ROOT_ELEMENT_NAME)) {
throw new IllegalArgumentException(
"root not found: " + GeoTiffConstants.GEOTIFF_IIO_ROOT_ELEMENT_NAME);
}
final Element ifd1 = element.getChild(GeoTiffConstants.GEOTIFF_IFD_TAG);
if (ifd1 == null) {
throw new IllegalArgumentException(
"Unable to find child " + GeoTiffConstants.GEOTIFF_IFD_TAG);
}
final Element ifd2 = createIFD();
ifd1.setAttribute(
GeoTiffConstants.GEOTIFF_TAGSETS_ATT_NAME,
ifd2.getAttributeValue(GeoTiffConstants.GEOTIFF_TAGSETS_ATT_NAME));
final Element[] childElems = (Element[]) ifd2.getChildren().toArray(new Element[0]);
for (int i = 0; i < childElems.length; i++) {
final Element child = childElems[i];
ifd2.removeContent(child);
ifd1.addContent(child);
}
}
代码示例来源:origin: Unidata/thredds
private void addCoord(Element tableElem, String name, String kind) {
if (name != null) {
Element elem = new Element("coordinate").setAttribute("kind", kind);
elem.addContent(name);
tableElem.addContent(elem);
}
}
代码示例来源:origin: geotools/geotools
private Element createGeoDoubleParamsElement() {
Element field = createFieldElement(getGeoDoubleParamsTag());
Element data = new Element(GeoTiffConstants.GEOTIFF_DOUBLES_TAG);
field.addContent(data);
for (int i = 0; i < numGeoTiffDoubleParams; i++) {
Element param = createDoubleElement(geoTiffDoubleParams[i]);
data.addContent(param);
}
return field;
}
代码示例来源:origin: edu.ucar/netcdf
private void addCoord(Element tableElem, String name, String kind) {
if (name != null) {
Element elem = new Element("coordinate").setAttribute("kind", kind);
elem.addContent(name);
tableElem.addContent(elem);
}
}
代码示例来源:origin: geotools/geotools
private void createMetadataElement(Element ifd) {
if (ifd != null && tiffTagsMetadata != null && !tiffTagsMetadata.isEmpty()) {
Iterator<String> keys = tiffTagsMetadata.keySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
String[] setIdPair = key.split(":");
String set = TagSet.BASELINE.toString();
if (setIdPair.length > 1) {
set = setIdPair[0].toUpperCase();
}
String keyName = setIdPair[setIdPair.length - 1];
if (GeoTiffConstants.isNumeric(keyName)) {
final String value = tiffTagsMetadata.get(key);
final TIFFTag tag = getAsciiTag(set, Integer.valueOf(keyName));
if (tag != null) {
Element field = createFieldElement(tag);
Element data = new Element(GeoTiffConstants.GEOTIFF_ASCIIS_TAG);
field.addContent(data);
data.addContent(createAsciiElement(value));
ifd.addContent(field);
}
}
}
}
}
代码示例来源:origin: edu.ucar/netcdf
private Element genParamElement( String name, List<String> allowedValues )
{
Element paramElem = new Element( "Parameter", owcsNS ).setAttribute( "name", name );
Element allowedValuesElem = new Element( "AllowedValues", owcsNS );
for ( String curVal : allowedValues )
allowedValuesElem.addContent( new Element( "Value", owcsNS).addContent( curVal ) );
return paramElem.addContent( allowedValuesElem);
}
代码示例来源:origin: geotools/geotools
private Element createModelTransformationElement() {
Element field = createFieldElement(getModelTransformationTag());
Element data = new Element(GeoTiffConstants.GEOTIFF_DOUBLES_TAG);
field.addContent(data);
addDoubleElements(data, modelTransformation);
return field;
}
代码示例来源:origin: edu.ucar/netcdf
private Element genCapabilityOperationElem( String operationAsString )
{
Element getCapOpsElem;
getCapOpsElem= new Element( operationAsString, wcsNS );
getCapOpsElem.addContent(
new Element( "DCPType", wcsNS ).addContent(
new Element( "HTTP", wcsNS ).addContent(
new Element( "Get", wcsNS ).addContent(
new Element( "OnlineResource", wcsNS ).setAttribute(
"href", serverURI.toString(), xlinkNS ) ) ) ) );
return getCapOpsElem;
}
代码示例来源:origin: geotools/geotools
private Element createGeoKeyDirectoryElement() {
Element field = createFieldElement(getGeoKeyDirectoryTag());
Element data = new Element(GeoTiffConstants.GEOTIFF_SHORTS_TAG);
field.addContent(data);
int[] values;
// GeoKey directory root tag
values = getGeoKeyEntryAt(0).getValues();
data.addContent(createShortElement(values[0]));
data.addContent(createShortElement(values[1]));
data.addContent(createShortElement(values[3]));
data.addContent(createShortElement(values[2]));
// GeoKeys
for (int i = 1; i < numGeoTiffEntries; i++) {
values = getGeoKeyEntryAt(i).getValues();
int lenght = values.length;
for (int j = 0; j < lenght; j++) {
Element GeoKeyRecord = createShortElement(values[j]);
data.addContent(GeoKeyRecord);
}
}
return field;
}
代码示例来源:origin: edu.ucar/netcdf
private Element genCapabilityOperationElem( String operationAsString )
{
Element getCapOpsElem;
getCapOpsElem= new Element( operationAsString, wcsNS );
getCapOpsElem.addContent(
new Element( "DCPType", wcsNS ).addContent(
new Element( "HTTP", wcsNS ).addContent(
new Element( "Get", wcsNS ).addContent(
new Element( "OnlineResource", wcsNS ).setAttribute(
"href", serverURI.toString(), xlinkNS ) ) ) ) );
return getCapOpsElem;
}
代码示例来源:origin: geotools/geotools
private Element createModelTiePointsElement() {
Element field = createFieldElement(getModelTiePointTag());
Element data = new Element(GeoTiffConstants.GEOTIFF_DOUBLES_TAG);
field.addContent(data);
for (int i = 0; i < numModelTiePoints; i++) {
addDoubleElements(data, modelTiePoints[i].getData());
}
return field;
}
代码示例来源:origin: isisaddons/isis-app-todoapp
private static Element addTable(final Element body, final String id) {
final Element table = new Element("table");
body.addContent(table);
table.setAttribute("id", id);
return table;
}
内容来源于网络,如有侵权,请联系作者删除!