库房监控系统软件代码.docx

上传人:b****1 文档编号:1806244 上传时间:2023-05-01 格式:DOCX 页数:96 大小:32.49KB
下载 相关 举报
库房监控系统软件代码.docx_第1页
第1页 / 共96页
库房监控系统软件代码.docx_第2页
第2页 / 共96页
库房监控系统软件代码.docx_第3页
第3页 / 共96页
库房监控系统软件代码.docx_第4页
第4页 / 共96页
库房监控系统软件代码.docx_第5页
第5页 / 共96页
库房监控系统软件代码.docx_第6页
第6页 / 共96页
库房监控系统软件代码.docx_第7页
第7页 / 共96页
库房监控系统软件代码.docx_第8页
第8页 / 共96页
库房监控系统软件代码.docx_第9页
第9页 / 共96页
库房监控系统软件代码.docx_第10页
第10页 / 共96页
库房监控系统软件代码.docx_第11页
第11页 / 共96页
库房监控系统软件代码.docx_第12页
第12页 / 共96页
库房监控系统软件代码.docx_第13页
第13页 / 共96页
库房监控系统软件代码.docx_第14页
第14页 / 共96页
库房监控系统软件代码.docx_第15页
第15页 / 共96页
库房监控系统软件代码.docx_第16页
第16页 / 共96页
库房监控系统软件代码.docx_第17页
第17页 / 共96页
库房监控系统软件代码.docx_第18页
第18页 / 共96页
库房监控系统软件代码.docx_第19页
第19页 / 共96页
库房监控系统软件代码.docx_第20页
第20页 / 共96页
亲,该文档总共96页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

库房监控系统软件代码.docx

《库房监控系统软件代码.docx》由会员分享,可在线阅读,更多相关《库房监控系统软件代码.docx(96页珍藏版)》请在冰点文库上搜索。

库房监控系统软件代码.docx

库房监控系统软件代码

packageorg.jsoup.select;

importjava.util.ArrayList;

importjava.util.Arrays;

importjava.util.Collection;

importjava.util.Collections;

importjava.util.LinkedHashSet;

importjava.util.List;

importjava.util.Map;

importjava.util.Set;

importjava.util.StorageRoom.Pattern;

importjava.util.StorageRoom.PatternSyntaxException;

publicabstractclassNode

implementsCloneable

