當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.setAttribute方法代碼示例

本文整理匯總了Java中org.jdom.Element.setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.setAttribute方法的具體用法?Java Element.setAttribute怎麽用?Java Element.setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdom.Element的用法示例。


在下文中一共展示了Element.setAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateGeneratorElement

import org.jdom.Element; //導入方法依賴的package包/類
protected Element generateGeneratorElement(Generator generator) {
    Element generatorElement = new Element("generator", getFeedNamespace());

    if (generator.getUrl() != null) {
        Attribute urlAttribute = new Attribute("url", generator.getUrl());
        generatorElement.setAttribute(urlAttribute);
    }

    if (generator.getVersion() != null) {
        Attribute versionAttribute = new Attribute("version", generator.getVersion());
        generatorElement.setAttribute(versionAttribute);
    }

    if (generator.getValue() != null) {
        generatorElement.addContent(generator.getValue());
    }

    return generatorElement;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:Atom03Generator.java

示例2: getState

import org.jdom.Element; //導入方法依賴的package包/類
@Nullable
@Override
public Element getState() {
    final Element element = new Element(KEY.ROOT.toString());
    element.setAttribute(KEY.VERSION.toString(), version);

    return element;
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:9,代碼來源:TYPO3CMSSettings.java

示例3: getState

import org.jdom.Element; //導入方法依賴的package包/類
@Nullable
@Override
public Element getState() {
    synchronized (lock) {
        final Element element = new Element("state");

        for (Entity entity : queue) {
            final Element entityElement = new Element(TAG_ENTITY);
            entityElement.setAttribute(ATTR_ACTION, entity.getAction().name());
            entityElement.setAttribute(ATTR_DATE, entity.getDateStr());
            final String parameters = entity.getParameters();

            if (parameters != null) {
                entityElement.setAttribute(ATTR_NAME, parameters);
            }
            element.addContent(entityElement);
        }
        return element;
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:21,代碼來源:DefaultStatsCollector.java

示例4: loadStateShouldLoadFromElement

import org.jdom.Element; //導入方法依賴的package包/類
@Test
public void loadStateShouldLoadFromElement() throws Exception {
    // setup
    final Element state = new Element("component");
    state.setAttribute("style", "JACKSON");
    state.setAttribute("classNamePrefix", "Foo");
    state.setAttribute("classNameSuffix", "Baz");
    state.setAttribute("annotationGenerated", "true");
    state.setAttribute("annotationSuppressWarnings", "false");

    // exercise
    underTest.loadState(state);

    // verify
    final Element actual = underTest.getState();
    assertThat(actual)
            .isNotNull()
            .hasName("component")
            .hasAttribute("style", "JACKSON")
            .hasAttribute("classNamePrefix", "Foo")
            .hasAttribute("classNameSuffix", "Baz")
            .hasAttribute("annotationGenerated", "true")
            .hasAttribute("annotationSuppressWarnings", "false");
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:25,代碼來源:PersistentJson2JavaSettingsTest.java

示例5: generateCloud

import org.jdom.Element; //導入方法依賴的package包/類
protected Element generateCloud(Cloud cloud) {
    Element eCloud = new Element("cloud",getFeedNamespace());

    if (cloud.getDomain() != null) {
        eCloud.setAttribute(new Attribute("domain", cloud.getDomain()));
    }

    if (cloud.getPort() != 0) {
        eCloud.setAttribute(new Attribute("port", String.valueOf(cloud.getPort())));
    }

    if (cloud.getPath() != null) {
        eCloud.setAttribute(new Attribute("path", cloud.getPath()));
    }

    if (cloud.getRegisterProcedure() != null) {
        eCloud.setAttribute(new Attribute("registerProcedure", cloud.getRegisterProcedure()));
    }

    if (cloud.getProtocol() != null) {
        eCloud.setAttribute(new Attribute("protocol", cloud.getProtocol()));
    }
    return eCloud;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:RSS092Generator.java

示例6: generateTagLineElement

import org.jdom.Element; //導入方法依賴的package包/類
protected Element generateTagLineElement(Content tagline) {
    Element taglineElement = new Element("subtitle", getFeedNamespace());

    if (tagline.getType() != null) {
        Attribute typeAttribute = new Attribute("type", tagline.getType());
        taglineElement.setAttribute(typeAttribute);
    }

    if (tagline.getValue() != null) {
        taglineElement.addContent(tagline.getValue());
    }
    return taglineElement;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:14,代碼來源:Atom10Generator.java

示例7: write

import org.jdom.Element; //導入方法依賴的package包/類
public static void write( Writer w, Model newModel, boolean namespaceDeclaration )
    throws IOException
{
    Element root = new Element( "project" );

    if ( namespaceDeclaration )
    {
        String modelVersion = newModel.getModelVersion();

        Namespace pomNamespace = Namespace.getNamespace( "", "http://maven.apache.org/POM/" + modelVersion );

        root.setNamespace( pomNamespace );

        Namespace xsiNamespace = Namespace.getNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );

        root.addNamespaceDeclaration( xsiNamespace );

        if ( root.getAttribute( "schemaLocation", xsiNamespace ) == null )
        {
            root.setAttribute( "schemaLocation",
                               "http://maven.apache.org/POM/" + modelVersion + " http://maven.apache.org/maven-v"
                                   + modelVersion.replace( '.', '_' ) + ".xsd", xsiNamespace );
        }
    }

    Document doc = new Document( root );

    MavenJDOMWriter writer = new MavenJDOMWriter();

    String encoding = newModel.getModelEncoding() != null ? newModel.getModelEncoding() : "UTF-8";

    Format format = Format.getPrettyFormat().setEncoding( encoding );

    writer.write( newModel, doc, w, format );
}
 
開發者ID:javiersigler,項目名稱:apache-maven-shade-plugin,代碼行數:36,代碼來源:PomWriter.java

示例8: addChildWithName

import org.jdom.Element; //導入方法依賴的package包/類
public static Element addChildWithName(Element parent, String name, Object value) {
  Element child = new Element(OPTION);
  child.setAttribute(NAME, name);
  child.setAttribute(VALUE, value.toString());
  parent.addContent(child);
  return child;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:8,代碼來源:StudySerializationUtils.java

示例9: getInfoUrlAsElement

import org.jdom.Element; //導入方法依賴的package包/類
public Element getInfoUrlAsElement(){
	/*
		<info url="http://acme.com/" text="Using MsTeamsNotifications in Acme Inc." />
	 */
	if (this.msteamsnotificationInfoUrl != null && this.msteamsnotificationInfoUrl.length() > 0){
		Element e = new Element("info");
		e.setAttribute("url", msteamsnotificationInfoUrl);
		if (this.msteamsnotificationInfoText != null && this.msteamsnotificationInfoText.length() > 0){
			e.setAttribute("text", msteamsnotificationInfoText);
		} else {
			e.setAttribute("text", msteamsnotificationInfoUrl);
		}
		e.setAttribute("show-reading", msteamsnotificationShowFurtherReading.toString());
		
		return e;
	}
	return null;
}
 
開發者ID:spyder007,項目名稱:teamcity-msteams-notifier,代碼行數:19,代碼來源:MsTeamsNotificationMainConfig.java

示例10: getProxyAsElement

import org.jdom.Element; //導入方法依賴的package包/類
public Element getProxyAsElement(){
	/*
   		  <proxy host="myproxy.mycompany.com" port="8080" >
     			<noproxy url=".mycompany.com" />
     			<noproxy url="192.168.0." />
   		  </proxy>
	 */
	if (this.getProxyHost() == null || this.getProxyPort() == null){
		return null;
	}
	Element el = new Element(PROXY);
	el.setAttribute("host", this.getProxyHost());
	el.setAttribute("port", String.valueOf(this.getProxyPort()));
	if (   this.proxyPassword != null && this.proxyPassword.length() > 0 
		&& this.proxyUsername != null && this.proxyUsername.length() > 0 )
	{
		el.setAttribute(USERNAME, this.getProxyUsername());
		el.setAttribute(PASSWORD, this.getProxyPassword());
		
	}
	return el;
}
 
開發者ID:spyder007,項目名稱:teamcity-msteams-notifier,代碼行數:23,代碼來源:MsTeamsNotificationMainConfig.java

示例11: save

import org.jdom.Element; //導入方法依賴的package包/類
public void save(File sav) {
	Document document = new Document();
	Element root = new Element("blocks");
	document.setRootElement(root);
	for (int x = 0; x < BLOCKS_WIDTH; x++) {
		for (int y = 0; y < BLOCKS_HEIGHT; y++) {
			Element block = new Element("block");
			block.setAttribute("x", String.valueOf((int) (blocks[x][y].getX() / BLOCK_SIZE)));
			block.setAttribute("y", String.valueOf((int) (blocks[x][y].getY() / BLOCK_SIZE)));
			block.setAttribute("type", String.valueOf(blocks[x][y].getType()));
			root.addContent(block);
		}
	}
	XMLOutputter output = new XMLOutputter();
	try {
		output.output(document, new FileOutputStream(sav));
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:21,代碼來源:BlockGrid.java

示例12: writeExternal

import org.jdom.Element; //導入方法依賴的package包/類
@Override
public void writeExternal(Element element) throws WriteExternalException {
  super.writeExternal(element);
  if (!StringUtil.isEmpty(scriptPath)) {
    element.setAttribute(SCRIPT_PATH_URL, scriptPath);
  }
  if (!StringUtil.isEmpty(scriptParameters)) {
    element.setAttribute(SCRIPT_PARAMETERS, scriptParameters);
  }
  if (!StringUtil.isEmpty(scriptOptions)) {
    element.setAttribute(SCRIPT_OPTIONS, scriptOptions);
  }
  element.setAttribute(SCRIPT_SHOW_EVENTS, myShowAppleEvents ? "true" : "false");
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:15,代碼來源:AppleScriptRunConfiguration.java

示例13: addTextChildMap

import org.jdom.Element; //導入方法依賴的package包/類
public static Element addTextChildMap(Element parent, String name, Map<String, String> value) {
  Element mapElement = new Element(MAP);
  for (Map.Entry<String, String> entry : value.entrySet()) {
    Element entryElement = new Element("entry");
    mapElement.addContent(entryElement);
    String key = entry.getKey();
    entryElement.setAttribute("key", key);
    entryElement.setAttribute("value", entry.getValue());
  }
  return addChildWithName(parent, name, mapElement);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:12,代碼來源:StudySerializationUtils.java

示例14: addLibrary

import org.jdom.Element; //導入方法依賴的package包/類
private void addLibrary(Element runtime, String type, String path, String id)
{
	Element lib = new Element("library");
	lib.setAttribute("type", type);
	lib.setAttribute("path", path);
	lib.setAttribute("id", id);
	runtime.addContent(lib);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:NewJPFPluginWizardPageOne.java

示例15: addEntry

import org.jdom.Element; //導入方法依賴的package包/類
protected void addEntry(Entry entry,Element parent) throws FeedException {
    Element eEntry = new Element("entry", getFeedNamespace());
    if (entry.getXmlBase() != null) {
        eEntry.setAttribute("base", entry.getXmlBase(), Namespace.XML_NAMESPACE);
    }
    populateEntry(entry,eEntry);
    checkEntryConstraints(eEntry);
    generateItemModules(entry.getModules(),eEntry);
    parent.addContent(eEntry);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:11,代碼來源:Atom10Generator.java


注:本文中的org.jdom.Element.setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。