库房监控系统软件代码Word格式.docx
《库房监控系统软件代码Word格式.docx》由会员分享,可在线阅读,更多相关《库房监控系统软件代码Word格式.docx(96页珍藏版)》请在冰点文库上搜索。
![库房监控系统软件代码Word格式.docx](https://file1.bingdoc.com/fileroot1/2023-5/1/c6a01552-b356-4e77-a1e6-b75ccd7f1d02/c6a01552-b356-4e77-a1e6-b75ccd7f1d021.gif)
privatestaticfinalString[]combinators={"
"
"
>
"
+"
~"
"
};
privatestaticfinalString[]AttributeEvals={"
="
!
^="
$="
*="
~="
privateMonitortq;
privateStringquery;
privateList<
Evaluator>
evals=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))
elseif(seenWhite)
combinator('
'
else{
if(this.evals.size()==1){
return(Evaluator)this.evals.get(0);
returnnewCombiningEvaluator.And(this.evals);
privatevoidcombinator(charcombinator){
StringsubQuery=consumeSubQuery();
EvaluatornewEval=parse(subQuery);
booleanreplaceRightMost=false;
EvaluatorcurrentEval;
EvaluatorrootEval;
if(this.evals.size()==1)
EvaluatorrootEval=currentEval=(Evaluator)this.evals.get(0);
if(((rootEvalinstanceofCombiningEvaluator.Or))&
&
(combinator!
='
'
)){
currentEval=((CombiningEvaluator.Or)currentEval).rightMostEvaluator();
replaceRightMost=true;
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)});
+'
currentEval=newCombiningEvaluator.And(newEvaluator[]{newEval,newStructuralEvaluator.ImmediatePreviousSibling(currentEval)});
~'
currentEval=newCombiningEvaluator.And(newEvaluator[]{newEval,newStructuralEvaluator.PreviousSibling(currentEval)});
)
CombiningEvaluator.Oror;
if((currentEvalinstanceofCombiningEvaluator.Or)){
CombiningEvaluator.Oror=(CombiningEvaluator.Or)currentEval;
or.add(newEval);
or=newCombiningEvaluator.Or();
or.add(currentEval);
currentEval=or;
thrownewSelector.SelectorParseException("
Unknowncombinator:
+combinator,newObject[0]);
if(replaceRightMost)
((CombiningEvaluator.Or)rootEval).replaceRightMostEvaluator(currentEval);
elserootEval=currentEval;
this.evals.add(rootEval);
privateStringconsumeSubQuery(){
StringBuildersq=newStringBuilder();
if(this.tq.matches("
("
sq.append("
).append(this.tq.chompBalanced('
('
'
)'
)).append("
)"
}elseif(this.tq.matches("
["
['
]'
]"
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();
*"
allElements();
:
lt("
indexLessThan();
gt("
indexGreaterThan();
eq("
indexEquals();
has("
has();
contains("
contains(false);
containsOwn("
contains(true);
matches("
matches(false);
matchesOwn("
matches(true);
not("
not();
nth-child("
cssNthChild(false,false);
nth-last-child("
cssNthChild(true,false);
nth-of-type("
cssNthChild(false,true);
nth-last-of-type("
cssNthChild(true,true);
first-child"
this.evals.add(newEvaluator.IsFirstChild());
last-child"
this.evals.add(newEvaluator.IsLastChild());
first-of-type"
this.evals.add(newEvaluator.IsFirstOfType());
last-of-type"
this.evals.add(newEvaluator.IsLastOfType());
only-child"
this.evals.add(newEvaluator.IsOnlyChild());
only-of-type"
this.evals.add(newEvaluator.IsOnlyOfType());
empty"
this.evals.add(newEvaluator.IsEmpty());
root"
this.evals.add(newEvaluator.IsRoot());
else
Couldnotparsequery'
%s'
unexpectedtokenat'
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)));
this.evals.add(newEvaluator.Attribute(key));
elseif(cq.matchChomp("
this.evals.add(newEvaluator.AttributeWithValue(key,cq.remainder()));
this.evals.add(newEvaluator.AttributeWithValueNot(key,cq.remainder()));
this.evals.add(newEvaluator.AttributeWithValueStarting(key,cq.remainder()));
this.evals.add(newEvaluator.AttributeWithValueEnding(key,cq.remainder()));
this.evals.add(newEvaluator.AttributeWithValueContaining(key,cq.remainder()));
this.evals.add(newEvaluator.AttributeWithValueMatching(key,Ppile(cq.remainder())));
Couldnotparseattributequery'
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;
even"
b=0;
if(mAB.matches()){
inta=mAB.group(3)!
=null?
Integer.parseInt(mAB.group
(1).replaceFirst("
^\\+"
)):
1;
b=mAB.group(4)!
Integer.parseInt(mAB.group(4).replaceFirst("
0;
if(mB.matches()){
inta=0;
b=Integer.parseInt(mB.group().replaceFirst("
Couldnotparsenth-index'
unexpectedformat"
newObject[]{argS});
inta;
if(ofType){
if(backwards)
this.evals.add(newEvaluator.IsNthLastOfType(a,b));
this.evals.add(newEvaluator.IsNthOfType(a,b));
elseif(backwards)
this.evals.add(newEvaluator.IsNthLastChild(a,b));
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