{

privatestaticfinalListEMPTY_NODES=Collections.emptyList();

NodeparentNode;

ListchildNodes;

Attributesattributes;

StringbaseUri;

intsiblingIndex;

packageorg.jsoup.select;

importjava.util.ArrayList;

importjava.util.List;

importjava.util.StorageRoom.Matcher;

importjava.util.StorageRoom.Pattern;

importorg.jsoup.helper.StringUtil;

importorg.jsoup.helper.Validate;

importorg.jsoup.parser.Monitor;

classQueryParser

{

privatestaticfinalString[]combinators={",",">","+","~",""};

privatestaticfinalString[]AttributeEvals={"=","!

=","^=","$=","*=","~="};

privateMonitortq;

privateStringquery;

privateListevals=newArrayList();

privatestaticfinalPatternNTH_AB=Ppile("((\\+|-)?

(\\d+)?

)n(\\s*(\\+|-)?

\\s*\\d+)?

",2);

privatestaticfinalPatternNTH_B=Ppile("(\\+|-)?

(\\d+)");

privateQueryParser(Stringquery)

{

this.query=query;

this.tq=newMonitor(query);

}

publicstaticEvaluatorparse(Stringquery)

{

QueryParserp=newQueryParser(query);

returnp.parse();

}

Evaluatorparse()

{

this.tq.consumeWhitespace();

if(this.tq.matchesAny(combinators)){

this.evals.add(newStructuralEvaluator.Root());

combinator(this.tq.consume());

}else{

findElements();

}

while(!

this.tq.isEmpty())

{

booleanseenWhite=this.tq.consumeWhitespace();

if(this.tq.matchesAny(combinators))

combinator(this.tq.consume());

elseif(seenWhite)

combinator('');

else{

findElements();

}

}

if(this.evals.size()==1){

return(Evaluator)this.evals.get(0);

}

returnnewCombiningEvaluator.And(this.evals);

}

privatevoidcombinator(charcombinator){

this.tq.consumeWhitespace();

StringsubQuery=consumeSubQuery();

EvaluatornewEval=parse(subQuery);

booleanreplaceRightMost=false;

EvaluatorcurrentEval;

EvaluatorrootEval;

if(this.evals.size()==1)

{

EvaluatorcurrentEval;

EvaluatorrootEval=currentEval=(Evaluator)this.evals.get(0);

if(((rootEvalinstanceofCombiningEvaluator.Or))&&(combinator!

=',')){

currentEval=((CombiningEvaluator.Or)currentEval).rightMostEvaluator();

replaceRightMost=true;

}

}

else{

rootEval=currentEval=newCombiningEvaluator.And(this.evals);

}

this.evals.clear();

if(combinator=='>'){

currentEval=newCombiningEvaluator.And(newEvaluator[]{newEval,newStructuralEvaluator.ImmediateParent(currentEval)});

}elseif(combinator==''){

currentEval=newCombiningEvaluator.And(newEvaluator[]{newEval,newStructuralEvaluator.Parent(currentEval)});

}elseif(combinator=='+'){

currentEval=newCombiningEvaluator.And(newEvaluator[]{newEval,newStructuralEvaluator.ImmediatePreviousSibling(currentEval)});

}elseif(combinator=='~'){

currentEval=newCombiningEvaluator.And(newEvaluator[]{newEval,newStructuralEvaluator.PreviousSibling(currentEval)});

}elseif(combinator==',')

{

CombiningEvaluator.Oror;

if((currentEvalinstanceofCombiningEvaluator.Or)){

CombiningEvaluator.Oror=(CombiningEvaluator.Or)currentEval;

or.add(newEval);

}else{

or=newCombiningEvaluator.Or();

or.add(currentEval);

or.add(newEval);

}

currentEval=or;

}

else{

thrownewSelector.SelectorParseException("Unknowncombinator:

"+combinator,newObject[0]);

}

if(replaceRightMost)

((CombiningEvaluator.Or)rootEval).replaceRightMostEvaluator(currentEval);

elserootEval=currentEval;

this.evals.add(rootEval);

}

privateStringconsumeSubQuery(){

StringBuildersq=newStringBuilder();

while(!

this.tq.isEmpty())

if(this.tq.matches("(")){

sq.append("(").append(this.tq.chompBalanced('(',')')).append(")");

}elseif(this.tq.matches("[")){

sq.append("[").append(this.tq.chompBalanced('[',']')).append("]");}else{

if(this.tq.matchesAny(combinators)){

break;

}

sq.append(this.tq.consume());

}

returnsq.toString();

}

privatevoidfindElements(){

if(this.tq.matchChomp("#"))

byId();

elseif(this.tq.matchChomp("."))

byClass();

elseif(this.tq.matchesWord())

byTag();

elseif(this.tq.matches("["))

byAttribute();

elseif(this.tq.matchChomp("*"))

allElements();

elseif(this.tq.matchChomp(":

lt("))

indexLessThan();

elseif(this.tq.matchChomp(":

gt("))

indexGreaterThan();

elseif(this.tq.matchChomp(":

eq("))

indexEquals();

elseif(this.tq.matches(":

has("))

has();

elseif(this.tq.matches(":

contains("))

contains(false);

elseif(this.tq.matches(":

containsOwn("))

contains(true);

elseif(this.tq.matches(":

matches("))

matches(false);

elseif(this.tq.matches(":

matchesOwn("))

matches(true);

elseif(this.tq.matches(":

not("))

not();

elseif(this.tq.matchChomp(":

nth-child("))

cssNthChild(false,false);

elseif(this.tq.matchChomp(":

nth-last-child("))

cssNthChild(true,false);

elseif(this.tq.matchChomp(":

nth-of-type("))

cssNthChild(false,true);

elseif(this.tq.matchChomp(":

nth-last-of-type("))

cssNthChild(true,true);

elseif(this.tq.matchChomp(":

first-child"))

this.evals.add(newEvaluator.IsFirstChild());

elseif(this.tq.matchChomp(":

last-child"))

this.evals.add(newEvaluator.IsLastChild());

elseif(this.tq.matchChomp(":

first-of-type"))

this.evals.add(newEvaluator.IsFirstOfType());

elseif(this.tq.matchChomp(":

last-of-type"))

this.evals.add(newEvaluator.IsLastOfType());

elseif(this.tq.matchChomp(":

only-child"))

this.evals.add(newEvaluator.IsOnlyChild());

elseif(this.tq.matchChomp(":

only-of-type"))

this.evals.add(newEvaluator.IsOnlyOfType());

elseif(this.tq.matchChomp(":

empty"))

this.evals.add(newEvaluator.IsEmpty());

elseif(this.tq.matchChomp(":

root"))

this.evals.add(newEvaluator.IsRoot());

else

thrownewSelector.SelectorParseException("Couldnotparsequery'%s':

unexpectedtokenat'%s'",newObject[]{this.query,this.tq.remainder()});

}

privatevoidbyId()

{

Stringid=this.tq.consumeCssIdentifier();

Validate.notEmpty(id);

this.evals.add(newEvaluator.Id(id));

}

privatevoidbyClass(){

StringclassName=this.tq.consumeCssIdentifier();

Validate.notEmpty(className);

this.evals.add(newEvaluator.Class(className.trim().toLowerCase()));

}

privatevoidbyTag(){

StringtagName=this.tq.consumeElementSelector();

Validate.notEmpty(tagName);

if(tagName.contains("|")){

tagName=tagName.replace("|",":

");

}

this.evals.add(newEvaluator.Tag(tagName.trim().toLowerCase()));

}

privatevoidbyAttribute(){

Monitorcq=newMonitor(this.tq.chompBalanced('[',']'));

Stringkey=cq.consumeToAny(AttributeEvals);

Validate.notEmpty(key);

cq.consumeWhitespace();

if(cq.isEmpty()){

if(key.startsWith("^"))

this.evals.add(newEvaluator.AttributeStarting(key.substring

(1)));

else

this.evals.add(newEvaluator.Attribute(key));

}

elseif(cq.matchChomp("=")){

this.evals.add(newEvaluator.AttributeWithValue(key,cq.remainder()));

}

elseif(cq.matchChomp("!

=")){

this.evals.add(newEvaluator.AttributeWithValueNot(key,cq.remainder()));

}

elseif(cq.matchChomp("^=")){

this.evals.add(newEvaluator.AttributeWithValueStarting(key,cq.remainder()));

}

elseif(cq.matchChomp("$=")){

this.evals.add(newEvaluator.AttributeWithValueEnding(key,cq.remainder()));

}

elseif(cq.matchChomp("*=")){

this.evals.add(newEvaluator.AttributeWithValueContaining(key,cq.remainder()));

}

elseif(cq.matchChomp("~="))

this.evals.add(newEvaluator.AttributeWithValueMatching(key,Ppile(cq.remainder())));

else

thrownewSelector.SelectorParseException("Couldnotparseattributequery'%s':

unexpectedtokenat'%s'",newObject[]{this.query,cq.remainder()});

}

privatevoidallElements()

{

this.evals.add(newEvaluator.AllElements());

}

privatevoidindexLessThan()

{

this.evals.add(newEvaluator.IndexLessThan(consumeIndex()));

}

privatevoidindexGreaterThan(){

this.evals.add(newEvaluator.IndexGreaterThan(consumeIndex()));

}

privatevoidindexEquals(){

this.evals.add(newEvaluator.IndexEquals(consumeIndex()));

}

privatevoidcssNthChild(booleanbackwards,booleanofType)

{

StringargS=this.tq.chompTo(")").trim().toLowerCase();

MatchermAB=NTH_AB.matcher(argS);

MatchermB=NTH_B.matcher(argS);

intb;

if("odd".equals(argS)){

inta=2;

b=1;

}

else

{

intb;

if("even".equals(argS)){

inta=2;

b=0;

}

else

{

intb;

if(mAB.matches()){

inta=mAB.group(3)!

=null?

Integer.parseInt(mAB.group

(1).replaceFirst("^\\+","")):

1;

b=mAB.group(4)!

=null?

Integer.parseInt(mAB.group(4).replaceFirst("^\\+","")):

0;

}

else

{

intb;

if(mB.matches()){

inta=0;

b=Integer.parseInt(mB.group().replaceFirst("^\\+",""));

}else{

thrownewSelector.SelectorParseException("Couldnotparsenth-index'%s':

unexpectedformat",newObject[]{argS});

}

}

}

}

intb;

inta;

if(ofType){

if(backwards)

this.evals.add(newEvaluator.IsNthLastOfType(a,b));

else

this.evals.add(newEvaluator.IsNthOfType(a,b));

}

elseif(backwards)

this.evals.add(newEvaluator.IsNthLastChild(a,b));

else

this.evals.add(newEvaluator.IsNthChild(a,b));

}

privateintconsumeIndex()

{

StringindexS=this.tq.chompTo(")").trim();

Validate.isTrue(StringUtil.isNumeric(indexS),"Indexmustbenumeric");

returnInteger.parseInt(indexS);

}

privatevoidhas()

{

this.tq.cons

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2