本文整理汇总了Java中org.htmlparser.Attribute.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getName方法的具体用法?Java Attribute.getName怎么用?Java Attribute.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.htmlparser.Attribute
的用法示例。
在下文中一共展示了Attribute.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseFlashEmbedTag
import org.htmlparser.Attribute; //导入方法依赖的package包/类
/**
* Processes the EMBED node that should contain the Flash animation:
* @param embedTag the Root object tag to tackle
* @param flashObjToFill the flash obect to fill in with data
* @return the updated flash object
*/
@SuppressWarnings("unchecked")
private FlashEmbeddedObject parseFlashEmbedTag( NodeList embeds, final FlashEmbeddedObject flashObjToFill ) {
if( embeds != null ) {
logger.debug( "The number of embed-tag nodes is " + embeds.size() );
for( int i = 0; i < embeds.size() ; i++ ) {
Node embedNode = embeds.elementAt( i );
if( embedNode instanceof Tag ) {
Tag embedTag = (Tag) embedNode;
//If it is not an end node then we process its attributes, if it is an empty
//XML tag then we do the same I believe an empty XML tag is smth like: <TAG />
if( !embedTag.isEndTag() || embedTag.isEmptyXmlTag() ) {
//Process the attributes
logger.debug("Processing embed node's '" + embedTag + "' attributes");
Vector<Attribute> atts = (Vector<Attribute>) embedTag.getAttributesEx();
if( atts != null ) {
for( Attribute att : atts ) {
String nameValue = att.getName();
String valueValue = att.getValue();
if( ! flashObjToFill.setNameValue( nameValue, valueValue ) ) {
logger.warn("An unknown EMBED attribute, name='" + nameValue + "' value='" + valueValue + "'" );
} else {
logger.debug("Set the EMBED attribute, name='" + nameValue + "' value='" + valueValue + "'");
}
}
}
} else {
logger.warn( "Encountered an EMBED node: " + embedTag + " that is an end tag!" );
}
} else {
logger.warn( "Encountered a EMBED node: " + embedNode + " that is not an EMBED tag!" );
}
}
} else {
logger.debug( "The list of embed-tag nodes is null" );
}
return flashObjToFill;
}
示例2: checkAndValidateAttributes
import org.htmlparser.Attribute; //导入方法依赖的package包/类
/**
* Given a tag, check its attributes, removing those unwanted or not secure
*
* @param tag The tag to analyze
* @param checkIfAttributeIsWelcome true if the attribute name should be matched against the list of welcome attributes, set in the main
* configuration file.
*/
@SuppressWarnings("unchecked")
private void checkAndValidateAttributes(Tag tag, boolean checkIfAttributeIsWelcome) {
Vector<Attribute> newAttributes = new Vector<Attribute>();
for (Iterator<Attribute> iter = tag.getAttributesEx().iterator(); iter.hasNext();) {
Attribute a = iter.next();
String name = a.getName();
if (name == null) {
newAttributes.add(a);
}
else {
name = name.toUpperCase();
if (a.getValue() == null) {
newAttributes.add(a);
continue;
}
String value = a.getValue().toLowerCase();
if (checkIfAttributeIsWelcome && !this.isAttributeWelcome(name)) {
continue;
}
if (!this.isAttributeSafe(name, value)) {
continue;
}
if (a.getValue().indexOf("&#") > -1) {
a.setValue(StringUtils.replace(a.getValue(), "&#", "&#"));
}
newAttributes.add(a);
}
}
tag.setAttributesEx(newAttributes);
}
示例3: checkAndValidateAttributes
import org.htmlparser.Attribute; //导入方法依赖的package包/类
/**
* Given a tag, check its attributes, removing those unwanted or not secure.
*
* @param tag
* The tag to analyze
* @param checkIfAttributeIsWelcome
* true if the attribute name should be matched against the list
* of welcome attributes, set in the main configuration file.
*/
private void checkAndValidateAttributes(Tag tag, boolean checkIfAttributeIsWelcome) {
Vector newAttributes = new Vector();
for (Iterator iter = tag.getAttributesEx().iterator(); iter.hasNext();) {
Attribute a = (Attribute) iter.next();
String name = a.getName();
if (name == null) {
newAttributes.add(a);
} else {
name = name.toUpperCase();
if (a.getValue() == null) {
newAttributes.add(a);
continue;
}
String value = a.getValue().toLowerCase();
if (checkIfAttributeIsWelcome && !this.isAttributeWelcome(name)) {
continue;
}
if (!this.isAttributeSafe(name, value)) {
continue;
}
if (a.getValue().indexOf("&#") > -1) {
a.setValue(a.getValue().replaceAll("&#", "&#"));
}
newAttributes.add(a);
}
}
tag.setAttributesEx(newAttributes);
}
示例4: handleTagOpen
import org.htmlparser.Attribute; //导入方法依赖的package包/类
public void handleTagOpen(TagNode tag) {
String name = tag.getTagName();
if(name.equals("TITLE")) {
inTitle = !tag.isEmptyXmlTag();
return;
}
// first the global attributes:
Vector<Attribute> attributes = tag.getAttributesEx();
for (Attribute a : attributes) {
String attrName = a.getName();
String attrValue = a.getValue();
if (attrName == null || attrValue == null) {
continue;
}
attrName = attrName.toLowerCase(Locale.ROOT);
if (globalHrefAttributes.contains(attrName)) {
data.addHref(PATH,makePath(name,attrName),"url",attrValue);
}
}
// TODO: style attribute, BASE(href) tag, Resolve URLs
TagExtractor extractor = extractors.get(name);
if(extractor != null) {
extractor.extract(data, tag, this);
}
}