• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Tag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.htmlparser.Tag的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Tag类属于org.htmlparser包,在下文中一共展示了Tag类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getEndLine

import org.htmlparser.Tag; //导入依赖的package包/类
public int getEndLine()
{
  int nr = arg0.getStartingLineNumber() + 1;
  int nrE = nr;
  Tag endTag = arg0.getEndTag();
  if (endTag != null)
  {
    nrE = endTag.getEndingLineNumber();
    int offset = endTag.getStartPosition() - endTag.getEndPosition();
    if (offset == 0)
      fEditor.addProblemMarker(endTag.getTagName().toLowerCase()
          + " is not correctly closed proposed line for closing is line "
          + nrE, nr, IMarker.SEVERITY_WARNING);
  }
  return nrE;
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:17,代码来源:VelocityReconcilingStrategy.java


示例2: ensureAllAttributesAreSafe

import org.htmlparser.Tag; //导入依赖的package包/类
/**
 * Given an input, analyze each HTML tag and remove unsecure attributes from
 * them.
 * 
 * @param contents
 *            The content to verify
 * @return the content, secure.
 */
public String ensureAllAttributesAreSafe(String contents) {
	StringBuffer sb = new StringBuffer(contents.length());

	try {
		Lexer lexer = new Lexer(contents);
		Node node;

		while ((node = lexer.nextNode()) != null) {
			if (node instanceof Tag) {
				Tag tag = (Tag) node;

				this.checkAndValidateAttributes(tag, false);

				sb.append(tag.toHtml());
			} else {
				sb.append(node.toHtml());
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Problems while parsing HTML", e);
	}

	return sb.toString();
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:33,代码来源:SafeHtml.java


示例3: HTMLInputHandler

import org.htmlparser.Tag; //导入依赖的package包/类
public HTMLInputHandler(Attribute attr, Tag tag, int lineNumber, File file, Set<CFGFunction> functions) {

		this.file = file;
		this.tag = tag;
		this.attribute = attr;
		this.functions = functions;
		this.lineNumber = lineNumber + 1;
		
	}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:10,代码来源:HTMLInputHandler.java


示例4: visitTag

import org.htmlparser.Tag; //导入依赖的package包/类
@Override
public void visitTag(Tag tag) {
  String lcName = tag.getTagName().toLowerCase();
  
  setFlags(lcName, true);
  processParagraphs(lcName, true);
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:8,代码来源:ConvertStackOverflow.java


示例5: visitEndTag

import org.htmlparser.Tag; //导入依赖的package包/类
@Override
public void visitEndTag(Tag tag) {
  String Name = tag.getTagName().toLowerCase();
    
  setFlags(Name, false);
  processParagraphs(Name, false);
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:8,代码来源:ConvertStackOverflow.java


示例6: parseFlashEmbedTag

import org.htmlparser.Tag; //导入依赖的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;
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:44,代码来源:FlashEmbeddedParser.java


示例7: ensureAllAttributesAreSafe

import org.htmlparser.Tag; //导入依赖的package包/类
/**
 * Given an input, analyze each HTML tag and remove unsecure attributes from them.
 *
 * @param contents The content to verify
 * @return the content, secure.
 */
public String ensureAllAttributesAreSafe(String contents) {
	StringBuilder sb = new StringBuilder(contents.length());

	try {
		Lexer lexer = new Lexer(contents);
		Node node;

		while ((node = lexer.nextNode()) != null) {
			if (node instanceof Tag) {
				Tag tag = (Tag) node;

				this.checkAndValidateAttributes(tag, false);

				sb.append(tag.toHtml());
			}
			else {
				sb.append(node.toHtml());
			}
		}
	}
	catch (Exception e) {
		throw new ForumException("Problems while parsing HTML: " + e, e);
	}

	return sb.toString();
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:33,代码来源:SafeHtml.java


示例8: isTagWelcome

import org.htmlparser.Tag; //导入依赖的package包/类
/**
 * Returns true if a given tag is allowed. Also, it checks and removes any unwanted attribute the tag may contain.
 *
 * @param node The tag node to analyze
 * @return true if it is a valid tag.
 */
private boolean isTagWelcome(Node node) {
	Tag tag = (Tag) node;

	if (!welcomeTags.contains(tag.getTagName())) {
		return false;
	}

	this.checkAndValidateAttributes((Tag)node, true);

	return true;
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:18,代码来源:SafeHtml.java


示例9: checkAndValidateAttributes

import org.htmlparser.Tag; //导入依赖的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(), "&#", "&amp;#"));
			}

			newAttributes.add(a);
		}
	}

	tag.setAttributesEx(newAttributes);
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:47,代码来源:SafeHtml.java


示例10: isTagWelcome

import org.htmlparser.Tag; //导入依赖的package包/类
/**
 * Returns true if a given tag is allowed. Also, it checks and removes any
 * unwanted attribute the tag may contain.
 * 
 * @param node
 *            The tag node to analyze
 * @return true if it is a valid tag.
 */
private boolean isTagWelcome(Node node) {
	Tag tag = (Tag) node;

	if (!welcomeTags.contains(tag.getTagName())) {
		return false;
	}

	this.checkAndValidateAttributes(tag, true);

	return true;
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:20,代码来源:SafeHtml.java


示例11: checkAndValidateAttributes

import org.htmlparser.Tag; //导入依赖的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("&#", "&amp;#"));
			}

			newAttributes.add(a);
		}
	}

	tag.setAttributesEx(newAttributes);
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:48,代码来源:SafeHtml.java


示例12: findAndRewriteJsEvents

import org.htmlparser.Tag; //导入依赖的package包/类
/**
 * Search and rewrites urls into common javascript events
 *
 * @param tag the tag to serach for events..
 * @param aResource the current Resource
 */
private void findAndRewriteJsEvents(Tag tag, ProxymaResource aResource) {
    for (int i = 0; i < EVENTS.length; i++) {
        String tagValue = tag.getAttribute(EVENTS[i]);
        if (tagValue != null) {
            tag.removeAttribute(EVENTS[i]);
            Attribute attribute = new Attribute();
            attribute.setName(EVENTS[i]);
            attribute.setAssignment("=");
            attribute.setRawValue("'" + findAndRewriteJSLinks(tagValue, aResource) + "'");
            tag.setAttributeEx(attribute);
        }
    }
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:20,代码来源:JSRewriteTransformer.java


示例13: visitTag

import org.htmlparser.Tag; //导入依赖的package包/类
public void visitTag(Tag tag) {
    if (tag.getRawTagName().equalsIgnoreCase("img")) {
        String imageValue = tag.getAttribute("src");

        if (imageValue.contains("base64")) {
            String contentId = getContentId();
            tag.setAttribute("src", "cid:" + contentId);
            base64ImagesMap.put(contentId,
                    imageValue.substring(imageValue.indexOf("base64") + 7, imageValue.length()));
        }
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:13,代码来源:HtmlImageNodeVisitor.java


示例14: visitTag

import org.htmlparser.Tag; //导入依赖的package包/类
public void visitTag(Tag tag) {
    String Name = tag.getTagName().toLowerCase();

    //System.out.println(Name + " -> " + tag.isEndTag());
    String attr, content;
    
    if (Name.equals("meta")) {
    	if ((attr = tag.getAttribute("name")) != null) { 
    		 boolean bDesc = attr.equals("description");
    		 boolean bKeyw = attr.equals("keywords");
    		 
    		 if ((bDesc || bKeyw) && (content = tag.getAttribute("content")) != null) {
    			 content = CleanText(content);
    			 if (bDesc) mDescription += content;
    			 if (bKeyw) mKeywords += content;
    		 }
    	}
    } else if (Name.equals("base") && (content = tag.getAttribute("href")) != null) {
    	SetBaseHref(content);
    } else if ((Name.equals("frame") || Name.equals("iframe")) && 
                (content = tag.getAttribute("src")) != null) {
    	AddLinkOut(content, "");
    }
    
    SetFlags(Name, true);
    
    if (mInHref) {
    	mHrefAddr = tag.getAttribute("href");
    	mLinkText = "";
    }
    
	ProcessParagraphs(Name, true);        
}
 
开发者ID:searchivarius,项目名称:IndexTextCollect,代码行数:34,代码来源:LeoCleanerUtil.java


示例15: visitEndTag

import org.htmlparser.Tag; //导入依赖的package包/类
public void visitEndTag(Tag tag) {
    String Name = tag.getTagName().toLowerCase();
    
    if (mInHref && mHrefAddr != null) {
        AddLinkOut(mHrefAddr, mLinkText);
    }
    
    //System.out.println(Name + " -> " + tag.isEndTag());
	
	SetFlags(Name, false);
	if (Name.equals("head")) {
		mInBody = true;
	}
	ProcessParagraphs(Name, false);
}
 
开发者ID:searchivarius,项目名称:IndexTextCollect,代码行数:16,代码来源:LeoCleanerUtil.java


示例16: HtmlNode

import org.htmlparser.Tag; //导入依赖的package包/类
/**
* 
*/
  public HtmlNode(Tag arg0)
  {
    this.arg0 = arg0;
  }
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:8,代码来源:VelocityReconcilingStrategy.java


示例17: visitTag

import org.htmlparser.Tag; //导入依赖的package包/类
public void visitTag(final Tag arg0)
{
  htmlTags.add(new HtmlNode(arg0));
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:5,代码来源:VelocityReconcilingStrategy.java


示例18: parseNodes

import org.htmlparser.Tag; //导入依赖的package包/类
/**
 * Recursively parse all nodes to pick up all form encodings
 *
 * @param e the nodes to be parsed
 * @param formEncodings the Map where we should add form encodings found
 * @param pageEncoding the encoding used for the page where the nodes are present
 */
private void parseNodes(final NodeIterator e, Map<String, String> formEncodings, String pageEncoding)
    throws HTMLParseException, ParserException {
    while(e.hasMoreNodes()) {
        Node node = e.nextNode();
        // a url is always in a Tag.
        if (!(node instanceof Tag)) {
            continue;
        }
        Tag tag = (Tag) node;

        // Only check form tags
        if (tag instanceof FormTag) {
            // Find the action / form url
            String action = tag.getAttribute("action");
            String acceptCharSet = tag.getAttribute("accept-charset");
            if(action != null && action.length() > 0) {
                // We use the page encoding where the form resides, as the
                // default encoding for the form
                String formCharSet = pageEncoding;
                // Check if we found an accept-charset attribute on the form
                if(acceptCharSet != null) {
                    String[] charSets = JOrphanUtils.split(acceptCharSet, ",");
                    // Just use the first one of the possible many charsets
                    if(charSets.length > 0) {
                        formCharSet = charSets[0].trim();
                        if(formCharSet.length() == 0) {
                            formCharSet = null;
                        }
                    }
                }
                if(formCharSet != null) {
                    synchronized (formEncodings) {
                        formEncodings.put(action, formCharSet);
                    }
                }
            }
        }

        // second, if the tag was a composite tag,
        // recursively parse its children.
        if (tag instanceof CompositeTag) {
            CompositeTag composite = (CompositeTag) tag;
            parseNodes(composite.elements(), formEncodings, pageEncoding);
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:54,代码来源:FormCharSetFinder.java


示例19: getTag

import org.htmlparser.Tag; //导入依赖的package包/类
public Tag getTag() { return tag; } 
开发者ID:andyjko,项目名称:feedlack,代码行数:2,代码来源:HTMLInputHandler.java



注:本文中的org.htmlparser.Tag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Label类代码示例发布时间:2022-05-21
下一篇:
Java PsiCodeBlock类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap