本文整理了Java中org.dom4j.Element.addElement()
方法的一些代码示例,展示了Element.addElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addElement()
方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:addElement
暂无
代码示例来源:origin: hibernate/hibernate-orm
public static Element addNativelyGeneratedId(
Element parent, String name, String type,
boolean useRevisionEntityWithNativeId) {
final Element idMapping = parent.addElement( "id" );
idMapping.addAttribute( "name", name ).addAttribute( "type", type );
final Element generatorMapping = idMapping.addElement( "generator" );
if ( useRevisionEntityWithNativeId ) {
generatorMapping.addAttribute( "class", "native" );
}
else {
generatorMapping.addAttribute( "class", "org.hibernate.envers.enhanced.OrderedSequenceGenerator" );
generatorMapping.addElement( "param" ).addAttribute( "name", "sequence_name" ).setText(
"REVISION_GENERATOR"
);
generatorMapping.addElement( "param" )
.addAttribute( "name", "table_name" )
.setText( "REVISION_GENERATOR" );
generatorMapping.addElement( "param" ).addAttribute( "name", "initial_value" ).setText( "1" );
generatorMapping.addElement( "param" ).addAttribute( "name", "increment_size" ).setText( "1" );
}
// generatorMapping.addAttribute("class", "sequence");
// generatorMapping.addElement("param").addAttribute("name", "sequence").setText("custom");
return idMapping;
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Adds <code>formula</code> element.
*
* @param element Parent element.
* @param formula Formula descriptor.
*/
public static void addFormula(Element element, Formula formula) {
element.addElement( "formula" ).setText( formula.getText() );
}
代码示例来源:origin: hibernate/hibernate-orm
public static Element addProperty(
Element parent,
String name,
String type,
boolean insertable,
boolean updateable,
boolean key) {
final Element propMapping;
if ( key ) {
propMapping = parent.addElement( "key-property" );
}
else {
propMapping = parent.addElement( "property" );
propMapping.addAttribute( "insert", Boolean.toString( insertable ) );
propMapping.addAttribute( "update", Boolean.toString( updateable ) );
}
propMapping.addAttribute( "name", name );
if ( type != null ) {
propMapping.addAttribute( "type", type );
}
return propMapping;
}
代码示例来源:origin: hibernate/hibernate-orm
private void mapEnumerationType(Element parent, Type type, Properties parameters) {
if ( parameters.getProperty( EnumType.ENUM ) != null ) {
parent.addElement( "param" )
.addAttribute( "name", EnumType.ENUM )
.setText( parameters.getProperty( EnumType.ENUM ) );
}
else {
parent.addElement( "param" )
.addAttribute( "name", EnumType.ENUM )
.setText( type.getReturnedClass().getName() );
}
if ( parameters.getProperty( EnumType.NAMED ) != null ) {
parent.addElement( "param" )
.addAttribute( "name", EnumType.NAMED )
.setText( parameters.getProperty( EnumType.NAMED ) );
}
else {
parent.addElement( "param" )
.addAttribute( "name", EnumType.NAMED )
.setText( "" + !( (EnumType) ( (CustomType) type ).getUserType() ).isOrdinal() );
}
}
代码示例来源:origin: gocd/gocd
void populateXml(Element materials, Modifications modifications, XmlWriterContext writerContext) {
Element materialElement = materials.addElement("material");
materialElement.addAttribute("materialUri", writerContext.getBaseUrl() + "/api/materials/" + material.getId() + ".xml");
for (Map.Entry<String, Object> criterion : material.getAttributesForXml().entrySet()) {
if (criterion.getValue() != null) {
materialElement.addAttribute(criterion.getKey(), criterion.getValue().toString());
}
}
Element modificationsTag = materialElement.addElement("modifications");
populateXmlForModifications(modifications, writerContext, modificationsTag);
}
代码示例来源:origin: spotbugs/spotbugs
private Document endDocument(Project project) {
// Save the error information
Element errorsElement = root.addElement(ERRORS_ELEMENT_NAME);
for (AnalysisError analysisError : bugCollection.getErrors()) {
errorsElement.addElement(ANALYSIS_ERROR_ELEMENT_NAME).setText(analysisError.getMessage());
}
for (Iterator<String> i = bugCollection.missingClassIterator(); i.hasNext();) {
errorsElement.addElement(MISSING_CLASS_ELEMENT_NAME).setText(i.next());
}
return document;
}
代码示例来源:origin: spotbugs/spotbugs
/**
* Add BugCode elements.
*
* @param bugCodeSet
* all bug codes (abbrevs) referenced in the BugCollection
*/
private void addBugCodes(Set<String> bugCodeSet) {
Element root = document.getRootElement();
for (String bugCode : bugCodeSet) {
Element element = root.addElement("BugCode");
element.addAttribute("abbrev", bugCode);
Element description = element.addElement("Description");
description.setText(I18N.instance().getBugTypeDescription(bugCode));
}
}
代码示例来源:origin: hibernate/hibernate-orm
String joinTableValueColumnName,
String joinTableValueColumnType) {
final Element set = classMapping.addElement( "set" );
set.addAttribute( "name", propertyName );
set.addAttribute( "table", joinTableName );
set.addAttribute( "schema", joinTableSchema );
set.addAttribute( "catalog", joinTableCatalog );
set.addAttribute( "cascade", "persist, delete" );
set.addAttribute( "fetch", "join" );
set.addAttribute( "lazy", "false" );
final Element key = set.addElement( "key" );
key.addAttribute( "column", joinTablePrimaryKeyColumnName );
final Element element = set.addElement( "element" );
element.addAttribute( "type", joinTableValueColumnType );
final Element column = element.addElement( "column" );
column.addAttribute( "name", joinTableValueColumnName );
代码示例来源:origin: ronmamo/reflections
private Document createDocument(final Reflections reflections) {
Store map = reflections.getStore();
Document document = DocumentFactory.getInstance().createDocument();
Element root = document.addElement("Reflections");
for (String indexName : map.keySet()) {
Element indexElement = root.addElement(indexName);
for (String key : map.get(indexName).keySet()) {
Element entryElement = indexElement.addElement("entry");
entryElement.addElement("key").setText(key);
Element valuesElement = entryElement.addElement("values");
for (String value : map.get(indexName).get(key)) {
valuesElement.addElement("value").setText(value);
}
}
}
return document;
}
}
代码示例来源:origin: igniterealtime/Openfire
element.addElement(propName[i]);
element.addElement(eleName);
element.element(eleName).addAttribute(attName, value);
element.addElement(lastName);
element.element(lastName).setText(value);
代码示例来源:origin: hibernate/hibernate-orm
public static Element createJoin(
Element parent,
String tableName,
String schema,
String catalog) {
final Element joinMapping = parent.addElement( "join" );
joinMapping.addAttribute( "table", tableName );
if ( !StringTools.isEmpty( schema ) ) {
joinMapping.addAttribute( "schema", schema );
}
if ( !StringTools.isEmpty( catalog ) ) {
joinMapping.addAttribute( "catalog", catalog );
}
return joinMapping;
}
代码示例来源:origin: org.reflections/reflections
private Document createDocument(final Reflections reflections) {
Store map = reflections.getStore();
Document document = DocumentFactory.getInstance().createDocument();
Element root = document.addElement("Reflections");
for (String indexName : map.keySet()) {
Element indexElement = root.addElement(indexName);
for (String key : map.get(indexName).keySet()) {
Element entryElement = indexElement.addElement("entry");
entryElement.addElement("key").setText(key);
Element valuesElement = entryElement.addElement("values");
for (String value : map.get(indexName).get(key)) {
valuesElement.addElement("value").setText(value);
}
}
}
return document;
}
}
代码示例来源:origin: igniterealtime/Openfire
@Override
public Presence kickOccupant(JID jid, JID actorJID, String actorNickname, String reason)
throws NotAllowedException {
// Update the presence with the new role and inform all occupants
Presence updatedPresence = changeOccupantRole(jid, MUCRole.Role.none);
if (updatedPresence != null) {
Element frag = updatedPresence.getChildElement(
"x", "http://jabber.org/protocol/muc#user");
// Add the status code 307 that indicates that the user was kicked
frag.addElement("status").addAttribute("code", "307");
// Add the reason why the user was kicked
if (reason != null && reason.trim().length() > 0) {
frag.element("item").addElement("reason").setText(reason);
}
// Effectively kick the occupant from the room
kickPresence(updatedPresence, actorJID, actorNickname);
//Inform the other occupants that user has been kicked
broadcastPresence(updatedPresence, false);
}
return updatedPresence;
}
代码示例来源:origin: gocd/gocd
@Override
void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) {
for (Modification modification : modifications) {
Element changeset = modificationsTag.addElement("changeset");
changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId()));
changeset.addElement("user").addCDATA(modification.getUserDisplayName());
changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime()));
changeset.addElement("revision").addCDATA(modification.getRevision());
changeset.addElement("message").addCDATA(modification.getComment());
}
}
}
代码示例来源:origin: igniterealtime/Openfire
public IQVersionHandler() {
super("XMPP Server Version Handler");
info = new IQHandlerInfo("query", "jabber:iq:version");
if (bodyElement == null) {
bodyElement = DocumentHelper.createElement(QName.get("query", "jabber:iq:version"));
bodyElement.addElement("name").setText(AdminConsole.getAppName());
bodyElement.addElement("version").setText(AdminConsole.getVersionString());
}
}
代码示例来源:origin: spotbugs/spotbugs
/**
* Add BugCategory elements.
*
* @param bugCategorySet
* all bug categories referenced in the BugCollection
*/
private void addBugCategories(Set<String> bugCategorySet) {
Element root = document.getRootElement();
for (String category : bugCategorySet) {
Element element = root.addElement("BugCategory");
element.addAttribute("category", category);
Element description = element.addElement("Description");
description.setText(I18N.instance().getBugCategoryDescription(category));
BugCategory bc = DetectorFactoryCollection.instance().getBugCategory(category);
if (bc != null) { // shouldn't be null
String s = bc.getAbbrev();
if (s != null) {
Element abbrev = element.addElement("Abbreviation");
abbrev.setText(s);
}
s = bc.getDetailText();
if (s != null) {
Element details = element.addElement("Details");
details.setText(s);
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
String customWrite,
boolean quoted) {
final Element columnMapping = parent.addElement( "column" );
columnMapping.addAttribute( "name", quoted ? "`" + name + "`" : name );
if ( length != null ) {
columnMapping.addAttribute( "length", length.toString() );
columnMapping.addAttribute( "scale", Integer.toString( scale ) );
代码示例来源:origin: igniterealtime/Openfire
@Override
public IQ handleIQ(IQ packet) {
IQ response = IQ.createResultIQ(packet);
Element timeElement = DocumentHelper.createElement(QName.get(info.getName(), info.getNamespace()));
timeElement.addElement("tzo").setText(formatsTimeZone(TimeZone.getDefault()));
timeElement.addElement("utc").setText(getUtcDate(new Date()));
response.setChildElement(timeElement);
return response;
}
代码示例来源:origin: hibernate/hibernate-orm
private void applyNestedType(SimpleValue value, Element propertyMapping) {
final Properties typeParameters = value.getTypeParameters();
final Element typeMapping = propertyMapping.addElement( "type" );
final String typeName = getBasicTypeName( value.getType() );
typeMapping.addAttribute( "name", typeName );
if ( isEnumType( value.getType(), typeName ) ) {
// Proper handling of enumeration type
mapEnumerationType( typeMapping, value.getType(), typeParameters );
}
else {
// By default copying all Hibernate properties
for ( Object object : typeParameters.keySet() ) {
final String keyType = (String) object;
final String property = typeParameters.getProperty( keyType );
if ( property != null ) {
typeMapping.addElement( "param" ).addAttribute( "name", keyType ).setText( property );
}
}
}
}
代码示例来源:origin: gocd/gocd
@Override
void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) {
Modification firstModification = modifications.first();
Element changeset = modificationsTag.addElement("changeset");
String revision = firstModification.getRevision();
changeset.addAttribute("changesetUri", StageXmlViewModel.httpUrlFor(writerContext.getBaseUrl(), writerContext.stageIdForLocator(revision)));
changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(firstModification.getModifiedTime()));
changeset.addElement("revision").addText(revision);
}
}
内容来源于网络,如有侵权,请联系作者删除!