org.jdom.Attribute.setAttributeType()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.jdom.Attribute.setAttributeType()方法的一些代码示例,展示了Attribute.setAttributeType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.setAttributeType()方法的具体详情如下:
包路径:org.jdom.Attribute
类名称:Attribute
方法名:setAttributeType

Attribute.setAttributeType介绍

[英]This will set the type of the Attribute.
[中]这将设置Attribute的类型。

代码示例

代码示例来源:origin: org.jdom/jdom-legacy

/**
 * This will create a new <code>Attribute</code> with the
 * specified (local) name, value, and type, and in the provided
 * <code>{@link Namespace}</code>.
 *
 * @param name <code>String</code> name of <code>Attribute</code>.
 * @param value <code>String</code> value for new attribute.
 * @param type <code>int</code> type for new attribute.
 * @param namespace <code>Namespace</code> namespace for new attribute.
 * @throws IllegalNameException if the given name is illegal as an
 *         attribute name or if if the new namespace is the default
 *         namespace. Attributes cannot be in a default namespace.
 * @throws IllegalDataException if the given attribute value is
 *         illegal character data (as determined by
 *         {@link org.jdom.Verifier#checkCharacterData}) or
 *         if the given attribute type is not one of the
 *         supported types.
 */
public Attribute(final String name, final String value, final int type, final Namespace namespace) {
  setName(name);
  setValue(value);
  setAttributeType(type);
  setNamespace(namespace);
}

代码示例来源:origin: org.jdom/jdom-contrib

public Attribute setAttributeType(int type) {
    int oldType = this.getAttributeType();

    if (type != oldType) {
      super.setAttributeType(type);

      // Udpate the owning document's lookup table.
      Document doc = this.getDocument();
      if (doc instanceof IdDocument) {
        if (oldType == Attribute.ID_TYPE) {
          ((IdDocument)doc).removeId(this.getValue());
        }
        if (type == Attribute.ID_TYPE) {
          ((IdDocument)doc).addId(this.getValue(), this.getParent());
        }
      }
    }
    return this;
  }
}

相关文章