java attributelist_Java AttributeList.getName方法代码示例

import org.xml.sax.AttributeList; //导入方法依赖的package包/类

/**

* Initialisation routine called after handler creation

* with the element name and attributes. The attributes which

* this handler can deal with are: "default",

* "name", "id" and "basedir".

*

* @param tag Name of the element which caused this handler

* to be created. Should not be null.

* Ignored in this implementation.

* @param attrs Attributes of the element which caused this

* handler to be created. Must not be null.

*

* @exception SAXParseException if an unexpected attribute is

* encountered or if the "default" attribute

* is missing.

*/

public void init(String tag, AttributeList attrs) throws SAXParseException {

String def = null;

String name = null;

String id = null;

String baseDir = null;

for (int i = 0; i < attrs.getLength(); i++) {

String key = attrs.getName(i);

String value = attrs.getValue(i);

if ("default".equals(key)) {

def = value;

} else if ("name".equals(key)) {

name = value;

} else if ("id".equals(key)) {

id = value;

} else if ("basedir".equals(key)) {

baseDir = value;

} else {

throw new SAXParseException(

"Unexpected attribute \"" + attrs.getName(i)

+ "\"", helperImpl.locator);

}

}

if (def != null && !def.isEmpty()) {

helperImpl.project.setDefault(def);

} else {

throw new BuildException("The default attribute is required");

}

if (name != null) {

helperImpl.project.setName(name);

helperImpl.project.addReference(name, helperImpl.project);

}

if (id != null) {

helperImpl.project.addReference(id, helperImpl.project);

}

if (helperImpl.project.getProperty("basedir") != null) {

helperImpl.project.setBasedir(helperImpl.project.getProperty("basedir"));

} else {

if (baseDir == null) {

helperImpl.project.setBasedir(helperImpl.buildFileParent.getAbsolutePath());

} else {

// check whether the user has specified an absolute path

if ((new File(baseDir)).isAbsolute()) {

helperImpl.project.setBasedir(baseDir);

} else {

File resolvedBaseDir = FILE_UTILS.resolveFile(helperImpl.buildFileParent,

baseDir);

helperImpl.project.setBaseDir(resolvedBaseDir);

}

}

}

helperImpl.project.addTarget("", helperImpl.implicitTarget);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值