file_id
int64
1
215k
content
stringlengths
7
454k
repo
stringlengths
6
113
path
stringlengths
6
251
742
//### This file created by BYACC 1.8(/Java extension 1.15) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; package ch4; import static ch4.lexer.yylex; import static ch4.yyerror.yyerror; public class Parser { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //public class ParserVal is defined in ParserVal.java String yytext;//user variable to return contextual strings ParserVal yyval; //used to return semantic vals from action routines ParserVal yylval;//the 'lval' (result) I got from yylex() ParserVal valstk[]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### void val_init() { valstk=new ParserVal[YYSTACKSIZE]; yyval=new ParserVal(); yylval=new ParserVal(); valptr=-1; } void val_push(ParserVal val) { if (valptr>=YYSTACKSIZE) return; valstk[++valptr]=val; } ParserVal val_pop() { if (valptr<0) return new ParserVal(); return valstk[valptr--]; } void val_drop(int cnt) { int ptr; ptr=valptr-cnt; if (ptr<0) return; valptr = ptr; } ParserVal val_peek(int relative) { int ptr; ptr=valptr-relative; if (ptr<0) return new ParserVal(); return valstk[ptr]; } final ParserVal dup_yyval(ParserVal val) { ParserVal dup = new ParserVal(); dup.ival = val.ival; dup.dval = val.dval; dup.sval = val.sval; dup.obj = val.obj; return dup; } //#### end semantic value section #### public final static short NAME=257; public final static short NUMBER=258; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 0, 1, }; final static short yylen[] = { 2, 2, 0, 2, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 1, }; final static short yydgoto[] = { 2, 3, }; final static short yysindex[] = { -257, -256, 0, -257, 0, 0, }; final static short yyrindex[] = { 1, 0, 0, 1, 0, 0, }; final static short yygindex[] = { 2, 0, }; final static int YYTABLESIZE=5; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 1, 2, 4, 0, 0, 5, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 257, 0, 258, -1, -1, 3, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=258; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"NAME","NUMBER", }; final static String yyrule[] = { "$accept : sequence", "sequence : pair sequence", "sequence :", "pair : NAME NUMBER", }; //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it val_push(yylval); //save empty value while (true) //until parsing is done, either correctly, or w/error { doaction=true; if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### if (yychar < 0) //it it didn't work/error { yychar = 0; //change it to default string (no -1!) if (yydebug) yylexdebug(yystate,yychar); } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { if (yydebug) debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0) //check for under & overflow here { yyerror("stack underflow. aborting..."); //note lower case 's' return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { if (yydebug) debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { if (yydebug) debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0) //check for under & overflow here { yyerror("Stack underflow. aborting..."); //capital 'S' return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort if (yydebug) { yys = null; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (yys == null) yys = "illegal-symbol"; debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); } yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs if (yydebug) debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value yyval = dup_yyval(yyval); //duplicate yyval if ParserVal is used as semantic value switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character if (yychar<0) yychar=0; //clean, if necessary if (yydebug) yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### /** * A default run method, used for operating this parser * object in the background. It is intended for extending Thread * or implementing Runnable. Turn off with -Jnorun . */ public void run() { yyparse(); } //## end of method run() ######################################## //## Constructors ############################################### /** * Default constructor. Turn off with -Jnoconstruct . */ public Parser() { //nothing to do } /** * Create a parser, setting the debug to true or false. * @param debugMe true for debugging, false for no debug. */ public Parser(boolean debugMe) { yydebug=debugMe; } //############################################################### } //################### END OF CLASS ##############################
PacktPublishing/Build-Your-Own-Programming-Language
ch4/Parser.java
743
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jena.iri.impl; import java.io.UnsupportedEncodingException; import java.util.AbstractSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import org.apache.jena.iri.IRI ; import org.apache.jena.iri.IRIComponents ; import org.apache.jena.iri.ViolationCodes ; public class IRIFactoryImpl extends AbsIRIFactoryImpl implements ViolationCodes, Force, IRIComponents { public static final int UNKNOWN_SYNTAX = -4; // boolean throwUncheckedExceptions = false; /* static final long conformanceMasks[] = { // RFC3986 (1l<<ILLEGAL_CHAR) |(1l<<ILLEGAL_PERCENT_ENCODING) |(1l<<EMPTY_SCHEME) |(1l<<IP_V4_HAS_FOUR_COMPONENTS) |(1l<<IP_V4_OCTET_RANGE) |(1l<<IP_V6_OR_FUTURE_ADDRESS_SYNTAX) |(1l<<IRI_CHAR) |(1l<<LTR_CHAR) |(1l<<NOT_XML_SCHEMA_WHITESPACE) |(1l<<SCHEME_MUST_START_WITH_LETTER) |(1l<<UNWISE_CHAR) |(1l<<WHITESPACE) |(1l<<ARBITRARY_CHAR) , // RFC3987 (1l<<ILLEGAL_CHAR) |(1l<<ILLEGAL_PERCENT_ENCODING) |(1l<<EMPTY_SCHEME) |(1l<<IP_V4_HAS_FOUR_COMPONENTS) |(1l<<IP_V4_OCTET_RANGE) |(1l<<IP_V6_OR_FUTURE_ADDRESS_SYNTAX) |(1l<<LTR_CHAR) |(1l<<NOT_XML_SCHEMA_WHITESPACE) |(1l<<SCHEME_MUST_START_WITH_LETTER) |(1l<<UNWISE_CHAR) |(1l<<WHITESPACE) |(1l<<ARBITRARY_CHAR) , // RDF (1l<<ILLEGAL_CHAR) |(1l<<ILLEGAL_PERCENT_ENCODING) |(1l<<EMPTY_SCHEME) |(1l<<IP_V4_HAS_FOUR_COMPONENTS) |(1l<<IP_V4_OCTET_RANGE) |(1l<<IP_V6_OR_FUTURE_ADDRESS_SYNTAX) |(1l<<SCHEME_MUST_START_WITH_LETTER) |(1l<<RELATIVE_URI) , // XLink (1l<<ILLEGAL_CHAR) |(1l<<ILLEGAL_PERCENT_ENCODING) |(1l<<EMPTY_SCHEME) |(1l<<IP_V4_HAS_FOUR_COMPONENTS) |(1l<<IP_V4_OCTET_RANGE) |(1l<<IP_V6_OR_FUTURE_ADDRESS_SYNTAX) |(1l<<SCHEME_MUST_START_WITH_LETTER) |(1l<<NON_XML_CHARACTER) , // XMLSchema (1l<<ILLEGAL_CHAR) |(1l<<ILLEGAL_PERCENT_ENCODING) |(1l<<EMPTY_SCHEME) |(1l<<IP_V4_HAS_FOUR_COMPONENTS) |(1l<<IP_V4_OCTET_RANGE) |(1l<<IP_V6_OR_FUTURE_ADDRESS_SYNTAX) |(1l<<SCHEME_MUST_START_WITH_LETTER) |(1l<<NOT_XML_SCHEMA_WHITESPACE) |(1l<<NON_XML_CHARACTER) , // IDN // (1l<<ACE_PREFIX) 0 , // Should (1l<<LOWERCASE_PREFERRED) |(1l<<PORT_SHOULD_NOT_BE_EMPTY) |(1l<<PORT_SHOULD_NOT_START_IN_ZERO) // |(1l<<SCHEME_NAMES_SHOULD_BE_LOWER_CASE) |(1l<<PERCENT_ENCODING_SHOULD_BE_UPPERCASE) |(1l<<IPv6ADDRESS_SHOULD_BE_LOWERCASE) |(1l<<USE_PUNYCODE_NOT_PERCENTS) , // Minting /* consider HAS_PASSWORD vs LOWER_CASE_PREFERRED * The former should be an error unless switched * off (but it can be, unlike a MUST), whereas the * latter should be a warning by default. * / (1l<<LOWERCASE_PREFERRED) |(1l<<PORT_SHOULD_NOT_BE_EMPTY) |(1l<<PORT_SHOULD_NOT_START_IN_ZERO) // |(1l<<SCHEME_NAMES_SHOULD_BE_LOWER_CASE) |(1l<<PERCENT_ENCODING_SHOULD_BE_UPPERCASE) |(1l<<IPv6ADDRESS_SHOULD_BE_LOWERCASE) |(1l<<USE_PUNYCODE_NOT_PERCENTS) , // DNS (1l<<NOT_DNS_NAME) , }; */ protected long errors; protected long warnings; protected Set<Specification> specs = new HashSet<>(); public IRIFactoryImpl() { } public IRIFactoryImpl(IRIFactoryImpl template) { if (backwardCompatibleRelativeRefs.size()==Integer.MAX_VALUE) backwardCompatibleRelativeRefs = template.backwardCompatibleRelativeRefs; else backwardCompatibleRelativeRefs = new HashSet<>(backwardCompatibleRelativeRefs); encoding = template.encoding; errors = template.errors; prohibited = template.prohibited; required = template.required; warnings = template.warnings; System.arraycopy(template.asErrors,0,asErrors,0,asErrors.length); System.arraycopy(template.asWarnings,0,asWarnings,0,asWarnings.length); for ( Entry<String, SchemeSpecificPart> entry : template.schemes.entrySet() ) { SchemeSpecificPart p = entry.getValue(); if ( p.withScheme() ) { schemes.put( entry.getKey(), new WithScheme( (WithScheme) p ) ); } else if ( p.port() != IRI.NO_PORT ) { schemes.put( entry.getKey(), new NoScheme( p.port() ) ); } } } /* protected long recsToMask(int recs) { long mask = 0; for (int i=0; recs != 0 && i<conformanceMasks.length; i++) { if ((recs & (1<<i)) != 0) { mask |= conformanceMasks[i]; recs &= ~(1<<i); } } return mask; } */ private final long getMask(boolean includeWarnings) { return includeWarnings?(errors|warnings):errors; } @Override protected IRIFactoryImpl getFactory() { return this; } @Override public IRI create(IRI i) { if (i instanceof AbsIRIImpl && ((AbsIRIImpl)i).getFactory()==this) return i; return create(i.toString()); } boolean getSameSchemaRelativeReferences(String scheme) { return backwardCompatibleRelativeRefs.contains(scheme.toLowerCase()); } private String encoding = "utf-8"; String getEncoding() { return encoding; } public void setEncoding(String enc) throws UnsupportedEncodingException { // check enc is valid encoding. "".getBytes(enc); encoding = enc; } boolean asErrors[] = new boolean[]{ true, true, false, true, true, true, }; boolean asWarnings[] = new boolean[]{ false, false, true, false, false, false }; protected void setViolation(int ix, boolean e, boolean w){ if (e && w) throw new IllegalArgumentException("xxxViolation(true,true) is not permitted."); initializing(); asErrors[ix]=e; asWarnings[ix]=w; } protected boolean getAsWarnings(int ix) { return asWarnings[ix]; } protected boolean getAsErrors(int ix) { return asErrors[ix]; } // boolean isException(int code) { // return (errors & (1l<<code))!=0; // } private boolean initializing = true; private Set<String> backwardCompatibleRelativeRefs = new HashSet<>(); protected void initializing() { if (!initializing) throw new IllegalStateException("Cannot reinitialize IRIFactory after first use."); } @Override public IRI create(String s) { initializing = false; return super.create(s); } public void setSameSchemeRelativeReferences(String scheme) { if (scheme.equals("*")) backwardCompatibleRelativeRefs = new AbstractSet<String>(){ @Override public int size() { return Integer.MAX_VALUE; } @Override public Iterator<String> iterator() { throw new UnsupportedOperationException(); } @Override public boolean add(String o) { return false; } @Override public boolean contains(Object o) { return true; } }; else backwardCompatibleRelativeRefs.add(scheme.toLowerCase()); } protected void useSpec(String name, boolean asErr) { initializing(); Specification spec = Specification.get(name); specs.add(spec); for (int i=0; i<Force.SIZE; i++) { if (asErrors[i] || (asWarnings[i] && asErr)) { errors |= spec.getErrors(i); } if (asWarnings[i] ) { warnings |= spec.getErrors(i); } } prohibited |= spec.getProhibited(); required |= spec.getRequired(); warnings &= ~errors; } public SchemeSpecificPart getScheme(String scheme, Parser parser) { scheme = scheme.toLowerCase(); SchemeSpecificPart p = schemes.get(scheme); if (p!=null) { p.usedBy(parser); return p; } int dash = scheme.indexOf('-'); if (dash != -1) { if (scheme.startsWith("x-")) { p = noScheme(); } else { if (nonIETFScheme==null) nonIETFScheme = new NoScheme() { @Override void usedBy(Parser pp) { pp.recordError(SCHEME,UNREGISTERED_NONIETF_SCHEME_TREE); } }; p = nonIETFScheme; } } else if (Specification.schemes.containsKey(scheme)) { SchemeSpecification spec = (SchemeSpecification)Specification.schemes.get(scheme); p = new NoScheme(spec.port); } else{ if (unregisteredScheme==null){ unregisteredScheme = new NoScheme() { @Override void usedBy(Parser pp) { pp.recordError(SCHEME,UNREGISTERED_IANA_SCHEME); } }; } p= unregisteredScheme; } p.usedBy(parser); // System.err.println("Scheme: "+scheme); if (schemes.size() < 1000) schemes.put(scheme,p); return p; } private NoScheme unregisteredScheme=null; private NoScheme nonIETFScheme=null; public SchemeSpecificPart noScheme() { return noScheme; } private class WithScheme extends SchemeSpecificPart { long zerrors; long zwarnings; int zrequired; int zprohibited; boolean inited = false; final SchemeSpecification scheme; private WithScheme(WithScheme ws) { zerrors = ws.zerrors; zwarnings = ws.zwarnings; zprohibited = ws.zprohibited; zrequired = ws.zrequired; scheme = ws.scheme; } private WithScheme(SchemeSpecification spec, boolean asErr){ scheme = spec; for (int i=0; i<Force.SIZE; i++) { if (asErrors[i] || (asWarnings[i] && asErr)) { zerrors |= spec.getErrors(i); } if (asWarnings[i] ) { zwarnings |= spec.getErrors(i); } } } @Override void usedBy(Parser parser) { if (!inited) { inited = true; zerrors |= errors; zwarnings |= warnings; zwarnings &= ~zerrors; zrequired = scheme.getRequired() | required; zprohibited = scheme.getProhibited() | prohibited; } } @Override public long getMask(boolean includeWarnings) { return includeWarnings?(zerrors|zwarnings):zerrors; } @Override public int getRequired() { return zrequired; } @Override public int getProhibited() { return zprohibited; } @Override public void analyse(Parser parser, int range) { scheme.analyse(parser,range); } @Override public int port() { return scheme.port; } @Override public boolean withScheme() { return true; } } private class NoScheme extends SchemeSpecificPart { NoScheme() { this(-1); } final private int port; NoScheme(int i) { port = i; } @Override public long getMask(boolean includeWarnings) { return IRIFactoryImpl.this.getMask(includeWarnings); } @Override public int getRequired() { return IRIFactoryImpl.this.getRequired(); } @Override public int getProhibited() { return IRIFactoryImpl.this.getProhibited(); } @Override void usedBy(Parser parser) { /* nothing */ } @Override public void analyse(Parser parser, int range) {/* nothing */ } @Override public int port() { return port; } @Override public boolean withScheme() { return false; } } final private NoScheme noScheme = new NoScheme(); private int required = 0; private int prohibited = 0; public int getRequired() { return required; } public int getProhibited() { return prohibited ; } final private Map<String, SchemeSpecificPart> schemes = new HashMap<>(); public void useSchemeSpecificRules(String scheme, boolean asErr) { if (scheme.equals("*")) { for ( String s : Specification.schemes.keySet() ) { scheme = s; if ( !schemes.containsKey( scheme ) ) { useSchemeSpecificRules( scheme, asErr ); } } return ; } scheme = scheme.toLowerCase() ; SchemeSpecification spec = (SchemeSpecification) Specification.schemes.get(scheme) ; if (spec == null) { schemes.put(scheme, noScheme) ; } else { schemes.put(scheme, new WithScheme(spec, asErr)) ; } } }
apache/jena
jena-iri/src/main/java/org/apache/jena/iri/impl/IRIFactoryImpl.java
744
/* * Copyright 2017-present Open Networking Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.onosproject.dhcprelay; import org.onlab.packet.BasePacket; import org.onlab.packet.DHCP6; import org.onlab.packet.DHCP6.MsgType; import org.onlab.packet.Ip6Address; import org.onlab.packet.IpAddress; import org.onlab.packet.VlanId; import org.onlab.packet.dhcp.Dhcp6ClientIdOption; import org.onlab.packet.dhcp.Dhcp6RelayOption; import org.onlab.packet.dhcp.Dhcp6Option; import org.onlab.packet.Ethernet; import org.onlab.packet.IPv6; import org.onlab.packet.MacAddress; import org.onlab.packet.UDP; import org.onlab.util.HexString; import org.onosproject.dhcprelay.api.DhcpServerInfo; import org.onosproject.dhcprelay.store.DhcpRelayCounters; import org.onosproject.net.ConnectPoint; import org.onosproject.net.host.InterfaceIpAddress; import org.onosproject.net.intf.Interface; import org.onosproject.net.packet.PacketContext; import org.onosproject.net.DeviceId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Set; import java.util.List; import java.util.ArrayList; import org.onosproject.net.intf.InterfaceService; import org.onosproject.net.Host; import org.onosproject.net.host.HostService; import org.onosproject.net.HostLocation; import static com.google.common.base.Preconditions.checkNotNull; public final class Dhcp6HandlerUtil { private static final Logger log = LoggerFactory.getLogger(Dhcp6HandlerUtil.class); private Dhcp6HandlerUtil() { } // Returns the first v6 interface ip out of a set of interfaces or null. // Checks all interfaces, and ignores v6 interface ips public static Ip6Address getRelayAgentIPv6Address(Set<Interface> intfs) { for (Interface intf : intfs) { for (InterfaceIpAddress ip : intf.ipAddressesList()) { Ip6Address relayAgentIp = ip.ipAddress().getIp6Address(); if (relayAgentIp != null) { return relayAgentIp; } } } return null; } /** * Returns the first interface ip from interface. * * @param iface interface of one connect point * @return the first interface IP; null if not exists an IP address in * these interfaces */ private static Ip6Address getFirstIpFromInterface(Interface iface) { checkNotNull(iface, "Interface can't be null"); return iface.ipAddressesList().stream() .map(InterfaceIpAddress::ipAddress) .filter(IpAddress::isIp6) .map(IpAddress::getIp6Address) .findFirst() .orElse(null); } /** * * process the LQ reply packet from dhcp server. * * @param defaultServerInfoList default server list * @param indirectServerInfoList default indirect server list * @param serverInterface server interface * @param interfaceService interface service * @param hostService host service * @param context packet context * @param receivedPacket server ethernet packet * @param recevingInterfaces set of server side interfaces * @return a packet ready to be sent to relevant output interface */ public static InternalPacket processLQ6PacketFromServer( List<DhcpServerInfo> defaultServerInfoList, List<DhcpServerInfo> indirectServerInfoList, Interface serverInterface, InterfaceService interfaceService, HostService hostService, PacketContext context, Ethernet receivedPacket, Set<Interface> recevingInterfaces) { // get dhcp6 header. Ethernet etherReply = (Ethernet) receivedPacket.clone(); IPv6 ipv6Packet = (IPv6) etherReply.getPayload(); UDP udpPacket = (UDP) ipv6Packet.getPayload(); DHCP6 lq6Reply = (DHCP6) udpPacket.getPayload(); // TODO: refactor ConnectPoint receivedFrom = context.inPacket().receivedFrom(); DeviceId receivedFromDevice = receivedFrom.deviceId(); DhcpServerInfo serverInfo; Ip6Address dhcpServerIp = null; ConnectPoint dhcpServerConnectPoint = null; MacAddress dhcpConnectMac = null; VlanId dhcpConnectVlan = null; Ip6Address dhcpGatewayIp = null; // todo: refactor Ip6Address indirectDhcpServerIp = null; ConnectPoint indirectDhcpServerConnectPoint = null; MacAddress indirectDhcpConnectMac = null; VlanId indirectDhcpConnectVlan = null; Ip6Address indirectDhcpGatewayIp = null; Ip6Address indirectRelayAgentIpFromCfg = null; if (!defaultServerInfoList.isEmpty()) { serverInfo = defaultServerInfoList.get(0); dhcpConnectMac = serverInfo.getDhcpConnectMac().orElse(null); dhcpGatewayIp = serverInfo.getDhcpGatewayIp6().orElse(null); dhcpServerIp = serverInfo.getDhcpServerIp6().orElse(null); dhcpServerConnectPoint = serverInfo.getDhcpServerConnectPoint().orElse(null); dhcpConnectVlan = serverInfo.getDhcpConnectVlan().orElse(null); } if (!indirectServerInfoList.isEmpty()) { serverInfo = indirectServerInfoList.get(0); indirectDhcpConnectMac = serverInfo.getDhcpConnectMac().orElse(null); indirectDhcpGatewayIp = serverInfo.getDhcpGatewayIp6().orElse(null); indirectDhcpServerIp = serverInfo.getDhcpServerIp6().orElse(null); indirectDhcpServerConnectPoint = serverInfo.getDhcpServerConnectPoint().orElse(null); indirectDhcpConnectVlan = serverInfo.getDhcpConnectVlan().orElse(null); indirectRelayAgentIpFromCfg = serverInfo.getRelayAgentIp6(receivedFromDevice).orElse(null); } Boolean directConnFlag = directlyConnected(lq6Reply); ConnectPoint inPort = context.inPacket().receivedFrom(); if ((directConnFlag || indirectDhcpServerIp == null) && !inPort.equals(dhcpServerConnectPoint)) { log.warn("Receiving port {} is not the same as server connect point {} for direct or indirect-null", inPort, dhcpServerConnectPoint); return null; } if (!directConnFlag && indirectDhcpServerIp != null && !inPort.equals(indirectDhcpServerConnectPoint)) { log.warn("Receiving port {} is not the same as server connect point {} for indirect", inPort, indirectDhcpServerConnectPoint); return null; } Ip6Address nextHopIP = Ip6Address.valueOf(ipv6Packet.getDestinationAddress()); // use hosts store to find out the next hop mac and connection point Set<Host> hosts = hostService.getHostsByIp(nextHopIP); Host host; if (!hosts.isEmpty()) { host = hosts.iterator().next(); } else { log.warn("Host {} is not in store", nextHopIP); return null; } HostLocation hl = host.location(); String clientConnectionPointStr = hl.toString(); // iterator().next()); ConnectPoint clientConnectionPoint = ConnectPoint.deviceConnectPoint(clientConnectionPointStr); VlanId originalPacketVlanId = VlanId.vlanId(etherReply.getVlanID()); Interface iface; iface = interfaceService.getInterfacesByPort(clientConnectionPoint) .stream() .filter(iface1 -> interfaceContainsVlan(iface1, originalPacketVlanId)) .findFirst() .orElse(null); etherReply.setSourceMACAddress(iface.mac()); etherReply.setDestinationMACAddress(host.mac()); // workaround for a bug where core sends src port as 547 (server) udpPacket.setDestinationPort(UDP.DHCP_V6_SERVER_PORT); udpPacket.setPayload(lq6Reply); udpPacket.resetChecksum(); ipv6Packet.setPayload(udpPacket); etherReply.setPayload(ipv6Packet); return InternalPacket.internalPacket(etherReply, clientConnectionPoint); } /** * extract DHCP6 payload from dhcp6 relay message within relay-forwrd/reply. * * @param dhcp6 dhcp6 relay-reply or relay-forward * @return dhcp6Packet dhcp6 packet extracted from relay-message */ public static DHCP6 dhcp6PacketFromRelayPacket(DHCP6 dhcp6) { // extract the relay message if exist DHCP6 dhcp6Payload = dhcp6.getOptions().stream() .filter(opt -> opt instanceof Dhcp6RelayOption) .map(BasePacket::getPayload) .map(pld -> (DHCP6) pld) .findFirst() .orElse(null); if (dhcp6Payload == null) { // Can't find dhcp payload log.debug("Can't find dhcp6 payload from relay message"); } else { log.debug("dhcp6 payload found from relay message {}", dhcp6Payload); } return dhcp6Payload; } /** * find the leaf DHCP6 packet from multi-level relay packet. * * @param relayPacket dhcp6 relay packet * @return leafPacket non-relay dhcp6 packet */ public static DHCP6 getDhcp6Leaf(DHCP6 relayPacket) { DHCP6 dhcp6Parent = relayPacket; DHCP6 dhcp6Child = null; log.debug("getDhcp6Leaf entered."); while (dhcp6Parent != null) { dhcp6Child = dhcp6PacketFromRelayPacket(dhcp6Parent); if (dhcp6Child != null) { if (dhcp6Child.getMsgType() != DHCP6.MsgType.RELAY_FORW.value() && dhcp6Child.getMsgType() != DHCP6.MsgType.RELAY_REPL.value()) { log.debug("leaf dhcp6 packet found."); break; } else { // found another relay, go for another loop dhcp6Parent = dhcp6Child; } } else { log.debug("Expected dhcp6 within relay pkt, but no dhcp6 leaf found."); break; } } return dhcp6Child; } /** * Determine DHCP message type (direct DHCPv6 or wrapped into relay messages). * * @param relayPacket {@link DHCP6} packet to be parsed * @return {@link DHCP6.MsgType} contained message type of dhcpv6 packet/relay-message */ public static DHCP6.MsgType getDhcp6LeafMessageType(DHCP6 relayPacket) { checkNotNull(relayPacket); DHCP6 dhcp6Child = getDhcp6Leaf(relayPacket); return DHCP6.MsgType.getType(dhcp6Child != null ? dhcp6Child.getMsgType() : relayPacket.getMsgType()); } /** * check if DHCP6 relay-reply is reply. * * @param relayPacket dhcp6 relay-reply * @return boolean relay-reply contains ack */ public static boolean isDhcp6Reply(DHCP6 relayPacket) { DHCP6 leafDhcp6 = getDhcp6Leaf(relayPacket); if (leafDhcp6 != null) { if (leafDhcp6.getMsgType() == DHCP6.MsgType.REPLY.value()) { log.debug("isDhcp6Reply true."); return true; // must be directly connected } else { log.debug("isDhcp6Reply false. leaf dhcp6 is not replay. MsgType {}", leafDhcp6.getMsgType()); } } else { log.debug("isDhcp6Reply false. Expected dhcp6 within relay pkt but not found."); } log.debug("isDhcp6Reply false."); return false; } /** * check if DHCP6 is release or relay-forward contains release. * * @param dhcp6Payload dhcp6 packet * @return boolean dhcp6 contains release */ public static boolean isDhcp6Release(DHCP6 dhcp6Payload) { if (dhcp6Payload.getMsgType() == DHCP6.MsgType.RELEASE.value()) { log.debug("isDhcp6Release true."); return true; // must be directly connected } else { DHCP6 dhcp6Leaf = getDhcp6Leaf(dhcp6Payload); if (dhcp6Leaf != null) { if (dhcp6Leaf.getMsgType() == DHCP6.MsgType.RELEASE.value()) { log.debug("isDhcp6Release true. indirectlry connected"); return true; } else { log.debug("leaf dhcp6 is not release. MsgType {}", dhcp6Leaf.getMsgType()); return false; } } else { log.debug("isDhcp6Release false. dhcp6 is niether relay nor release."); return false; } } } /** * convert dhcp6 msgType to String. * * @param msgTypeVal msgType byte of dhcp6 packet * @return String string value of dhcp6 msg type */ public static String getMsgTypeStr(byte msgTypeVal) { MsgType msgType = DHCP6.MsgType.getType(msgTypeVal); return DHCP6.MsgType.getMsgTypeStr(msgType); } /** * find the string of dhcp6 leaf packets's msg type. * * @param directConnFlag boolean value indicating direct/indirect connection * @param dhcp6Packet dhcp6 packet * @return String string value of dhcp6 leaf packet msg type */ public static String findLeafMsgType(boolean directConnFlag, DHCP6 dhcp6Packet) { if (directConnFlag) { return getMsgTypeStr(dhcp6Packet.getMsgType()); } else { DHCP6 leafDhcp = getDhcp6Leaf(dhcp6Packet); if (leafDhcp != null) { return getMsgTypeStr(leafDhcp.getMsgType()); } else { return DhcpRelayCounters.INVALID_PACKET; } } } /** * Determind if an Interface contains a vlan id. * * @param iface the Interface * @param vlanId the vlan id * @return true if the Interface contains the vlan id */ public static boolean interfaceContainsVlan(Interface iface, VlanId vlanId) { if (vlanId.equals(VlanId.NONE)) { // untagged packet, check if vlan untagged or vlan native is not NONE return !iface.vlanUntagged().equals(VlanId.NONE) || !iface.vlanNative().equals(VlanId.NONE); } // tagged packet, check if the interface contains the vlan return iface.vlanTagged().contains(vlanId); } /** * Check if the host is directly connected to the network or not. * * @param dhcp6Payload the dhcp6 payload * @return true if the host is directly connected to the network; false otherwise */ public static boolean directlyConnected(DHCP6 dhcp6Payload) { log.debug("directlyConnected enters"); if (dhcp6Payload.getMsgType() == DHCP6.MsgType.LEASEQUERY.value() || dhcp6Payload.getMsgType() == DHCP6.MsgType.LEASEQUERY_REPLY.value()) { log.debug("directlyConnected false. MsgType {}", dhcp6Payload.getMsgType()); return false; } if (dhcp6Payload.getMsgType() != DHCP6.MsgType.RELAY_FORW.value() && dhcp6Payload.getMsgType() != DHCP6.MsgType.RELAY_REPL.value()) { log.debug("directlyConnected true. MsgType {}", dhcp6Payload.getMsgType()); return true; } // Regardless of relay-forward or relay-replay, check if we see another relay message DHCP6 dhcp6Payload2 = dhcp6PacketFromRelayPacket(dhcp6Payload); if (dhcp6Payload2 != null) { if (dhcp6Payload.getMsgType() == DHCP6.MsgType.RELAY_FORW.value()) { log.debug("directlyConnected false. 1st relay-forward, 2nd MsgType {}", dhcp6Payload2.getMsgType()); return false; } else { // relay-reply if (dhcp6Payload2.getMsgType() != DHCP6.MsgType.RELAY_REPL.value() && dhcp6Payload2.getMsgType() != MsgType.LEASEQUERY_REPLY.value()) { log.debug("directlyConnected true. 2nd MsgType {}", dhcp6Payload2.getMsgType()); return true; // must be directly connected } else { log.debug("directlyConnected false. 1st relay-reply, 2nd relay-reply MsgType {}", dhcp6Payload2.getMsgType()); return false; // must be indirectly connected } } } else { log.debug("directlyConnected true."); return true; } } /** * Check if a given server info has v6 ipaddress. * * @param serverInfo server info to check * @return true if server info has v6 ip address; false otherwise */ public static boolean isServerIpEmpty(DhcpServerInfo serverInfo) { if (!serverInfo.getDhcpServerIp6().isPresent()) { log.warn("DhcpServerIp not available, use default DhcpServerIp {}", HexString.toHexString(serverInfo.getDhcpServerIp6().get().toOctets())); return true; } return false; } private static boolean isConnectMacEmpty(DhcpServerInfo serverInfo, Set<Interface> clientInterfaces) { if (!serverInfo.getDhcpConnectMac().isPresent()) { log.warn("DHCP6 {} not yet resolved .. Aborting DHCP " + "packet processing from client on port: {}", !serverInfo.getDhcpGatewayIp6().isPresent() ? "server IP " + serverInfo.getDhcpServerIp6() : "gateway IP " + serverInfo.getDhcpGatewayIp6(), clientInterfaces.iterator().next().connectPoint()); return true; } return false; } private static Dhcp6Option getInterfaceIdIdOption(PacketContext context, Ethernet clientPacket) { String inPortString = "-" + context.inPacket().receivedFrom().toString() + ":"; Dhcp6Option interfaceId = new Dhcp6Option(); interfaceId.setCode(DHCP6.OptionCode.INTERFACE_ID.value()); byte[] clientSoureMacBytes = clientPacket.getSourceMACAddress(); byte[] inPortStringBytes = inPortString.getBytes(); byte[] vlanIdBytes = new byte[2]; vlanIdBytes[0] = (byte) ((clientPacket.getVlanID() >> 8) & 0xff); vlanIdBytes[1] = (byte) (clientPacket.getVlanID() & 0xff); byte[] interfaceIdBytes = new byte[clientSoureMacBytes.length + inPortStringBytes.length + vlanIdBytes.length]; log.debug("Length: interfaceIdBytes {} clientSoureMacBytes {} inPortStringBytes {} vlan {}", interfaceIdBytes.length, clientSoureMacBytes.length, inPortStringBytes.length, vlanIdBytes.length); System.arraycopy(clientSoureMacBytes, 0, interfaceIdBytes, 0, clientSoureMacBytes.length); System.arraycopy(inPortStringBytes, 0, interfaceIdBytes, clientSoureMacBytes.length, inPortStringBytes.length); System.arraycopy(vlanIdBytes, 0, interfaceIdBytes, clientSoureMacBytes.length + inPortStringBytes.length, vlanIdBytes.length); interfaceId.setData(interfaceIdBytes); interfaceId.setLength((short) interfaceIdBytes.length); log.debug("interfaceId write srcMac {} portString {}, vlanId {}", HexString.toHexString(clientSoureMacBytes, ":"), inPortString, vlanIdBytes); return interfaceId; } private static void addDhcp6OptionsFromClient(List<Dhcp6Option> options, byte[] dhcp6PacketByte, PacketContext context, Ethernet clientPacket) { Dhcp6Option relayMessage = new Dhcp6Option(); relayMessage.setCode(DHCP6.OptionCode.RELAY_MSG.value()); relayMessage.setLength((short) dhcp6PacketByte.length); relayMessage.setData(dhcp6PacketByte); options.add(relayMessage); // create interfaceId option Dhcp6Option interfaceId = getInterfaceIdIdOption(context, clientPacket); options.add(interfaceId); } /** * build the DHCP6 solicit/request packet with gatewayip. * * @param context packet context * @param clientPacket client ethernet packet * @param clientInterfaces set of client side interfaces * @param serverInfo target server which a packet is generated for * @param serverInterface target server interface * @return ethernet packet with dhcp6 packet info */ public static Ethernet buildDhcp6PacketFromClient(PacketContext context, Ethernet clientPacket, Set<Interface> clientInterfaces, DhcpServerInfo serverInfo, Interface serverInterface) { ConnectPoint receivedFrom = context.inPacket().receivedFrom(); DeviceId receivedFromDevice = receivedFrom.deviceId(); Ip6Address relayAgentIp = getRelayAgentIPv6Address(clientInterfaces); MacAddress relayAgentMac = clientInterfaces.iterator().next().mac(); if (relayAgentIp == null || relayAgentMac == null) { log.warn("Missing DHCP relay agent interface Ipv6 addr config for " + "packet from client on port: {}. Aborting packet processing", clientInterfaces.iterator().next().connectPoint()); return null; } IPv6 clientIpv6 = (IPv6) clientPacket.getPayload(); UDP clientUdp = (UDP) clientIpv6.getPayload(); DHCP6 clientDhcp6 = (DHCP6) clientUdp.getPayload(); boolean directConnFlag = directlyConnected(clientDhcp6); Ip6Address serverIpFacing = getFirstIpFromInterface(serverInterface); if (serverIpFacing == null || serverInterface.mac() == null) { log.warn("No IP v6 address for server Interface {}", serverInterface); return null; } Ethernet etherReply = clientPacket.duplicate(); etherReply.setSourceMACAddress(serverInterface.mac()); // set default info and replace with indirect if available later on. if (serverInfo.getDhcpConnectMac().isPresent()) { etherReply.setDestinationMACAddress(serverInfo.getDhcpConnectMac().get()); } if (serverInfo.getDhcpConnectVlan().isPresent()) { etherReply.setVlanID(serverInfo.getDhcpConnectVlan().get().toShort()); } IPv6 ipv6Packet = (IPv6) etherReply.getPayload(); byte[] peerAddress = clientIpv6.getSourceAddress(); ipv6Packet.setSourceAddress(serverIpFacing.toOctets()); ipv6Packet.setDestinationAddress(serverInfo.getDhcpServerIp6().get().toOctets()); UDP udpPacket = (UDP) ipv6Packet.getPayload(); udpPacket.setSourcePort(UDP.DHCP_V6_SERVER_PORT); DHCP6 dhcp6Packet = (DHCP6) udpPacket.getPayload(); byte[] dhcp6PacketByte = dhcp6Packet.serialize(); DHCP6 dhcp6Relay = new DHCP6(); dhcp6Relay.setMsgType(DHCP6.MsgType.RELAY_FORW.value()); if (directConnFlag) { dhcp6Relay.setLinkAddress(relayAgentIp.toOctets()); } else { if (isServerIpEmpty(serverInfo)) { log.warn("indirect DhcpServerIp empty... use default server "); } else { // Indirect case, replace destination to indirect dhcp server if exist // Check if mac is obtained for valid server ip if (isConnectMacEmpty(serverInfo, clientInterfaces)) { log.warn("indirect Dhcp ConnectMac empty ..."); return null; } etherReply.setDestinationMACAddress(serverInfo.getDhcpConnectMac().get()); etherReply.setVlanID(serverInfo.getDhcpConnectVlan().get().toShort()); ipv6Packet.setDestinationAddress(serverInfo.getDhcpServerIp6().get().toOctets()); } if (!serverInfo.getRelayAgentIp6(receivedFromDevice).isPresent()) { log.debug("indirect connection: relayAgentIp NOT availale from config file! Use dynamic. {}", HexString.toHexString(relayAgentIp.toOctets(), ":")); serverIpFacing = relayAgentIp; } else { serverIpFacing = serverInfo.getRelayAgentIp6(receivedFromDevice).get(); } log.debug("Source IP address set as relay agent IP with value: {}", serverIpFacing); dhcp6Relay.setLinkAddress(serverIpFacing.toOctets()); ipv6Packet.setSourceAddress(serverIpFacing.toOctets()); } // peer address: address of the client or relay agent from which the message to be relayed was received. dhcp6Relay.setPeerAddress(peerAddress); // directly connected case, hop count is zero; otherwise, hop count + 1 if (directConnFlag) { dhcp6Relay.setHopCount((byte) 0); } else { dhcp6Relay.setHopCount((byte) (dhcp6Packet.getHopCount() + 1)); } List<Dhcp6Option> options = new ArrayList<>(); addDhcp6OptionsFromClient(options, dhcp6PacketByte, context, clientPacket); dhcp6Relay.setOptions(options); udpPacket.setPayload(dhcp6Relay); udpPacket.resetChecksum(); ipv6Packet.setPayload(udpPacket); ipv6Packet.setHopLimit((byte) 64); etherReply.setPayload(ipv6Packet); return etherReply; } /** * build the DHCP6 solicit/request packet with gatewayip. * * @param directConnFlag flag indicating if packet is from direct client or not * @param serverInfo server to check its connect point * @return boolean true if serverInfo is found; false otherwise */ public static boolean checkDhcpServerConnPt(boolean directConnFlag, DhcpServerInfo serverInfo) { if (serverInfo.getDhcpServerConnectPoint() == null) { log.warn("DHCP6 server connect point for {} connPt {}", directConnFlag ? "direct" : "indirect", serverInfo.getDhcpServerConnectPoint()); return false; } return true; } /** * extract from dhcp6 packet ClientIdOption. * * @param directConnFlag directly connected host * @param dhcp6Payload the dhcp6 payload * @return Dhcp6ClientIdOption clientIdOption, or null if not exists. */ static Dhcp6ClientIdOption extractClientId(Boolean directConnFlag, DHCP6 dhcp6Payload) { Dhcp6ClientIdOption clientIdOption; if (directConnFlag) { clientIdOption = dhcp6Payload.getOptions() .stream() .filter(opt -> opt instanceof Dhcp6ClientIdOption) .map(opt -> (Dhcp6ClientIdOption) opt) .findFirst() .orElse(null); } else { DHCP6 leafDhcp = Dhcp6HandlerUtil.getDhcp6Leaf(dhcp6Payload); clientIdOption = leafDhcp.getOptions() .stream() .filter(opt -> opt instanceof Dhcp6ClientIdOption) .map(opt -> (Dhcp6ClientIdOption) opt) .findFirst() .orElse(null); } return clientIdOption; } }
opennetworkinglab/onos
apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerUtil.java
745
//### This file created by BYACC 1.8(/Java extension 1.15) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; package ch5; import static ch5.j0.yylex; import static ch5.yyerror.yyerror; public class parser { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //public class parserVal is defined in parserVal.java String yytext;//user variable to return contextual strings parserVal yyval; //used to return semantic vals from action routines parserVal yylval;//the 'lval' (result) I got from yylex() parserVal valstk[]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### void val_init() { valstk=new parserVal[YYSTACKSIZE]; yyval=new parserVal(); yylval=new parserVal(); valptr=-1; } void val_push(parserVal val) { if (valptr>=YYSTACKSIZE) return; valstk[++valptr]=val; } parserVal val_pop() { if (valptr<0) return new parserVal(); return valstk[valptr--]; } void val_drop(int cnt) { int ptr; ptr=valptr-cnt; if (ptr<0) return; valptr = ptr; } parserVal val_peek(int relative) { int ptr; ptr=valptr-relative; if (ptr<0) return new parserVal(); return valstk[ptr]; } final parserVal dup_yyval(parserVal val) { parserVal dup = new parserVal(); dup.ival = val.ival; dup.dval = val.dval; dup.sval = val.sval; dup.obj = val.obj; return dup; } //#### end semantic value section #### public final static short BREAK=257; public final static short DOUBLE=258; public final static short ELSE=259; public final static short FOR=260; public final static short IF=261; public final static short INT=262; public final static short RETURN=263; public final static short VOID=264; public final static short WHILE=265; public final static short IDENTIFIER=266; public final static short CLASSNAME=267; public final static short CLASS=268; public final static short STRING=269; public final static short BOOL=270; public final static short INTLIT=271; public final static short DOUBLELIT=272; public final static short STRINGLIT=273; public final static short BOOLLIT=274; public final static short NULLVAL=275; public final static short LESSTHANOREQUAL=276; public final static short GREATERTHANOREQUAL=277; public final static short ISEQUALTO=278; public final static short NOTEQUALTO=279; public final static short LOGICALAND=280; public final static short LOGICALOR=281; public final static short INCREMENT=282; public final static short DECREMENT=283; public final static short PUBLIC=284; public final static short STATIC=285; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 7, 7, 7, 7, 7, 9, 9, 10, 8, 8, 11, 11, 12, 12, 5, 13, 15, 16, 16, 17, 17, 18, 6, 14, 19, 19, 20, 20, 21, 21, 22, 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 25, 33, 33, 28, 29, 30, 30, 37, 37, 38, 31, 32, 39, 39, 39, 40, 40, 41, 41, 42, 42, 26, 26, 27, 43, 43, 43, 43, 44, 44, 44, 44, 44, 46, 46, 45, 47, 47, 35, 35, 48, 48, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 52, 52, 52, 52, 53, 53, 54, 54, 54, 55, 55, 56, 56, 36, 36, 34, 57, 57, 58, 58, 58, }; final static short yylen[] = { 2, 4, 3, 2, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 3, 1, 1, 2, 4, 4, 1, 0, 1, 3, 2, 2, 3, 1, 0, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 5, 7, 6, 8, 1, 2, 2, 5, 9, 1, 1, 0, 1, 0, 1, 0, 1, 3, 2, 3, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 3, 1, 0, 4, 6, 1, 1, 2, 2, 1, 1, 3, 3, 3, 1, 3, 3, 1, 1, 1, 1, 1, 3, 1, 3, 3, 1, 3, 1, 3, 1, 1, 3, 1, 1, 1, 1, 1, }; final static short yydefred[] = { 0, 0, 0, 0, 0, 0, 1, 11, 10, 0, 13, 12, 0, 3, 0, 4, 6, 7, 8, 0, 0, 16, 0, 0, 0, 0, 2, 5, 20, 0, 0, 0, 0, 24, 32, 15, 0, 0, 0, 29, 23, 22, 0, 9, 0, 0, 17, 0, 0, 0, 0, 0, 80, 81, 83, 82, 84, 43, 0, 0, 0, 42, 0, 0, 36, 38, 39, 0, 44, 45, 46, 47, 48, 49, 50, 51, 0, 53, 0, 0, 76, 0, 0, 0, 26, 0, 0, 25, 0, 21, 0, 73, 0, 0, 0, 0, 0, 118, 78, 67, 0, 0, 96, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 37, 40, 52, 0, 123, 124, 122, 0, 30, 74, 65, 71, 0, 0, 0, 0, 77, 94, 95, 75, 0, 0, 0, 0, 0, 104, 105, 106, 107, 0, 0, 0, 0, 0, 0, 79, 85, 0, 0, 0, 119, 0, 0, 0, 98, 99, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 72, 0, 62, 86, 0, 0, 0, 0, 59, 91, 0, 0, 0, 56, 61, 0, 60, 0, 0, 58, 63, 0, 0, 55, }; final static short yydgoto[] = { 2, 6, 14, 15, 16, 17, 18, 59, 29, 130, 21, 30, 42, 22, 61, 23, 37, 38, 39, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 97, 98, 99, 182, 183, 127, 100, 185, 128, 101, 80, 81, 152, 153, 102, 103, 104, 105, 144, 106, 107, 108, 109, 82, 122, }; final static short yysindex[] = { -218, -200, 0, -181, -35, -95, 0, 0, 0, 51, 0, 0, -177, 0, -93, 0, 0, 0, 0, -152, 79, 0, 16, 16, 227, 217, 0, 0, 0, -30, 65, -133, 169, 0, 0, 0, -152, 117, 116, 0, 0, 0, -96, 0, -152, 95, 0, -46, 132, 150, 50, 153, 0, 0, 0, 0, 0, 0, 50, -152, 52, 0, 72, 169, 0, 0, 0, 141, 0, 0, 0, 0, 0, 0, 0, 0, 143, 0, 0, 158, 0, 0, -24, 65, 0, 227, 51, 0, 65, 0, 148, 0, -39, 50, 50, 50, 52, 0, 0, 0, 151, 158, 0, 0, 145, 109, 97, -100, -69, -68, 50, 171, 170, 50, 0, 0, 0, 0, -51, 0, 0, 0, 50, 0, 0, 0, 0, 157, 173, 177, 52, 0, 0, 0, 0, 50, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 50, 180, 0, 0, 182, 188, 197, 0, 50, -1, 16, 0, 0, 0, 145, 145, 109, 97, 97, -100, -69, 268, 50, 0, 50, 179, 52, 0, -11, 0, 0, 219, -1, -111, 9, 0, 0, 222, 173, 224, 0, 0, -111, 0, 16, 50, 0, 0, 234, 16, 0, }; final static short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, -44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 235, 0, 0, 0, 0, 0, 6, 0, 172, 0, 0, 0, 0, 0, 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, -58, 0, 0, 175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 0, 0, -37, 0, -13, 0, 0, 0, 0, 14, 0, 0, 0, 246, 0, 0, 0, 1, 0, 0, 0, 0, 10, 0, 0, 56, 76, 15, 90, 45, 43, 0, 0, 247, 266, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 276, 0, -26, 0, 240, 0, 0, 0, 0, 0, 62, 68, 82, 23, 88, 96, 102, 0, 0, 0, 266, 0, -21, 0, 124, 0, 0, 0, 277, 0, 144, 0, 0, 0, 278, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; final static short yygindex[] = { 0, 0, 0, 314, 0, 0, 0, 181, 270, 445, 0, 5, 0, 0, 4, 289, 0, 0, 245, 0, 0, 287, 0, 195, 273, 0, 0, 0, -71, 0, 0, 0, 0, -12, 288, 388, 378, 0, 190, 0, 223, 0, 198, 390, 0, 441, 0, 203, 0, 329, 42, 244, 0, 53, 253, 255, 0, 0, 0, }; final static int YYTABLESIZE=638; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 77, 58, 15, 120, 77, 77, 77, 77, 77, 77, 77, 87, 32, 91, 44, 87, 87, 87, 87, 87, 87, 87, 77, 77, 121, 77, 33, 34, 31, 43, 13, 31, 26, 87, 87, 87, 87, 121, 93, 58, 120, 83, 93, 93, 93, 93, 93, 92, 93, 88, 18, 92, 92, 92, 92, 92, 110, 92, 19, 110, 93, 93, 120, 93, 111, 18, 1, 111, 3, 92, 92, 93, 92, 19, 110, 93, 93, 93, 93, 93, 126, 93, 111, 95, 117, 4, 115, 117, 5, 115, 58, 24, 113, 93, 93, 94, 93, 101, 31, 101, 101, 101, 117, 103, 115, 103, 103, 103, 25, 102, 189, 102, 102, 102, 28, 101, 101, 108, 101, 189, 108, 103, 103, 109, 103, 31, 109, 102, 102, 112, 102, 113, 112, 46, 113, 108, 108, 114, 108, 32, 114, 109, 109, 116, 109, 175, 116, 112, 54, 113, 187, 54, 139, 78, 138, 114, 45, 142, 84, 143, 85, 116, 176, 7, 55, 7, 54, 8, 126, 8, 86, 9, 92, 9, 10, 11, 10, 11, 145, 146, 162, 163, 137, 55, 57, 188, 19, 135, 89, 12, 93, 12, 136, 110, 194, 19, 195, 114, 165, 166, 116, 198, 117, 57, 118, 36, 41, 124, 14, 58, 134, 147, 150, 148, 44, 154, 156, 157, 158, 7, 90, 169, 15, 8, 120, 120, 170, 35, 57, 171, 10, 11, 52, 53, 54, 55, 56, 172, 180, 77, 77, 77, 77, 77, 77, 121, 121, 55, 181, 55, 87, 87, 87, 87, 87, 87, 87, 87, 119, 120, 184, 120, 120, 192, 193, 35, 36, 57, 190, 57, 52, 53, 54, 55, 56, 197, 28, 93, 93, 93, 93, 93, 93, 120, 120, 14, 92, 92, 92, 92, 92, 92, 32, 110, 110, 110, 110, 35, 27, 68, 34, 111, 111, 111, 111, 66, 41, 89, 58, 64, 93, 93, 93, 93, 93, 93, 35, 88, 70, 69, 77, 52, 53, 54, 55, 56, 115, 57, 27, 112, 123, 87, 101, 101, 101, 101, 101, 101, 103, 103, 103, 103, 103, 103, 102, 102, 102, 102, 102, 102, 115, 77, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109, 109, 109, 177, 125, 112, 112, 112, 112, 113, 113, 191, 140, 141, 179, 114, 114, 186, 173, 77, 55, 55, 116, 55, 55, 55, 55, 164, 55, 55, 32, 0, 55, 55, 55, 55, 55, 55, 55, 167, 57, 57, 168, 57, 57, 57, 57, 0, 57, 57, 0, 0, 57, 57, 57, 57, 57, 57, 57, 78, 0, 79, 132, 133, 0, 47, 7, 0, 48, 49, 8, 50, 0, 51, 35, 111, 0, 10, 11, 52, 53, 54, 55, 56, 77, 0, 0, 0, 0, 20, 78, 0, 79, 0, 0, 0, 77, 0, 20, 0, 0, 0, 0, 159, 160, 161, 0, 77, 20, 20, 129, 0, 0, 0, 7, 0, 60, 0, 8, 78, 40, 79, 35, 0, 7, 10, 11, 149, 8, 0, 151, 0, 35, 0, 96, 10, 11, 0, 0, 155, 0, 0, 96, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, 48, 49, 20, 50, 0, 51, 35, 131, 131, 60, 96, 52, 53, 54, 55, 56, 0, 78, 0, 79, 178, 0, 151, 0, 0, 0, 0, 96, 0, 78, 96, 79, 0, 0, 0, 0, 0, 0, 0, 96, 78, 0, 79, 196, 0, 0, 0, 0, 131, 131, 131, 131, 131, 0, 0, 0, 0, 131, 131, 131, 131, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 174, 96, 0, 96, 0, 0, 0, 0, 0, 0, 0, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 37, 40, 46, 61, 41, 42, 43, 44, 45, 46, 47, 37, 123, 59, 44, 41, 42, 43, 44, 45, 46, 47, 59, 60, 61, 62, 22, 23, 41, 59, 125, 44, 125, 59, 60, 61, 62, 61, 37, 40, 61, 36, 41, 42, 43, 44, 45, 37, 47, 44, 44, 41, 42, 43, 44, 45, 41, 47, 44, 44, 59, 60, 61, 62, 41, 59, 284, 44, 268, 59, 60, 37, 62, 59, 59, 41, 42, 43, 44, 45, 92, 47, 59, 33, 41, 266, 41, 44, 123, 44, 40, 40, 40, 59, 60, 45, 62, 41, 46, 43, 44, 45, 59, 41, 59, 43, 44, 45, 285, 41, 181, 43, 44, 45, 266, 59, 60, 41, 62, 190, 44, 59, 60, 41, 62, 46, 44, 59, 60, 41, 62, 41, 44, 266, 44, 59, 60, 41, 62, 123, 44, 59, 60, 41, 62, 157, 44, 59, 41, 59, 261, 44, 43, 46, 45, 59, 91, 60, 41, 62, 44, 59, 158, 258, 40, 258, 59, 262, 180, 262, 266, 266, 40, 266, 269, 270, 269, 270, 278, 279, 138, 139, 37, 59, 40, 181, 5, 42, 93, 284, 40, 284, 47, 40, 190, 14, 192, 125, 145, 146, 59, 197, 59, 59, 46, 24, 25, 59, 266, 40, 59, 280, 41, 281, 44, 266, 59, 44, 41, 258, 266, 41, 266, 262, 282, 283, 44, 266, 59, 41, 269, 270, 271, 272, 273, 274, 275, 40, 59, 276, 277, 278, 279, 280, 281, 282, 283, 123, 259, 125, 276, 277, 278, 279, 280, 281, 282, 283, 282, 283, 41, 282, 283, 41, 40, 266, 85, 123, 259, 125, 271, 272, 273, 274, 275, 41, 41, 276, 277, 278, 279, 280, 281, 282, 283, 266, 276, 277, 278, 279, 280, 281, 123, 278, 279, 280, 281, 125, 41, 59, 125, 278, 279, 280, 281, 59, 59, 41, 40, 59, 276, 277, 278, 279, 280, 281, 266, 41, 41, 41, 32, 271, 272, 273, 274, 275, 281, 59, 14, 59, 85, 42, 276, 277, 278, 279, 280, 281, 276, 277, 278, 279, 280, 281, 276, 277, 278, 279, 280, 281, 63, 63, 276, 277, 278, 279, 280, 281, 276, 277, 278, 279, 280, 281, 169, 92, 278, 279, 280, 281, 280, 281, 182, 276, 277, 172, 280, 281, 180, 156, 92, 257, 258, 281, 260, 261, 262, 263, 144, 265, 266, 123, -1, 269, 270, 271, 272, 273, 274, 275, 147, 257, 258, 148, 260, 261, 262, 263, -1, 265, 266, -1, -1, 269, 270, 271, 272, 273, 274, 275, 32, -1, 32, 94, 95, -1, 257, 258, -1, 260, 261, 262, 263, -1, 265, 266, 58, -1, 269, 270, 271, 272, 273, 274, 275, 157, -1, -1, -1, -1, 5, 63, -1, 63, -1, -1, -1, 169, -1, 14, -1, -1, -1, -1, 135, 136, 137, -1, 180, 24, 25, 93, -1, -1, -1, 258, -1, 32, -1, 262, 92, 264, 92, 266, -1, 258, 269, 270, 110, 262, -1, 113, -1, 266, -1, 50, 269, 270, -1, -1, 122, -1, -1, 58, -1, -1, -1, -1, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, -1, -1, 260, 261, 85, 263, -1, 265, 266, 94, 95, 92, 93, 271, 272, 273, 274, 275, -1, 157, -1, 157, 170, -1, 172, -1, -1, -1, -1, 110, -1, 169, 113, 169, -1, -1, -1, -1, -1, -1, -1, 122, 180, -1, 180, 193, -1, -1, -1, -1, 135, 136, 137, 138, 139, -1, -1, -1, -1, 144, 145, 146, 147, 148, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 156, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 169, 170, -1, 172, -1, -1, -1, -1, -1, -1, -1, 180, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 193, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=285; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,null, "';'","'<'","'='","'>'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"BREAK","DOUBLE","ELSE","FOR","IF", "INT","RETURN","VOID","WHILE","IDENTIFIER","CLASSNAME","CLASS","STRING","BOOL", "INTLIT","DOUBLELIT","STRINGLIT","BOOLLIT","NULLVAL","LESSTHANOREQUAL", "GREATERTHANOREQUAL","ISEQUALTO","NOTEQUALTO","LOGICALAND","LOGICALOR", "INCREMENT","DECREMENT","PUBLIC","STATIC", }; final static String yyrule[] = { "$accept : ClassDecl", "ClassDecl : PUBLIC CLASS IDENTIFIER ClassBody", "ClassBody : '{' ClassBodyDecls '}'", "ClassBody : '{' '}'", "ClassBodyDecls : ClassBodyDecl", "ClassBodyDecls : ClassBodyDecls ClassBodyDecl", "ClassBodyDecl : FieldDecl", "ClassBodyDecl : MethodDecl", "ClassBodyDecl : ConstructorDecl", "FieldDecl : Type VarDecls ';'", "Type : INT", "Type : DOUBLE", "Type : BOOL", "Type : STRING", "Type : Name", "Name : IDENTIFIER", "Name : QualifiedName", "QualifiedName : Name '.' IDENTIFIER", "VarDecls : VarDeclarator", "VarDecls : VarDecls ',' VarDeclarator", "VarDeclarator : IDENTIFIER", "VarDeclarator : VarDeclarator '[' ']'", "MethodReturnVal : Type", "MethodReturnVal : VOID", "MethodDecl : MethodHeader Block", "MethodHeader : PUBLIC STATIC MethodReturnVal MethodDeclarator", "MethodDeclarator : IDENTIFIER '(' FormalParmListOpt ')'", "FormalParmListOpt : FormalParmList", "FormalParmListOpt :", "FormalParmList : FormalParm", "FormalParmList : FormalParmList ',' FormalParm", "FormalParm : Type VarDeclarator", "ConstructorDecl : MethodDeclarator Block", "Block : '{' BlockStmtsOpt '}'", "BlockStmtsOpt : BlockStmts", "BlockStmtsOpt :", "BlockStmts : BlockStmt", "BlockStmts : BlockStmts BlockStmt", "BlockStmt : LocalVarDeclStmt", "BlockStmt : Stmt", "LocalVarDeclStmt : LocalVarDecl ';'", "LocalVarDecl : Type VarDecls", "Stmt : Block", "Stmt : ';'", "Stmt : ExprStmt", "Stmt : BreakStmt", "Stmt : ReturnStmt", "Stmt : IfThenStmt", "Stmt : IfThenElseStmt", "Stmt : IfThenElseIfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "ExprStmt : StmtExpr ';'", "StmtExpr : Assignment", "StmtExpr : MethodCall", "IfThenStmt : IF '(' Expr ')' Block", "IfThenElseStmt : IF '(' Expr ')' Block ELSE Block", "IfThenElseIfStmt : IF '(' Expr ')' Block ElseIfSequence", "IfThenElseIfStmt : IF '(' Expr ')' Block ElseIfSequence ELSE Block", "ElseIfSequence : ElseIfStmt", "ElseIfSequence : ElseIfSequence ElseIfStmt", "ElseIfStmt : ELSE IfThenStmt", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' ForInit ';' ExprOpt ';' ForUpdate ')' Block", "ForInit : StmtExprList", "ForInit : LocalVarDecl", "ForInit :", "ExprOpt : Expr", "ExprOpt :", "ForUpdate : StmtExprList", "ForUpdate :", "StmtExprList : StmtExpr", "StmtExprList : StmtExprList ',' StmtExpr", "BreakStmt : BREAK ';'", "BreakStmt : BREAK IDENTIFIER ';'", "ReturnStmt : RETURN ExprOpt ';'", "Primary : Literal", "Primary : FieldAccess", "Primary : MethodCall", "Primary : '(' Expr ')'", "Literal : INTLIT", "Literal : DOUBLELIT", "Literal : BOOLLIT", "Literal : STRINGLIT", "Literal : NULLVAL", "ArgList : Expr", "ArgList : ArgList ',' Expr", "FieldAccess : Primary '.' IDENTIFIER", "ArgListOpt : ArgList", "ArgListOpt :", "MethodCall : Name '(' ArgListOpt ')'", "MethodCall : Primary '.' IDENTIFIER '(' ArgListOpt ')'", "PostFixExpr : Primary", "PostFixExpr : Name", "UnaryExpr : '-' UnaryExpr", "UnaryExpr : '!' UnaryExpr", "UnaryExpr : PostFixExpr", "MulExpr : UnaryExpr", "MulExpr : MulExpr '*' UnaryExpr", "MulExpr : MulExpr '/' UnaryExpr", "MulExpr : MulExpr '%' UnaryExpr", "AddExpr : MulExpr", "AddExpr : AddExpr '+' MulExpr", "AddExpr : AddExpr '-' MulExpr", "RelOp : LESSTHANOREQUAL", "RelOp : GREATERTHANOREQUAL", "RelOp : '<'", "RelOp : '>'", "RelExpr : AddExpr", "RelExpr : RelExpr RelOp AddExpr", "EqExpr : RelExpr", "EqExpr : EqExpr ISEQUALTO RelExpr", "EqExpr : EqExpr NOTEQUALTO RelExpr", "CondAndExpr : EqExpr", "CondAndExpr : CondAndExpr LOGICALAND EqExpr", "CondOrExpr : CondAndExpr", "CondOrExpr : CondOrExpr LOGICALOR CondAndExpr", "Expr : CondOrExpr", "Expr : Assignment", "Assignment : LeftHandSide AssignOp Expr", "LeftHandSide : Name", "LeftHandSide : FieldAccess", "AssignOp : '='", "AssignOp : INCREMENT", "AssignOp : DECREMENT", }; //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it val_push(yylval); //save empty value while (true) //until parsing is done, either correctly, or w/error { doaction=true; if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### if (yychar < 0) //it it didn't work/error { yychar = 0; //change it to default string (no -1!) if (yydebug) yylexdebug(yystate,yychar); } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { if (yydebug) debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0) //check for under & overflow here { yyerror("stack underflow. aborting..."); //note lower case 's' return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { if (yydebug) debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { if (yydebug) debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0) //check for under & overflow here { yyerror("Stack underflow. aborting..."); //capital 'S' return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort if (yydebug) { yys = null; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (yys == null) yys = "illegal-symbol"; debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); } yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs if (yydebug) debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value yyval = dup_yyval(yyval); //duplicate yyval if ParserVal is used as semantic value switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 8 "j0gram.y" { yyval=j0.node("ClassDecl",1000,val_peek(1),val_peek(0)); j0.print(yyval); } break; case 2: //#line 12 "j0gram.y" { yyval=j0.node("ClassBody",1010,val_peek(1)); } break; case 3: //#line 13 "j0gram.y" { yyval=j0.node("ClassBody",1011); } break; case 5: //#line 15 "j0gram.y" { yyval=j0.node("ClassBodyDecls",1020,val_peek(1),val_peek(0)); } break; case 9: //#line 18 "j0gram.y" { yyval=j0.node("FieldDecl",1030,val_peek(2),val_peek(1)); } break; case 17: //#line 23 "j0gram.y" { yyval=j0.node("QualifiedName",1040,val_peek(2),val_peek(0));} break; case 19: //#line 26 "j0gram.y" { yyval=j0.node("VarDecls",1050,val_peek(2),val_peek(0)); } break; case 21: //#line 28 "j0gram.y" { yyval=j0.node("VarDeclarator",1060,val_peek(2)); } break; case 24: //#line 32 "j0gram.y" { yyval=j0.node("MethodDecl",1380,val_peek(1),val_peek(0)); } break; case 25: //#line 35 "j0gram.y" { yyval=j0.node("MethodHeader",1070,val_peek(1),val_peek(0)); } break; case 26: //#line 37 "j0gram.y" { yyval=j0.node("MethodDeclarator",1080,val_peek(3),val_peek(1)); } break; case 30: //#line 41 "j0gram.y" { yyval=j0.node("FormalParmList",1090,val_peek(2),val_peek(0)); } break; case 31: //#line 43 "j0gram.y" { yyval=j0.node("FormalParm",1100,val_peek(1),val_peek(0)); } break; case 32: //#line 47 "j0gram.y" { yyval=j0.node("ConstructorDecl",1110,val_peek(1),val_peek(0)); } break; case 33: //#line 50 "j0gram.y" {yyval=j0.node("Block",1200,val_peek(1));} break; case 37: //#line 52 "j0gram.y" { yyval=j0.node("BlockStmts",1130,val_peek(1),val_peek(0)); } break; case 41: //#line 57 "j0gram.y" { yyval=j0.node("LocalVarDecl",1140,val_peek(1),val_peek(0)); } break; case 55: //#line 68 "j0gram.y" { yyval=j0.node("IfThenStmt",1150,val_peek(2),val_peek(0)); } break; case 56: //#line 70 "j0gram.y" { yyval=j0.node("IfThenElseStmt",1160,val_peek(4),val_peek(2),val_peek(0)); } break; case 57: //#line 72 "j0gram.y" { yyval=j0.node("IfThenElseIfStmt",1170,val_peek(3),val_peek(1),val_peek(0)); } break; case 58: //#line 74 "j0gram.y" { yyval=j0.node("IfThenElseIfStmt",1171,val_peek(5),val_peek(3),val_peek(2),val_peek(0)); } break; case 60: //#line 77 "j0gram.y" { yyval=j0.node("ElseIfSequence",1180,val_peek(1),val_peek(0)); } break; case 61: //#line 79 "j0gram.y" { yyval=j0.node("ElseIfStmt",1190,val_peek(0)); } break; case 62: //#line 81 "j0gram.y" { yyval=j0.node("WhileStmt",1210,val_peek(2),val_peek(0)); } break; case 63: //#line 84 "j0gram.y" { yyval=j0.node("ForStmt",1220,val_peek(6),val_peek(4),val_peek(2),val_peek(0)); } break; case 72: //#line 90 "j0gram.y" { yyval=j0.node("StmtExprList",1230,val_peek(2),val_peek(0)); } break; case 74: //#line 93 "j0gram.y" { yyval=j0.node("BreakStmt",1240,val_peek(1)); } break; case 75: //#line 95 "j0gram.y" { yyval=j0.node("ReturnStmt",1250,val_peek(1)); } break; case 79: //#line 98 "j0gram.y" { yyval=val_peek(1);} break; case 86: //#line 102 "j0gram.y" { yyval=j0.node("ArgList",1270,val_peek(2),val_peek(0)); } break; case 87: //#line 104 "j0gram.y" { yyval=j0.node("FieldAccess",1280,val_peek(2),val_peek(0)); } break; case 90: //#line 108 "j0gram.y" { yyval=j0.node("MethodCall",1290,val_peek(3),val_peek(1)); } break; case 91: //#line 110 "j0gram.y" { yyval=j0.node("MethodCall",1291,val_peek(5),val_peek(3),val_peek(1)); } break; case 94: //#line 115 "j0gram.y" { yyval=j0.node("UnaryExpr",1300,val_peek(1),val_peek(0)); } break; case 95: //#line 117 "j0gram.y" { yyval=j0.node("UnaryExpr",1301,val_peek(1),val_peek(0)); } break; case 98: //#line 121 "j0gram.y" { yyval=j0.node("MulExpr",1310,val_peek(2),val_peek(0)); } break; case 99: //#line 123 "j0gram.y" { yyval=j0.node("MulExpr",1311,val_peek(2),val_peek(0)); } break; case 100: //#line 125 "j0gram.y" { yyval=j0.node("MulExpr",1312,val_peek(2),val_peek(0)); } break; case 102: //#line 128 "j0gram.y" { yyval=j0.node("AddExpr",1320,val_peek(2),val_peek(0)); } break; case 103: //#line 130 "j0gram.y" { yyval=j0.node("AddExpr",1321,val_peek(2),val_peek(0)); } break; case 109: //#line 133 "j0gram.y" { yyval=j0.node("RelExpr",1330,val_peek(2),val_peek(1),val_peek(0)); } break; case 111: //#line 137 "j0gram.y" { yyval=j0.node("EqExpr",1340,val_peek(2),val_peek(0)); } break; case 112: //#line 139 "j0gram.y" { yyval=j0.node("EqExpr",1341,val_peek(2),val_peek(0)); } break; case 114: //#line 141 "j0gram.y" { yyval=j0.node("CondAndExpr", 1350, val_peek(2), val_peek(0)); } break; case 116: //#line 143 "j0gram.y" { yyval=j0.node("CondOrExpr", 1360, val_peek(2), val_peek(0)); } break; case 119: //#line 147 "j0gram.y" { yyval=j0.node("Assignment",1370, val_peek(2), val_peek(1), val_peek(0)); } break; //#line 900 "parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character if (yychar<0) yychar=0; //clean, if necessary if (yydebug) yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### /** * A default run method, used for operating this parser * object in the background. It is intended for extending Thread * or implementing Runnable. Turn off with -Jnorun . */ public void run() { yyparse(); } //## end of method run() ######################################## //## Constructors ############################################### /** * Default constructor. Turn off with -Jnoconstruct . */ public parser() { //nothing to do } /** * Create a parser, setting the debug to true or false. * @param debugMe true for debugging, false for no debug. */ public parser(boolean debugMe) { yydebug=debugMe; } //############################################################### } //################### END OF CLASS ##############################
PacktPublishing/Build-Your-Own-Programming-Language
ch5/parser.java
746
// Copyright (C) 2000-2013 SuperWaba Ltda. // Copyright (C) 2014-2020 TotalCross Global Mobile Platform Ltda. // // SPDX-License-Identifier: LGPL-2.1-only package samples.sys.testcases; import litebase.*; import totalcross.unit.*; /** * Tests sequences of inserts and deletes */ public class TestCachedRows extends TestCase // Catchs error found in 555_3 { /** * The main method of the test. */ public void testRun() { String[] querysSQL = { "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 38", "INSERT INTO ACT_CLIENTE VALUES (38L, '38', 'ADENILZA xxxxxxxxxxxxxxxxxxxxxE', 'ADENILZA 111111111111111111111E', '11.111.222//4443-22', " + "'', 1, 1, '', 4, '3423423421', '', '', '1', 20051110101123, 20051110101123, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 114L", "INSERT INTO ACT_CLIENTE VALUES (114L, '114', 'NIETO yyyyyyyyyyyyyyyyyyyyE', 'NIETO 2222222222222222222EE', '22.222.333//3333-33', '', 1, " + "1, '', 4, '4342342423', '', '', '1', 20051110101123, 20051110101123, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 161L", "INSERT INTO ACT_CLIENTE VALUES (161L, '161', 'ANTONIO bbbbbbbbbbbbbbbbbbbbbbE', 'ANTONIO 33333333333333333333333', '44.444.444//4441-44', " + "'', 1, 1, '', 4, '5435656458', '', '', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 421L", "INSERT INTO ACT_CLIENTE VALUES (421L, '421', 'CLAUDIOMIR cccccccccccccccccMEE', 'CLAUDIOMIR 444444444444444444EE', '55.555.555//5555-26', " + "'', 1, 1, '', 4, '', '', '', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 443L", "INSERT INTO ACT_CLIENTE VALUES (443L, '443', 'MARIA dddddddddddddddddSO', 'MARIA 55555555555555555SO', '777.777.777-20', '', 1, 1, '', 4, " + "'6756756756', '', '', '2', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 941L", "INSERT INTO ACT_CLIENTE VALUES (941L, '941', 'J.B.eeeeeeeeeeeeeeeeeeeeeeeeeeE', 'J.B.6666666666666666666666666EE', '88.888.888//8889-83', " + "'', 1, 1, '', 4, '8655676565', '', '', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 968L", "INSERT INTO ACT_CLIENTE VALUES (968L, '968', 'JARDELIO fffffffffffffffffffffffE', 'JARDELIO 7777777777777777777777EE'," + " '99.999.999//9999-82', '', 1, 1, '', 4, '7656456547', '', '', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 1217L", "INSERT INTO ACT_CLIENTE VALUES (1217L, '1217', 'N.gggggggggggggggE', 'N.C.8888888888888E', '00.000.000//1111-16', '', 1, 1, '', 4, " + "'4532432439', '', '', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 1450L", "INSERT INTO ACT_CLIENTE VALUES (1450L, '1450', 'OTTO COMhhhhhhhhhhhhhhhhhhhhhhhE', 'OTTO 9999999999999999999999999EE', " + "'22.222.222//2222-17', '', 1, 1, '', 4, '4535345340', '', '', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 1585L", "INSERT INTO ACT_CLIENTE VALUES (1585L, '1585', 'OROSINO iiiiiiiiiiiiiiiiiiiE', 'OROSINO 0000000000000000000E', " + "'33.333.333//3333-33', '', 1, 1, '', 4, '5435345357', '', '30 ', '1', 20051110101124, 20051110101124, 1)", "DELETE ACT_CLIENTE WHERE ACTCLIENTEID = 1664L" }; LitebaseConnection driver = AllTests.getInstance("Test"); int numSQL = querysSQL.length; if (driver.exists("act_cliente")) driver.executeUpdate("drop table act_cliente"); driver.execute("create table act_cliente (actclienteid long, actcodcliente char(30), actrazaosocial char(100), " + "actnomefantasia char(100), actie char(20), actcnpj char(20), actstatus long, acttipocliente long, actmail char(255), " + "actvendedorid long, acttelefone char(18), actobservacao char(255), actfax char(18), actcodtabela char(20), " + "actdatinclusao long, actdatalteracao long, actusuarioid long)"); int i = -1; while (++i < numSQL) assertEquals(i & 1, driver.executeUpdate(querysSQL[i])); // Delete must return 0; insert must return 1. driver.closeAll(); // rnovais@570_77 ResultSet rs = (driver = AllTests.getInstance("Test")) .executeQuery("select actrazaosocial from act_cliente where actrazaosocial='ADENILZA xxxxxxxxxxxxxxxxxxxxxE'"); assertEquals(1, rs.getRowCount()); // Would be 6 without 555_3 fix. rs.close(); assertEquals(10, (rs = driver.executeQuery("select * from act_cliente")).getRowCount()); rs.close(); driver.closeAll(); } }
TotalCross/totalcross
LitebaseSDK/src/java/samples/sys/testcases/TestCachedRows.java
747
package com.sixtyfour.basicshell; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.MouseEvent; import javax.swing.JComponent; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultCaret; import javax.swing.text.JTextComponent; /** * Code based on Groovy text editor ... * groovy-console/src/main/groovy/groovy/ui/text/TextEditor.java * * @author nietoperz809 */ public class BlockCaret extends DefaultCaret { private static final long serialVersionUID = 1L; public BlockCaret() { setBlinkRate(500); } protected synchronized void damage(Rectangle r) { if (r != null) { JTextComponent component = getComponent(); x = r.x; y = r.y; Font font = component.getFont(); width = component.getFontMetrics(font).charWidth('w'); height = r.height; repaint(); } } public void mouseClicked(MouseEvent e) { JComponent c = (JComponent) e.getComponent(); c.repaint(); } public void paint(Graphics g) { if (isVisible()) { try { JTextComponent component = getComponent(); @SuppressWarnings("deprecation") Rectangle r = component.getUI().modelToView(component, getDot()); Color c = g.getColor(); g.setColor(component.getBackground()); g.setXORMode(component.getCaretColor()); r.setBounds(r.x, r.y, g.getFontMetrics().charWidth('w'), g.getFontMetrics().getHeight()); g.fillRect(r.x, r.y, r.width, r.height); g.setPaintMode(); g.setColor(c); } catch (BadLocationException e) { e.printStackTrace(); } } } }
EgonOlsen71/basicv2
src/main/java/com/sixtyfour/basicshell/BlockCaret.java
748
/** * Copyright (c) 2003-2021 The Apereo Foundation * * Licensed under the Educational Community License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://opensource.org/licenses/ecl2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.sakaiproject.entitybroker.providers.model; import java.util.Properties; import java.util.Set; import org.azeckoski.reflectutils.annotations.ReflectIgnoreClassFields; import org.sakaiproject.entitybroker.entityprovider.annotations.EntityId; import org.sakaiproject.tool.api.Tool; /** * EntityTool * * This entity represents a sakai Tool configuration * * @author Earle Nietzel * Created on Sep 5, 2013 * */ @ReflectIgnoreClassFields({"accessSecurity"}) public class EntityTool implements Tool, Comparable<Tool> { private static final String ACCESS_SECURITY_PORTAL = "portal"; private static final String ACCESS_SECURITY_TOOL = "tool"; private transient Tool tool; @EntityId private String id; private String home; private String title; private String description; private Properties registeredConfig; private Properties mutableConfig; private Properties finalConfig; private Set<String> keywords; private Set<String> categories; private String access; public EntityTool(Tool tool) { if (tool != null) { this.tool = tool; this.id = tool.getId(); this.home = tool.getHome(); this.title = tool.getTitle(); this.description = tool.getDescription(); this.registeredConfig = tool.getRegisteredConfig(); this.mutableConfig = tool.getMutableConfig(); this.finalConfig = tool.getFinalConfig(); this.keywords = tool.getKeywords(); this.categories = tool.getCategories(); this.access = getAccessSecurity() == Tool.AccessSecurity.PORTAL ? ACCESS_SECURITY_PORTAL : ACCESS_SECURITY_TOOL; } else { throw new UnsupportedOperationException(); } } public EntityTool() { } @Override @EntityId public String getId() { return this.id; } @Override public String getHome() { return this.home; } @Override public String getTitle() { return this.title; } @Override public String getDescription() { return this.description; } @Override public Properties getRegisteredConfig() { return this.registeredConfig; } @Override public Properties getMutableConfig() { return this.mutableConfig; } @Override public Properties getFinalConfig() { return this.finalConfig; } @Override public Set<String> getKeywords() { return this.keywords; } @Override public Set<String> getCategories() { return this.categories; } @Override public AccessSecurity getAccessSecurity() { if (tool != null) { return tool.getAccessSecurity(); } throw new UnsupportedOperationException(); } public String getAccess() { return access; } @Override public int compareTo(Tool tool) { return getId().compareTo(tool.getId()); } }
sakaiproject/sakai
entitybroker/core-providers/src/java/org/sakaiproject/entitybroker/providers/model/EntityTool.java
749
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 11 "Parser.y" package decaf.frontend; import decaf.tree.Tree; import decaf.tree.Tree.*; import decaf.error.*; import java.util.*; //#line 25 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short VOID=257; public final static short BOOL=258; public final static short INT=259; public final static short STRING=260; public final static short CLASS=261; public final static short NULL=262; public final static short EXTENDS=263; public final static short THIS=264; public final static short WHILE=265; public final static short FOR=266; public final static short IF=267; public final static short ELSE=268; public final static short RETURN=269; public final static short BREAK=270; public final static short NEW=271; public final static short PRINT=272; public final static short READ_INTEGER=273; public final static short READ_LINE=274; public final static short LITERAL=275; public final static short IDENTIFIER=276; public final static short AND=277; public final static short OR=278; public final static short STATIC=279; public final static short INSTANCEOF=280; public final static short LESS_EQUAL=281; public final static short GREATER_EQUAL=282; public final static short EQUAL=283; public final static short NOT_EQUAL=284; public final static short MIN_CP=285; public final static short SWITCH=286; public final static short CASE=287; public final static short DEFAULT=288; public final static short REPEAT=289; public final static short UNTIL=290; public final static short CONTINUE=291; public final static short PCLONE=292; public final static short UMINUS=293; public final static short EMPTY=294; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 4, 5, 5, 5, 5, 5, 5, 2, 6, 6, 7, 7, 7, 9, 9, 10, 10, 8, 8, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 27, 27, 24, 24, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 29, 29, 28, 28, 30, 30, 16, 17, 22, 23, 15, 18, 32, 32, 34, 33, 33, 19, 31, 31, 20, 20, 21, }; final static short yylen[] = { 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 6, 2, 0, 2, 2, 0, 1, 0, 3, 1, 7, 6, 3, 2, 0, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 3, 1, 0, 2, 0, 2, 4, 5, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 4, 5, 6, 5, 5, 3, 1, 1, 1, 0, 3, 1, 5, 9, 1, 1, 6, 8, 2, 0, 4, 3, 0, 6, 2, 0, 2, 1, 4, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 2, 0, 0, 13, 17, 0, 7, 8, 6, 9, 0, 0, 12, 15, 0, 0, 16, 10, 0, 4, 0, 0, 0, 0, 11, 0, 21, 0, 0, 0, 0, 5, 0, 0, 0, 26, 23, 20, 22, 0, 76, 68, 0, 0, 0, 0, 83, 0, 0, 0, 0, 75, 0, 0, 26, 84, 0, 0, 0, 24, 27, 38, 25, 0, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 33, 34, 35, 36, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 67, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 97, 0, 0, 0, 0, 45, 0, 0, 0, 81, 0, 0, 70, 0, 0, 88, 0, 72, 0, 46, 0, 0, 85, 71, 0, 92, 0, 93, 0, 0, 0, 87, 0, 0, 26, 86, 82, 26, 0, 0, }; final static short yydgoto[] = { 2, 3, 4, 66, 20, 33, 8, 11, 22, 34, 35, 67, 45, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 87, 80, 89, 82, 172, 83, 133, 187, 189, 195, 196, }; final static short yysindex[] = { -228, -224, 0, -228, 0, -219, 0, -214, -66, 0, 0, -91, 0, 0, 0, 0, -209, -120, 0, 0, 12, -85, 0, 0, -83, 0, 41, -10, 46, -120, 0, -120, 0, -80, 47, 45, 50, 0, -28, -120, -28, 0, 0, 0, 0, 2, 0, 0, 53, 57, 58, 871, 0, -46, 59, 60, 63, 0, 64, 67, 0, 0, 871, 871, 810, 0, 0, 0, 0, 52, 0, 0, 0, 0, 55, 62, 76, 83, 84, 48, 740, 0, -154, 0, 871, 871, 871, 0, 740, 0, 86, 32, 871, 103, 111, 871, 871, 37, -30, -30, -123, 477, 0, 0, 0, 0, 0, 0, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 0, 871, 871, 871, 122, 489, 95, 513, 124, 1022, 740, -3, 0, 0, 540, 552, 123, 130, 0, 740, 998, 948, 73, 73, 1049, 1049, -22, -22, -30, -30, -30, 73, 73, 564, 576, 3, 871, 72, 871, 72, 0, 650, 871, 0, -95, 69, 871, 871, 0, 871, 134, 138, 0, 674, -78, 0, 740, 157, 0, 824, 0, 740, 0, 871, 72, 0, 0, -208, 0, 158, 0, -232, 145, 81, 0, 72, 150, 0, 0, 0, 0, 72, 72, }; final static short yyrindex[] = { 0, 0, 0, 209, 0, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 176, 0, 176, 0, 0, 0, 177, 0, 0, 0, 0, 0, 0, 0, 0, 0, -56, 0, 0, 0, 0, 0, -54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, -55, -55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 846, 0, 447, 0, 0, -55, -56, -55, 0, 164, 0, 0, 0, -55, 0, 0, -55, -55, -56, 114, 142, 0, 0, 0, 0, 0, 0, 0, 0, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, 0, -55, -55, -55, 87, 0, 0, 0, 0, -55, 10, 0, 0, 0, 0, 0, 0, 0, 0, -20, -27, 975, 705, 918, 43, 625, 881, 905, 370, 394, 423, 943, 968, 0, 0, -40, -32, -56, -55, -56, 0, 0, -55, 0, 0, 0, -55, -55, 0, -55, 0, 205, 0, 0, -33, 0, 31, 0, 0, 0, 0, 15, 0, -31, -56, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, -56, 0, 0, 0, 0, 0, -57, 224, }; final static short yygindex[] = { 0, 0, 245, 238, -2, 11, 0, 0, 0, 239, 0, 38, -5, -101, -72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1052, 1241, 1115, 0, 0, 96, 121, 0, 0, 0, 0, }; final static int YYTABLESIZE=1412; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 94, 74, 41, 41, 74, 96, 27, 94, 27, 78, 41, 27, 94, 128, 61, 119, 122, 61, 74, 74, 117, 39, 21, 74, 122, 118, 94, 32, 24, 32, 46, 61, 61, 1, 18, 63, 61, 43, 165, 39, 119, 164, 64, 57, 7, 117, 115, 62, 116, 122, 118, 80, 5, 74, 80, 97, 73, 10, 174, 73, 176, 123, 9, 121, 91, 120, 61, 23, 90, 123, 63, 25, 79, 73, 73, 79, 42, 64, 44, 193, 194, 29, 62, 30, 55, 192, 31, 55, 38, 39, 94, 40, 94, 84, 123, 41, 201, 85, 86, 92, 93, 55, 55, 94, 95, 63, 55, 96, 73, 108, 119, 102, 64, 191, 103, 117, 115, 62, 116, 122, 118, 104, 126, 131, 44, 41, 130, 65, 44, 44, 44, 44, 44, 44, 44, 105, 55, 12, 13, 14, 15, 16, 106, 107, 134, 44, 44, 44, 44, 44, 44, 64, 135, 139, 160, 64, 64, 64, 64, 64, 41, 64, 158, 168, 123, 162, 12, 13, 14, 15, 16, 169, 64, 64, 64, 184, 64, 64, 44, 65, 44, 179, 164, 65, 65, 65, 65, 65, 17, 65, 186, 26, 180, 28, 203, 41, 37, 204, 188, 197, 65, 65, 65, 199, 65, 65, 200, 64, 202, 1, 5, 12, 13, 14, 15, 16, 14, 19, 18, 43, 43, 43, 43, 95, 94, 94, 94, 94, 94, 94, 90, 94, 94, 94, 94, 65, 94, 94, 94, 94, 94, 94, 94, 94, 43, 43, 77, 94, 6, 19, 61, 61, 74, 94, 94, 94, 94, 94, 94, 12, 13, 14, 15, 16, 46, 61, 47, 48, 49, 50, 36, 51, 52, 53, 54, 55, 56, 57, 91, 173, 109, 110, 58, 41, 111, 112, 113, 114, 59, 198, 0, 60, 0, 61, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 0, 0, 55, 55, 0, 59, 0, 0, 60, 138, 61, 12, 13, 14, 15, 16, 46, 55, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 89, 0, 0, 58, 0, 0, 0, 0, 0, 59, 0, 0, 60, 0, 61, 44, 44, 0, 0, 44, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 0, 0, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 64, 52, 0, 0, 0, 52, 52, 52, 52, 52, 0, 52, 0, 65, 65, 0, 0, 65, 65, 65, 65, 0, 52, 52, 52, 53, 52, 52, 65, 53, 53, 53, 53, 53, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 53, 53, 0, 53, 53, 0, 0, 54, 0, 0, 52, 54, 54, 54, 54, 54, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, 48, 54, 54, 53, 40, 48, 48, 0, 48, 48, 48, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 40, 48, 0, 48, 48, 89, 89, 0, 119, 0, 54, 0, 140, 117, 115, 0, 116, 122, 118, 0, 119, 0, 0, 0, 159, 117, 115, 0, 116, 122, 118, 121, 48, 120, 124, 0, 0, 0, 0, 0, 0, 0, 0, 121, 119, 120, 124, 0, 161, 117, 115, 0, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 121, 0, 120, 124, 119, 0, 0, 123, 0, 117, 115, 166, 116, 122, 118, 0, 119, 0, 0, 0, 167, 117, 115, 0, 116, 122, 118, 121, 119, 120, 124, 123, 0, 117, 115, 0, 116, 122, 118, 121, 119, 120, 124, 0, 0, 117, 115, 0, 116, 122, 118, 121, 0, 120, 124, 0, 0, 0, 123, 0, 0, 171, 0, 121, 0, 120, 124, 0, 0, 0, 123, 0, 0, 0, 52, 52, 0, 0, 52, 52, 52, 52, 123, 0, 170, 0, 0, 0, 0, 52, 0, 0, 0, 56, 123, 0, 56, 0, 53, 53, 0, 0, 53, 53, 53, 53, 0, 0, 0, 0, 56, 56, 0, 53, 119, 56, 0, 0, 0, 117, 115, 0, 116, 122, 118, 0, 0, 54, 54, 0, 0, 54, 54, 54, 54, 0, 0, 121, 119, 120, 124, 0, 54, 117, 115, 56, 116, 122, 118, 0, 0, 48, 48, 0, 0, 48, 48, 48, 48, 0, 185, 121, 0, 120, 124, 0, 48, 0, 123, 0, 177, 0, 0, 59, 0, 0, 59, 0, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 0, 59, 59, 123, 109, 110, 59, 125, 111, 112, 113, 114, 0, 0, 0, 119, 0, 0, 0, 125, 117, 115, 0, 116, 122, 118, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 59, 0, 121, 0, 120, 124, 0, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 0, 0, 0, 0, 109, 110, 123, 125, 111, 112, 113, 114, 0, 0, 0, 0, 109, 110, 63, 125, 111, 112, 113, 114, 0, 64, 0, 0, 109, 110, 62, 125, 111, 112, 113, 114, 119, 0, 0, 0, 190, 117, 115, 125, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 121, 0, 120, 124, 47, 47, 0, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 56, 56, 63, 0, 47, 0, 47, 47, 0, 64, 0, 0, 0, 123, 62, 56, 0, 0, 0, 0, 50, 0, 50, 50, 50, 109, 110, 0, 0, 111, 112, 113, 114, 0, 0, 47, 0, 50, 50, 50, 125, 50, 50, 0, 51, 0, 51, 51, 51, 109, 110, 0, 0, 111, 112, 113, 114, 60, 0, 0, 60, 51, 51, 51, 125, 51, 51, 0, 0, 0, 0, 0, 50, 0, 60, 60, 0, 0, 0, 60, 59, 59, 58, 119, 0, 58, 59, 59, 117, 115, 0, 116, 122, 118, 0, 59, 51, 0, 0, 58, 58, 0, 0, 0, 58, 0, 121, 57, 120, 60, 57, 0, 0, 0, 62, 109, 110, 62, 0, 111, 112, 113, 114, 0, 57, 57, 0, 0, 0, 57, 125, 62, 62, 119, 58, 0, 62, 123, 117, 115, 0, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 121, 0, 120, 57, 64, 0, 0, 0, 0, 62, 62, 0, 0, 100, 46, 0, 47, 0, 0, 0, 0, 0, 0, 53, 0, 55, 56, 57, 119, 0, 0, 123, 58, 117, 115, 0, 116, 122, 118, 79, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 121, 0, 120, 0, 0, 0, 30, 125, 0, 0, 0, 0, 0, 0, 47, 47, 0, 0, 47, 47, 47, 47, 0, 0, 46, 0, 47, 0, 79, 47, 0, 123, 0, 53, 0, 55, 56, 57, 0, 0, 79, 0, 58, 0, 0, 0, 0, 0, 0, 50, 50, 81, 0, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 51, 51, 0, 0, 51, 51, 51, 51, 0, 0, 0, 0, 0, 60, 60, 51, 0, 0, 81, 60, 60, 0, 0, 0, 0, 0, 0, 0, 60, 79, 81, 79, 0, 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, 109, 58, 58, 0, 111, 112, 113, 114, 0, 0, 58, 0, 79, 79, 0, 0, 0, 0, 0, 0, 57, 57, 0, 0, 79, 0, 57, 57, 62, 0, 79, 79, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 81, 0, 81, 0, 0, 111, 112, 113, 114, 0, 46, 0, 47, 0, 0, 0, 0, 0, 88, 53, 0, 55, 56, 57, 0, 0, 81, 81, 58, 98, 99, 101, 0, 0, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 81, 81, 0, 0, 0, 0, 0, 127, 0, 129, 0, 0, 111, 112, 0, 132, 0, 0, 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 0, 155, 156, 157, 0, 0, 0, 0, 0, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 0, 175, 0, 0, 0, 178, 0, 0, 0, 181, 182, 0, 183, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 41, 59, 59, 44, 59, 91, 40, 91, 41, 41, 91, 45, 85, 41, 37, 46, 44, 58, 59, 42, 41, 11, 63, 46, 47, 59, 29, 17, 31, 262, 58, 59, 261, 125, 33, 63, 39, 41, 59, 37, 44, 40, 275, 263, 42, 43, 45, 45, 46, 47, 41, 276, 93, 44, 60, 41, 123, 159, 44, 161, 91, 276, 60, 53, 62, 93, 276, 125, 91, 33, 59, 41, 58, 59, 44, 38, 40, 40, 287, 288, 40, 45, 93, 41, 186, 40, 44, 41, 44, 123, 41, 125, 40, 91, 123, 197, 40, 40, 40, 40, 58, 59, 40, 40, 33, 63, 40, 93, 61, 37, 59, 40, 185, 59, 42, 43, 45, 45, 46, 47, 59, 276, 91, 37, 123, 40, 125, 41, 42, 43, 44, 45, 46, 47, 59, 93, 257, 258, 259, 260, 261, 59, 59, 41, 58, 59, 60, 61, 62, 63, 37, 41, 276, 59, 41, 42, 43, 44, 45, 123, 47, 40, 40, 91, 41, 257, 258, 259, 260, 261, 41, 58, 59, 60, 41, 62, 63, 91, 37, 93, 276, 44, 41, 42, 43, 44, 45, 279, 47, 268, 276, 123, 276, 199, 123, 276, 202, 41, 41, 58, 59, 60, 58, 62, 63, 125, 93, 58, 0, 59, 257, 258, 259, 260, 261, 123, 41, 41, 276, 276, 276, 276, 59, 257, 258, 259, 260, 261, 262, 276, 264, 265, 266, 267, 93, 269, 270, 271, 272, 273, 274, 275, 276, 276, 276, 41, 280, 3, 11, 277, 278, 292, 286, 287, 288, 289, 290, 291, 257, 258, 259, 260, 261, 262, 292, 264, 265, 266, 267, 31, 269, 270, 271, 272, 273, 274, 275, 125, 158, 277, 278, 280, 59, 281, 282, 283, 284, 286, 193, -1, 289, -1, 291, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, -1, -1, 277, 278, -1, 286, -1, -1, 289, 290, 291, 257, 258, 259, 260, 261, 262, 292, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, 125, -1, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, 291, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 58, 59, 60, 37, 62, 63, 292, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 37, -1, -1, 93, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, 37, 62, 63, 93, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, 276, -1, -1, -1, -1, -1, 59, 60, -1, 62, 63, 287, 288, -1, 37, -1, 93, -1, 41, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 60, 91, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, 63, 37, -1, -1, 91, -1, 42, 43, 44, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, 91, -1, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, 58, -1, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 91, -1, 93, -1, -1, -1, -1, 292, -1, -1, -1, 41, 91, -1, 44, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, 58, 59, -1, 292, 37, 63, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 60, 37, 62, 63, -1, 292, 42, 43, 93, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 59, 60, -1, 62, 63, -1, 292, -1, 91, -1, 93, -1, -1, 41, -1, -1, 44, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 58, 59, 91, 277, 278, 63, 292, 281, 282, 283, 284, -1, -1, -1, 37, -1, -1, -1, 292, 42, 43, -1, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 93, -1, 60, -1, 62, 63, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, 277, 278, 91, 292, 281, 282, 283, 284, -1, -1, -1, -1, 277, 278, 33, 292, 281, 282, 283, 284, -1, 40, -1, -1, 277, 278, 45, 292, 281, 282, 283, 284, 37, -1, -1, -1, 41, 42, 43, 292, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, 60, -1, 62, 63, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, 33, -1, 60, -1, 62, 63, -1, 40, -1, -1, -1, 91, 45, 292, -1, -1, -1, -1, 41, -1, 43, 44, 45, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 91, -1, 58, 59, 60, 292, 62, 63, -1, 41, -1, 43, 44, 45, 277, 278, -1, -1, 281, 282, 283, 284, 41, -1, -1, 44, 58, 59, 60, 292, 62, 63, -1, -1, -1, -1, -1, 93, -1, 58, 59, -1, -1, -1, 63, 277, 278, 41, 37, -1, 44, 283, 284, 42, 43, -1, 45, 46, 47, -1, 292, 93, -1, -1, 58, 59, -1, -1, -1, 63, -1, 60, 41, 62, 93, 44, -1, -1, -1, 41, 277, 278, 44, -1, 281, 282, 283, 284, -1, 58, 59, -1, -1, -1, 63, 292, 58, 59, 37, 93, -1, 63, 91, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, 60, -1, 62, 93, 40, -1, -1, -1, -1, 45, 93, -1, -1, 261, 262, -1, 264, -1, -1, -1, -1, -1, -1, 271, -1, 273, 274, 275, 37, -1, -1, 91, 280, 42, 43, -1, 45, 46, 47, 45, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 60, -1, 62, -1, -1, -1, 93, 292, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 262, -1, 264, -1, 85, 292, -1, 91, -1, 271, -1, 273, 274, 275, -1, -1, 97, -1, 280, -1, -1, -1, -1, -1, -1, 277, 278, 45, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, 277, 278, 292, -1, -1, 85, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, 159, 97, 161, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 277, 283, 284, -1, 281, 282, 283, 284, -1, -1, 292, -1, 185, 186, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 197, -1, 283, 284, 278, -1, 203, 204, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, 159, -1, 161, -1, -1, 281, 282, 283, 284, -1, 262, -1, 264, -1, -1, -1, -1, -1, 51, 271, -1, 273, 274, 275, -1, -1, 185, 186, 280, 62, 63, 64, -1, -1, -1, -1, -1, -1, 197, -1, -1, -1, -1, -1, 203, 204, -1, -1, -1, -1, -1, 84, -1, 86, -1, -1, 281, 282, -1, 92, -1, -1, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, -1, 123, 124, 125, -1, -1, -1, -1, -1, 131, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 158, -1, 160, -1, -1, -1, 164, -1, -1, -1, 168, 169, -1, 171, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=294; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'","'?'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING", "CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK", "NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR", "STATIC","INSTANCEOF","LESS_EQUAL","GREATER_EQUAL","EQUAL","NOT_EQUAL","MIN_CP", "SWITCH","CASE","DEFAULT","REPEAT","UNTIL","CONTINUE","PCLONE","UMINUS","EMPTY", }; final static String yyrule[] = { "$accept : Program", "Program : ClassList", "ClassList : ClassList ClassDef", "ClassList : ClassDef", "VariableDef : Variable ';'", "Variable : Type IDENTIFIER", "Type : INT", "Type : VOID", "Type : BOOL", "Type : STRING", "Type : CLASS IDENTIFIER", "Type : Type '[' ']'", "ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'", "ExtendsClause : EXTENDS IDENTIFIER", "ExtendsClause :", "FieldList : FieldList VariableDef", "FieldList : FieldList FunctionDef", "FieldList :", "Formals : VariableList", "Formals :", "VariableList : VariableList ',' Variable", "VariableList : Variable", "FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock", "FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock", "StmtBlock : '{' StmtList '}'", "StmtList : StmtList Stmt", "StmtList :", "Stmt : VariableDef", "Stmt : SimpleStmt ';'", "Stmt : IfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "Stmt : SwitchStmt", "Stmt : RepeatStmt ';'", "Stmt : ReturnStmt ';'", "Stmt : PrintStmt ';'", "Stmt : BreakStmt ';'", "Stmt : ContinueStmt ';'", "Stmt : StmtBlock", "SimpleStmt : LValue '=' Expr", "SimpleStmt : Call", "SimpleStmt :", "Receiver : Expr '.'", "Receiver :", "LValue : Receiver IDENTIFIER", "LValue : Expr '[' Expr ']'", "Call : Receiver IDENTIFIER '(' Actuals ')'", "Expr : LValue", "Expr : Call", "Expr : Constant", "Expr : Expr '+' Expr", "Expr : Expr '-' Expr", "Expr : Expr '*' Expr", "Expr : Expr '/' Expr", "Expr : Expr '%' Expr", "Expr : Expr EQUAL Expr", "Expr : Expr NOT_EQUAL Expr", "Expr : Expr '<' Expr", "Expr : Expr '>' Expr", "Expr : Expr LESS_EQUAL Expr", "Expr : Expr GREATER_EQUAL Expr", "Expr : Expr AND Expr", "Expr : Expr OR Expr", "Expr : '(' Expr ')'", "Expr : '-' Expr", "Expr : '!' Expr", "Expr : READ_INTEGER '(' ')'", "Expr : READ_LINE '(' ')'", "Expr : THIS", "Expr : NEW IDENTIFIER '(' ')'", "Expr : NEW Type '[' Expr ']'", "Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'", "Expr : '(' CLASS IDENTIFIER ')' Expr", "Expr : Expr '?' Expr ':' Expr", "Expr : Expr PCLONE Expr", "Constant : LITERAL", "Constant : NULL", "Actuals : ExprList", "Actuals :", "ExprList : ExprList ',' Expr", "ExprList : Expr", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt", "BreakStmt : BREAK", "ContinueStmt : CONTINUE", "IfStmt : IF '(' Expr ')' Stmt ElseClause", "SwitchStmt : SWITCH '(' Expr ')' '{' CaseStmtList DefaultStmt '}'", "CaseStmtList : CaseStmtList CaseStmt", "CaseStmtList :", "CaseStmt : CASE Constant ':' StmtList", "DefaultStmt : DEFAULT ':' StmtList", "DefaultStmt :", "RepeatStmt : REPEAT StmtList UNTIL '(' Expr ')'", "ElseClause : ELSE Stmt", "ElseClause :", "ReturnStmt : RETURN Expr", "ReturnStmt : RETURN", "PrintStmt : PRINT '(' ExprList ')'", }; //#line 486 "Parser.y" /** * 打印当前归约所用的语法规则<br> * 请勿修改。 */ public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 694 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 59 "Parser.y" { tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc); } break; case 2: //#line 65 "Parser.y" { yyval.clist.add(val_peek(0).cdef); } break; case 3: //#line 69 "Parser.y" { yyval.clist = new ArrayList<Tree.ClassDef>(); yyval.clist.add(val_peek(0).cdef); } break; case 5: //#line 79 "Parser.y" { yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc); } break; case 6: //#line 85 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc); } break; case 7: //#line 89 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc); } break; case 8: //#line 93 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc); } break; case 9: //#line 97 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc); } break; case 10: //#line 101 "Parser.y" { yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc); } break; case 11: //#line 105 "Parser.y" { yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc); } break; case 12: //#line 111 "Parser.y" { yyval.cdef = new Tree.ClassDef(val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc); } break; case 13: //#line 117 "Parser.y" { yyval.ident = val_peek(0).ident; } break; case 14: //#line 121 "Parser.y" { yyval = new SemValue(); } break; case 15: //#line 127 "Parser.y" { yyval.flist.add(val_peek(0).vdef); } break; case 16: //#line 131 "Parser.y" { yyval.flist.add(val_peek(0).fdef); } break; case 17: //#line 135 "Parser.y" { yyval = new SemValue(); yyval.flist = new ArrayList<Tree>(); } break; case 19: //#line 143 "Parser.y" { yyval = new SemValue(); yyval.vlist = new ArrayList<Tree.VarDef>(); } break; case 20: //#line 150 "Parser.y" { yyval.vlist.add(val_peek(0).vdef); } break; case 21: //#line 154 "Parser.y" { yyval.vlist = new ArrayList<Tree.VarDef>(); yyval.vlist.add(val_peek(0).vdef); } break; case 22: //#line 161 "Parser.y" { yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 23: //#line 165 "Parser.y" { yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 24: //#line 171 "Parser.y" { yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc); } break; case 25: //#line 177 "Parser.y" { yyval.slist.add(val_peek(0).stmt); } break; case 26: //#line 181 "Parser.y" { yyval = new SemValue(); yyval.slist = new ArrayList<Tree>(); } break; case 27: //#line 188 "Parser.y" { yyval.stmt = val_peek(0).vdef; } break; case 28: //#line 193 "Parser.y" { if (yyval.stmt == null) { yyval.stmt = new Tree.Skip(val_peek(0).loc); } } break; case 39: //#line 211 "Parser.y" { yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc); } break; case 40: //#line 215 "Parser.y" { yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc); } break; case 41: //#line 219 "Parser.y" { yyval = new SemValue(); } break; case 43: //#line 226 "Parser.y" { yyval = new SemValue(); } break; case 44: //#line 232 "Parser.y" { yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc); if (val_peek(1).loc == null) { yyval.loc = val_peek(0).loc; } } break; case 45: //#line 239 "Parser.y" { yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc); } break; case 46: //#line 245 "Parser.y" { yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc); if (val_peek(4).loc == null) { yyval.loc = val_peek(3).loc; } } break; case 47: //#line 254 "Parser.y" { yyval.expr = val_peek(0).lvalue; } break; case 50: //#line 260 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 51: //#line 264 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 52: //#line 268 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 53: //#line 272 "Parser.y" { yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 54: //#line 276 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 55: //#line 280 "Parser.y" { yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 56: //#line 284 "Parser.y" { yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 57: //#line 288 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 58: //#line 292 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 59: //#line 296 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 60: //#line 300 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 61: //#line 304 "Parser.y" { yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 62: //#line 308 "Parser.y" { yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 63: //#line 312 "Parser.y" { yyval = val_peek(1); } break; case 64: //#line 316 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc); } break; case 65: //#line 320 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc); } break; case 66: //#line 324 "Parser.y" { yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc); } break; case 67: //#line 328 "Parser.y" { yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc); } break; case 68: //#line 332 "Parser.y" { yyval.expr = new Tree.ThisExpr(val_peek(0).loc); } break; case 69: //#line 336 "Parser.y" { yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc); } break; case 70: //#line 340 "Parser.y" { yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc); } break; case 71: //#line 344 "Parser.y" { yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc); } break; case 72: //#line 348 "Parser.y" { yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc); } break; case 73: //#line 352 "Parser.y" { yyval.expr = new Tree.Ternary(Tree.CONDEXPR, val_peek(4).expr, val_peek(2).expr, val_peek(0).expr, val_peek(3).loc); } break; case 74: //#line 356 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PCLONE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 75: //#line 362 "Parser.y" { yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc); } break; case 76: //#line 366 "Parser.y" { yyval.expr = new Null(val_peek(0).loc); } break; case 78: //#line 373 "Parser.y" { yyval = new SemValue(); yyval.elist = new ArrayList<Tree.Expr>(); } break; case 79: //#line 380 "Parser.y" { yyval.elist.add(val_peek(0).expr); } break; case 80: //#line 384 "Parser.y" { yyval.elist = new ArrayList<Tree.Expr>(); yyval.elist.add(val_peek(0).expr); } break; case 81: //#line 391 "Parser.y" { yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc); } break; case 82: //#line 397 "Parser.y" { yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc); } break; case 83: //#line 403 "Parser.y" { yyval.stmt = new Tree.Break(val_peek(0).loc); } break; case 84: //#line 409 "Parser.y" { yyval.stmt = new Tree.Continue(val_peek(0).loc); } break; case 85: //#line 415 "Parser.y" { yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc); } break; case 86: //#line 421 "Parser.y" { yyval.stmt = new Tree.Switch(val_peek(5).expr, val_peek(2).caselist, val_peek(1).slist, val_peek(7).loc); } break; case 87: //#line 427 "Parser.y" { yyval.caselist.add(val_peek(0).casedef); } break; case 88: //#line 431 "Parser.y" { yyval = new SemValue(); yyval.caselist = new ArrayList<Case>(); } break; case 89: //#line 438 "Parser.y" { yyval.casedef = new Tree.Case(val_peek(2).expr, val_peek(0).slist, val_peek(3).loc); } break; case 90: //#line 444 "Parser.y" { yyval.slist = val_peek(0).slist; } break; case 91: //#line 448 "Parser.y" { yyval = new SemValue(); } break; case 92: //#line 454 "Parser.y" { yyval.stmt = new Tree.Repeat(val_peek(1).expr, new Tree.Block(val_peek(4).slist, val_peek(5).loc), val_peek(5).loc); } break; case 93: //#line 460 "Parser.y" { yyval.stmt = val_peek(0).stmt; } break; case 94: //#line 464 "Parser.y" { yyval = new SemValue(); } break; case 95: //#line 470 "Parser.y" { yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc); } break; case 96: //#line 474 "Parser.y" { yyval.stmt = new Tree.Return(null, val_peek(0).loc); } break; case 97: //#line 480 "Parser.y" { yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc); } break; //#line 1342 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
PKUanonym/REKCARC-TSC-UHT
大三上/编译原理/hw/2016_黄家晖_PA/20603895_3_decaf_PA2/src/decaf/frontend/Parser.java
750
package com.sixtyfour.basicshell; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; /** * Helper class to load resources * * @author nietoperz809 */ public class ResourceLoader { private final static String ICON = "commodore.png"; private final static String FONT = "C64_Pro_Mono-STYLE.ttf"; private static InputStream resourceAsStream(String name) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); return loader.getResourceAsStream(name); } public static Font getFont() { Font nt = null; try { nt = Font.createFont(Font.TRUETYPE_FONT, resourceAsStream(FONT)); return nt.deriveFont(16f); } catch (Exception e) { e.printStackTrace(); return null; } } public static BufferedImage getIcon() { try { return ImageIO.read(resourceAsStream(ICON)); } catch (IOException e) { e.printStackTrace(); return null; } } }
EgonOlsen71/basicv2
src/main/java/com/sixtyfour/basicshell/ResourceLoader.java
751
package com.rong360.main; import com.coreos.jetcd.data.KeyValue; import com.github.shyiko.mysql.binlog.BinaryLogClient; import com.github.shyiko.mysql.binlog.TraceEventListener; import com.github.shyiko.mysql.binlog.TraceLifecycleListener; import com.mysql.jdbc.StringUtils; import com.rong360.binlogutil.GlobalConfig; import com.rong360.binlogutil.RongUtil; import com.rong360.etcd.EtcdApi; import com.rong360.etcd.EtcdClient; import com.rong360.etcd.GuardEtcd; import com.rong360.etcd.WatchEtcd; import com.rong360.model.QueueData; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.LoggerContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.management.ManagementFactory; import java.net.InetAddress; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** * @author [email protected] */ public class CdcClient { private final static Logger logger = LoggerFactory.getLogger(CdcClient.class); private static BinaryLogClient client; public static String instance = ""; public static String cluster = "master"; public static String pid; public static String ip; public static Long registerLeaseId; public static String logBaseHome = ""; public static String uniEtcdKeyPrefix = "cdc"; public static boolean watchAllTable = false; private static final List<MessageListener> messageListeners = new LinkedList<>(); public void setInstance(String instance) { CdcClient.instance = instance; } public void setCluster(String cluster) { CdcClient.cluster = cluster; } public void setWatchAllTable(boolean watchAllTable) { CdcClient.watchAllTable = watchAllTable; } public void setLogBaseHome(String logBaseHome) { CdcClient.logBaseHome = logBaseHome; } public CdcClient(String etcdHost, String etcdUsername, String etcdPassword) { GlobalConfig.etcd_host = etcdHost.trim().split(","); GlobalConfig.etcd_username = etcdUsername.trim(); GlobalConfig.etcd_password = etcdPassword.trim(); } public CdcClient(String etcdHost, String etcdUsername, String etcdPassword, String prefix) { this(etcdHost, etcdUsername, etcdPassword); uniEtcdKeyPrefix = prefix; } public void start() { try { String baseLogHome = System.getProperty("cdc.log.base.home"); if (StringUtils.isEmptyOrWhitespaceOnly(baseLogHome)) { System.setProperty("LOG_HOME", logBaseHome + instance); } else { System.setProperty("LOG_HOME", baseLogHome + "/" + instance); } final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); ctx.reconfigure(); ip = InetAddress.getLocalHost().getHostAddress(); String name = ManagementFactory.getRuntimeMXBean().getName(); pid = name.split("@")[0]; registerLeaseId = EtcdApi.register(RongUtil.getRegisterKey(), Constant.REGISTER_STATUS_OK); logger.info("register success: {}", registerLeaseId); new Thread(new GuardEtcd(registerLeaseId)).start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { logger.info("revoke {}", registerLeaseId); try { EtcdClient.getInstance().getLeaseClient().revoke(registerLeaseId).get(); } catch (Exception e) { logger.error("revoke {}", registerLeaseId, e); } })); EtcdApi.getLock(registerLeaseId); GlobalConfig.loadConfig(); client = new BinaryLogClient(GlobalConfig.mysql_host, GlobalConfig.mysql_port, GlobalConfig.mysql_username, GlobalConfig.mysql_password); client.setKeepAlive(true); client.registerEventListener(new TraceEventListener()); client.registerLifecycleListener(new TraceLifecycleListener()); setServerId(); new Thread(new RongTimer(client)).start(); client.connect(TimeUnit.SECONDS.toMillis(GlobalConfig.connect_timedout)); new Thread(new WatchEtcd(RongUtil.etcdPrefix() + "config/cdc")).start(); } catch (IOException e) { logger.error("IOException:", e); System.exit(1); } catch (TimeoutException e) { logger.error("TimeoutException:", e); System.exit(1); } catch (Exception e) { logger.error("Exception:", e); System.exit(1); } } private static void setServerId() throws Exception { List<KeyValue> list = EtcdApi.getPrefix(CdcClient.uniEtcdKeyPrefix); Long localServerId = client.getServerId(); for (KeyValue keyValue : list) { String key = keyValue.getKey().toStringUtf8(); if (key.contains("/" + instance + "/serverid")) { String[] split = key.split("/"); Long serverId = Long.parseLong(keyValue.getValue().toStringUtf8()); if (split[1].equals(cluster)) { localServerId = serverId; break; } if (localServerId >= serverId) { localServerId = serverId - 1; } } } EtcdApi.set(RongUtil.etcdPrefix() + "serverid", String.valueOf(localServerId)); logger.info("{} set server id:{}", cluster, localServerId); client.setServerId(localServerId); } /** * Register message listener. Note that multiple message listeners will be called in order they * where registered. * * @param messageListener message listener */ public void registerMessageListener(MessageListener messageListener) { messageListeners.add(messageListener); } /** * @return registered message listeners */ public static List<MessageListener> getMessageListeners() { return Collections.unmodifiableList(messageListeners); } public static boolean notifyMessageListeners(List<QueueData> dataList) { boolean result = true; for (MessageListener messageListener : messageListeners) { try { result = messageListener.publishBatch(dataList); if (!result) { return result; } } catch (Exception e) { logger.warn(messageListener + " choked on " + dataList, e); } } return result; } /** * {@link CdcClient}'s message listener. */ public interface MessageListener { boolean publishBatch(List<QueueData> dataList); } }
rong360/cdc
src/main/java/com/rong360/main/CdcClient.java
752
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.netbeans.modules.refactoring.java.plugins; import com.sun.source.tree.*; import com.sun.source.util.TreePath; import org.netbeans.api.java.source.support.ErrorAwareTreeScanner; import com.sun.source.util.Trees; import java.util.EnumSet; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeParameterElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Types; import org.netbeans.api.java.source.ElementHandle; import org.netbeans.api.java.source.GeneratorUtilities; import org.netbeans.api.java.source.SourceUtils; import org.netbeans.api.java.source.TreeMaker; import org.netbeans.api.java.source.TreePathHandle; import org.netbeans.api.java.source.WorkingCopy; import org.netbeans.modules.refactoring.java.api.MemberInfo; import org.netbeans.modules.refactoring.java.api.MemberInfo.Group; import org.netbeans.modules.refactoring.java.api.PullUpRefactoring; import org.netbeans.modules.refactoring.java.spi.RefactoringVisitor; import org.netbeans.modules.refactoring.java.spi.ToPhaseException; /** * * @author Jan Becicka * @author Ralph Benjamin Ruijs */ public class PullUpTransformer extends RefactoringVisitor { private MemberInfo<ElementHandle<? extends Element>>[] members; private TypeElement targetType; private TypeElement sourceType; private PullUpRefactoring refactoring; public PullUpTransformer(PullUpRefactoring refactoring) { this.refactoring = refactoring; this.members = refactoring.getMembers(); } @Override public void setWorkingCopy(WorkingCopy copy) throws ToPhaseException { SourceUtils.forceSource(copy, refactoring.getSourceType().getFileObject()); super.setWorkingCopy(copy); this.targetType = refactoring.getTargetType().resolve(copy); this.sourceType = (TypeElement) refactoring.getSourceType().resolveElement(copy); } @Override public Tree visitClass(ClassTree tree, Element p) { Element classElement = workingCopy.getTrees().getElement(getCurrentPath()); GeneratorUtilities genUtils = GeneratorUtilities.get(workingCopy); // helper AtomicBoolean classIsAbstract = new AtomicBoolean(classElement.getKind().isInterface()); if (classElement.equals(targetType)) { addMembersToTarget(tree, classIsAbstract, targetType, genUtils); } else if (classElement.equals(sourceType)) { removeMembersFromSource(tree, classIsAbstract); } return super.visitClass(tree, p); } private void addMembersToTarget(ClassTree tree, AtomicBoolean classIsAbstract, TypeElement classElement, GeneratorUtilities genUtils) { ClassTree njuClass = tree; for (int i = 0; i < members.length; i++) { Element member = members[i].getElementHandle().resolve(workingCopy); if(member.getKind() == ElementKind.METHOD) { ExecutableElement method = (ExecutableElement) member; method = (ExecutableElement) workingCopy.getElementUtilities().getImplementationOf(method, sourceType); if(method != null) { member = method; } } Group group = members[i].getGroup(); if (group == MemberInfo.Group.IMPLEMENTS) { njuClass = make.addClassImplementsClause(njuClass, make.QualIdent(member)); } else { if (members[i].isMakeAbstract()) { if (classIsAbstract.compareAndSet(false, true)) { makeClassAbstract(njuClass); } njuClass = addAbstractMemberToTarget(njuClass, member, classElement, genUtils); } else { if (member.getModifiers().contains(Modifier.ABSTRACT) && classIsAbstract.compareAndSet(false, true)) { makeClassAbstract(njuClass); } njuClass = addMemberToTarget(njuClass, member, classElement, group, genUtils); } } } if (njuClass != tree) { rewrite(tree, njuClass); } } private void removeMembersFromSource(ClassTree tree, AtomicBoolean classIsAbstract) { ClassTree njuClass = tree; for (int i = 0; i < members.length; i++) { if (members[i].getGroup() == MemberInfo.Group.IMPLEMENTS) { for (Tree t : njuClass.getImplementsClause()) { Element currentInterface = workingCopy.getTrees().getElement(TreePath.getPath(getCurrentPath(), t)); if (currentInterface != null && currentInterface.equals(members[i].getElementHandle().resolve(workingCopy))) { njuClass = make.removeClassImplementsClause(njuClass, t); rewrite(tree, njuClass); } } } else { Element current = workingCopy.getTrees().getElement(getCurrentPath()); Element member = members[i].getElementHandle().resolve(workingCopy); if(member != null && member.getKind() == ElementKind.METHOD) { ExecutableElement method = (ExecutableElement) member; method = (ExecutableElement) workingCopy.getElementUtilities().getImplementationOf(method, sourceType); if(method != null) { member = method; } } if (member != null && member.getEnclosingElement().equals(current)) { if ((classIsAbstract.get() && !member.getModifiers().contains(Modifier.DEFAULT)) || !members[i].isMakeAbstract() || (member.getModifiers().contains(Modifier.ABSTRACT) && targetType.getKind().isInterface())) { // in case of interface always remove pulled method njuClass = make.removeClassMember(njuClass, workingCopy.getTrees().getTree(member)); rewrite(tree, njuClass); } else if (members[i].isMakeAbstract() && member.getModifiers().contains(Modifier.PRIVATE)) { MethodTree method = (MethodTree) workingCopy.getTrees().getTree(member); ModifiersTree mods = make.removeModifiersModifier(method.getModifiers(), Modifier.PRIVATE); mods = make.addModifiersModifier(mods, targetType.getKind().isInterface() ? Modifier.PUBLIC : Modifier.PROTECTED); rewrite(method.getModifiers(), mods); } } } } } private ClassTree addAbstractMemberToTarget(ClassTree njuClass, Element methodElm, Element classElement, GeneratorUtilities genUtils) { MethodTree method = (MethodTree) workingCopy.getTrees().getTree(methodElm); Set<Modifier> flags = method.getModifiers().getFlags(); Set<Modifier> mod = flags.isEmpty() ? EnumSet.noneOf(Modifier.class) : EnumSet.copyOf(flags); mod.add(Modifier.ABSTRACT); mod.remove(Modifier.FINAL); // abstract method cannot be default mod.remove(Modifier.DEFAULT); // abstract method cannot be synchronized mod.remove(Modifier.SYNCHRONIZED); if (classElement.getKind().isInterface()) { mod.remove(Modifier.PUBLIC); mod.remove(Modifier.PROTECTED); mod.remove(Modifier.PRIVATE); mod.remove(Modifier.ABSTRACT); } if (mod.contains(Modifier.PRIVATE)) { mod.remove(Modifier.PRIVATE); mod.add(Modifier.PROTECTED); } MethodTree newMethod = make.Method( make.Modifiers(mod), method.getName(), method.getReturnType(), method.getTypeParameters(), method.getParameters(), method.getThrows(), (BlockTree) null, (ExpressionTree) method.getDefaultValue()); newMethod = genUtils.importFQNs(newMethod); method = genUtils.importComments(method, workingCopy.getTrees().getPath(methodElm).getCompilationUnit()); genUtils.copyComments(method, newMethod, false); genUtils.copyComments(method, newMethod, true); njuClass = genUtils.insertClassMember(njuClass, newMethod); return njuClass; } private void makeClassAbstract(ClassTree njuClass) { Set<Modifier> mod = EnumSet.copyOf(njuClass.getModifiers().getFlags()); mod.add(Modifier.ABSTRACT); mod.remove(Modifier.FINAL); ModifiersTree modifiers = make.Modifiers(mod); rewrite(njuClass.getModifiers(), modifiers); } private ClassTree addMemberToTarget(ClassTree njuClass, Element member, TypeElement classElement, Group group, GeneratorUtilities genUtils) { TreePath mpath = workingCopy.getTrees().getPath(member); Tree memberTree = genUtils.importComments(mpath.getLeaf(), mpath.getCompilationUnit()); memberTree = genUtils.importFQNs(memberTree); memberTree = fixGenericTypes(memberTree, mpath, member); if (member.getModifiers().contains(Modifier.PRIVATE)) { Tree newMemberTree = null; if (group == Group.METHOD) { MethodTree oldOne = (MethodTree) memberTree; BlockTree body = updateSuperThisReferences(oldOne.getBody(), mpath); newMemberTree = make.Method( make.addModifiersModifier(make.removeModifiersModifier(oldOne.getModifiers(), Modifier.PRIVATE), Modifier.PROTECTED), oldOne.getName(), oldOne.getReturnType(), oldOne.getTypeParameters(), oldOne.getParameters(), oldOne.getThrows(), body, (ExpressionTree) oldOne.getDefaultValue()); } else if (group == Group.FIELD) { VariableTree oldOne = (VariableTree) memberTree; newMemberTree = make.Variable( make.addModifiersModifier(make.removeModifiersModifier(oldOne.getModifiers(), Modifier.PRIVATE), Modifier.PROTECTED), oldOne.getName(), oldOne.getType(), oldOne.getInitializer()); } else if (group == Group.TYPE) { ClassTree oldOne = (ClassTree) memberTree; switch (member.getKind()) { case CLASS: newMemberTree = make.Class( make.addModifiersModifier(make.removeModifiersModifier(oldOne.getModifiers(), Modifier.PRIVATE), Modifier.PROTECTED), oldOne.getSimpleName(), oldOne.getTypeParameters(), oldOne.getExtendsClause(), oldOne.getImplementsClause(), oldOne.getMembers()); break; case INTERFACE: newMemberTree = make.Interface( make.addModifiersModifier(make.removeModifiersModifier(oldOne.getModifiers(), Modifier.PRIVATE), Modifier.PROTECTED), oldOne.getSimpleName(), oldOne.getTypeParameters(), oldOne.getImplementsClause(), oldOne.getMembers()); break; case ANNOTATION_TYPE: newMemberTree = make.AnnotationType( make.addModifiersModifier(make.removeModifiersModifier(oldOne.getModifiers(), Modifier.PRIVATE), Modifier.PROTECTED), oldOne.getSimpleName(), oldOne.getMembers()); break; case ENUM: newMemberTree = make.Enum( make.addModifiersModifier(make.removeModifiersModifier(oldOne.getModifiers(), Modifier.PRIVATE), Modifier.PROTECTED), oldOne.getSimpleName(), oldOne.getImplementsClause(), oldOne.getMembers()); break; } } if (newMemberTree != null) { genUtils.copyComments(memberTree, newMemberTree, false); genUtils.copyComments(memberTree, newMemberTree, true); njuClass = genUtils.insertClassMember(njuClass, newMemberTree); } } else { if (group == Group.METHOD) { MethodTree oldOne = (MethodTree) memberTree; BlockTree body = updateSuperThisReferences(oldOne.getBody(), mpath); ExecutableElement overriddenMethod = workingCopy.getElementUtilities().getOverriddenMethod((ExecutableElement) member); MethodTree newMemberTree = make.Method( overriddenMethod != null && workingCopy.getElementUtilities().isMemberOf(overriddenMethod, targetType)? oldOne.getModifiers() : removeAnnotations(workingCopy, make, oldOne.getModifiers(), mpath), oldOne.getName(), oldOne.getReturnType(), oldOne.getTypeParameters(), oldOne.getParameters(), oldOne.getThrows(), body, (ExpressionTree) oldOne.getDefaultValue()); genUtils.copyComments(memberTree, newMemberTree, false); genUtils.copyComments(memberTree, newMemberTree, true); njuClass = genUtils.insertClassMember(njuClass, newMemberTree); } else { njuClass = genUtils.insertClassMember(njuClass, memberTree); } } return njuClass; } static ModifiersTree removeAnnotations(WorkingCopy workingCopy, TreeMaker make,ModifiersTree oldOne, TreePath path) { TypeElement override = workingCopy.getElements().getTypeElement("java.lang.Override"); if(override == null) { return oldOne; } List<AnnotationTree> newAnnotations = new LinkedList<>(); for (AnnotationTree annotationTree : oldOne.getAnnotations()) { Element el = workingCopy.getTrees().getElement(new TreePath(path, annotationTree)); if(!override.equals(el)) { newAnnotations.add(annotationTree); } } return make.Modifiers(oldOne, newAnnotations); } private <E extends Tree> E fixGenericTypes(E tree, final TreePath path, final Element member) { final Map<TypeMirror, TypeParameterElement> mappings = new HashMap<TypeMirror, TypeParameterElement>(); DeclaredType declaredType = (DeclaredType) sourceType.asType(); for (TypeMirror typeMirror : declaredType.getTypeArguments()) { DeclaredType currentElement = declaredType; deepSearchTypes(currentElement, typeMirror, typeMirror, mappings); } final Types types = workingCopy.getTypes(); final Map<IdentifierTree, Tree> original2Translated = new HashMap<IdentifierTree, Tree>(); ErrorAwareTreeScanner<Void, Void> scanner = new ErrorAwareTreeScanner<Void, Void>() { @Override public Void visitIdentifier(IdentifierTree node, Void p) { Element element = workingCopy.getTrees().getElement(new TreePath(path, node)); if (element != null && element.getKind() == ElementKind.TYPE_PARAMETER) { Element typeElement = types.asElement(element.asType()); if (typeElement != null && typeElement.getKind() == ElementKind.TYPE_PARAMETER) { TypeParameterElement parameterElement = (TypeParameterElement) typeElement; Element genericElement = parameterElement.getGenericElement(); if (genericElement != member) { // genericElement is niet gelijk aan het te verplaatsen element. Dus we moeten deze veranderen. // Is het parameterElement gebruikt bij het maken van de superclass Tree type; TypeParameterElement target = mappings.get(parameterElement.asType()); if (target != null) { type = make.Type(target.asType()); } else { List<? extends TypeMirror> bounds = parameterElement.getBounds(); if (bounds.isEmpty()) { type = make.Type("Object"); // NOI18N } else { type = make.Type(bounds.get(0)); } } original2Translated.put(node, type); } } } return super.visitIdentifier(node, p); } }; scanner.scan(tree, null); E result = (E) workingCopy.getTreeUtilities().translate(tree, original2Translated); return result; } private BlockTree updateSuperThisReferences(BlockTree body, final TreePath mpath) { final Map<ExpressionTree, ExpressionTree> original2Translated = new HashMap<ExpressionTree, ExpressionTree>(); final Trees trees = workingCopy.getTrees(); ErrorAwareTreeScanner<Boolean, Void> idScan = new ErrorAwareTreeScanner<Boolean, Void>() { @Override public Boolean visitMemberSelect(MemberSelectTree node, Void nothing) { String isThis = node.getExpression().toString(); if (isThis.equals("super") || isThis.endsWith(".super")) { //NOI18N TreePath currentPath = new TreePath(mpath, node); Element el = trees.getElement(currentPath); if (el != null && el.getEnclosingElement().equals(targetType)) { original2Translated.put(node, make.Identifier(node.getIdentifier())); return Boolean.TRUE; } } return super.visitMemberSelect(node, nothing); } @Override public Boolean reduce(Boolean r1, Boolean r2) { return (r1 == Boolean.TRUE || r2 == Boolean.TRUE); } }; boolean update = idScan.scan(body, null) == Boolean.TRUE; if (update) { body = (BlockTree) workingCopy.getTreeUtilities().translate(body, original2Translated); } return body; } private boolean deepSearchTypes(DeclaredType currentElement, TypeMirror orig, TypeMirror something, Map<TypeMirror, TypeParameterElement> mappings) { Types types = workingCopy.getTypes(); List<? extends TypeMirror> directSupertypes = types.directSupertypes(currentElement); for (TypeMirror superType : directSupertypes) { DeclaredType type = (DeclaredType) superType; List<? extends TypeMirror> typeArguments = type.getTypeArguments(); for (int i = 0; i < typeArguments.size(); i++) { TypeMirror typeArgument = typeArguments.get(i); if (something.equals(typeArgument)) { TypeElement asElement = (TypeElement) type.asElement(); mappings.put(orig, asElement.getTypeParameters().get(i)); if (types.erasure(targetType.asType()).equals(types.erasure(superType))) { return true; } if(deepSearchTypes(type, orig, typeArgument, mappings)) { break; } } } if (types.erasure(targetType.asType()).equals(types.erasure(superType))) { mappings.remove(orig); return true; } } return false; } }
apache/netbeans
java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
753
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.struts2.showcase.action; import com.opensymphony.xwork2.ActionSupport; import java.util.*; public class ExampleAction extends ActionSupport { public static final String CONSTANT = "Struts Rocks!"; public static Date getCurrentDate() { return new Date(); } public String getName() { return "John Galt"; } public String[] getBands() { return new String[]{"Pink Floyd", "Metallica", "Guns & Roses"}; } public List<String> getMovies() { return Arrays.asList("Lord of the Rings", "Matrix"); } public Book getBook() { return new Book("Iliad", "Homer"); } public Map<String, Book> getBooks() { Map<String, Book> books = new HashMap<String, Book>(); books.put("Iliad", new Book("Iliad", "Homer")); books.put("The Republic", new Book("The Replublic", "Plato")); books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra", "Friedrich Nietzsche")); return books; } } class Book { private String title; private String author; public Book(String title, String author) { this.title = title; this.author = author; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } }
apache/struts
apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java
754
/* * Copyright 2010 Aalto University, ComNet * Released under GPLv3. See LICENSE.txt for details. */ package routing; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import routing.maxprop.MaxPropDijkstra; import routing.maxprop.MeetingProbabilitySet; import routing.util.RoutingInfo; import util.Tuple; import core.Connection; import core.DTNHost; import core.Message; import core.Settings; import core.SimClock; /** * Implementation of MaxProp router as described in * <I>MaxProp: Routing for Vehicle-Based Disruption-Tolerant Networks</I> by * John Burgess et al. * * but with parameter estimation for finding an alpha based on timescale * definition: * * Extension of the protocol by adding a parameter alpha (default 1) * By new connection, the delivery likelihood is increased by alpha * and divided by 1+alpha. Using the default results in the original * algorithm. Refer to Karvo and Ott, <I>Time Scales and Delay-Tolerant Routing * Protocols</I> Chants, 2008 * * This version tries to estimate a good value of alpha from a timescale parameter * given by the user, and from the encounters the node sees during simulation. * * @version 1.0 */ public class MaxPropRouterWithEstimation extends ActiveRouter { /** probabilities of meeting hosts */ private MeetingProbabilitySet probs; /** meeting probabilities of all hosts from this host's point of view * mapped using host's network address */ private Map<Integer, MeetingProbabilitySet> allProbs; /** the cost-to-node calculator */ private MaxPropDijkstra dijkstra; /** IDs of the messages that are known to have reached the final dst */ private Set<String> ackedMessageIds; /** mapping of the current costs for all messages. This should be set to * null always when the costs should be updated (a host is met or a new * message is received) */ private Map<Integer, Double> costsForMessages; /** From host of the last cost calculation */ private DTNHost lastCostFrom; /** Over how many samples the "average number of bytes transferred per * transfer opportunity" is taken */ public static int BYTES_TRANSFERRED_AVG_SAMPLES = 10; private int[] avgSamples; private int nextSampleIndex = 0; /** current value for the "avg number of bytes transferred per transfer * opportunity" */ private int avgTransferredBytes = 0; /** MaxPROP router's setting namespace ({@value})*/ public static final String MAXPROP_NS = "MaxPropRouterWithEstimation"; /* Number of seconds in time scale.*/ public static final String TIME_SCALE_S ="timeScale"; /** The alpha variable, default = 1; */ private double alpha; /** The default value for alpha */ public static final double DEFAULT_ALPHA = 1.0; /** value of time scale variable */ private int timescale; /** last meeting time with a node */ private Map<DTNHost, Double> meetings; private int nrofSamplesIET; private double meanIET; /** number of encounters between encounters */ private Map<DTNHost, Integer> encounters; private int nrofSamplesENC; private double meanENC; private int nrofTotENC; /** * Constructor. Creates a new prototype router based on the settings in * the given Settings object. * @param settings The settings object */ public MaxPropRouterWithEstimation(Settings settings) { super(settings); Settings maxPropSettings = new Settings(MAXPROP_NS); alpha = DEFAULT_ALPHA; timescale = maxPropSettings.getInt(TIME_SCALE_S); initMeetings(); } /** * Copy constructor. Creates a new router based on the given prototype. * @param r The router prototype where setting values are copied from */ protected MaxPropRouterWithEstimation(MaxPropRouterWithEstimation r) { super(r); this.alpha = r.alpha; this.timescale = r.timescale; this.probs = new MeetingProbabilitySet( MeetingProbabilitySet.INFINITE_SET_SIZE, this.alpha); this.allProbs = new HashMap<Integer, MeetingProbabilitySet>(); this.dijkstra = new MaxPropDijkstra(this.allProbs); this.ackedMessageIds = new HashSet<String>(); this.avgSamples = new int[BYTES_TRANSFERRED_AVG_SAMPLES]; initMeetings(); } /** * Initializes interencounter estimators */ private void initMeetings() { this.meetings = new HashMap<DTNHost, Double>(); this.encounters = new HashMap<DTNHost, Integer>(); this.meanIET = 0; this.nrofSamplesIET = 0; this.meanENC = 0; this.nrofSamplesENC = 0; this.nrofTotENC = 0; } @Override public void changedConnection(Connection con) { super.changedConnection(con); if (con.isUp()) { // new connection this.costsForMessages = null; // invalidate old cost estimates if (con.isInitiator(getHost())) { /* initiator performs all the actions on behalf of the * other node too (so that the meeting probs are updated * for both before exchanging them) */ DTNHost otherHost = con.getOtherNode(getHost()); MessageRouter mRouter = otherHost.getRouter(); assert mRouter instanceof MaxPropRouterWithEstimation : "MaxProp only works "+ " with other routers of same type"; MaxPropRouterWithEstimation otherRouter = (MaxPropRouterWithEstimation)mRouter; /* update the estimators */ if (this.updateEstimators(otherHost)) { this.updateParam(); } if (otherRouter.updateEstimators(getHost())) { otherRouter.updateParam(); } /* exchange ACKed message data */ this.ackedMessageIds.addAll(otherRouter.ackedMessageIds); otherRouter.ackedMessageIds.addAll(this.ackedMessageIds); deleteAckedMessages(); otherRouter.deleteAckedMessages(); /* update both meeting probabilities */ probs.updateMeetingProbFor(otherHost.getAddress()); otherRouter.probs.updateMeetingProbFor(getHost().getAddress()); /* exchange the transitive probabilities */ this.updateTransitiveProbs(otherRouter.allProbs); otherRouter.updateTransitiveProbs(this.allProbs); this.allProbs.put(otherHost.getAddress(), otherRouter.probs.replicate()); otherRouter.allProbs.put(getHost().getAddress(), this.probs.replicate()); } } else { /* connection went down, update transferred bytes average */ updateTransferredBytesAvg(con.getTotalBytesTransferred()); } } /** * Updates transitive probability values by replacing the current * MeetingProbabilitySets with the values from the given mapping * if the given sets have more recent updates. * @param p Mapping of the values of the other host */ private void updateTransitiveProbs(Map<Integer, MeetingProbabilitySet> p) { for (Map.Entry<Integer, MeetingProbabilitySet> e : p.entrySet()) { MeetingProbabilitySet myMps = this.allProbs.get(e.getKey()); if (myMps == null || e.getValue().getLastUpdateTime() > myMps.getLastUpdateTime() ) { this.allProbs.put(e.getKey(), e.getValue().replicate()); } } } /** * Updates the MaxPROP estimators * @param host */ protected boolean updateEstimators(DTNHost host) { /* First estimate the mean InterEncounter Time */ double currentTime = SimClock.getTime(); if (meetings.containsKey(host)) { double timeDiff = currentTime - meetings.get(host); // System.out.printf("current time: %f\t last time: %f\n",currentTime,meetings.get(host)); nrofSamplesIET++; meanIET = (((double)nrofSamplesIET -1) / (double)nrofSamplesIET) * meanIET + (1 / (double)nrofSamplesIET) * timeDiff; meetings.put(host, currentTime); } else { /* nothing to update */ meetings.put(host,currentTime); } /* Then estimate the number of encounters * */ nrofTotENC++; // the number of encounter if (encounters.containsKey(host)) { int encounterNro = nrofTotENC - encounters.get(host); // System.out.printf("current time: %f\t last time: %f\n",currentTime,meetings.get(host)); nrofSamplesENC++; meanENC = (((double)nrofSamplesENC -1) / (double)nrofSamplesENC) * meanENC + (1 / (double)nrofSamplesENC) * (double)encounterNro; encounters.put(host,nrofTotENC); return true; } else { /* nothing to update */ encounters.put(host,nrofTotENC); return false; } } /** * update the alpha parameter based on the estimators */ protected void updateParam() { double err = .01; double ntarg = Math.ceil(timescale/meanIET); double ee = 1; double alphadiff = .1; int ob = 0; double fstable; double fnzero; double fnone; double eezero; double eeone; double A; /* * the estimation algorith does not work for timescales * shorter than the mean IET - so use defaults */ if (meanIET > (double)timescale) { System.out.printf("meanIET %f > %d timescale\n",meanIET,timescale); return; } if (meanIET == 0) { System.out.printf("Mean IET == 0\n"); return; } if (meanENC == 0) { System.out.printf("Mean ENC == 0\n"); return; } while (ee != err) { A = Math.pow(1+alpha,meanENC+1); fstable = alpha/(A-1); fnzero = (alpha/A)*(1-Math.pow(A,-ntarg))/(1-1/A); fnone = fnzero + 1/(Math.pow(A,ntarg)); eezero = Math.abs(fnzero-fstable); eeone = Math.abs(fnone -fstable); ee = Math.max(eezero,eeone); if (ee > err ) { if (ob == 2) { alphadiff = alphadiff / 2.0; } ob = 1; alpha = alpha+alphadiff; } else { if (ee < (err-err*0.001)) { if (ob == 1) { alphadiff = alphadiff / 2.0; } ob = 2; alpha = alpha - alphadiff; // double precision floating makes problems... if ((alpha <= 0) | (((1 + alpha) - 1) == 0)) { alpha = alphadiff; alphadiff = alphadiff / 2.0; ob = 0; } } else { ee = err; } } } probs.setAlpha(alpha); } /** * Deletes the messages from the message buffer that are known to be ACKed */ private void deleteAckedMessages() { for (String id : this.ackedMessageIds) { if (this.hasMessage(id) && !isSending(id)) { this.deleteMessage(id, false); } } } @Override public Message messageTransferred(String id, DTNHost from) { this.costsForMessages = null; // new message -> invalidate costs Message m = super.messageTransferred(id, from); /* was this node the final recipient of the message? */ if (isDeliveredMessage(m)) { this.ackedMessageIds.add(id); } return m; } /** * Method is called just before a transfer is finalized * at {@link ActiveRouter#update()}. MaxProp makes book keeping of the * delivered messages so their IDs are stored. * @param con The connection whose transfer was finalized */ @Override protected void transferDone(Connection con) { Message m = con.getMessage(); /* was the message delivered to the final recipient? */ if (m.getTo() == con.getOtherNode(getHost())) { this.ackedMessageIds.add(m.getId()); // yes, add to ACKed messages this.deleteMessage(m.getId(), false); // delete from buffer } } /** * Updates the average estimate of the number of bytes transferred per * transfer opportunity. * @param newValue The new value to add to the estimate */ private void updateTransferredBytesAvg(int newValue) { int realCount = 0; int sum = 0; this.avgSamples[this.nextSampleIndex++] = newValue; if(this.nextSampleIndex >= BYTES_TRANSFERRED_AVG_SAMPLES) { this.nextSampleIndex = 0; } for (int i=0; i < BYTES_TRANSFERRED_AVG_SAMPLES; i++) { if (this.avgSamples[i] > 0) { // only values above zero count realCount++; sum += this.avgSamples[i]; } } if (realCount > 0) { this.avgTransferredBytes = sum / realCount; } else { // no samples or all samples are zero this.avgTransferredBytes = 0; } } /** * Returns the next message that should be dropped, according to MaxProp's * message ordering scheme (see MaxPropTupleComparator). * @param excludeMsgBeingSent If true, excludes message(s) that are * being sent from the next-to-be-dropped check (i.e., if next message to * drop is being sent, the following message is returned) * @return The oldest message or null if no message could be returned * (no messages in buffer or all messages in buffer are being sent and * exludeMsgBeingSent is true) */ protected Message getNextMessageToRemove(boolean excludeMsgBeingSent) { Collection<Message> messages = this.getMessageCollection(); List<Message> validMessages = new ArrayList<Message>(); for (Message m : messages) { if (excludeMsgBeingSent && isSending(m.getId())) { continue; // skip the message(s) that router is sending } validMessages.add(m); } Collections.sort(validMessages, new MaxPropComparator(this.calcThreshold())); return validMessages.get(validMessages.size()-1); // return last message } @Override public void update() { super.update(); if (!canStartTransfer() ||isTransferring()) { return; // nothing to transfer or is currently transferring } // try messages that could be delivered to final recipient if (exchangeDeliverableMessages() != null) { return; } tryOtherMessages(); } /** * Returns the message delivery cost between two hosts from this host's * point of view. If there is no path between "from" and "to" host, * Double.MAX_VALUE is returned. Paths are calculated only to hosts * that this host has messages to. * @param from The host where a message is coming from * @param to The host where a message would be destined to * @return The cost of the cheapest path to the destination or * Double.MAX_VALUE if such a path doesn't exist */ public double getCost(DTNHost from, DTNHost to) { /* check if the cached values are OK */ if (this.costsForMessages == null || lastCostFrom != from) { /* cached costs are invalid -> calculate new costs */ this.allProbs.put(getHost().getAddress(), this.probs); int fromIndex = from.getAddress(); /* calculate paths only to nodes we have messages to * (optimization) */ Set<Integer> toSet = new HashSet<Integer>(); for (Message m : getMessageCollection()) { toSet.add(m.getTo().getAddress()); } this.costsForMessages = dijkstra.getCosts(fromIndex, toSet); this.lastCostFrom = from; // store source host for caching checks } if (costsForMessages.containsKey(to.getAddress())) { return costsForMessages.get(to.getAddress()); } else { /* there's no known path to the given host */ return Double.MAX_VALUE; } } /** * Tries to send all other messages to all connected hosts ordered by * hop counts and their delivery probability * @return The return value of {@link #tryMessagesForConnected(List)} */ private Tuple<Message, Connection> tryOtherMessages() { List<Tuple<Message, Connection>> messages = new ArrayList<Tuple<Message, Connection>>(); Collection<Message> msgCollection = getMessageCollection(); /* for all connected hosts that are not transferring at the moment, * collect all the messages that could be sent */ for (Connection con : getConnections()) { DTNHost other = con.getOtherNode(getHost()); MaxPropRouterWithEstimation othRouter = (MaxPropRouterWithEstimation)other.getRouter(); if (othRouter.isTransferring()) { continue; // skip hosts that are transferring } for (Message m : msgCollection) { /* skip messages that the other host has or that have * passed the other host */ if (othRouter.hasMessage(m.getId()) || m.getHops().contains(other)) { continue; } messages.add(new Tuple<Message, Connection>(m,con)); } } if (messages.size() == 0) { return null; } /* sort the message-connection tuples according to the criteria * defined in MaxPropTupleComparator */ Collections.sort(messages, new MaxPropTupleComparator(calcThreshold())); return tryMessagesForConnected(messages); } /** * Calculates and returns the current threshold value for the buffer's split * based on the average number of bytes transferred per transfer opportunity * and the hop counts of the messages in the buffer. Method is public only * to make testing easier. * @return current threshold value (hop count) for the buffer's split */ public int calcThreshold() { /* b, x and p refer to respective variables in the paper's equations */ long b = this.getBufferSize(); long x = this.avgTransferredBytes; long p; if (x == 0) { /* can't calc the threshold because there's no transfer data */ return 0; } /* calculates the portion (bytes) of the buffer selected for priority */ if (x < b/2) { p = x; } else if (b/2 <= x && x < b) { p = Math.min(x, b-x); } else { return 0; // no need for the threshold } /* creates a copy of the messages list, sorted by hop count */ ArrayList<Message> msgs = new ArrayList<Message>(); msgs.addAll(getMessageCollection()); if (msgs.size() == 0) { return 0; // no messages -> no need for threshold } /* anonymous comparator class for hop count comparison */ Comparator<Message> hopCountComparator = new Comparator<Message>() { public int compare(Message m1, Message m2) { return m1.getHopCount() - m2.getHopCount(); } }; Collections.sort(msgs, hopCountComparator); /* finds the first message that is beyond the calculated portion */ int i=0; for (int n=msgs.size(); i<n && p>0; i++) { p -= msgs.get(i).getSize(); } i--; // the last round moved i one index too far /* now i points to the first packet that exceeds portion p; * the threshold is that packet's hop count + 1 (so that packet and * perhaps some more are included in the priority part) */ return msgs.get(i).getHopCount() + 1; } /** * Message comparator for the MaxProp routing module. * Messages that have a hop count smaller than the given * threshold are given priority and they are ordered by their hop count. * Other messages are ordered by their delivery cost. */ private class MaxPropComparator implements Comparator<Message> { private int threshold; private DTNHost from1; private DTNHost from2; /** * Constructor. Assumes that the host where all the costs are calculated * from is this router's host. * @param treshold Messages with the hop count smaller than this * value are transferred first (and ordered by the hop count) */ public MaxPropComparator(int treshold) { this.threshold = treshold; this.from1 = this.from2 = getHost(); } /** * Constructor. * @param treshold Messages with the hop count smaller than this * value are transferred first (and ordered by the hop count) * @param from1 The host where the cost of msg1 is calculated from * @param from2 The host where the cost of msg2 is calculated from */ public MaxPropComparator(int treshold, DTNHost from1, DTNHost from2) { this.threshold = treshold; this.from1 = from1; this.from2 = from2; } /** * Compares two messages and returns -1 if the first given message * should be first in order, 1 if the second message should be first * or 0 if message order can't be decided. If both messages' hop count * is less than the threshold, messages are compared by their hop count * (smaller is first). If only other's hop count is below the threshold, * that comes first. If both messages are below the threshold, the one * with smaller cost (determined by * {@link MaxPropRouterWithEstimation#getCost(DTNHost, DTNHost)}) is first. */ public int compare(Message msg1, Message msg2) { double p1, p2; int hopc1 = msg1.getHopCount(); int hopc2 = msg2.getHopCount(); if (msg1 == msg2) { return 0; } /* if one message's hop count is above and the other one's below the * threshold, the one below should be sent first */ if (hopc1 < threshold && hopc2 >= threshold) { return -1; // message1 should be first } else if (hopc2 < threshold && hopc1 >= threshold) { return 1; // message2 -"- } /* if both are below the threshold, one with lower hop count should * be sent first */ if (hopc1 < threshold && hopc2 < threshold) { return hopc1 - hopc2; } /* both messages have more than threshold hops -> cost of the * message path is used for ordering */ p1 = getCost(from1, msg1.getTo()); p2 = getCost(from2, msg2.getTo()); /* the one with lower cost should be sent first */ if (p1-p2 == 0) { /* if costs are equal, hop count breaks ties. If even hop counts are equal, the queue ordering is used */ if (hopc1 == hopc2) { return compareByQueueMode(msg1, msg2); } else { return hopc1 - hopc2; } } else if (p1-p2 < 0) { return -1; // msg1 had the smaller cost } else { return 1; // msg2 had the smaller cost } } } /** * Message-Connection tuple comparator for the MaxProp routing * module. Uses MaxPropComparator on the messages of the tuples * setting the "from" host for that message to be the one in the connection * tuple (i.e., path is calculated starting from the host on the other end * of the connection). */ private class MaxPropTupleComparator implements Comparator <Tuple<Message, Connection>> { private int threshold; public MaxPropTupleComparator(int threshold) { this.threshold = threshold; } /** * Compares two message-connection tuples using the * {@link MaxPropComparator#compare(Message, Message)}. */ public int compare(Tuple<Message, Connection> tuple1, Tuple<Message, Connection> tuple2) { MaxPropComparator comp; DTNHost from1 = tuple1.getValue().getOtherNode(getHost()); DTNHost from2 = tuple2.getValue().getOtherNode(getHost()); comp = new MaxPropComparator(threshold, from1, from2); return comp.compare(tuple1.getKey(), tuple2.getKey()); } } @Override public RoutingInfo getRoutingInfo() { RoutingInfo top = super.getRoutingInfo(); RoutingInfo ri = new RoutingInfo(probs.getAllProbs().size() + " meeting probabilities"); /* show meeting probabilities for this host */ for (Map.Entry<Integer, Double> e : probs.getAllProbs().entrySet()) { Integer host = e.getKey(); Double value = e.getValue(); ri.addMoreInfo(new RoutingInfo(String.format("host %d : %.6f", host, value))); } ri.addMoreInfo(new RoutingInfo(String.format("meanIET: %f\t from %d samples",meanIET,nrofSamplesIET))); ri.addMoreInfo(new RoutingInfo(String.format("meanENC: %f\t from %d samples",meanENC,nrofSamplesENC))); ri.addMoreInfo(new RoutingInfo(String.format("current alpha: %f",alpha))); top.addMoreInfo(ri); top.addMoreInfo(new RoutingInfo("Avg transferred bytes: " + this.avgTransferredBytes)); return top; } @Override public MessageRouter replicate() { MaxPropRouterWithEstimation r = new MaxPropRouterWithEstimation(this); return r; } }
aunroel/the-one
src/routing/MaxPropRouterWithEstimation.java
755
// -*- mode: java; c-basic-offset: 2; -*- // Copyright 2016 Massachusetts Institute of Technology. All rights reserved. /** * @fileoverview Dutch (Flanders (Belgium)/the Netherlands) strings. * @author [email protected] (volunteers from the Flemish Coderdojo Community) */ 'use strict'; goog.require('Blockly.Msg.nl'); goog.provide('AI.Blockly.Msg.nl'); /** * Due to the frequency of long strings, the 80-column wrap rule need not apply * to message files. */ Blockly.Msg.nl.switch_language_to_dutch = { // Switch language to Dutch. category: '', helpUrl: '', init: function() { Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT = 'Zoek op per paar sleutel %1 paren %2 nietGevonden %3'; Blockly.Msg.VARIABLE_CATEGORY = 'Variabelen'; Blockly.Msg.ADD_COMMENT = 'Commentaar toevoegen'; Blockly.Msg.EXPAND_BLOCK = 'Blok uitbreiden'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TITLE_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT = 'Verdeelt tekst in stukken met de tekst \'op\' als splitspunt en levert een lijst van de resultaten. \n"één,twee,drie,vier" splitsen op "," (komma) geeft de lijst "(één twee drie vier)" terug. \n"één-aardappel,twee-aardappel,drie-aardappel,vier" splitsen op "-aardappel," geeft ook de lijst "(één twee drie vier)" terug.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TOOLTIP = 'Geeft de waarde terug die was doorgegeven bij het openen van het scherm, meestal door een ander scherm in een app met meerdere schermen. Als er geen waarde was meegegeven, wordt er een lege tekst teruggegeven.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TITLE = 'item'; Blockly.Msg.DELETE_BLOCK = 'Verwijder blok'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TOOLTIP = 'Geeft het nummer terug in decimale notatie\nmet een bepaald aantal getallen achter de komma.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE = 'terwijl'; Blockly.Msg.LANG_COLOUR_PINK = 'roze'; Blockly.Msg.CONNECT_TO_DO_IT = 'U moet verbonden zijn met de AI Companion app of emulator om "Doe het" te gebruiken'; Blockly.Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT = 'krijg'; Blockly.Msg.LANG_MATH_TRIG_SIN = 'sin'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = 'ga verder met volgende iteratie'; Blockly.Msg.DISABLE_BLOCK = 'Schakel Blok uit'; Blockly.Msg.REPL_HELPER_Q = 'Helper?'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT = 'Vervang alle tekst %1 stukje tekst %2 vervangingstekst %3'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN = 'wanneer'; Blockly.Msg.LANG_COLOUR_CYAN = 'Lichtblauw'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_COLLAPSED_TEXT = 'sluit scherm met waarde'; Blockly.Msg.LANG_MATH_TRIG_ASIN = 'asin'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV = 'lijst naar .csv tabel'; Blockly.Msg.REPL_NOW_DOWNLOADING = 'We downloaden nu een update van de App Inventor server. Even geduld aub.'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TOOLTIP = 'specificeert een numerieke seed waarde\nvoor de willekeurige nummer maker'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT = 'zet om'; Blockly.Msg.LANG_MATH_SINGLE_OP_EXP = 'e^'; Blockly.Msg.LANG_TEXT_COMPARE_EQUAL = ' ='; Blockly.Msg.LANG_TEXT_COMPARE_NEQ = ' ≠'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ROOT = 'Geeft de vierkantswortel van een getal.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TOOLTIP = 'Voeg items toe aan het einde van een lijst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_TEXT_COMPARE_GT = ' >'; Blockly.Msg.REPL_USB_CONNECTED_WAIT = 'USB verbonden, effe wachten aub'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES = 'lokale namen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR = 'maak kleur'; Blockly.Msg.LANG_MATH_DIVIDE = '÷'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP = 'Voert alle blokken uit in \'do\' en geeft een statement terug. Handig wanneer je een procedure wil uitvoeren voor een waarde terug te geven aan een variabele.'; Blockly.Msg.COPY_ALLBLOCKS = 'Kopieer alle blokken naar de rugzak'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT_LIST = 'op (lijst)'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT = 'globaal'; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE = 'invoer:'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_NOT_FOUND = 'nietGevonden'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP = 'Laat je toe variabelen te maken die enkel toegankelijk zijn in het doe deel van dit blok.'; Blockly.Msg.REPL_PLUGGED_IN_Q = 'Aangesloten?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP = ''; Blockly.Msg.HORIZONTAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST = 'is een lijst?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE = 'invoer'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_FROM = 'van'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TITLE_APPEND = 'voeg toe aan lijst'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX = ' binnen bereik'; Blockly.Msg.NEW_VARIABLE_TITLE = 'Nieuwe variabelenaam:'; Blockly.Msg.VERTICAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TITLE_REPLACE = 'vervang element in de lijst'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_ANY = 'Verdeelt de gegeven tekst in een lijst, waarbij elk element in de lijst \'\'op\'\' als het\nverdeelpunt, en geeft een lijst terug van het resultaat. \nSplitsen van "sinaasappel,banaan,appel,hondenvoer" met als "op" een lijst van 2 elementen met als eerste \nelement een komma en als tweede element "pel" geeft een lijst van 4 elementen: \n"(sinaasap banaan ap hondenvoer)".'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN = 'in'; Blockly.Msg.DO_IT = 'Voer uit'; Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE = 'absoluut'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME = 'functie die niets teruggeeft'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_TOOLTIP = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.BACKPACK_DOCUMENTATION = 'De Rugzak is een knip/plak functie. Het laat toe om blokken te kopieren van een project of scherm en ze in een ander scherm of project te plakken. Om te kopieren sleep je de blokken in de rugzak. Om te plakken klik je op het Rugzak icoon en sleep je de blokken in de werkplaats.</p><p> De inhoud van de Rugzak blijft behouden tijdens de ganse App Inventor sessie. Als je de App Inventor dicht doet, of als je je browser herlaadt, wordt de Rugzak leeggemaakt.</p><p>Voor meer info en een video, bekijk:</p><p><a href="/reference/other/backpack.html" target="_blank">http://ai2.appinventor.mit.edu/reference/other/backpack.html</a>'; Blockly.Msg.LANG_MATH_TRIG_ATAN2 = 'atan2'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX = 'aanroep '; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSEIF = 'of als'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN = 'resultaat'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_CALL = 'roep aan'; Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE = 'splits bij spaties'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV = 'lijst van .csv rij'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE = 'x'; Blockly.Msg.REPL_CONNECTION_FAILURE1 = 'Verbindingsfout'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST_OF_ANY = 'Splitst een gegeven tekst in een lijst met twee elementen. De eerste plaats van eender welk item in de lijst "aan" is het \'\'splitsingspunt\'\'. \n\nBijvoorbeeld als je "Ik hou van appels, bananen en ananas" splitst volgens de lijst "(ba,ap)", dan geeft dit \neen lijst van 2 elementen terug. Het eerste item is "Ik hou van" en het tweede item is \n"pels, bananen en ananas."'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE = 'open een ander scherm'; Blockly.Msg.LANG_LISTS_IS_LIST_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties om dit lijst blok opnieuw te configureren. '; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GTE = 'Geef waar terug als het eerste getal groter is\ndan of gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_FOR_TOOLTIP = 'Tel van een start- tot een eindnummer.\nZet het huidige nummer, voor iedere tel, op\nvariabele "%1", en doe erna een aantal dingen.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TOOLTIP = 'Geef een willekeurig getal tussen 0 en 1 terug.'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_VARIABLE = ' variabele'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.WARNING_DELETE_X_BLOCKS = 'Weet u zeker dat u alle %1 van deze blokken wilt verwijderen?'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TOOLTIP = ''; Blockly.Msg.LANG_LISTS_INSERT_INPUT_ITEM = 'item'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE = 'sluit scherm'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_EQUAL = 'Test of stukken tekst identiek zijn, of ze dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale=\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn=\nmaar niet tekst =.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_NEQ = 'Test of stukken tekst verschillend zijn, of ze niet dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale≠\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn tekst ≠\nmaar wiskundig =.'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_ROUND = 'Rond een nummer af naar boven of beneden.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_END = 'tot'; Blockly.Msg.LANG_COLOUR_ORANGE = 'oranje'; Blockly.Msg.REPL_STARTING_COMPANION_IN_EMULATOR = 'AI Companion App wordt opgestart in de emulator.'; Blockly.Msg.LANG_MATH_COMPARE_LT = '<'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ABS = 'Geef de absolute waarde van een getal terug.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM = 'item'; Blockly.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN = 'Selecteer een geldig item uit de drop down.'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD = 'graden naar radialen'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TOOLTIP = 'Geeft de platte tekst terug die doorgegeven werd toen dit scherm werd gestart door een andere app. Als er geen waarde werd doorgegeven, geeft deze functie een lege tekst terug. Voor multischerm apps, gebruik dan neem start waarde in plaats van neem platte start tekst.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM = 'voor elk'; Blockly.Msg.BACKPACK_DOC_TITLE = 'Rugzak informatie'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN = 'samenvoegen'; Blockly.Msg.LANG_TEXT_LENGTH_TOOLTIP = 'Geeft het aantal letters (inclusief spaties)\nterug in de meegegeven tekst.'; Blockly.Msg.LANG_CONTROLS_IF_IF_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties\nom dit blok opnieuw te configureren.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1 = 'De AI Companion die je op je smartphone gebruikt, is verouderd.<br/><br/>Deze versie van de App Inventor moet gebruikt worden met Companion versie'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE = 'hoofdletters'; Blockly.Msg.LANG_MATH_ARITHMETIC_ADD = '+'; Blockly.Msg.REPL_COMPANION_VERSION_CHECK = 'Versie controle van de AI Companion'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP = 'Een procedure die een resultaat teruggeeft.'; Blockly.Msg.LANG_MATH_TRIG_ATAN2_X = 'x'; Blockly.Msg.EXPAND_ALL = 'Blok uitbreiden'; Blockly.Msg.CHANGE_VALUE_TITLE = 'Wijzig waarde:'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TOOLTIP = 'Opent een nieuw scherm in een app met meerdere schermen.'; Blockly.Msg.LANG_TEXT_ISEMPTY_TOOLTIP = 'Geeft waar terug als de lengte van de\ntekst gelijk is aan 0, anders wordt niet waar teruggegeven.'; Blockly.Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT = 'ingesteld'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM = 'willekeurig deel'; Blockly.Msg.LANG_COLOUR_BLUE = 'blauw'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = 'tot'; Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET = 'krijg'; Blockly.Msg.REPL_APPROVE_UPDATE = ' scherm omdat je gevraagd gaat worden om een update goed te keuren.'; Blockly.Msg.LANG_TEXT_TRIM_TOOLTIP = 'Geeft een kopie terug van de tekst argumenten met elke\nspatie vooraan en achteraan verwijderd.'; Blockly.Msg.REPL_EMULATORS = 'emulators'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM = 'is een getal?'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX = 'to '; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE = 'vergelijk teksten'; Blockly.Msg.LANG_MATH_NUMBER_TOOLTIP = 'Rapporteer het getoonde getal.'; Blockly.Msg.LANG_TEXT_COMPARE_LT = ' <'; Blockly.Msg.LANG_LISTS_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TOOLTIP = 'Verwijdert het element op de gegeven positie uit de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_TITLE_IS_IN = 'staat in een lijst?'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_CEILING = 'Rond de input af tot het kleinste\ngetal dat niet kleiner is dan de input'; Blockly.Msg.LANG_COLOUR_YELLOW = 'geel'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_FLOOR = 'Rond de input af tot het grootste\ngetal dat niet groter is dan de input'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_MODULO = 'Geeft de gehele deling terug.'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TITLE_ITEM = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_STARTS_AT_TOOLTIP = 'Geeft de beginpositie terug van het stukje in de tekst\nwaar index 1 het begin van de tekst aangeeft. Geeft 0 terug wanneer\nhet stuk tekst niet voorkomt.'; Blockly.Msg.SORT_W = 'Sorteer blokken op breedte'; Blockly.Msg.ENABLE_BLOCK = 'Schakel blok aan'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_COLLAPSED_TEXT = 'evalueer maar negeer'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_ADD = 'Geeft de som van twee getallen terug.'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT = 'index in lijst item %1 lijst %2'; Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING = ' seconden om er zeker van te zijn dat alles draait.'; Blockly.Msg.REPL_NO_ERROR_FIVE_SECONDS = '<br/><i>Merk op:</i>&nbsp,Je zal geen andere foutmeldingen zien gedurende de volgende 5 seconden.'; Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT = 'niet'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CATEGORY_CONTROLS = 'Bediening'; Blockly.Msg.LANG_COLOUR_MAGENTA = 'magenta'; Blockly.Msg.LANG_LISTS_IS_IN_TOOLTIP = 'Geeft waar terug als het ding een item is dat in de lijst zit, anders wordt onwaar teruggegeven.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT = 'vervang lijst item lijst %1 index %2 vervanging %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Neemt een positief geheel decimaal getal en geeft de tekst weer die dat getal voorstelt in binair'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex naar dec'; Blockly.Msg.LANG_LOGIC_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME = 'naam'; Blockly.Msg.NEW_VARIABLE = 'Nieuwe variabele ...'; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_OR = 'Geef waar terug als de invoer waar is.'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP = ''; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_CONTAINS = 'bevat'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT = 'verwijder lijstitem lijst %1 index %2'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT = 'segment tekst %1 start %2 lengte %3'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT = 'lengte van de lijst lijst %1'; Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP = 'Test of het stukje voorkomt in de tekst.'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_RAD_TO_DEG = 'Geeft de graden terug tussen\n(0,360) die overeenkomt met het argument in radialen.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_COLLAPSED_TEXT = 'Neem platte start tekst'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_SEGMENT = 'segment'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_LIST = ' lijst'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_TAN = 'tan'; Blockly.Msg.LANG_MATH_TRIG_ATAN = 'atan'; Blockly.Msg.LANG_MATH_RANDOM_SEED_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = 'Terwijl een waarde onwaar is, doe enkele andere stappen.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_INPUT_RESULT = 'resultaat'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG = 'radialen naar graden'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_SELECT = 'kies een item uit de lijst'; Blockly.Msg.LANG_CATEGORY_TEXT = 'Tekst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT = 'voeg toe aan lijst lijst1 %1 lijst2 %2'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR = 'splits kleur'; Blockly.Msg.LANG_CONTROLS_IF_MSG_IF = 'als'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP = 'Roep een procedure op die iets teruggeeft.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND = 'rond af'; Blockly.Msg.REPL_DISMISS = 'Negeer'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TOOLTIP = 'Vervangt het n\'de item in een lijst.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_GT = 'Geeft aan of tekst1 lexicologisch groter is dan tekst2.\nAls een tekst het eerste deel is van de andere, dan wordt de kortere tekst aanzien als kleiner.\nHoofdletters hebben voorrang op kleine letters.'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR = 'item'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO = 'tot'; Blockly.Msg.LANG_COLOUR_RED = 'rood'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_TO = 'tot'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.REPL_KEEP_TRYING = 'Blijf Proberen'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST = 'maak een lijst'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING = 'afrondenNaarBoven'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_SET = 'zet'; Blockly.Msg.EXTERNAL_INPUTS = 'Externe ingangen'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_PAIRS = 'paren'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE = 'open ander scherm met startwaarde'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Neemt een tekst die een hexadecimaal getal voorstelt en geeft een tekst terug die dat nummer voorstelt als decimaal getal.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_SIN = 'Geeft de sinus van de gegeven hoek (in graden).'; Blockly.Msg.REPL_GIVE_UP = 'Opgeven'; Blockly.Msg.LANG_CATEGORY_LOGIC = 'Logica'; Blockly.Msg.LANG_LISTS_COPY_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_INSERT_INPUT = 'voeg lijstitem toe lijst %1 index %2 item %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Neemt een positief decimaal getal en geeft een tekst terug die dat getal voorstelt in hexadecimale notatie.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_START = 'van'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = 'breek uit'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. door komma\'s gescheiden waarde) opgemaakte rij om een ​​lijst met velden te produceren. Als de rij tekst meerdere onbeschermde nieuwe regels (meerdere lijnen) bevat in de velden, krijg je een foutmelding. Je moet de rij tekst laten eindigen in een nieuwe regel of CRLF.'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_POWER = 'Geeft het eerste getal verheven tot\nde macht van het tweede getal.'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET = 'zet'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_DO = 'doe'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_COLOUR_GRAY = 'grijs'; Blockly.Msg.REPL_NETWORK_ERROR_RESTART = 'Netwerk Communicatie Fout met de AI Companion. <br />Probeer eens de smartphone te herstarten en opnieuw te connecteren.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM = 'kies een willekeurig item'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_LT = 'Controleert of tekst1 lexicografisch kleiner is dan text2. \ NAls een stuk tekst het voorvoegsel is van de andere, dan wordt de kortere tekst \ nals kleiner beschouwd. Kleine letters worden voorafgegaan door hoofdletters.'; Blockly.Msg.LANG_TEXT_APPEND_APPENDTEXT = 'voeg tekst toe'; Blockly.Msg.REPL_CANCEL = 'Annuleren'; Blockly.Msg.LANG_CATEGORY_MATH = 'Wiskunde'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE_TOOLTIP = 'Produceert tekst, zoals een tekstblok. Het verschil is dat de \ntekst niet gemakkelijk te detecteren is door de APK van de app te onderzoeken. Gebruik deze functie daarom bij het maken van apps \n die vertrouwelijke informatie bevatten, zoals API sleutels. \nWaarschuwing: tegen complexe security-aanvallen biedt deze functie slechts een zeer lage bescherming.'; Blockly.Msg.SORT_C = 'Sorteer blokken op categorie'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TOOLTIP = 'Geeft het item op positie index in de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH = 'lengte van de lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME = 'naam'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TITLE = 'maak op als decimaal'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = 'Zolang een waarde waar is, do dan enkele regels code.'; Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE = 'maak lege lijst'; Blockly.Msg.LANG_MATH_ARITHMETIC_POWER = '^'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TOOLTIP = 'Voert het aangesloten blok code uit en negeert de return waarde (indien aanwezig). Deze functie is handig wanneer je een procedure wil aanroepen die een return waarde heeft, zonder dat je die waarde zelf nodig hebt.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TOOLTIP = 'Maak een lijst met een bepaald aantal items.'; Blockly.Msg.ERROR_DUPLICATE_EVENT_HANDLER = 'Dit een een copy van een signaalafhandelaar voor deze component.'; Blockly.Msg.LANG_MATH_TRIG_COS = 'cos'; Blockly.Msg.BACKPACK_CONFIRM_EMPTY = 'Weet u zeker dat u de rugzak wil ledigen?'; Blockly.Msg.LANG_LISTS_IS_EMPTY_TOOLTIP = 'Geeft \'waar\' terug als de lijst leeg is.'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME = 'oproep weergave'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_LN = 'Teruggave van het natuurlijke logaritme van een getal, d.w.z. het logaritme met het grondtal e (2,71828 ...)'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_UPPERCASE = 'Geeft een kopie van de meegegeven tekst omgezet in hoofdletters.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TOOLTIP = 'Toevoegen, verwijderen of herschikken van secties om dit lijstblok te herconfigureren.'; Blockly.Msg.LANG_COLOUR_DARK_GRAY = 'donkergrijs'; Blockly.Msg.ARRANGE_H = 'Rangschik blokken horizontaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF = 'anders als'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TOOLTIP = 'Sluit het huidig scherm en geeft een resultaat terug aan het scherm dat deze opende.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_4 = 'Als de eerste waarde \'waar\' is, voer dan het eerste blok met opdrachten uit.\nAnders, als de tweede waarde \'waar\' is, voer dan het tweede blok met opdrachten uit.\nAls geen van de waarden \'waar\' is, voer dan het laatste blok met opdrachten uit.'; Blockly.Msg.REPL_NETWORK_CONNECTION_ERROR = 'Fout netwerkverbinding'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX = ' in lijst'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT = 'is in lijst? item %1 lijst %2'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_VAR = 'x'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM = 'is decimaal?'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_TOOLTIP = 'Een lijst van vier elementen, elk op een schaal van 0 tot 255, die de rode, groene, blauwe en alfa componenten voorstellen.'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE = 'evalueer maar negeer het resultaat'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_INPUT_LIST = 'lijst'; Blockly.Msg.CAN_NOT_DO_IT = 'Kan dit niet doen'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME = 'initialiseer lokale variable in doe'; Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE = '“'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = 'Sla de rest van deze loop over en \n begin met de volgende iteratie.'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_FROM = 'van'; Blockly.Msg.COPY_TO_BACKPACK = 'Voeg toe aan rugzak'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY = 'is leeg'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY = 'splits bij elk'; Blockly.Msg.EXPORT_IMAGE = 'Download blokken als afbeelding'; Blockly.Msg.REPL_GOT_IT = 'Begrepen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP = 'Een kleur met de gegeven rood, groen, blauw en optionele alfa componenten.'; Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY = 'is de lijst leeg?'; Blockly.Msg.LANG_MATH_SINGLE_OP_NEG = 'negatief'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET = 'stel in'; Blockly.Msg.INLINE_INPUTS = 'Inlijn invulveld'; Blockly.Msg.LANG_LISTS_INSERT_TOOLTIP = 'Voeg een element toe op een specifieke plaats in een lijst.'; Blockly.Msg.REPL_CONNECTING = 'Verbinden ...'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TOOLTIP = 'Geeft de waarde terug die hoort bij de sleutel in een lijst van paren'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_NEG = 'Geeft het negatief van een getal.'; Blockly.Msg.REPL_UNABLE_TO_LOAD = 'Opladen naar de App Inventor server mislukt'; Blockly.Msg.LANG_LISTS_COPY_TOOLTIP = 'Maakt een kopie van een lijst. Sublijsten worden ook gekopieerd'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_TRUE = 'Geeft de booleaanse waar terug.'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE = 'Onleesbaar gemaakte Tekst'; Blockly.Msg.LANG_TEXT_TEXT_TOOLTIP = 'Een tekst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT = 'Selecteer een element uit lijst %1 index %2'; Blockly.Msg.REPL_DO_YOU_REALLY_Q = 'Wil Je Dit Echt? Echt echt?'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP = 'Laat je toe om variabelen te maken die je alleen kan gebruiken in het deel van dit blok dat iets teruggeeft.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT = 'Initializeer globaal'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM = 'is hexadecimaal?'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_QUOTIENT = 'Berekent het quotient.'; Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM = 'is binair?'; Blockly.Msg.LANG_CONTROLS_FOREACH_TOOLTIP = 'Voert de blokken in het \'doe\' deel uit voor elk element van de lijst. Gebruik de opgegeven naam van de variabele om te verwijzen naar het huidige element.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE = '”'; Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN = 'dan'; Blockly.Msg.LANG_CONTROLS_WHILE_TITLE = 'terwijl'; Blockly.Msg.LANG_MATH_COMPARE_GT = '>'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_TOOLTIP = 'Test of iets een string is die een positief integraal grondgetal 10 voorstelt.'; Blockly.Msg.LANG_MATH_MUTATOR_ITEM_INPUT_NUMBER = 'getal'; Blockly.Msg.LANG_LISTS_ADD_ITEM_TOOLTIP = 'Voeg een item toe aan de lijst.'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO = 'in'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LT = 'Geeft Waar terug als het eerste nummer\nkleiner is dan het tweede nummer.'; Blockly.Msg.LANG_COLOUR_BLACK = 'zwart'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TOOLTIP = 'Sluit het huidige scherm af en geeft de tekst terug aan de app die dit scherm geopend heeft. Deze functie is bedoeld om tekst te retourneren aan activiteiten die niet gerelateerd zijn aan App Inventor en niet om naar App Inventor schermen terug te keren. Voor App Inventor apps met meerdere schermen, gebruik de functie Sluit Scherm met Waarde, niet Sluit Scherm met Gewone Tekst.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE = 'Jouw Companion App is te oud. Klik "OK" om bijwerken te starten. Bekijk jouw '; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_AND = 'Geef Waar terug als alle invoer Waar is.'; Blockly.Msg.REPL_NO_START_EMULATOR = 'Het is niet gelukt de MIT AI Companion te starten in de Emulator'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = 'Breek uit de omliggende lus.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_EQ = 'Geef Waar terug als beide getallen gelijk zijn aan elkaar.'; Blockly.Msg.LANG_LOGIC_OPERATION_AND = 'en'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST = 'Verdeelt de opgegeven tekst in twee delen en gebruikt hiervoor de plaats het eerste voorkomen \nvan de tekst \'aan\' als splitser, en geeft een lijst met twee elementen terug. Deze lijst bestaat \nuit het deel voor de splitser en het deel achter de splitser. \nHet splitsen van "appel,banaan,kers,hondeneten" met als een komma als splitser geeft een lijst \nterug met twee elementen: het eerste is de tekst "appel" en het tweede is de tekst \n"banaan,kers,hondeneten". \nMerk op de de komma achter "appel\' niet in het resultaat voorkomt, omdat dit de splitser is.'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binair naar decimaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TOOLTIP = 'Voeg een finaal, vang-alles-op conditie toe aan het als blok.'; Blockly.Msg.GENERATE_YAIL = 'Genereer Yail'; Blockly.Msg.LANG_LOGIC_COMPARE_TRANSLATED_NAME = 'logische is gelijk'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_DOWNCASE = 'Geeft een kopie terug van de tekst in kleine letters.'; Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT = 'quotiënt van'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_NEQ = 'Geef Waar terug als beide getallen niet gelijk zijn aan elkaar.'; Blockly.Msg.DELETE_X_BLOCKS = 'Verwijder %1 blokken'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'rest van'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT = 'start op tekst %1 stuk %2'; Blockly.Msg.BACKPACK_EMPTY = 'Maak de Rugzak leeg'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST = 'in lijst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP = 'Voert de blokken in \'\'doe\'\' uit en geeft een statement terug. Handig als je een procedure wil uitvoeren alvorens een waarde terug te geven aan een variabele.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP = 'Voert de blokken in de \'doe\' sectie uit voor elke numerieke waarde van begin tot eind, telkens verdergaand met de volgende waarde. Gebruik de gegeven naam van de variabele om te verwijzen naar de actuele waarde.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TITLE_REMOVE = 'verwijder lijst item'; Blockly.Msg.REPL_STARTING_COMPANION_ON_PHONE = 'Bezig het opstarten van de Companion App op de aangesloten telefoon.'; Blockly.Msg.ARRANGE_S = 'Rangschik blokken diagonaal'; Blockly.Msg.ERROR_COMPONENT_DOES_NOT_EXIST = 'Component bestaat niet'; Blockly.Msg.LANG_MATH_COMPARE_LTE = '≤'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT = 'bevat tekst %1 stuk %2'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN = 'min'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT = 'Formatteer als decimaal getal %1 plaatsen %2'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_TEST = ''; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP = ''; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_TAN = 'Geeft de tangens van de gegeven hoek in graden.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO = 'tot'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.HELP = 'Hulp'; Blockly.Msg.LANG_LISTS_POSITION_IN_TITLE_POSITION = 'positie in lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE = 'toepassing sluiten'; Blockly.Msg.LANG_COLOUR_GREEN = 'groen'; Blockly.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF = 'Markeer Procedure'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE = 'krijg startwaarde'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP = 'van lus'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX = 'roep op '; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE = 'Verkrijg gewone starttekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP = 'Roep een procedure op die geen waarde teruggeeft.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV = 'lijst van een csv tabel'; Blockly.Msg.LANG_LISTS_INSERT_TITLE_INSERT_LIST = 'voeg een lijst element toe'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST1 = 'lijst1'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST2 = 'lijst2'; Blockly.Msg.REPL_UPDATE_INFO = 'De update wordt nu geïnstalleerd op je toestel. Hou je scherm (of emulator) in het oog en keur de installatie goed wanneer je dat gevraagd wordt.<br /><br />BELANGRIJK: Wanneer de update afloopt, kies "VOLTOOID" (klik niet op "open"). Ga dan naar App Inventor in je web browser, klik op het "Connecteer" menu en kies "Herstart Verbinding". Verbind dan het toestel.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LTE = 'Geeft waar terug als het eerste getal kleiner is\nof gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_COLLAPSED_TEXT = 'sluit scherm met platte tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_COLLAPSED_TEXT = 'herhaal tot'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_KEY = 'sleutel'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_CREATEWITH = 'maak tekst met'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TOOLTIP = 'Interpreteert de lijst als een rij van een tabel en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de rij representeert. Elk item in de rij lijst wordt beschouwd als een veld, er wordt naar verwezen met dubbele aanhalingstekens in de CSV tekst. Items worden gescheiden door een komma. De geretourneerde rij tekst heeft geen lijn separator aan het einde.'; Blockly.Msg.LANG_TEXT_JOIN_TOOLTIP = 'Voegt alle inputs samen tot 1 enkele tekst.\nAls er geen inputs zijn, wordt een lege tekst gemaakt.'; Blockly.Msg.LANG_COLOUR_WHITE = 'Wit'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE = 'Geeft het quotiënt van twee getallen.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT = 'voeg items to lijst lijst %1 item %2'; Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE = 'onwaar'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_INDEX = 'index'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. een door komma\'s gescheiden waarde) opgemaakte tabel om een ​​lijst van rijen te produceren, elke rij is een lijst van velden. Rijen kunnen worden gescheiden door nieuwe lijnen (n) of CRLF (rn).'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN = 'anders'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TOOLTIP = 'Opent een nieuw scherm in een meer-schermen app en geeft de startwaarde mee aan dat scherm.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ASIN = 'Geeft een hoek tussen [-90,+90]\ngraden met de gegeven sinus waarde.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_GETTER_TITLE_OF_COMPONENT = 'van component'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM = 'stel willekeurige seed in'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO = 'doe'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TITLE_LOOKUP_IN_PAIRS = 'zoek op in paren'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_STARTS_AT = 'begint bij'; Blockly.Msg.REPL_NOT_NOW = 'Niet Nu. Later, misschien ...'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT = 'voor component'; Blockly.Msg.HIDE_WARNINGS = 'Waarschuwingen Verbergen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'decimaal naar hexadecimaal'; Blockly.Msg.REPL_CONNECT_TO_COMPANION = 'Connecteer met de Companion'; Blockly.Msg.LANG_COLOUR_PICKER_TOOLTIP = 'Klik op de rechthoek om een kleur te kiezen.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_TO = ' tot'; Blockly.Msg.REPL_SOFTWARE_UPDATE = 'Software bijwerken'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TOOLTIP = 'Als de voorwaarde die wordt getest waar is,retourneer dan het resultaat verbonden aan het \'dan-teruggave\' veld, indien niet, geef dan het resultaat terug van het \'zoneen-teruggave\' veld, op zijn minst een van de resultaten verbonden aan beide teruggave velden wordt weergegeven.'; Blockly.Msg.RENAME_VARIABLE_TITLE = 'Hernoem alle "%1" variabelen naar:'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_FALSE = 'Geeft booleaanse niet waar terug.'; Blockly.Msg.REPL_TRY_AGAIN1 = 'Connecteren met de AI2 Companion is mislukt, probeer het eens opnieuw.'; Blockly.Msg.REPL_VERIFYING_COMPANION = 'Kijken of de Companion gestart is...'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_LISTS_POSITION_IN_TOOLTIP = 'Zoek de positie van het ding op in de lijst. Als het ding niet in de lijst zit, geef 0 terug.'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Waarschuwing:\nDit blok mag alleen\ngebruikt worden in een lus.'; Blockly.Msg.REPL_AI_NO_SEE_DEVICE = 'AI2 ziet je toestel niet, zorg ervoor dat de kabel is aangesloten en dat de besturingsprogramma\'s juist zijn.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_DEG_TO_RAD = 'Geeft de waarde in radialen terug volgens een schaal van\n[-π, +π) overeenkomstig met de graden.'; Blockly.Msg.REPL_STARTING_EMULATOR = 'Bezig met opstarten van de Android Emulator<br/>Even geduld: Dit kan een minuutje of twee duren (of koop snellere computer, grapke Pol! :p).'; Blockly.Msg.REPL_RUNTIME_ERROR = 'Uitvoeringsfout'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_COLLAPSED_TEXT = 'open scherm'; Blockly.Msg.REPL_FACTORY_RESET = 'Deze probeert jouw Emulator te herstellen in zijn initiële staat. Als je eerder je AI Companion had geupdate in de emulator, ga je dit waarschijnlijk op nieuw moeten doen. '; Blockly.Msg.LANG_LISTS_ADD_ITEM_TITLE = 'item'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE = 'als'; Blockly.Msg.LANG_CATEGORY_LISTS = 'Lijsten'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GT = 'Geeft waar terug als het eerste getal groter is\ndan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_COLLAPSED_TEXT = 'sluit toepassing'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_COLLAPSED_TEXT = 'Krijg start waarde'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_COLLAPSED_TEXT = 'sluit scherm'; Blockly.Msg.REMOVE_COMMENT = 'Commentaar Verwijderen'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.REPL_OK_LOWER = 'OK'; Blockly.Msg.LANG_MATH_SINGLE_OP_LN = 'log'; Blockly.Msg.LANG_MATH_IS_A_BINARY_TOOLTIP = 'Test of iets een tekst is die een binair getal voorstelt.'; Blockly.Msg.REPL_UNABLE_TO_UPDATE = 'Het is niet gelukt een update naar het toestel/emulator te sturen.'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO = 'tot'; Blockly.Msg.LANG_MATH_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP = 'bij'; Blockly.Msg.LANG_MATH_COMPARE_GTE = '≥'; Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_ACOS = 'acos'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN = 'Geeft een hoek tussen [-90, +90]\ngraden met de gegeven tangens.'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS = '-'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_1 = 'Als een waarde waar is, voer dan enkele stappen uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_3 = 'Als de eerste waarde waar is, voer dan het eerste codeblok uit.\nAnders, als de tweede waarde waar is, voer het tweede codeblok uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_2 = 'Als de waarde waar is, voer dan het eerste codeblok uit.\nAnders, voer het tweede codeblok uit.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR = 'naar beneden afgerond'; Blockly.Msg.LANG_TEXT_APPEND_TO = 'naar'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TOOLTIP = 'Voeg een test toe aan het als blok.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT = 'herhaal'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_WITH = 'tel met'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP = 'Maakt een globale variabele en geeft die de waarde van de geconnecteerde blokken'; Blockly.Msg.CLEAR_DO_IT_ERROR = 'Wis Fout'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV = 'lijst to csv rij'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_EXP = 'Geef e (2.71828...) tot de macht terug'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME = 'naam'; Blockly.Msg.LANG_MATH_ARITHMETIC_MULTIPLY = '*'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TOOLTIP = 'Sluit al de schermen af in deze app en stopt de app.'; Blockly.Msg.MISSING_SOCKETS_WARNINGS = 'Je moet alle connecties opvullen met blokken'; Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE = '/'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TOOLTIP = 'Sluit het huidige scherm'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TOOLTIP = 'Interpreteert de lijst als een tabel in rij-eerst formaat en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de tabel voorstelt. Elk element in de lijst zou op zijn beurt zelf een lijst moeten zijn die een rij van de CSV tabel voorstelt. Elk element in de rij lijst wordt beschouwd als een veld, waarvan de uiteindelijke CSV tekst zich binnen dubbele aanhalingstekens bevindt. In de teruggegeven tekst worden de elementen in de rijen gescheiden door komma\'s en worden de rijen zelf gescheiden door CRLF (\\r\\n).'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE = 'sluit venster met waarde'; Blockly.Msg.LANG_TEXT_SPLIT_AT_TOOLTIP = 'Splitst de tekst in stukjes bij elke spatie.'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_TOOLTIP = 'Test of iets een getal is.'; Blockly.Msg.LANG_LISTS_IS_LIST_TOOLTIP = 'Test of iets in een lijst zit.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ACOS = 'Geeft een hoek tussen [0, 180]\ngraden met de gegeven cosinus waarde.'; Blockly.Msg.LANG_MATH_RANDOM_INT_TITLE_RANDOM = 'willekeurig getal'; Blockly.Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINTION = 'Dit blok kan niet in een definitie'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_REMAINDER = 'Geef de rest terug.'; Blockly.Msg.REPL_CONNECTING_USB_CABLE = 'Aan het connecteren via USB kabel'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_PLACES = 'plaatsen'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_COLLAPSED_TEXT = 'open scherm met waarde'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TOOLTIP = 'Voeg alle elementen van list2 achteraan toe bij lijst1. Na deze toevoegoperatie zal lijst1 de toegevoegde elementen bevatten, lijst2 zal niet gewijzigd zijn.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE_IMMEDIATE = 'Je gebrukt een oude Companion. Je zou zo snel mogelijk moeten upgraden naar MIT AI2 Companion. Als je automatisch updaten hebt ingesteld in de store, gebeurt de update binnenkort vanzelf.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_COS = 'Geeft de cosinus van een gegeven hoek in graden.'; Blockly.Msg.LANG_TEXT_SEGMENT_TITLE_SEGMENT = 'segment'; Blockly.Msg.BACKPACK_GET = 'Plak Alle Blokken van Rugzak'; Blockly.Msg.PROCEDURE_CATEGORY = 'Procedures'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_TO = ' tot'; Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY = 'copieer lijst'; Blockly.Msg.LANG_LISTS_LENGTH_TOOLTIP = 'Telt het aantal elementen van een lijst'; Blockly.Msg.LANG_VARIABLES_GET_TOOLTIP = 'Geeft de waarde van deze variabele terug.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_INPUT_DO = 'doe'; Blockly.Msg.LANG_TEXT_APPEND_VARIABLE = 'item'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY = 'Geeft het product van twee getallen terug.'; Blockly.Msg.REPL_OK = 'OK'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_ATAN2_Y = 'j'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DO = 'doe'; Blockly.Msg.REPL_HELPER_NOT_RUNNING = 'De aiStarter helper lijkt niet opgestart<br /><a href="http://appinventor.mit.edu" target="_blank">hulp nodig?</a>'; Blockly.Msg.LANG_TEXT_SEGMENT_AT_TOOLTIP = 'Haalt een deel van gegeven lengte uit de gegeven tekst\nstartend van de gegeven tekst op de gegeven positie. Positie \n1 betekent het begin van de tekst.'; Blockly.Msg.LANG_LOGIC_OPERATION_OR = 'of'; Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS = 'Dit blok moet worden geconnecteerd met een gebeurtenisblok of de definitie van een procedure'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS = 'Geeft het verschil tussen twee getallen terug.'; Blockly.Msg.LANG_TEXT_APPEND_TOOLTIP = 'Voeg wat tekst toe aan variabele "%1".'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TITLE_REPLACE_ALL = 'vervang allemaal'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_TEST = 'test'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX = 'tot '; Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM = 'trim'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR = 'getal'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_NUM = 'getal'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN2 = 'Geeft een hoek in tussen [-180, +180]\ngraden met de gegeven rechthoekcoordinaten.'; Blockly.Msg.REPL_YOUR_CODE_IS = 'Jouw code is'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT = 'splits'; Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF = 'als'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_DO = 'doe'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME = 'initializeer lokaal in return'; Blockly.Msg.REPL_EMULATOR_STARTED = 'Emulator gestart, wachten '; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST = 'splits aan de eerste'; Blockly.Msg.LANG_COLOUR_LIGHT_GRAY = 'lichtgrijs'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_1 = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.DUPLICATE_BLOCK = 'Dupliceer'; Blockly.Msg.SORT_H = 'Soorteer Blokken op Hoogte'; Blockly.Msg.ARRANGE_V = 'Organizeer Blokken Vertikaal'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT = 'willekeurig getal tussen %1 en %2'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_EQ = 'Test of twee dingen gelijk zijn. \nDe dingen die worden vergeleken kunnen vanalles zijn, niet enkel getallen. \nGetallen worden als gelijk beschouwd aan hun tekstvorm, \nbijvoorbeeld, het getal 0 is gelijk aan de tekst "0". Ook two tekstvelden \ndie getallen voorstellen zijn gelijk aan elkaar als de getallen gelijk zijn aan mekaar. \n"1" is gelijk aan "01".'; Blockly.Msg.LANG_LOGIC_COMPARE_EQ = '='; Blockly.Msg.RENAME_VARIABLE = 'Geef variabele een andere naam...'; Blockly.Msg.LANG_MATH_RANDOM_INT_TOOLTIP = 'Geeft een willekeurige geheel getal tussen de boven en de\nondergrens. De grenzen worden afgerond tot getallen kleiner\ndan 2**30.'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE = 'waar'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM = 'voor elk'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TOOLTIP = 'Neem een willekeurig element van de lijst.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE = 'Sluit het venster met gewone tekst'; Blockly.Msg.REPL_UNABLE_TO_LOAD_NO_RESPOND = 'Kan geen update laden van de App Inventor server (de server antwoordt niet)'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_START = 'start'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE = 'doe resultaat'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP = 'Een procedure die geen waarde teruggeeft.'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_TOOLTIP = 'Tests of iets een tekst is die een hexadecimaal getal voorstelt.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TOOLTIP = 'Geeft een nieuwe tekst terug door alle stukjes tekst zoals het segment\nte vervangen door de vervangtekst.'; Blockly.Msg.LANG_VARIABLES_SET_TOOLTIP = 'Zet deze variabele gelijk aan de input.'; Blockly.Msg.REPL_ERROR_FROM_COMPANION = 'Fout van de Companion'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_NEQ = 'Geef waar terug als beide inputs niet gelijk zijn aan elkaar.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT = 'van de component'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP = 'Voeg een element toe aan de lijst.'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE = 'naar kleine letters'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT = 'voor element in lijst'; Blockly.Msg.COLLAPSE_ALL = 'Klap blokken dicht'; Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Waarschuwing:\nDeze procedure heeft\ndubbele inputs.'; Blockly.Msg.LANG_CONTROLS_CHOOSE_COLLAPSED_TEXT = 'als'; Blockly.Msg.REPL_NETWORK_ERROR = 'Netwerkfout'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'zet getal om'; Blockly.Msg.COLLAPSE_BLOCK = 'Klap blok dicht'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD = 'voeg dingen toe aan lijst'; Blockly.Msg.REPL_COMPANION_STARTED_WAITING = 'Companion start op, effe wachten ...'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Neemt een tekst die een binair getal voorstelt en geeft de tekst terug die dat getal decimaal voorstelt'; Blockly.Msg.LANG_LOGIC_NEGATE_TOOLTIP = 'Geeft waar terug wanneer de input niet waar is.\nGeeft niet waar terug waneer de input waar is.'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER = 'de rest van'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY = 'splits bij de eerste van'; Blockly.Msg.SHOW_WARNINGS = 'Toon Waarschuwingen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'decimaal naar binair'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT = 'initializeer lokaal'; Blockly.Msg.REPL_DEVICES = 'apparaten'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN = 'dan'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT = 'op'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT = 'voor getal in een zeker bereik'; Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT = 'vierkantswortel'; Blockly.Msg.LANG_MATH_COMPARE_EQ = '='; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Geeft het kleinste van zijn argumenten terug..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Geeft het grootste van zijn argumenten terug..'; Blockly.Msg.TIME_YEARS = "Jaren"; Blockly.Msg.TIME_MONTHS = "Maanden"; Blockly.Msg.TIME_WEEKS = "Weken"; Blockly.Msg.TIME_DAYS = "Dagen"; Blockly.Msg.TIME_HOURS = "Uren"; Blockly.Msg.TIME_MINUTES = "Minuten"; Blockly.Msg.TIME_SECONDS = "Seconden"; Blockly.Msg.TIME_DURATION = "Duurtijd"; Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION = "Toon Rugzak informatie"; Blockly.Msg.ENABLE_GRID = 'Toon Werkruimte raster'; Blockly.Msg.DISABLE_GRID = 'Werkruimte raster verbergen'; Blockly.Msg.ENABLE_SNAPPING = 'Uitlijnen op raster aanzetten'; Blockly.Msg.DISABLE_SNAPPING = 'Uitlijnen op raster uitzetten'; } }; // Initalize language definition to Dutch Blockly.Msg.nl.switch_blockly_language_to_nl.init(); Blockly.Msg.nl.switch_language_to_dutch.init();
DreamsForSchools/appinventor-sources
appinventor/blocklyeditor/src/msg/nl/_messages.js
756
package com.sixtyfour.basicshell; import com.sixtyfour.plugins.impl.ConsoleOutputChannel; /** * @author nietoperz809 */ public class ShellOutputChannel extends ConsoleOutputChannel { private BasicShell shellFrame; public ShellOutputChannel(BasicShell shellFrame) { this.shellFrame = shellFrame; } @Override public void print(int id, String txt) { shellFrame.putString(ShellConverter.translateToFont(txt, shellFrame)); } @Override public void println(int id, String txt) { shellFrame.putString(ShellConverter.translateToFont(txt, shellFrame) + '\n'); } }
EgonOlsen71/basicv2
src/main/java/com/sixtyfour/basicshell/ShellOutputChannel.java
757
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 11 "Parser.y" package decaf.frontend; import decaf.tree.Tree; import decaf.tree.Tree.*; import decaf.error.*; import java.util.*; //#line 25 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short VOID=257; public final static short BOOL=258; public final static short INT=259; public final static short STRING=260; public final static short CLASS=261; public final static short NULL=262; public final static short EXTENDS=263; public final static short THIS=264; public final static short WHILE=265; public final static short FOR=266; public final static short IF=267; public final static short ELSE=268; public final static short RETURN=269; public final static short BREAK=270; public final static short NEW=271; public final static short PRINT=272; public final static short READ_INTEGER=273; public final static short READ_LINE=274; public final static short LITERAL=275; public final static short IDENTIFIER=276; public final static short AND=277; public final static short OR=278; public final static short STATIC=279; public final static short INSTANCEOF=280; public final static short NUMINSTANCES=281; public final static short LESS_EQUAL=282; public final static short GREATER_EQUAL=283; public final static short EQUAL=284; public final static short NOT_EQUAL=285; public final static short DOUBLE_PLUS=286; public final static short DOUBLE_MINUS=287; public final static short FI=288; public final static short TRIBLE_OR=289; public final static short DO=290; public final static short OD=291; public final static short UMINUS=292; public final static short EMPTY=293; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 4, 5, 5, 5, 5, 5, 5, 2, 6, 6, 7, 7, 7, 9, 9, 10, 10, 8, 8, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 23, 25, 25, 21, 22, 14, 14, 14, 28, 28, 26, 26, 27, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 30, 30, 29, 29, 31, 31, 16, 17, 20, 15, 32, 32, 18, 18, 19, }; final static short yylen[] = { 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 6, 2, 0, 2, 2, 0, 1, 0, 3, 1, 7, 6, 3, 2, 0, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 3, 1, 3, 3, 3, 3, 1, 0, 2, 0, 2, 4, 5, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 4, 5, 6, 5, 2, 2, 2, 2, 5, 4, 1, 1, 1, 0, 3, 1, 5, 9, 1, 6, 2, 0, 2, 1, 4, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 2, 0, 0, 13, 17, 0, 7, 8, 6, 9, 0, 0, 12, 15, 0, 0, 16, 10, 0, 4, 0, 0, 0, 0, 11, 0, 21, 0, 0, 0, 0, 5, 0, 0, 0, 26, 23, 20, 22, 0, 84, 72, 0, 0, 0, 0, 91, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 24, 27, 35, 25, 0, 29, 30, 31, 0, 0, 0, 36, 37, 0, 0, 0, 0, 53, 0, 0, 0, 39, 0, 0, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 32, 33, 34, 0, 0, 0, 0, 0, 0, 77, 79, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 70, 71, 0, 0, 42, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 40, 73, 0, 0, 97, 0, 82, 0, 49, 0, 0, 0, 89, 0, 0, 74, 0, 0, 76, 0, 50, 0, 0, 92, 75, 0, 93, 0, 90, }; final static short yydgoto[] = { 2, 3, 4, 67, 20, 33, 8, 11, 22, 34, 35, 68, 45, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 87, 79, 89, 90, 91, 82, 179, 83, 140, 192, }; final static short yysindex[] = { -253, -252, 0, -253, 0, -229, 0, -233, -77, 0, 0, -92, 0, 0, 0, 0, -218, -44, 0, 0, 3, -86, 0, 0, -82, 0, 23, -16, 40, -44, 0, -44, 0, -78, 41, 42, 43, 0, -35, -44, -35, 0, 0, 0, 0, 2, 0, 0, 47, 49, 131, 151, 0, 189, 51, 53, 54, 0, 58, 64, 151, 151, 151, 151, 151, 91, 0, 0, 0, 0, 50, 0, 0, 0, 52, 57, 60, 0, 0, 754, 34, 0, -170, 0, 151, 151, 91, 0, 466, -270, 0, 0, 754, 68, 21, 151, 81, 85, 151, -159, -31, -31, -266, -42, -42, -148, 490, 0, 0, 0, 0, 151, 151, 151, 151, 151, 151, 0, 0, 151, 151, 151, 151, 151, 151, 151, 0, 151, 151, 151, 89, 502, 71, 526, 36, 0, 151, 92, 111, 754, -12, 0, 0, 553, 93, 0, 94, 0, 901, 889, -6, -6, 913, 913, -36, -36, -42, -42, -42, -6, -6, 564, 588, 754, 151, 36, 151, 70, 0, 0, 0, 626, 151, 0, -144, 0, 151, 0, 151, 98, 96, 0, 839, -127, 0, 754, 102, 0, 754, 0, 151, 36, 0, 0, 104, 0, 36, 0, }; final static short yyrindex[] = { 0, 0, 0, 147, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 112, 0, 112, 0, 0, 0, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, -57, 0, 0, 0, 0, -124, -56, 0, 0, 0, 0, 0, 0, 0, 0, -124, -124, -124, -124, -124, -124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 877, 455, 0, 0, -124, -57, -124, 0, 0, 0, 0, 0, 99, 0, 0, -124, 0, 0, -124, 0, 940, 964, 0, 1005, 1034, 0, 0, 0, 0, 0, 0, -124, -124, -124, -124, -124, -124, 0, 0, -124, -124, -124, -124, -124, -124, -124, 0, -124, -124, -124, 398, 0, 0, 0, -57, 0, -124, 0, -124, 15, 0, 0, 0, 0, 0, 0, 0, 0, 7, 55, 1240, 1251, 9, 79, 1087, 1215, 1043, 1168, 1192, 1288, 1290, 0, 0, -21, -27, -57, -124, 425, 0, 0, 0, 0, -124, 0, 0, 0, -124, 0, -124, 0, 116, 0, 0, -33, 0, 30, 0, 0, -14, 0, -24, -57, 0, 0, 0, 0, -57, 0, }; final static short yygindex[] = { 0, 0, 157, 150, 76, 11, 0, 0, 0, 132, 0, 35, 0, -113, -69, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1492, 100, 12, 16, 0, 0, 0, 6, 0, }; final static int YYTABLESIZE=1670; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 94, 123, 45, 96, 126, 27, 121, 94, 1, 27, 126, 122, 94, 27, 86, 126, 132, 45, 135, 136, 43, 168, 21, 136, 5, 145, 94, 81, 24, 173, 81, 123, 172, 18, 7, 64, 121, 119, 43, 120, 126, 122, 65, 9, 81, 81, 10, 63, 65, 127, 59, 65, 181, 59, 183, 127, 88, 80, 23, 88, 127, 81, 25, 29, 94, 65, 65, 59, 59, 64, 65, 87, 59, 42, 87, 44, 65, 30, 195, 81, 31, 63, 38, 197, 40, 127, 39, 84, 41, 85, 94, 95, 94, 96, 97, 129, 66, 80, 98, 66, 65, 81, 59, 64, 99, 32, 130, 32, 137, 107, 65, 108, 138, 66, 66, 43, 109, 144, 66, 110, 60, 194, 141, 60, 64, 41, 142, 66, 146, 164, 166, 65, 186, 170, 175, 176, 63, 60, 60, 189, 172, 191, 60, 193, 64, 196, 80, 1, 66, 14, 81, 65, 47, 19, 5, 18, 63, 85, 95, 41, 6, 19, 102, 36, 64, 12, 13, 14, 15, 16, 180, 86, 60, 169, 0, 0, 63, 80, 0, 80, 0, 81, 0, 81, 64, 0, 0, 17, 0, 0, 26, 65, 0, 41, 28, 0, 63, 0, 37, 0, 0, 0, 80, 80, 30, 0, 81, 81, 80, 0, 0, 0, 81, 12, 13, 14, 15, 16, 0, 47, 47, 0, 0, 0, 94, 94, 94, 94, 94, 94, 0, 94, 94, 94, 94, 0, 94, 94, 94, 94, 94, 94, 94, 94, 117, 118, 0, 94, 94, 47, 117, 118, 47, 94, 94, 94, 94, 94, 94, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 117, 118, 58, 59, 65, 65, 59, 59, 60, 61, 0, 0, 62, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 59, 0, 0, 0, 0, 60, 61, 0, 0, 62, 12, 13, 14, 15, 16, 46, 66, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 59, 105, 46, 0, 47, 60, 60, 0, 0, 62, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 0, 0, 48, 0, 60, 61, 48, 48, 48, 48, 48, 48, 48, 12, 13, 14, 15, 16, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 67, 0, 0, 93, 0, 67, 67, 0, 67, 67, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 45, 67, 0, 67, 67, 48, 0, 48, 52, 0, 0, 0, 44, 52, 52, 0, 52, 52, 52, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 44, 52, 67, 52, 52, 0, 0, 0, 0, 0, 134, 0, 125, 123, 124, 128, 0, 147, 121, 119, 0, 120, 126, 122, 0, 123, 0, 0, 0, 165, 121, 119, 52, 120, 126, 122, 125, 0, 124, 128, 0, 0, 0, 127, 0, 0, 0, 0, 125, 123, 124, 128, 0, 167, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 125, 0, 124, 128, 123, 0, 0, 127, 0, 121, 119, 174, 120, 126, 122, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 125, 0, 124, 128, 127, 0, 0, 0, 0, 0, 0, 125, 123, 124, 128, 0, 0, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 178, 0, 125, 0, 124, 128, 0, 0, 0, 127, 0, 177, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 48, 48, 0, 0, 127, 48, 48, 48, 48, 48, 48, 125, 0, 124, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 67, 67, 0, 0, 0, 67, 67, 67, 67, 67, 67, 0, 0, 0, 0, 127, 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 52, 0, 0, 0, 52, 52, 52, 52, 52, 52, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 125, 0, 124, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 111, 112, 0, 0, 127, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190, 125, 0, 124, 128, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 51, 0, 0, 0, 0, 51, 51, 0, 51, 51, 51, 0, 123, 0, 0, 0, 127, 121, 119, 0, 120, 126, 122, 51, 123, 51, 51, 0, 0, 121, 119, 0, 120, 126, 122, 125, 123, 124, 0, 0, 0, 121, 119, 0, 120, 126, 122, 125, 0, 124, 0, 0, 0, 0, 51, 0, 0, 0, 0, 125, 0, 124, 0, 78, 0, 0, 127, 78, 78, 78, 78, 78, 0, 78, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 78, 78, 78, 80, 78, 78, 127, 80, 80, 80, 80, 80, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 80, 80, 0, 80, 80, 0, 0, 0, 111, 112, 78, 0, 0, 113, 114, 115, 116, 117, 118, 68, 0, 0, 0, 68, 68, 68, 68, 68, 0, 68, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 68, 68, 68, 0, 68, 68, 0, 0, 69, 0, 0, 0, 69, 69, 69, 69, 69, 56, 69, 0, 0, 56, 56, 56, 56, 56, 0, 56, 0, 69, 69, 69, 0, 69, 69, 68, 0, 0, 56, 56, 56, 0, 56, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 69, 54, 0, 54, 54, 54, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, 0, 54, 54, 0, 0, 0, 51, 51, 0, 0, 0, 51, 51, 51, 51, 51, 51, 0, 111, 0, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 54, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 113, 114, 0, 0, 117, 118, 0, 0, 0, 0, 57, 0, 0, 0, 57, 57, 57, 57, 57, 0, 57, 0, 78, 78, 0, 0, 0, 78, 78, 78, 78, 57, 57, 57, 58, 57, 57, 0, 58, 58, 58, 58, 58, 0, 58, 0, 80, 80, 0, 0, 0, 80, 80, 80, 80, 58, 58, 58, 0, 58, 58, 55, 0, 55, 55, 55, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 0, 55, 55, 0, 0, 63, 68, 68, 63, 58, 0, 68, 68, 68, 68, 0, 64, 0, 0, 64, 0, 0, 63, 63, 0, 0, 0, 63, 0, 0, 0, 0, 55, 64, 64, 69, 69, 0, 64, 0, 69, 69, 69, 69, 56, 56, 0, 0, 0, 56, 56, 56, 56, 62, 0, 61, 62, 63, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 62, 62, 61, 61, 0, 62, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 0, 0, 0, 54, 54, 54, 54, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 57, 0, 0, 0, 57, 57, 57, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, 58, 58, 58, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 0, 0, 0, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 63, 0, 0, 0, 0, 0, 63, 63, 0, 0, 64, 64, 0, 0, 0, 0, 0, 64, 64, 0, 0, 0, 0, 0, 88, 92, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 88, 103, 104, 106, 0, 0, 0, 0, 0, 0, 0, 62, 62, 61, 61, 0, 0, 0, 62, 62, 61, 61, 131, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 149, 150, 151, 152, 153, 0, 0, 154, 155, 156, 157, 158, 159, 160, 0, 161, 162, 163, 0, 0, 0, 0, 0, 0, 88, 0, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 182, 0, 0, 0, 0, 0, 185, 0, 0, 0, 187, 0, 188, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 37, 59, 59, 46, 91, 42, 40, 261, 91, 46, 47, 45, 91, 41, 46, 85, 41, 288, 289, 41, 134, 11, 289, 276, 291, 59, 41, 17, 41, 44, 37, 44, 125, 263, 33, 42, 43, 59, 45, 46, 47, 40, 276, 58, 59, 123, 45, 41, 91, 41, 44, 165, 44, 167, 91, 41, 45, 276, 44, 91, 45, 59, 40, 53, 58, 59, 58, 59, 33, 63, 41, 63, 38, 44, 40, 40, 93, 191, 93, 40, 45, 41, 196, 41, 91, 44, 40, 123, 40, 123, 40, 125, 40, 40, 61, 41, 85, 40, 44, 93, 85, 93, 33, 40, 29, 276, 31, 40, 59, 40, 59, 91, 58, 59, 39, 59, 276, 63, 59, 41, 190, 41, 44, 33, 123, 41, 125, 276, 40, 59, 40, 276, 41, 41, 41, 45, 58, 59, 41, 44, 268, 63, 41, 33, 41, 134, 0, 93, 123, 134, 40, 276, 41, 59, 41, 45, 41, 59, 123, 3, 11, 62, 31, 33, 257, 258, 259, 260, 261, 164, 40, 93, 136, -1, -1, 45, 165, -1, 167, -1, 165, -1, 167, 33, -1, -1, 279, -1, -1, 276, 40, -1, 123, 276, -1, 45, -1, 276, -1, -1, -1, 190, 191, 93, -1, 190, 191, 196, -1, -1, -1, 196, 257, 258, 259, 260, 261, -1, 276, 276, -1, -1, -1, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, 276, 286, 287, -1, 280, 281, 276, 286, 287, 276, 286, 287, 288, 289, 290, 291, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, 286, 287, 280, 281, 277, 278, 277, 278, 286, 287, -1, -1, 290, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, 281, -1, -1, -1, -1, 286, 287, -1, -1, 290, 257, 258, 259, 260, 261, 262, 278, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, 281, 261, 262, -1, 264, 277, 278, -1, -1, 290, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, -1, -1, 37, -1, 286, 287, 41, 42, 43, 44, 45, 46, 47, 257, 258, 259, 260, 261, -1, -1, -1, -1, -1, 58, 59, 60, 61, 62, 63, 37, -1, -1, 276, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, 91, -1, 93, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, 59, 60, 91, 62, 63, -1, -1, -1, -1, -1, 58, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, 91, 45, 46, 47, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, -1, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, 63, 37, -1, -1, 91, -1, 42, 43, 44, 45, 46, 47, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 60, -1, 62, 63, 91, -1, -1, -1, -1, -1, -1, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 91, -1, 58, -1, 60, -1, 62, 63, -1, -1, -1, 91, -1, 93, -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 277, 278, -1, -1, 91, 282, 283, 284, 285, 286, 287, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 276, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, 91, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 277, 278, -1, -1, 91, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, -1, 62, 63, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 91, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, 60, 37, 62, -1, -1, -1, 42, 43, -1, 45, 46, 47, 60, -1, 62, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, -1, 37, -1, -1, 91, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, 58, 59, 60, 37, 62, 63, 91, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, 277, 278, 93, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, 93, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 37, -1, -1, -1, 41, 42, 43, 44, 45, 37, 47, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 58, 59, 60, -1, 62, 63, 93, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 93, 41, -1, 43, 44, 45, -1, -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 277, -1, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, 93, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, 282, 283, -1, -1, 286, 287, -1, -1, -1, -1, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 58, 59, 60, 37, 62, 63, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 58, 59, 60, -1, 62, 63, 41, -1, 43, 44, 45, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 41, 277, 278, 44, 93, -1, 282, 283, 284, 285, -1, 41, -1, -1, 44, -1, -1, 58, 59, -1, -1, -1, 63, -1, -1, -1, -1, 93, 58, 59, 277, 278, -1, 63, -1, 282, 283, 284, 285, 277, 278, -1, -1, -1, 282, 283, 284, 285, 41, -1, 41, 44, 93, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, 58, 59, 58, 59, -1, 63, -1, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, -1, -1, 284, 285, -1, -1, 277, 278, -1, -1, -1, -1, -1, 284, 285, -1, -1, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, -1, -1, -1, -1, -1, -1, -1, 277, 278, 277, 278, -1, -1, -1, 284, 285, 284, 285, 84, -1, 86, -1, -1, -1, -1, -1, -1, -1, -1, 95, -1, -1, 98, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 111, 112, 113, 114, 115, 116, -1, -1, 119, 120, 121, 122, 123, 124, 125, -1, 127, 128, 129, -1, -1, -1, -1, -1, -1, 136, -1, 138, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 164, -1, 166, -1, -1, -1, -1, -1, 172, -1, -1, -1, 176, -1, 178, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=293; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'","'?'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING", "CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK", "NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR", "STATIC","INSTANCEOF","NUMINSTANCES","LESS_EQUAL","GREATER_EQUAL","EQUAL", "NOT_EQUAL","DOUBLE_PLUS","DOUBLE_MINUS","FI","TRIBLE_OR","DO","OD","UMINUS", "EMPTY", }; final static String yyrule[] = { "$accept : Program", "Program : ClassList", "ClassList : ClassList ClassDef", "ClassList : ClassDef", "VariableDef : Variable ';'", "Variable : Type IDENTIFIER", "Type : INT", "Type : VOID", "Type : BOOL", "Type : STRING", "Type : CLASS IDENTIFIER", "Type : Type '[' ']'", "ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'", "ExtendsClause : EXTENDS IDENTIFIER", "ExtendsClause :", "FieldList : FieldList VariableDef", "FieldList : FieldList FunctionDef", "FieldList :", "Formals : VariableList", "Formals :", "VariableList : VariableList ',' Variable", "VariableList : Variable", "FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock", "FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock", "StmtBlock : '{' StmtList '}'", "StmtList : StmtList Stmt", "StmtList :", "Stmt : VariableDef", "Stmt : SimpleStmt ';'", "Stmt : IfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "Stmt : ReturnStmt ';'", "Stmt : PrintStmt ';'", "Stmt : BreakStmt ';'", "Stmt : StmtBlock", "Stmt : GuardedIFStmt", "Stmt : GuaededDOStmt", "GuardedES : Expr ':' Stmt", "GuardedStmts : GuardedES", "GuardedStmts : GuardedStmts TRIBLE_OR GuardedES", "GuardedIFStmt : IF GuardedStmts FI", "GuaededDOStmt : DO GuardedStmts OD", "SimpleStmt : LValue '=' Expr", "SimpleStmt : Call", "SimpleStmt :", "Receiver : Expr '.'", "Receiver :", "LValue : Receiver IDENTIFIER", "LValue : Expr '[' Expr ']'", "Call : Receiver IDENTIFIER '(' Actuals ')'", "Expr : LValue", "Expr : Call", "Expr : Constant", "Expr : Expr '+' Expr", "Expr : Expr '-' Expr", "Expr : Expr '*' Expr", "Expr : Expr '/' Expr", "Expr : Expr '%' Expr", "Expr : Expr EQUAL Expr", "Expr : Expr NOT_EQUAL Expr", "Expr : Expr '<' Expr", "Expr : Expr '>' Expr", "Expr : Expr LESS_EQUAL Expr", "Expr : Expr GREATER_EQUAL Expr", "Expr : Expr AND Expr", "Expr : Expr OR Expr", "Expr : '(' Expr ')'", "Expr : '-' Expr", "Expr : '!' Expr", "Expr : READ_INTEGER '(' ')'", "Expr : READ_LINE '(' ')'", "Expr : THIS", "Expr : NEW IDENTIFIER '(' ')'", "Expr : NEW Type '[' Expr ']'", "Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'", "Expr : '(' CLASS IDENTIFIER ')' Expr", "Expr : Expr DOUBLE_PLUS", "Expr : DOUBLE_PLUS Expr", "Expr : Expr DOUBLE_MINUS", "Expr : DOUBLE_MINUS Expr", "Expr : Expr '?' Expr ':' Expr", "Expr : NUMINSTANCES '(' IDENTIFIER ')'", "Constant : LITERAL", "Constant : NULL", "Actuals : ExprList", "Actuals :", "ExprList : ExprList ',' Expr", "ExprList : Expr", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt", "BreakStmt : BREAK", "IfStmt : IF '(' Expr ')' Stmt ElseClause", "ElseClause : ELSE Stmt", "ElseClause :", "ReturnStmt : RETURN Expr", "ReturnStmt : RETURN", "PrintStmt : PRINT '(' ExprList ')'", }; //#line 487 "Parser.y" /** * 打印当前归约所用的语法规则<br> * 请勿修改。 */ public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 741 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 58 "Parser.y" { tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc); } break; case 2: //#line 64 "Parser.y" { yyval.clist.add(val_peek(0).cdef); } break; case 3: //#line 68 "Parser.y" { yyval.clist = new ArrayList<Tree.ClassDef>(); yyval.clist.add(val_peek(0).cdef); } break; case 5: //#line 78 "Parser.y" { yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc); } break; case 6: //#line 84 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc); } break; case 7: //#line 88 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc); } break; case 8: //#line 92 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc); } break; case 9: //#line 96 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc); } break; case 10: //#line 100 "Parser.y" { yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc); } break; case 11: //#line 104 "Parser.y" { yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc); } break; case 12: //#line 110 "Parser.y" { yyval.cdef = new Tree.ClassDef(val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc); } break; case 13: //#line 116 "Parser.y" { yyval.ident = val_peek(0).ident; } break; case 14: //#line 120 "Parser.y" { yyval = new SemValue(); } break; case 15: //#line 126 "Parser.y" { yyval.flist.add(val_peek(0).vdef); } break; case 16: //#line 130 "Parser.y" { yyval.flist.add(val_peek(0).fdef); } break; case 17: //#line 134 "Parser.y" { yyval = new SemValue(); yyval.flist = new ArrayList<Tree>(); } break; case 19: //#line 142 "Parser.y" { yyval = new SemValue(); yyval.vlist = new ArrayList<Tree.VarDef>(); } break; case 20: //#line 149 "Parser.y" { yyval.vlist.add(val_peek(0).vdef); } break; case 21: //#line 153 "Parser.y" { yyval.vlist = new ArrayList<Tree.VarDef>(); yyval.vlist.add(val_peek(0).vdef); } break; case 22: //#line 160 "Parser.y" { yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 23: //#line 164 "Parser.y" { yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 24: //#line 170 "Parser.y" { yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc); } break; case 25: //#line 176 "Parser.y" { yyval.slist.add(val_peek(0).stmt); } break; case 26: //#line 180 "Parser.y" { yyval = new SemValue(); yyval.slist = new ArrayList<Tree>(); } break; case 27: //#line 187 "Parser.y" { yyval.stmt = val_peek(0).vdef; } break; case 28: //#line 192 "Parser.y" { if (yyval.stmt == null) { yyval.stmt = new Tree.Skip(val_peek(0).loc); } } break; case 38: //#line 209 "Parser.y" { yyval.guardedES = new Tree.GuardedES(val_peek(2).expr , val_peek(0).stmt , val_peek(1).loc); } break; case 39: //#line 215 "Parser.y" { yyval.myList = new ArrayList<Tree.GuardedES>(); yyval.myList.add(val_peek(0).guardedES); } break; case 40: //#line 222 "Parser.y" { yyval.myList.add(val_peek(0).guardedES); } break; case 41: //#line 229 "Parser.y" { yyval.stmt = new Tree.GuardedIFStmt(val_peek(1).myList , val_peek(2).loc); } break; case 42: //#line 235 "Parser.y" { yyval.stmt = new Tree.GuardedDOStmt(val_peek(1).myList , val_peek(2).loc); } break; case 43: //#line 241 "Parser.y" { yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc); } break; case 44: //#line 245 "Parser.y" { yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc); } break; case 45: //#line 249 "Parser.y" { yyval = new SemValue(); } break; case 47: //#line 256 "Parser.y" { yyval = new SemValue(); } break; case 48: //#line 262 "Parser.y" { yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc); if (val_peek(1).loc == null) { yyval.loc = val_peek(0).loc; } } break; case 49: //#line 269 "Parser.y" { yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc); } break; case 50: //#line 275 "Parser.y" { yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc); if (val_peek(4).loc == null) { yyval.loc = val_peek(3).loc; } } break; case 51: //#line 284 "Parser.y" { yyval.expr = val_peek(0).lvalue; } break; case 54: //#line 290 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 55: //#line 294 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 56: //#line 298 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 57: //#line 302 "Parser.y" { yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 58: //#line 306 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 59: //#line 310 "Parser.y" { yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 60: //#line 314 "Parser.y" { yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 61: //#line 318 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 62: //#line 322 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 63: //#line 326 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 64: //#line 330 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 65: //#line 334 "Parser.y" { yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 66: //#line 338 "Parser.y" { yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 67: //#line 342 "Parser.y" { yyval = val_peek(1); } break; case 68: //#line 346 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc); } break; case 69: //#line 350 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc); } break; case 70: //#line 354 "Parser.y" { yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc); } break; case 71: //#line 358 "Parser.y" { yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc); } break; case 72: //#line 362 "Parser.y" { yyval.expr = new Tree.ThisExpr(val_peek(0).loc); } break; case 73: //#line 366 "Parser.y" { yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc); } break; case 74: //#line 370 "Parser.y" { yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc); } break; case 75: //#line 374 "Parser.y" { yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc); } break; case 76: //#line 378 "Parser.y" { yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc); } break; case 77: //#line 382 "Parser.y" { yyval.expr = new Tree.Unary(Tree.POSTINC, val_peek(1).expr, val_peek(1).loc); } break; case 78: //#line 386 "Parser.y" { yyval.expr = new Tree.Unary(Tree.PREINC, val_peek(0).expr, val_peek(0).loc); } break; case 79: //#line 390 "Parser.y" { yyval.expr = new Tree.Unary(Tree.POSTDEC, val_peek(1).expr, val_peek(1).loc); } break; case 80: //#line 394 "Parser.y" { yyval.expr = new Tree.Unary(Tree.PREDEC, val_peek(0).expr, val_peek(0).loc); } break; case 81: //#line 398 "Parser.y" { yyval.expr = new Tree.QuestionAndColon(Tree.QUESTION_COLON, val_peek(4).expr, val_peek(2).expr, val_peek(0).expr, val_peek(4).loc); } break; case 82: //#line 402 "Parser.y" { yyval.expr = new Tree.NumTest(val_peek(1).ident, val_peek(3).loc); } break; case 83: //#line 408 "Parser.y" { yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc); } break; case 84: //#line 412 "Parser.y" { yyval.expr = new Null(val_peek(0).loc); } break; case 86: //#line 419 "Parser.y" { yyval = new SemValue(); yyval.elist = new ArrayList<Tree.Expr>(); } break; case 87: //#line 426 "Parser.y" { yyval.elist.add(val_peek(0).expr); } break; case 88: //#line 430 "Parser.y" { yyval.elist = new ArrayList<Tree.Expr>(); yyval.elist.add(val_peek(0).expr); } break; case 89: //#line 437 "Parser.y" { yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc); } break; case 90: //#line 443 "Parser.y" { yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc); } break; case 91: //#line 449 "Parser.y" { yyval.stmt = new Tree.Break(val_peek(0).loc); } break; case 92: //#line 455 "Parser.y" { yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc); } break; case 93: //#line 461 "Parser.y" { yyval.stmt = val_peek(0).stmt; } break; case 94: //#line 465 "Parser.y" { yyval = new SemValue(); } break; case 95: //#line 471 "Parser.y" { yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc); } break; case 96: //#line 475 "Parser.y" { yyval.stmt = new Tree.Return(null, val_peek(0).loc); } break; case 97: //#line 481 "Parser.y" { yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc); } break; //#line 1397 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
PKUanonym/REKCARC-TSC-UHT
大三上/编译原理/hw/2015_刘智峰_PA/PA2/src/decaf/frontend/Parser.java
758
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 11 "Parser.y" package decaf.frontend; import decaf.tree.Tree; import decaf.tree.Tree.*; import decaf.error.*; import java.util.*; //#line 25 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short VOID=257; public final static short BOOL=258; public final static short INT=259; public final static short STRING=260; public final static short CLASS=261; public final static short NULL=262; public final static short EXTENDS=263; public final static short THIS=264; public final static short WHILE=265; public final static short FOR=266; public final static short IF=267; public final static short ELSE=268; public final static short RETURN=269; public final static short BREAK=270; public final static short NEW=271; public final static short PRINT=272; public final static short READ_INTEGER=273; public final static short READ_LINE=274; public final static short LITERAL=275; public final static short IDENTIFIER=276; public final static short AND=277; public final static short OR=278; public final static short STATIC=279; public final static short INSTANCEOF=280; public final static short NUMINSTANCES=281; public final static short LESS_EQUAL=282; public final static short GREATER_EQUAL=283; public final static short EQUAL=284; public final static short NOT_EQUAL=285; public final static short DOUBLE_PLUS=286; public final static short DOUBLE_MINUS=287; public final static short FI=288; public final static short TRIBLE_OR=289; public final static short DO=290; public final static short OD=291; public final static short UMINUS=292; public final static short EMPTY=293; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 4, 5, 5, 5, 5, 5, 5, 2, 6, 6, 7, 7, 7, 9, 9, 10, 10, 8, 8, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 23, 25, 25, 21, 22, 14, 14, 14, 28, 28, 26, 26, 27, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 30, 30, 29, 29, 31, 31, 16, 17, 20, 15, 32, 32, 18, 18, 19, }; final static short yylen[] = { 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 6, 2, 0, 2, 2, 0, 1, 0, 3, 1, 7, 6, 3, 2, 0, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 3, 1, 3, 3, 3, 3, 1, 0, 2, 0, 2, 4, 5, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 4, 5, 6, 5, 2, 2, 2, 2, 5, 4, 1, 1, 1, 0, 3, 1, 5, 9, 1, 6, 2, 0, 2, 1, 4, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 2, 0, 0, 13, 17, 0, 7, 8, 6, 9, 0, 0, 12, 15, 0, 0, 16, 10, 0, 4, 0, 0, 0, 0, 11, 0, 21, 0, 0, 0, 0, 5, 0, 0, 0, 26, 23, 20, 22, 0, 84, 72, 0, 0, 0, 0, 91, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 24, 27, 35, 25, 0, 29, 30, 31, 0, 0, 0, 36, 37, 0, 0, 0, 0, 53, 0, 0, 0, 39, 0, 0, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 32, 33, 34, 0, 0, 0, 0, 0, 0, 77, 79, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 70, 71, 0, 0, 42, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 40, 73, 0, 0, 97, 0, 82, 0, 49, 0, 0, 0, 89, 0, 0, 74, 0, 0, 76, 0, 50, 0, 0, 92, 75, 0, 93, 0, 90, }; final static short yydgoto[] = { 2, 3, 4, 67, 20, 33, 8, 11, 22, 34, 35, 68, 45, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 87, 79, 89, 90, 91, 82, 179, 83, 140, 192, }; final static short yysindex[] = { -253, -252, 0, -253, 0, -229, 0, -233, -77, 0, 0, -92, 0, 0, 0, 0, -218, -44, 0, 0, 3, -86, 0, 0, -82, 0, 23, -16, 40, -44, 0, -44, 0, -78, 41, 42, 43, 0, -35, -44, -35, 0, 0, 0, 0, 2, 0, 0, 47, 49, 131, 151, 0, 189, 51, 53, 54, 0, 58, 64, 151, 151, 151, 151, 151, 91, 0, 0, 0, 0, 50, 0, 0, 0, 52, 57, 60, 0, 0, 754, 34, 0, -170, 0, 151, 151, 91, 0, 466, -270, 0, 0, 754, 68, 21, 151, 81, 85, 151, -159, -31, -31, -266, -42, -42, -148, 490, 0, 0, 0, 0, 151, 151, 151, 151, 151, 151, 0, 0, 151, 151, 151, 151, 151, 151, 151, 0, 151, 151, 151, 89, 502, 71, 526, 36, 0, 151, 92, 111, 754, -12, 0, 0, 553, 93, 0, 94, 0, 901, 889, -6, -6, 913, 913, -36, -36, -42, -42, -42, -6, -6, 564, 588, 754, 151, 36, 151, 70, 0, 0, 0, 626, 151, 0, -144, 0, 151, 0, 151, 98, 96, 0, 839, -127, 0, 754, 102, 0, 754, 0, 151, 36, 0, 0, 104, 0, 36, 0, }; final static short yyrindex[] = { 0, 0, 0, 147, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 112, 0, 112, 0, 0, 0, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, -57, 0, 0, 0, 0, -124, -56, 0, 0, 0, 0, 0, 0, 0, 0, -124, -124, -124, -124, -124, -124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 877, 455, 0, 0, -124, -57, -124, 0, 0, 0, 0, 0, 99, 0, 0, -124, 0, 0, -124, 0, 940, 964, 0, 1005, 1034, 0, 0, 0, 0, 0, 0, -124, -124, -124, -124, -124, -124, 0, 0, -124, -124, -124, -124, -124, -124, -124, 0, -124, -124, -124, 398, 0, 0, 0, -57, 0, -124, 0, -124, 15, 0, 0, 0, 0, 0, 0, 0, 0, 7, 55, 1240, 1251, 9, 79, 1087, 1215, 1043, 1168, 1192, 1288, 1290, 0, 0, -21, -27, -57, -124, 425, 0, 0, 0, 0, -124, 0, 0, 0, -124, 0, -124, 0, 116, 0, 0, -33, 0, 30, 0, 0, -14, 0, -24, -57, 0, 0, 0, 0, -57, 0, }; final static short yygindex[] = { 0, 0, 157, 150, 76, 11, 0, 0, 0, 132, 0, 35, 0, -113, -69, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1492, 100, 12, 16, 0, 0, 0, 6, 0, }; final static int YYTABLESIZE=1670; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 94, 123, 45, 96, 126, 27, 121, 94, 1, 27, 126, 122, 94, 27, 86, 126, 132, 45, 135, 136, 43, 168, 21, 136, 5, 145, 94, 81, 24, 173, 81, 123, 172, 18, 7, 64, 121, 119, 43, 120, 126, 122, 65, 9, 81, 81, 10, 63, 65, 127, 59, 65, 181, 59, 183, 127, 88, 80, 23, 88, 127, 81, 25, 29, 94, 65, 65, 59, 59, 64, 65, 87, 59, 42, 87, 44, 65, 30, 195, 81, 31, 63, 38, 197, 40, 127, 39, 84, 41, 85, 94, 95, 94, 96, 97, 129, 66, 80, 98, 66, 65, 81, 59, 64, 99, 32, 130, 32, 137, 107, 65, 108, 138, 66, 66, 43, 109, 144, 66, 110, 60, 194, 141, 60, 64, 41, 142, 66, 146, 164, 166, 65, 186, 170, 175, 176, 63, 60, 60, 189, 172, 191, 60, 193, 64, 196, 80, 1, 66, 14, 81, 65, 47, 19, 5, 18, 63, 85, 95, 41, 6, 19, 102, 36, 64, 12, 13, 14, 15, 16, 180, 86, 60, 169, 0, 0, 63, 80, 0, 80, 0, 81, 0, 81, 64, 0, 0, 17, 0, 0, 26, 65, 0, 41, 28, 0, 63, 0, 37, 0, 0, 0, 80, 80, 30, 0, 81, 81, 80, 0, 0, 0, 81, 12, 13, 14, 15, 16, 0, 47, 47, 0, 0, 0, 94, 94, 94, 94, 94, 94, 0, 94, 94, 94, 94, 0, 94, 94, 94, 94, 94, 94, 94, 94, 117, 118, 0, 94, 94, 47, 117, 118, 47, 94, 94, 94, 94, 94, 94, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 117, 118, 58, 59, 65, 65, 59, 59, 60, 61, 0, 0, 62, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 59, 0, 0, 0, 0, 60, 61, 0, 0, 62, 12, 13, 14, 15, 16, 46, 66, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 59, 105, 46, 0, 47, 60, 60, 0, 0, 62, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 0, 0, 48, 0, 60, 61, 48, 48, 48, 48, 48, 48, 48, 12, 13, 14, 15, 16, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 67, 0, 0, 93, 0, 67, 67, 0, 67, 67, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 45, 67, 0, 67, 67, 48, 0, 48, 52, 0, 0, 0, 44, 52, 52, 0, 52, 52, 52, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 44, 52, 67, 52, 52, 0, 0, 0, 0, 0, 134, 0, 125, 123, 124, 128, 0, 147, 121, 119, 0, 120, 126, 122, 0, 123, 0, 0, 0, 165, 121, 119, 52, 120, 126, 122, 125, 0, 124, 128, 0, 0, 0, 127, 0, 0, 0, 0, 125, 123, 124, 128, 0, 167, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 125, 0, 124, 128, 123, 0, 0, 127, 0, 121, 119, 174, 120, 126, 122, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 125, 0, 124, 128, 127, 0, 0, 0, 0, 0, 0, 125, 123, 124, 128, 0, 0, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 178, 0, 125, 0, 124, 128, 0, 0, 0, 127, 0, 177, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 48, 48, 0, 0, 127, 48, 48, 48, 48, 48, 48, 125, 0, 124, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 67, 67, 0, 0, 0, 67, 67, 67, 67, 67, 67, 0, 0, 0, 0, 127, 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 52, 0, 0, 0, 52, 52, 52, 52, 52, 52, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 125, 0, 124, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 111, 112, 0, 0, 127, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190, 125, 0, 124, 128, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 51, 0, 0, 0, 0, 51, 51, 0, 51, 51, 51, 0, 123, 0, 0, 0, 127, 121, 119, 0, 120, 126, 122, 51, 123, 51, 51, 0, 0, 121, 119, 0, 120, 126, 122, 125, 123, 124, 0, 0, 0, 121, 119, 0, 120, 126, 122, 125, 0, 124, 0, 0, 0, 0, 51, 0, 0, 0, 0, 125, 0, 124, 0, 78, 0, 0, 127, 78, 78, 78, 78, 78, 0, 78, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 78, 78, 78, 80, 78, 78, 127, 80, 80, 80, 80, 80, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 80, 80, 0, 80, 80, 0, 0, 0, 111, 112, 78, 0, 0, 113, 114, 115, 116, 117, 118, 68, 0, 0, 0, 68, 68, 68, 68, 68, 0, 68, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 68, 68, 68, 0, 68, 68, 0, 0, 69, 0, 0, 0, 69, 69, 69, 69, 69, 56, 69, 0, 0, 56, 56, 56, 56, 56, 0, 56, 0, 69, 69, 69, 0, 69, 69, 68, 0, 0, 56, 56, 56, 0, 56, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 69, 54, 0, 54, 54, 54, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, 0, 54, 54, 0, 0, 0, 51, 51, 0, 0, 0, 51, 51, 51, 51, 51, 51, 0, 111, 0, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 54, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 113, 114, 0, 0, 117, 118, 0, 0, 0, 0, 57, 0, 0, 0, 57, 57, 57, 57, 57, 0, 57, 0, 78, 78, 0, 0, 0, 78, 78, 78, 78, 57, 57, 57, 58, 57, 57, 0, 58, 58, 58, 58, 58, 0, 58, 0, 80, 80, 0, 0, 0, 80, 80, 80, 80, 58, 58, 58, 0, 58, 58, 55, 0, 55, 55, 55, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 0, 55, 55, 0, 0, 63, 68, 68, 63, 58, 0, 68, 68, 68, 68, 0, 64, 0, 0, 64, 0, 0, 63, 63, 0, 0, 0, 63, 0, 0, 0, 0, 55, 64, 64, 69, 69, 0, 64, 0, 69, 69, 69, 69, 56, 56, 0, 0, 0, 56, 56, 56, 56, 62, 0, 61, 62, 63, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 62, 62, 61, 61, 0, 62, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 0, 0, 0, 54, 54, 54, 54, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 57, 0, 0, 0, 57, 57, 57, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, 58, 58, 58, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 0, 0, 0, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 63, 0, 0, 0, 0, 0, 63, 63, 0, 0, 64, 64, 0, 0, 0, 0, 0, 64, 64, 0, 0, 0, 0, 0, 88, 92, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 88, 103, 104, 106, 0, 0, 0, 0, 0, 0, 0, 62, 62, 61, 61, 0, 0, 0, 62, 62, 61, 61, 131, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 149, 150, 151, 152, 153, 0, 0, 154, 155, 156, 157, 158, 159, 160, 0, 161, 162, 163, 0, 0, 0, 0, 0, 0, 88, 0, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 182, 0, 0, 0, 0, 0, 185, 0, 0, 0, 187, 0, 188, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 37, 59, 59, 46, 91, 42, 40, 261, 91, 46, 47, 45, 91, 41, 46, 85, 41, 288, 289, 41, 134, 11, 289, 276, 291, 59, 41, 17, 41, 44, 37, 44, 125, 263, 33, 42, 43, 59, 45, 46, 47, 40, 276, 58, 59, 123, 45, 41, 91, 41, 44, 165, 44, 167, 91, 41, 45, 276, 44, 91, 45, 59, 40, 53, 58, 59, 58, 59, 33, 63, 41, 63, 38, 44, 40, 40, 93, 191, 93, 40, 45, 41, 196, 41, 91, 44, 40, 123, 40, 123, 40, 125, 40, 40, 61, 41, 85, 40, 44, 93, 85, 93, 33, 40, 29, 276, 31, 40, 59, 40, 59, 91, 58, 59, 39, 59, 276, 63, 59, 41, 190, 41, 44, 33, 123, 41, 125, 276, 40, 59, 40, 276, 41, 41, 41, 45, 58, 59, 41, 44, 268, 63, 41, 33, 41, 134, 0, 93, 123, 134, 40, 276, 41, 59, 41, 45, 41, 59, 123, 3, 11, 62, 31, 33, 257, 258, 259, 260, 261, 164, 40, 93, 136, -1, -1, 45, 165, -1, 167, -1, 165, -1, 167, 33, -1, -1, 279, -1, -1, 276, 40, -1, 123, 276, -1, 45, -1, 276, -1, -1, -1, 190, 191, 93, -1, 190, 191, 196, -1, -1, -1, 196, 257, 258, 259, 260, 261, -1, 276, 276, -1, -1, -1, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, 276, 286, 287, -1, 280, 281, 276, 286, 287, 276, 286, 287, 288, 289, 290, 291, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, 286, 287, 280, 281, 277, 278, 277, 278, 286, 287, -1, -1, 290, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, 281, -1, -1, -1, -1, 286, 287, -1, -1, 290, 257, 258, 259, 260, 261, 262, 278, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, 281, 261, 262, -1, 264, 277, 278, -1, -1, 290, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, -1, -1, 37, -1, 286, 287, 41, 42, 43, 44, 45, 46, 47, 257, 258, 259, 260, 261, -1, -1, -1, -1, -1, 58, 59, 60, 61, 62, 63, 37, -1, -1, 276, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, 91, -1, 93, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, 59, 60, 91, 62, 63, -1, -1, -1, -1, -1, 58, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, 91, 45, 46, 47, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, -1, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, 63, 37, -1, -1, 91, -1, 42, 43, 44, 45, 46, 47, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 60, -1, 62, 63, 91, -1, -1, -1, -1, -1, -1, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 91, -1, 58, -1, 60, -1, 62, 63, -1, -1, -1, 91, -1, 93, -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 277, 278, -1, -1, 91, 282, 283, 284, 285, 286, 287, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 276, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, 91, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 277, 278, -1, -1, 91, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, -1, 62, 63, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 91, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, 60, 37, 62, -1, -1, -1, 42, 43, -1, 45, 46, 47, 60, -1, 62, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, -1, 37, -1, -1, 91, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, 58, 59, 60, 37, 62, 63, 91, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, 277, 278, 93, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, 93, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 37, -1, -1, -1, 41, 42, 43, 44, 45, 37, 47, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 58, 59, 60, -1, 62, 63, 93, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 93, 41, -1, 43, 44, 45, -1, -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 277, -1, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, 93, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, 282, 283, -1, -1, 286, 287, -1, -1, -1, -1, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 58, 59, 60, 37, 62, 63, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 58, 59, 60, -1, 62, 63, 41, -1, 43, 44, 45, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 41, 277, 278, 44, 93, -1, 282, 283, 284, 285, -1, 41, -1, -1, 44, -1, -1, 58, 59, -1, -1, -1, 63, -1, -1, -1, -1, 93, 58, 59, 277, 278, -1, 63, -1, 282, 283, 284, 285, 277, 278, -1, -1, -1, 282, 283, 284, 285, 41, -1, 41, 44, 93, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, 58, 59, 58, 59, -1, 63, -1, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, -1, -1, 284, 285, -1, -1, 277, 278, -1, -1, -1, -1, -1, 284, 285, -1, -1, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, -1, -1, -1, -1, -1, -1, -1, 277, 278, 277, 278, -1, -1, -1, 284, 285, 284, 285, 84, -1, 86, -1, -1, -1, -1, -1, -1, -1, -1, 95, -1, -1, 98, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 111, 112, 113, 114, 115, 116, -1, -1, 119, 120, 121, 122, 123, 124, 125, -1, 127, 128, 129, -1, -1, -1, -1, -1, -1, 136, -1, 138, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 164, -1, 166, -1, -1, -1, -1, -1, 172, -1, -1, -1, 176, -1, 178, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=293; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'","'?'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING", "CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK", "NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR", "STATIC","INSTANCEOF","NUMINSTANCES","LESS_EQUAL","GREATER_EQUAL","EQUAL", "NOT_EQUAL","DOUBLE_PLUS","DOUBLE_MINUS","FI","TRIBLE_OR","DO","OD","UMINUS", "EMPTY", }; final static String yyrule[] = { "$accept : Program", "Program : ClassList", "ClassList : ClassList ClassDef", "ClassList : ClassDef", "VariableDef : Variable ';'", "Variable : Type IDENTIFIER", "Type : INT", "Type : VOID", "Type : BOOL", "Type : STRING", "Type : CLASS IDENTIFIER", "Type : Type '[' ']'", "ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'", "ExtendsClause : EXTENDS IDENTIFIER", "ExtendsClause :", "FieldList : FieldList VariableDef", "FieldList : FieldList FunctionDef", "FieldList :", "Formals : VariableList", "Formals :", "VariableList : VariableList ',' Variable", "VariableList : Variable", "FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock", "FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock", "StmtBlock : '{' StmtList '}'", "StmtList : StmtList Stmt", "StmtList :", "Stmt : VariableDef", "Stmt : SimpleStmt ';'", "Stmt : IfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "Stmt : ReturnStmt ';'", "Stmt : PrintStmt ';'", "Stmt : BreakStmt ';'", "Stmt : StmtBlock", "Stmt : GuardedIFStmt", "Stmt : GuaededDOStmt", "GuardedES : Expr ':' Stmt", "GuardedStmts : GuardedES", "GuardedStmts : GuardedStmts TRIBLE_OR GuardedES", "GuardedIFStmt : IF GuardedStmts FI", "GuaededDOStmt : DO GuardedStmts OD", "SimpleStmt : LValue '=' Expr", "SimpleStmt : Call", "SimpleStmt :", "Receiver : Expr '.'", "Receiver :", "LValue : Receiver IDENTIFIER", "LValue : Expr '[' Expr ']'", "Call : Receiver IDENTIFIER '(' Actuals ')'", "Expr : LValue", "Expr : Call", "Expr : Constant", "Expr : Expr '+' Expr", "Expr : Expr '-' Expr", "Expr : Expr '*' Expr", "Expr : Expr '/' Expr", "Expr : Expr '%' Expr", "Expr : Expr EQUAL Expr", "Expr : Expr NOT_EQUAL Expr", "Expr : Expr '<' Expr", "Expr : Expr '>' Expr", "Expr : Expr LESS_EQUAL Expr", "Expr : Expr GREATER_EQUAL Expr", "Expr : Expr AND Expr", "Expr : Expr OR Expr", "Expr : '(' Expr ')'", "Expr : '-' Expr", "Expr : '!' Expr", "Expr : READ_INTEGER '(' ')'", "Expr : READ_LINE '(' ')'", "Expr : THIS", "Expr : NEW IDENTIFIER '(' ')'", "Expr : NEW Type '[' Expr ']'", "Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'", "Expr : '(' CLASS IDENTIFIER ')' Expr", "Expr : Expr DOUBLE_PLUS", "Expr : DOUBLE_PLUS Expr", "Expr : Expr DOUBLE_MINUS", "Expr : DOUBLE_MINUS Expr", "Expr : Expr '?' Expr ':' Expr", "Expr : NUMINSTANCES '(' IDENTIFIER ')'", "Constant : LITERAL", "Constant : NULL", "Actuals : ExprList", "Actuals :", "ExprList : ExprList ',' Expr", "ExprList : Expr", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt", "BreakStmt : BREAK", "IfStmt : IF '(' Expr ')' Stmt ElseClause", "ElseClause : ELSE Stmt", "ElseClause :", "ReturnStmt : RETURN Expr", "ReturnStmt : RETURN", "PrintStmt : PRINT '(' ExprList ')'", }; //#line 487 "Parser.y" /** * 打印当前归约所用的语法规则<br> * 请勿修改。 */ public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 741 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 58 "Parser.y" { tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc); } break; case 2: //#line 64 "Parser.y" { yyval.clist.add(val_peek(0).cdef); } break; case 3: //#line 68 "Parser.y" { yyval.clist = new ArrayList<Tree.ClassDef>(); yyval.clist.add(val_peek(0).cdef); } break; case 5: //#line 78 "Parser.y" { yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc); } break; case 6: //#line 84 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc); } break; case 7: //#line 88 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc); } break; case 8: //#line 92 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc); } break; case 9: //#line 96 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc); } break; case 10: //#line 100 "Parser.y" { yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc); } break; case 11: //#line 104 "Parser.y" { yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc); } break; case 12: //#line 110 "Parser.y" { yyval.cdef = new Tree.ClassDef(val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc); } break; case 13: //#line 116 "Parser.y" { yyval.ident = val_peek(0).ident; } break; case 14: //#line 120 "Parser.y" { yyval = new SemValue(); } break; case 15: //#line 126 "Parser.y" { yyval.flist.add(val_peek(0).vdef); } break; case 16: //#line 130 "Parser.y" { yyval.flist.add(val_peek(0).fdef); } break; case 17: //#line 134 "Parser.y" { yyval = new SemValue(); yyval.flist = new ArrayList<Tree>(); } break; case 19: //#line 142 "Parser.y" { yyval = new SemValue(); yyval.vlist = new ArrayList<Tree.VarDef>(); } break; case 20: //#line 149 "Parser.y" { yyval.vlist.add(val_peek(0).vdef); } break; case 21: //#line 153 "Parser.y" { yyval.vlist = new ArrayList<Tree.VarDef>(); yyval.vlist.add(val_peek(0).vdef); } break; case 22: //#line 160 "Parser.y" { yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 23: //#line 164 "Parser.y" { yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 24: //#line 170 "Parser.y" { yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc); } break; case 25: //#line 176 "Parser.y" { yyval.slist.add(val_peek(0).stmt); } break; case 26: //#line 180 "Parser.y" { yyval = new SemValue(); yyval.slist = new ArrayList<Tree>(); } break; case 27: //#line 187 "Parser.y" { yyval.stmt = val_peek(0).vdef; } break; case 28: //#line 192 "Parser.y" { if (yyval.stmt == null) { yyval.stmt = new Tree.Skip(val_peek(0).loc); } } break; case 38: //#line 209 "Parser.y" { yyval.guardedES = new Tree.GuardedES(val_peek(2).expr , val_peek(0).stmt , val_peek(1).loc); } break; case 39: //#line 215 "Parser.y" { yyval.myList = new ArrayList<Tree.GuardedES>(); yyval.myList.add(val_peek(0).guardedES); } break; case 40: //#line 222 "Parser.y" { yyval.myList.add(val_peek(0).guardedES); } break; case 41: //#line 229 "Parser.y" { yyval.stmt = new Tree.GuardedIFStmt(val_peek(1).myList , val_peek(2).loc); } break; case 42: //#line 235 "Parser.y" { yyval.stmt = new Tree.GuardedDOStmt(val_peek(1).myList , val_peek(2).loc); } break; case 43: //#line 241 "Parser.y" { yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc); } break; case 44: //#line 245 "Parser.y" { yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc); } break; case 45: //#line 249 "Parser.y" { yyval = new SemValue(); } break; case 47: //#line 256 "Parser.y" { yyval = new SemValue(); } break; case 48: //#line 262 "Parser.y" { yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc); if (val_peek(1).loc == null) { yyval.loc = val_peek(0).loc; } } break; case 49: //#line 269 "Parser.y" { yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc); } break; case 50: //#line 275 "Parser.y" { yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc); if (val_peek(4).loc == null) { yyval.loc = val_peek(3).loc; } } break; case 51: //#line 284 "Parser.y" { yyval.expr = val_peek(0).lvalue; } break; case 54: //#line 290 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 55: //#line 294 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 56: //#line 298 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 57: //#line 302 "Parser.y" { yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 58: //#line 306 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 59: //#line 310 "Parser.y" { yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 60: //#line 314 "Parser.y" { yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 61: //#line 318 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 62: //#line 322 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 63: //#line 326 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 64: //#line 330 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 65: //#line 334 "Parser.y" { yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 66: //#line 338 "Parser.y" { yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 67: //#line 342 "Parser.y" { yyval = val_peek(1); } break; case 68: //#line 346 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc); } break; case 69: //#line 350 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc); } break; case 70: //#line 354 "Parser.y" { yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc); } break; case 71: //#line 358 "Parser.y" { yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc); } break; case 72: //#line 362 "Parser.y" { yyval.expr = new Tree.ThisExpr(val_peek(0).loc); } break; case 73: //#line 366 "Parser.y" { yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc); } break; case 74: //#line 370 "Parser.y" { yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc); } break; case 75: //#line 374 "Parser.y" { yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc); } break; case 76: //#line 378 "Parser.y" { yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc); } break; case 77: //#line 382 "Parser.y" { yyval.expr = new Tree.Unary(Tree.POSTINC, val_peek(1).expr, val_peek(0).loc); } break; case 78: //#line 386 "Parser.y" { yyval.expr = new Tree.Unary(Tree.PREINC, val_peek(0).expr, val_peek(1).loc); } break; case 79: //#line 390 "Parser.y" { yyval.expr = new Tree.Unary(Tree.POSTDEC, val_peek(1).expr, val_peek(0).loc); } break; case 80: //#line 394 "Parser.y" { yyval.expr = new Tree.Unary(Tree.PREDEC, val_peek(0).expr, val_peek(1).loc); } break; case 81: //#line 398 "Parser.y" { yyval.expr = new Tree.QuestionAndColon(Tree.QUESTION_COLON, val_peek(4).expr, val_peek(2).expr, val_peek(0).expr, val_peek(4).loc); } break; case 82: //#line 402 "Parser.y" { yyval.expr = new Tree.NumTest(val_peek(1).ident, val_peek(3).loc); } break; case 83: //#line 408 "Parser.y" { yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc); } break; case 84: //#line 412 "Parser.y" { yyval.expr = new Null(val_peek(0).loc); } break; case 86: //#line 419 "Parser.y" { yyval = new SemValue(); yyval.elist = new ArrayList<Tree.Expr>(); } break; case 87: //#line 426 "Parser.y" { yyval.elist.add(val_peek(0).expr); } break; case 88: //#line 430 "Parser.y" { yyval.elist = new ArrayList<Tree.Expr>(); yyval.elist.add(val_peek(0).expr); } break; case 89: //#line 437 "Parser.y" { yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc); } break; case 90: //#line 443 "Parser.y" { yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc); } break; case 91: //#line 449 "Parser.y" { yyval.stmt = new Tree.Break(val_peek(0).loc); } break; case 92: //#line 455 "Parser.y" { yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc); } break; case 93: //#line 461 "Parser.y" { yyval.stmt = val_peek(0).stmt; } break; case 94: //#line 465 "Parser.y" { yyval = new SemValue(); } break; case 95: //#line 471 "Parser.y" { yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc); } break; case 96: //#line 475 "Parser.y" { yyval.stmt = new Tree.Return(null, val_peek(0).loc); } break; case 97: //#line 481 "Parser.y" { yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc); } break; //#line 1397 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
PKUanonym/REKCARC-TSC-UHT
大三上/编译原理/hw/2015_刘智峰_PA/PA1/src/decaf/frontend/Parser.java
759
/****************************************************************************** * Copyright 2015 sakaiproject.org Licensed under the Educational * Community License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://opensource.org/licenses/ECL-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. ******************************************************************************/ package org.sakaiproject.mbm.tool; import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Locale; import javax.annotation.Resource; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.sakaiproject.authz.api.SecurityService; import org.sakaiproject.component.api.ServerConfigurationService; import org.sakaiproject.mbm.tool.entities.ModulesFilterEntity; import org.sakaiproject.mbm.tool.entities.MessageEntity; import org.sakaiproject.mbm.tool.entities.SearchEntity; import org.sakaiproject.messagebundle.api.MessageBundleProperty; import org.sakaiproject.messagebundle.api.MessageBundleService; import org.sakaiproject.tool.api.SessionManager; import org.sakaiproject.user.api.PreferencesService; import org.springframework.context.MessageSource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; /** * MainController * * This is the controller used by Spring MVC to handle requests * * @author Earle Nietzel * ([email protected]) * */ @Slf4j @Controller public class MainController { @Resource(name="org.sakaiproject.messagebundle.api.MessageBundleService") private MessageBundleService messageBundleService; @Inject private ServerConfigurationService serverConfigurationService; @Inject private SecurityService securityService; @Inject private MessageSource messageSource; @Inject private PreferencesService preferencesService; @Inject private SessionManager sessionManager; @ModelAttribute("listMessageProperties") public List<MessageBundleProperty> listMessageProperties() { return messageBundleService.getAllProperties(null, null, null); } @ModelAttribute("listModifiedMessageProperties") public List<MessageBundleProperty> listModifiedMessageProperties() { return messageBundleService.getModifiedProperties(0, 0, 0, -1); } @ModelAttribute("countMessageProperties") public int countMessageBundleProperties() { return messageBundleService.getAllPropertiesCount(); } @ModelAttribute("countModifiedMessageProperties") public int countModifiedMessageProperties() { return messageBundleService.getModifiedPropertiesCount(); } @ModelAttribute("listMessagePropertyModules") public List<String> listMessagePropertyModules() { return messageBundleService.getAllModuleNames(); } @ModelAttribute("listMessagePropertyLocales") public List<String> listMessagePropertyLocales() { return messageBundleService.getLocales(); } @ModelAttribute("isLoadBundlesFromDb") public boolean isLoadBundlesFromDb() { return messageBundleService.isEnabled(); } @ModelAttribute("isAdmin") public boolean isAdmin() { return securityService.isSuperUser(); } @RequestMapping(value = {"/", "/index"}, method = RequestMethod.GET) public String showIndex(Model model) { log.debug("showIndex()"); return "index"; } @RequestMapping(value = "/modified", method = RequestMethod.GET) public String showModified(Model model) { log.debug("showModified()"); return "modified"; } // @RequestMapping(value = "/modified", params = {"dtf=csv","dti=modified"}, method = RequestMethod.GET, produces = "text/csv") // public void csv(@DatatablesParams DatatablesCriterias criterias, HttpServletRequest request, HttpServletResponse response) // throws IOException { // log.debug("csv() export"); // // String userId = sessionManager.getCurrentSessionUserId(); // Locale userLocale = preferencesService.getLocale(userId); // List<MessageBundleProperty> list = listModifiedMessageProperties(); // // ExportConf csvConf = new ExportConf.Builder(ReservedFormat.CSV) // .fileName("messages-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern(messageSource.getMessage("modified.csv.date.format", null, userLocale)))) // .header(true) // .exportClass(new CsvExport()) // .build(); // // HtmlTable csvTable = new HtmlTableBuilder<MessageBundleProperty>().newBuilder("modified", list, request, csvConf) // .column().fillWithProperty("id").title(messageSource.getMessage("modified.csv.id", null, userLocale)) // .column().fillWithProperty("moduleName").title(messageSource.getMessage("modified.csv.module", null, userLocale)) // .column().fillWithProperty("propertyName").title(messageSource.getMessage("modified.csv.property", null, userLocale)) // .column().fillWithProperty("value").title(messageSource.getMessage("modified.csv.value", null, userLocale)) // .column().fillWithProperty("defaultValue").title(messageSource.getMessage("modified.csv.default", null, userLocale)) // .column().fillWithProperty("locale").title(messageSource.getMessage("modified.csv.locale", null, userLocale)) // .build(); // // ExportUtils.renderExport(csvTable, csvConf, response); // } @RequestMapping(value = "/modules", method = RequestMethod.GET) public String showModules(Model model) { log.debug("showModules()"); List<MessageBundleProperty> properties = Collections.emptyList(); model.addAttribute("properties", properties); ModulesFilterEntity filter = new ModulesFilterEntity(); model.addAttribute(filter); return "modules"; } @RequestMapping(value = "/modules", params={"filter"}, method = RequestMethod.POST) public String processModules(final ModulesFilterEntity modulesFilterEntity, final BindingResult bindingResult, final ModelMap model) { if (bindingResult.hasErrors()) { return "modules"; } log.debug("processModules(): ModulesFilteredEntity = " + modulesFilterEntity); model.addAttribute("properties", messageBundleService.getAllProperties(modulesFilterEntity.getLocale(), null, modulesFilterEntity.getModule())); return "modules"; } @RequestMapping(value = "/edit", params = { "id" }, method = RequestMethod.GET) public String showEdit(@RequestParam long id, Model model) { log.debug("showEdit()"); MessageBundleProperty property = messageBundleService.getMessageBundleProperty(id); model.addAttribute(property); MessageEntity message = new MessageEntity(id, property.getValue()); model.addAttribute(message); return "edit"; } @RequestMapping(value = "/edit", params={"save"}, method = RequestMethod.POST) public String processSaveEdit(final MessageEntity messageEntity, final BindingResult bindingResult, final ModelMap model) { if (bindingResult.hasErrors()) { return "modified"; } log.debug("processSaveEdit(): MessageEntity = " + messageEntity); MessageBundleProperty property = messageBundleService.getMessageBundleProperty(messageEntity.getId()); property.setValue(messageEntity.getValue()); if (securityService.isSuperUser()) { messageBundleService.updateMessageBundleProperty(property); } else { throw new SecurityException("Only an admin type user is allowed to update message bundle properties"); } model.clear(); return "redirect:/modified"; } @RequestMapping(value = "/edit", params={"revert"}, method = RequestMethod.POST) public String processRevertEdit(final MessageEntity messageEntity, final BindingResult bindingResult, final ModelMap model) { if (bindingResult.hasErrors()) { return "modified"; } log.debug("processRevertEdit(): MessageEntity = " + messageEntity); MessageBundleProperty property = messageBundleService.getMessageBundleProperty(messageEntity.getId()); if (securityService.isSuperUser()) { messageBundleService.revert(property); } else { throw new SecurityException("Only an admin type user is allowed to revert message bundle properties"); } model.clear(); return "redirect:/modified"; } @RequestMapping(value = "/search", method = RequestMethod.GET) public String showSearch(Model model) { log.debug("showSearch()"); List<MessageBundleProperty> properties = Collections.emptyList(); model.addAttribute("properties", properties); SearchEntity search = new SearchEntity(); model.addAttribute(search); return "search"; } @RequestMapping(value = "/search", params={"search"}, method = RequestMethod.POST) public String processSearch(final SearchEntity searchEntity, final BindingResult bindingResult, final ModelMap model) { if (bindingResult.hasErrors()) { return "search"; } log.debug("processSearch(): searchEntity = " + searchEntity); model.addAttribute("properties", messageBundleService.search(searchEntity.getValue(), null, null, searchEntity.getLocale())); return "search"; } }
sakaiproject/sakai
site/sakai-message-bundle-manager-tool/src/main/java/org/sakaiproject/mbm/tool/MainController.java
760
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /* Anagram Game Application */ package com.toy.anagrams.lib; /** * Implementation of the logic for the Anagram Game application. */ final class StaticWordLibrary extends WordLibrary { private static final String[] WORD_LIST = { "abstraction", "ambiguous", "arithmetic", "backslash", "bitmap", "circumstance", "combination", "consequently", "consortium", "decrementing", "dependency", "disambiguate", "dynamic", "encapsulation", "equivalent", "expression", "facilitate", "fragment", "hexadecimal", "implementation", "indistinguishable", "inheritance", "internet", "java", "localization", "microprocessor", "navigation", "optimization", "parameter", "patrick", "pickle", "polymorphic", "rigorously", "simultaneously", "specification", "structure", "lexical", "likewise", "management", "manipulate", "mathematics", "hotjava", "vertex", "unsigned", "traditional"}; private static final String[] SCRAMBLED_WORD_LIST = { "batsartcoin", "maibuguos", "ratimhteci", "abkclssha", "ibmtpa", "iccrmutsnaec", "ocbmnitaoni", "ocsnqeeutnyl", "ocsnroitmu", "edrcmeneitgn", "edepdnneyc", "idasbmgiauet", "ydanicm", "neacsplutaoni", "qeiuaveltn", "xerpseisno", "aficilatet", "rfgaemtn", "ehaxedicalm", "milpmeneatitno", "niidtsniugsiahleb", "niehiratcen", "nietnret", "ajav", "olacilazitno", "imrcpoorecssro", "anivagitno", "poitimazitno", "aparemert", "aprtcki", "ipkcel", "opylomprich", "irogorsuyl", "isumtlnaoesuyl", "psceficitaoni", "tsurtcreu", "elixalc", "ilekiwse", "amanegemtn", "aminupalet", "amhtmetacsi", "ohjtvaa", "evtrxe", "nuisngde", "rtdatioialn" }; static final WordLibrary DEFAULT = new StaticWordLibrary(); /** * Singleton class. */ private StaticWordLibrary() { } /** * Gets the word at a given index. * @param idx index of required word * @return word at that index in its natural form */ public String getWord(int idx) { return WORD_LIST[idx]; } /** * Gets the word at a given index in its scrambled form. * @param idx index of required word * @return word at that index in its scrambled form */ public String getScrambledWord(int idx) { return SCRAMBLED_WORD_LIST[idx]; } /** * Gets the number of words in the library. * @return the total number of plain/scrambled word pairs in the library */ public int getSize() { return WORD_LIST.length; } /** * Checks whether a user's guess for a word at the given index is correct. * @param idx index of the word guessed * @param userGuess the user's guess for the actual word * @return true if the guess was correct; false otherwise */ public boolean isCorrect(int idx, String userGuess) { return userGuess.equals(getWord(idx)); } }
apache/netbeans
java/java.examples/anagrams/src/com/toy/anagrams/lib/StaticWordLibrary.java
761
package models; import java.util.List; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import play.db.ebean.Model; @Entity public class Horse extends Model { @Id public Long id; public String name; public final Integer price; @ManyToOne public Player player; public Horse(Integer price) { this.price = price; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } private static Finder<Long, Horse> find = new Finder<Long, Horse>(Long.class, Horse.class); public static List<Horse> findAvailableHorses() { // TODO only available horses return find.all(); } public static Horse refresh(Horse horse) { if (horse == null || horse.id == null) { throw new IllegalArgumentException("paard of id ontbreekt!"); } Horse refreshedHorse = findById(horse.id); if (refreshedHorse == null) { throw new IllegalArgumentException("Kon het paard met id " + horse.id + " niet verversen"); } return refreshedHorse; } public static Horse findById(Long horseId) { return find.byId(horseId); } }
cegekaplaycc/holdYourHorses2
app/models/Horse.java
762
/****************************************************************************** * $URL: $ * $Id: $ ****************************************************************************** * * Copyright (c) 2003-2014 The Apereo Foundation * * Licensed under the Educational Community License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://opensource.org/licenses/ecl2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *****************************************************************************/ package org.sakaiproject.config.impl; import java.util.Collections; import java.util.Date; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.hibernate.Criteria; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.springframework.orm.hibernate5.support.HibernateDaoSupport; import org.sakaiproject.config.api.HibernateConfigItem; import org.sakaiproject.config.api.HibernateConfigItemDao; import org.sakaiproject.db.api.SqlService; /** * KNL-1063 * HibernateConfigItemDaoImpl * Implementation for HibernateConfigItemDao * * @author Earle Nietzel * Created on Mar 8, 2013 */ @Slf4j public class HibernateConfigItemDaoImpl extends HibernateDaoSupport implements HibernateConfigItemDao { private static String SAKAI_CONFIG_ITEM_SQL = "sakai_config_item"; private SqlService sqlService; private boolean autoDdl; public void init() { if (autoDdl) { log.info("init: autoDDL " + SAKAI_CONFIG_ITEM_SQL); sqlService.ddl(this.getClass().getClassLoader(), SAKAI_CONFIG_ITEM_SQL); } } public void setSqlService(SqlService sqlService) { this.sqlService = sqlService; } public void setAutoDdl(boolean autoDdl) { this.autoDdl = autoDdl; } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#create(org.sakaiproject.config.api.HibernateConfigItem) */ @Override public void create(HibernateConfigItem item) { if (item != null) { currentSession().save(item); } } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#read(java.lang.Long) */ @Override public HibernateConfigItem read(Long id) { if (id == null) { return null; } return (HibernateConfigItem) currentSession().get(HibernateConfigItem.class, id); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#update(org.sakaiproject.config.api.HibernateConfigItem) */ @Override public void update(HibernateConfigItem item) { if (item == null) { return; } currentSession().update(item); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#delete(org.sakaiproject.config.api.HibernateConfigItem) */ @Override public void delete(HibernateConfigItem item) { if (item == null) { return; } currentSession().delete(item); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#countByNode(java.lang.String) */ public int countByNode(String node) { if (node == null) { return -1; } Criteria criteria = currentSession().createCriteria(HibernateConfigItem.class) .setProjection(Projections.rowCount()) .add(Restrictions.eq("node", node)); return ((Number) criteria.uniqueResult()).intValue(); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#countByNodeAndName(java.lang.String, java.lang.String) */ @Override public int countByNodeAndName(String node, String name) { if (node == null || name == null) { return -1; } Criteria criteria = currentSession().createCriteria(HibernateConfigItem.class) .setProjection(Projections.rowCount()) .add(Restrictions.eq("node", node)) .add(Restrictions.eq("name", name)); return ((Number) criteria.uniqueResult()).intValue(); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#saveOrUpdateAll(java.util.List) */ @Override public void saveOrUpdateAll(List<HibernateConfigItem> items) { if (items == null) { return; } for (HibernateConfigItem item : items) { if (item != null) { saveOrUpdate(item); } } } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#saveOrUpdate(org.sakaiproject.config.api.HibernateConfigItem) */ @Override public void saveOrUpdate(HibernateConfigItem item) { if (item == null) { return; } currentSession().saveOrUpdate(item); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#findAllByCriteriaByNode(java.lang.String, java.lang.String, java.lang.Boolean, java.lang.Boolean, java.lang.Boolean, java.lang.Boolean) */ @SuppressWarnings("unchecked") @Override public List<HibernateConfigItem> findAllByCriteriaByNode(String node, String name, Boolean defaulted, Boolean registered, Boolean dynamic, Boolean secured) { if (node == null) { // TODO get the globals only return Collections.emptyList(); } Criteria criteria = currentSession().createCriteria(HibernateConfigItem.class); criteria.add(Restrictions.eq("node", node)); // TODO make this search by null also if (name != null && name.length() > 0) { criteria.add(Restrictions.eq("name", name)); } if (defaulted != null) { criteria.add(Restrictions.eq("defaulted", defaulted)); } if (registered != null) { criteria.add(Restrictions.eq("registered", registered)); } if (dynamic != null) { criteria.add(Restrictions.eq("dynamic", dynamic)); } if (secured != null) { criteria.add(Restrictions.eq("secured", secured)); } // TODO throw away cases where node is null AND node is set (only keep node is set) - use order by name & node return criteria.list(); } /* (non-Javadoc) * @see org.sakaiproject.config.api.HibernateConfigItemDao#findPollOnByNode(java.lang.String, java.util.Date, java.util.Date) */ @SuppressWarnings("unchecked") @Override public List<HibernateConfigItem> findPollOnByNode(String node, Date onOrAfter, Date before) { Criteria criteria = currentSession().createCriteria(HibernateConfigItem.class) .add(Restrictions.eq("node", node)); if (onOrAfter == null && before == null) { criteria.add(Restrictions.isNotNull("pollOn")); } else { if (onOrAfter != null) { criteria.add(Restrictions.ge("pollOn", onOrAfter)); } if (before != null) { criteria.add(Restrictions.lt("pollOn", before)); } } return criteria.list(); } }
sakaiproject/sakai
kernel/kernel-impl/src/main/java/org/sakaiproject/config/impl/HibernateConfigItemDaoImpl.java
763
// -*- mode: java; c-basic-offset: 2; -*- // Copyright 2016 Massachusetts Institute of Technology. All rights reserved. /** * @fileoverview Dutch (Flanders (Belgium)/the Netherlands) strings. * @author [email protected] (volunteers from the Flemish Coderdojo Community) */ 'use strict'; goog.require('Blockly.Msg.nl'); goog.provide('AI.Blockly.Msg.nl'); /** * Due to the frequency of long strings, the 80-column wrap rule need not apply * to message files. */ Blockly.Msg.nl.switch_language_to_dutch = { // Switch language to Dutch. category: '', helpUrl: '', init: function() { Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT = 'Zoek op per paar sleutel %1 paren %2 nietGevonden %3'; Blockly.MSG_VARIABLE_CATEGORY = 'Variabelen'; Blockly.Msg.ADD_COMMENT = 'Commentaar toevoegen'; Blockly.Msg.EXPAND_BLOCK = 'Blok uitbreiden'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TITLE_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT = 'Verdeelt tekst in stukken met de tekst \'op\' als splitspunt en levert een lijst van de resultaten. \n"één,twee,drie,vier" splitsen op "," (komma) geeft de lijst "(één twee drie vier)" terug. \n"één-aardappel,twee-aardappel,drie-aardappel,vier" splitsen op "-aardappel," geeft ook de lijst "(één twee drie vier)" terug.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TOOLTIP = 'Geeft de waarde terug die was doorgegeven bij het openen van het scherm, meestal door een ander scherm in een app met meerdere schermen. Als er geen waarde was meegegeven, wordt er een lege tekst teruggegeven.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TITLE = 'item'; Blockly.Msg.DELETE_BLOCK = 'Verwijder blok'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TOOLTIP = 'Geeft het nummer terug in decimale notatie\nmet een bepaald aantal getallen achter de komma.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE = 'terwijl'; Blockly.Msg.LANG_COLOUR_PINK = 'roze'; Blockly.Msg.CONNECT_TO_DO_IT = 'U moet verbonden zijn met de AI Companion app of emulator om "Doe het" te gebruiken'; Blockly.Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT = 'krijg'; Blockly.Msg.LANG_MATH_TRIG_SIN = 'sin'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = 'ga verder met volgende iteratie'; Blockly.Msg.DISABLE_BLOCK = 'Schakel Blok uit'; Blockly.Msg.REPL_HELPER_Q = 'Helper?'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT = 'Vervang alle tekst %1 stukje tekst %2 vervangingstekst %3'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN = 'wanneer'; Blockly.Msg.LANG_COLOUR_CYAN = 'Lichtblauw'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_COLLAPSED_TEXT = 'sluit scherm met waarde'; Blockly.Msg.LANG_MATH_TRIG_ASIN = 'asin'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV = 'lijst naar .csv tabel'; Blockly.Msg.REPL_NOW_DOWNLOADING = 'We downloaden nu een update van de App Inventor server. Even geduld aub.'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TOOLTIP = 'specificeert een numerieke seed waarde\nvoor de willekeurige nummer maker'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT = 'zet om'; Blockly.Msg.LANG_MATH_SINGLE_OP_EXP = 'e^'; Blockly.Msg.LANG_TEXT_COMPARE_EQUAL = ' ='; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ROOT = 'Geeft de vierkantswortel van een getal.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TOOLTIP = 'Voeg items toe aan het einde van een lijst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_TEXT_COMPARE_GT = ' >'; Blockly.Msg.REPL_USB_CONNECTED_WAIT = 'USB verbonden, effe wachten aub'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES = 'lokale namen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR = 'maak kleur'; Blockly.Msg.LANG_MATH_DIVIDE = '÷'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP = 'Voert alle blokken uit in \'do\' en geeft een statement terug. Handig wanneer je een procedure wil uitvoeren voor een waarde terug te geven aan een variabele.'; Blockly.Msg.COPY_ALLBLOCKS = 'Kopieer alle blokken naar de rugzak'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT_LIST = 'op (lijst)'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT = 'globaal'; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE = 'invoer:'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_NOT_FOUND = 'nietGevonden'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP = 'Laat je toe variabelen te maken die enkel toegankelijk zijn in het doe deel van dit blok.'; Blockly.Msg.REPL_PLUGGED_IN_Q = 'Aangesloten?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP = ''; Blockly.Msg.HORIZONTAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST = 'is een lijst?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE = 'invoer'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_FROM = 'van'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TITLE_APPEND = 'voeg toe aan lijst'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX = ' binnen bereik'; Blockly.MSG_NEW_VARIABLE_TITLE = 'Nieuwe variabelenaam:'; Blockly.Msg.VERTICAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TITLE_REPLACE = 'vervang element in de lijst'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_ANY = 'Verdeelt de gegeven tekst in een lijst, waarbij elk element in de lijst \'\'op\'\' als het\nverdeelpunt, en geeft een lijst terug van het resultaat. \nSplitsen van "sinaasappel,banaan,appel,hondenvoer" met als "op" een lijst van 2 elementen met als eerste \nelement een komma en als tweede element "pel" geeft een lijst van 4 elementen: \n"(sinaasap banaan ap hondenvoer)".'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN = 'in'; Blockly.Msg.DO_IT = 'Voer uit'; Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE = 'absoluut'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME = 'functie die niets teruggeeft'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_TOOLTIP = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.BACKPACK_DOCUMENTATION = 'De Rugzak is een knip/plak functie. Het laat toe om blokken te kopieren van een project of scherm en ze in een ander scherm of project te plakken. Om te kopieren sleep je de blokken in de rugzak. Om te plakken klik je op het Rugzak icoon en sleep je de blokken in de werkplaats.</p><p> De inhoud van de Rugzak blijft behouden tijdens de ganse App Inventor sessie. Als je de App Inventor dicht doet, of als je je browser herlaadt, wordt de Rugzak leeggemaakt.</p><p>Voor meer info en een video, bekijk:</p><p><a href="/reference/other/backpack.html" target="_blank">http://ai2.appinventor.mit.edu/reference/other/backpack.html</a>'; Blockly.Msg.LANG_MATH_TRIG_ATAN2 = 'atan2'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX = 'aanroep '; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSEIF = 'of als'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN = 'resultaat'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_CALL = 'roep aan'; Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE = 'splits bij spaties'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV = 'lijst van .csv rij'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE = 'x'; Blockly.Msg.REPL_CONNECTION_FAILURE1 = 'Verbindingsfout'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST_OF_ANY = 'Splitst een gegeven tekst in een lijst met twee elementen. De eerste plaats van eender welk item in de lijst "aan" is het \'\'splitsingspunt\'\'. \n\nBijvoorbeeld als je "Ik hou van appels, bananen en ananas" splitst volgens de lijst "(ba,ap)", dan geeft dit \neen lijst van 2 elementen terug. Het eerste item is "Ik hou van" en het tweede item is \n"pels, bananen en ananas."'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE = 'open een ander scherm'; Blockly.Msg.LANG_LISTS_IS_LIST_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties om dit lijst blok opnieuw te configureren. '; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GTE = 'Geef waar terug als het eerste getal groter is\ndan of gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_FOR_TOOLTIP = 'Tel van een start- tot een eindnummer.\nZet het huidige nummer, voor iedere tel, op\nvariabele "%1", en doe erna een aantal dingen.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TOOLTIP = 'Geef een willekeurig getal tussen 0 en 1 terug.'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_VARIABLE = ' variabele'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.WARNING_DELETE_X_BLOCKS = 'Weet u zeker dat u alle %1 van deze blokken wilt verwijderen?'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TOOLTIP = ''; Blockly.Msg.LANG_LISTS_INSERT_INPUT_ITEM = 'item'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE = 'sluit scherm'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_EQUAL = 'Test of stukken tekst identiek zijn, of ze dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale=\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn=\nmaar niet tekst =.'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_ROUND = 'Rond een nummer af naar boven of beneden.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_END = 'tot'; Blockly.Msg.LANG_COLOUR_ORANGE = 'oranje'; Blockly.Msg.REPL_STARTING_COMPANION_IN_EMULATOR = 'AI Companion App wordt opgestart in de emulator.'; Blockly.Msg.LANG_MATH_COMPARE_LT = '<'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ABS = 'Geef de absolute waarde van een getal terug.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM = 'item'; Blockly.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN = 'Selecteer een geldig item uit de drop down.'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD = 'graden naar radialen'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TOOLTIP = 'Geeft de platte tekst terug die doorgegeven werd toen dit scherm werd gestart door een andere app. Als er geen waarde werd doorgegeven, geeft deze functie een lege tekst terug. Voor multischerm apps, gebruik dan neem start waarde in plaats van neem platte start tekst.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM = 'voor elk'; Blockly.Msg.BACKPACK_DOC_TITLE = 'Rugzak informatie'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN = 'samenvoegen'; Blockly.Msg.LANG_TEXT_LENGTH_TOOLTIP = 'Geeft het aantal letters (inclusief spaties)\nterug in de meegegeven tekst.'; Blockly.Msg.LANG_CONTROLS_IF_IF_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties\nom dit blok opnieuw te configureren.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1 = 'De AI Companion die je op je smartphone gebruikt, is verouderd.<br/><br/>Deze versie van de App Inventor moet gebruikt worden met Companion versie'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE = 'hoofdletters'; Blockly.Msg.LANG_MATH_ARITHMETIC_ADD = '+'; Blockly.Msg.REPL_COMPANION_VERSION_CHECK = 'Versie controle van de AI Companion'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP = 'Een procedure die een resultaat teruggeeft.'; Blockly.Msg.LANG_MATH_TRIG_ATAN2_X = 'x'; Blockly.Msg.EXPAND_ALL = 'Blok uitbreiden'; Blockly.MSG_CHANGE_VALUE_TITLE = 'Wijzig waarde:'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TOOLTIP = 'Opent een nieuw scherm in een app met meerdere schermen.'; Blockly.Msg.LANG_TEXT_ISEMPTY_TOOLTIP = 'Geeft waar terug als de lengte van de\ntekst gelijk is aan 0, anders wordt niet waar teruggegeven.'; Blockly.Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT = 'ingesteld'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM = 'willekeurig deel'; Blockly.Msg.LANG_COLOUR_BLUE = 'blauw'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = 'tot'; Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET = 'krijg'; Blockly.Msg.REPL_APPROVE_UPDATE = ' scherm omdat je gevraagd gaat worden om een update goed te keuren.'; Blockly.Msg.LANG_TEXT_TRIM_TOOLTIP = 'Geeft een kopie terug van de tekst argumenten met elke\nspatie vooraan en achteraan verwijderd.'; Blockly.Msg.REPL_EMULATORS = 'emulators'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM = 'is een getal?'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX = 'to '; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE = 'vergelijk teksten'; Blockly.Msg.LANG_MATH_NUMBER_TOOLTIP = 'Rapporteer het getoonde getal.'; Blockly.Msg.LANG_TEXT_COMPARE_LT = ' <'; Blockly.Msg.LANG_LISTS_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TOOLTIP = 'Verwijdert het element op de gegeven positie uit de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_TITLE_IS_IN = 'staat in een lijst?'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_CEILING = 'Rond de input af tot het kleinste\ngetal dat niet kleiner is dan de input'; Blockly.Msg.LANG_COLOUR_YELLOW = 'geel'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_FLOOR = 'Rond de input af tot het grootste\ngetal dat niet groter is dan de input'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_MODULO = 'Geeft de gehele deling terug.'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TITLE_ITEM = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_STARTS_AT_TOOLTIP = 'Geeft de beginpositie terug van het stukje in de tekst\nwaar index 1 het begin van de tekst aangeeft. Geeft 0 terug wanneer\nhet stuk tekst niet voorkomt.'; Blockly.Msg.SORT_W = 'Sorteer blokken op breedte'; Blockly.Msg.ENABLE_BLOCK = 'Schakel blok aan'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_COLLAPSED_TEXT = 'evalueer maar negeer'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_ADD = 'Geeft de som van twee getallen terug.'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT = 'index in lijst item %1 lijst %2'; Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING = ' seconden om er zeker van te zijn dat alles draait.'; Blockly.Msg.REPL_NO_ERROR_FIVE_SECONDS = '<br/><i>Merk op:</i>&nbsp,Je zal geen andere foutmeldingen zien gedurende de volgende 5 seconden.'; Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT = 'niet'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CATEGORY_CONTROLS = 'Bediening'; Blockly.Msg.LANG_COLOUR_MAGENTA = 'magenta'; Blockly.Msg.LANG_LISTS_IS_IN_TOOLTIP = 'Geeft waar terug als het ding een item is dat in de lijst zit, anders wordt onwaar teruggegeven.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT = 'vervang lijst item lijst %1 index %2 vervanging %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Neemt een positief geheel decimaal getal en geeft de tekst weer die dat getal voorstelt in binair'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex naar dec'; Blockly.Msg.LANG_LOGIC_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME = 'naam'; Blockly.MSG_NEW_VARIABLE = 'Nieuwe variabele ...'; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_OR = 'Geef waar terug als de invoer waar is.'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP = ''; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_CONTAINS = 'bevat'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT = 'verwijder lijstitem lijst %1 index %2'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT = 'segment tekst %1 start %2 lengte %3'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT = 'lengte van de lijst lijst %1'; Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP = 'Test of het stukje voorkomt in de tekst.'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_RAD_TO_DEG = 'Geeft de graden terug tussen\n(0,360) die overeenkomt met het argument in radialen.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_COLLAPSED_TEXT = 'Neem platte start tekst'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_SEGMENT = 'segment'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_LIST = ' lijst'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_TAN = 'tan'; Blockly.Msg.LANG_MATH_TRIG_ATAN = 'atan'; Blockly.Msg.LANG_MATH_RANDOM_SEED_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = 'Terwijl een waarde onwaar is, doe enkele andere stappen.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_INPUT_RESULT = 'resultaat'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG = 'radialen naar graden'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_SELECT = 'kies een item uit de lijst'; Blockly.Msg.LANG_CATEGORY_TEXT = 'Tekst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT = 'voeg toe aan lijst lijst1 %1 lijst2 %2'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR = 'splits kleur'; Blockly.Msg.LANG_CONTROLS_IF_MSG_IF = 'als'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP = 'Roep een procedure op die iets teruggeeft.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND = 'rond af'; Blockly.Msg.REPL_DISMISS = 'Negeer'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TOOLTIP = 'Vervangt het n\'de item in een lijst.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_GT = 'Geeft aan of tekst1 lexicologisch groter is dan tekst2.\nAls een tekst het eerste deel is van de andere, dan wordt de kortere tekst aanzien als kleiner.\nHoofdletters hebben voorrang op kleine letters.'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR = 'item'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO = 'tot'; Blockly.Msg.LANG_COLOUR_RED = 'rood'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_TO = 'tot'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.REPL_KEEP_TRYING = 'Blijf Proberen'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST = 'maak een lijst'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING = 'afrondenNaarBoven'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_SET = 'zet'; Blockly.Msg.EXTERNAL_INPUTS = 'Externe ingangen'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_PAIRS = 'paren'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE = 'open ander scherm met startwaarde'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Neemt een tekst die een hexadecimaal getal voorstelt en geeft een tekst terug die dat nummer voorstelt als decimaal getal.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_SIN = 'Geeft de sinus van de gegeven hoek (in graden).'; Blockly.Msg.REPL_GIVE_UP = 'Opgeven'; Blockly.Msg.LANG_CATEGORY_LOGIC = 'Logica'; Blockly.Msg.LANG_LISTS_COPY_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_INSERT_INPUT = 'voeg lijstitem toe lijst %1 index %2 item %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Neemt een positief decimaal getal en geeft een tekst terug die dat getal voorstelt in hexadecimale notatie.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_START = 'van'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = 'breek uit'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. door komma\'s gescheiden waarde) opgemaakte rij om een ​​lijst met velden te produceren. Als de rij tekst meerdere onbeschermde nieuwe regels (meerdere lijnen) bevat in de velden, krijg je een foutmelding. Je moet de rij tekst laten eindigen in een nieuwe regel of CRLF.'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_POWER = 'Geeft het eerste getal verheven tot\nde macht van het tweede getal.'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET = 'zet'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_DO = 'doe'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_COLOUR_GRAY = 'grijs'; Blockly.Msg.REPL_NETWORK_ERROR_RESTART = 'Netwerk Communicatie Fout met de AI Companion. <br />Probeer eens de smartphone te herstarten en opnieuw te connecteren.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM = 'kies een willekeurig item'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_LT = 'Controleert of tekst1 lexicografisch kleiner is dan text2. \ NAls een stuk tekst het voorvoegsel is van de andere, dan wordt de kortere tekst \ nals kleiner beschouwd. Kleine letters worden voorafgegaan door hoofdletters.'; Blockly.Msg.LANG_TEXT_APPEND_APPENDTEXT = 'voeg tekst toe'; Blockly.Msg.REPL_CANCEL = 'Annuleren'; Blockly.Msg.LANG_CATEGORY_MATH = 'Wiskunde'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE_TOOLTIP = 'Produceert tekst, zoals een tekstblok. Het verschil is dat de \ntekst niet gemakkelijk te detecteren is door de APK van de app te onderzoeken. Gebruik deze functie daarom bij het maken van apps \n die vertrouwelijke informatie bevatten, zoals API sleutels. \nWaarschuwing: tegen complexe security-aanvallen biedt deze functie slechts een zeer lage bescherming.'; Blockly.Msg.SORT_C = 'Sorteer blokken op categorie'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TOOLTIP = 'Geeft het item op positie index in de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH = 'lengte van de lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME = 'naam'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TITLE = 'maak op als decimaal'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = 'Zolang een waarde waar is, do dan enkele regels code.'; Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE = 'maak lege lijst'; Blockly.Msg.LANG_MATH_ARITHMETIC_POWER = '^'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TOOLTIP = 'Voert het aangesloten blok code uit en negeert de return waarde (indien aanwezig). Deze functie is handig wanneer je een procedure wil aanroepen die een return waarde heeft, zonder dat je die waarde zelf nodig hebt.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TOOLTIP = 'Maak een lijst met een bepaald aantal items.'; Blockly.ERROR_DUPLICATE_EVENT_HANDLER = 'Dit een een copy van een signaalafhandelaar voor deze component.'; Blockly.Msg.LANG_MATH_TRIG_COS = 'cos'; Blockly.Msg.BACKPACK_CONFIRM_EMPTY = 'Weet u zeker dat u de rugzak wil ledigen?'; Blockly.Msg.LANG_LISTS_IS_EMPTY_TOOLTIP = 'Geeft \'waar\' terug als de lijst leeg is.'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME = 'oproep weergave'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_LN = 'Teruggave van het natuurlijke logaritme van een getal, d.w.z. het logaritme met het grondtal e (2,71828 ...)'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_UPPERCASE = 'Geeft een kopie van de meegegeven tekst omgezet in hoofdletters.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TOOLTIP = 'Toevoegen, verwijderen of herschikken van secties om dit lijstblok te herconfigureren.'; Blockly.Msg.LANG_COLOUR_DARK_GRAY = 'donkergrijs'; Blockly.Msg.ARRANGE_H = 'Rangschik blokken horizontaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF = 'anders als'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TOOLTIP = 'Sluit het huidig scherm en geeft een resultaat terug aan het scherm dat deze opende.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_4 = 'Als de eerste waarde \'waar\' is, voer dan het eerste blok met opdrachten uit.\nAnders, als de tweede waarde \'waar\' is, voer dan het tweede blok met opdrachten uit.\nAls geen van de waarden \'waar\' is, voer dan het laatste blok met opdrachten uit.'; Blockly.Msg.REPL_NETWORK_CONNECTION_ERROR = 'Fout netwerkverbinding'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX = ' in lijst'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT = 'is in lijst? item %1 lijst %2'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_VAR = 'x'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM = 'is decimaal?'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_TOOLTIP = 'Een lijst van vier elementen, elk op een schaal van 0 tot 255, die de rode, groene, blauwe en alfa componenten voorstellen.'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE = 'evalueer maar negeer het resultaat'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_INPUT_LIST = 'lijst'; Blockly.Msg.CAN_NOT_DO_IT = 'Kan dit niet doen'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME = 'initialiseer lokale variable in doe'; Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE = '“'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = 'Sla de rest van deze loop over en \n begin met de volgende iteratie.'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_FROM = 'van'; Blockly.Msg.COPY_TO_BACKPACK = 'Voeg toe aan rugzak'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY = 'is leeg'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY = 'splits bij elk'; Blockly.Msg.EXPORT_IMAGE = 'Download blokken als afbeelding'; Blockly.Msg.REPL_GOT_IT = 'Begrepen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP = 'Een kleur met de gegeven rood, groen, blauw en optionele alfa componenten.'; Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY = 'is de lijst leeg?'; Blockly.Msg.LANG_MATH_SINGLE_OP_NEG = 'negatief'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET = 'stel in'; Blockly.Msg.INLINE_INPUTS = 'Inlijn invulveld'; Blockly.Msg.LANG_LISTS_INSERT_TOOLTIP = 'Voeg een element toe op een specifieke plaats in een lijst.'; Blockly.Msg.REPL_CONNECTING = 'Verbinden ...'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TOOLTIP = 'Geeft de waarde terug die hoort bij de sleutel in een lijst van paren'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_NEG = 'Geeft het negatief van een getal.'; Blockly.Msg.REPL_UNABLE_TO_LOAD = 'Opladen naar de App Inventor server mislukt'; Blockly.Msg.LANG_LISTS_COPY_TOOLTIP = 'Maakt een kopie van een lijst. Sublijsten worden ook gekopieerd'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_TRUE = 'Geeft de booleaanse waar terug.'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE = 'Onleesbaar gemaakte Tekst'; Blockly.Msg.LANG_TEXT_TEXT_TOOLTIP = 'Een tekst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT = 'Selecteer een element uit lijst %1 index %2'; Blockly.Msg.REPL_DO_YOU_REALLY_Q = 'Wil Je Dit Echt? Echt echt?'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP = 'Laat je toe om variabelen te maken die je alleen kan gebruiken in het deel van dit blok dat iets teruggeeft.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT = 'Initializeer globaal'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM = 'is hexadecimaal?'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_QUOTIENT = 'Berekent het quotient.'; Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM = 'is binair?'; Blockly.Msg.LANG_CONTROLS_FOREACH_TOOLTIP = 'Voert de blokken in het \'doe\' deel uit voor elk element van de lijst. Gebruik de opgegeven naam van de variabele om te verwijzen naar het huidige element.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE = '”'; Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN = 'dan'; Blockly.Msg.LANG_CONTROLS_WHILE_TITLE = 'terwijl'; Blockly.Msg.LANG_MATH_COMPARE_GT = '>'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_TOOLTIP = 'Test of iets een string is die een positief integraal grondgetal 10 voorstelt.'; Blockly.Msg.LANG_MATH_MUTATOR_ITEM_INPUT_NUMBER = 'getal'; Blockly.Msg.LANG_LISTS_ADD_ITEM_TOOLTIP = 'Voeg een item toe aan de lijst.'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO = 'in'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LT = 'Geeft Waar terug als het eerste nummer\nkleiner is dan het tweede nummer.'; Blockly.Msg.LANG_COLOUR_BLACK = 'zwart'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TOOLTIP = 'Sluit het huidige scherm af en geeft de tekst terug aan de app die dit scherm geopend heeft. Deze functie is bedoeld om tekst te retourneren aan activiteiten die niet gerelateerd zijn aan App Inventor en niet om naar App Inventor schermen terug te keren. Voor App Inventor apps met meerdere schermen, gebruik de functie Sluit Scherm met Waarde, niet Sluit Scherm met Gewone Tekst.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE = 'Jouw Companion App is te oud. Klik "OK" om bijwerken te starten. Bekijk jouw '; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_AND = 'Geef Waar terug als alle invoer Waar is.'; Blockly.Msg.REPL_NO_START_EMULATOR = 'Het is niet gelukt de MIT AI Companion te starten in de Emulator'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = 'Breek uit de omliggende lus.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_EQ = 'Geef Waar terug als beide getallen gelijk zijn aan elkaar.'; Blockly.Msg.LANG_LOGIC_OPERATION_AND = 'en'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST = 'Verdeelt de opgegeven tekst in twee delen en gebruikt hiervoor de plaats het eerste voorkomen \nvan de tekst \'aan\' als splitser, en geeft een lijst met twee elementen terug. Deze lijst bestaat \nuit het deel voor de splitser en het deel achter de splitser. \nHet splitsen van "appel,banaan,kers,hondeneten" met als een komma als splitser geeft een lijst \nterug met twee elementen: het eerste is de tekst "appel" en het tweede is de tekst \n"banaan,kers,hondeneten". \nMerk op de de komma achter "appel\' niet in het resultaat voorkomt, omdat dit de splitser is.'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binair naar decimaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TOOLTIP = 'Voeg een finaal, vang-alles-op conditie toe aan het als blok.'; Blockly.Msg.GENERATE_YAIL = 'Genereer Yail'; Blockly.Msg.LANG_LOGIC_COMPARE_TRANSLATED_NAME = 'logische is gelijk'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_DOWNCASE = 'Geeft een kopie terug van de tekst in kleine letters.'; Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT = 'quotiënt van'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_NEQ = 'Geef Waar terug als beide getallen niet gelijk zijn aan elkaar.'; Blockly.Msg.DELETE_X_BLOCKS = 'Verwijder %1 blokken'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'rest van'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT = 'start op tekst %1 stuk %2'; Blockly.Msg.BACKPACK_EMPTY = 'Maak de Rugzak leeg'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST = 'in lijst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP = 'Voert de blokken in \'\'doe\'\' uit en geeft een statement terug. Handig als je een procedure wil uitvoeren alvorens een waarde terug te geven aan een variabele.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP = 'Voert de blokken in de \'doe\' sectie uit voor elke numerieke waarde van begin tot eind, telkens verdergaand met de volgende waarde. Gebruik de gegeven naam van de variabele om te verwijzen naar de actuele waarde.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TITLE_REMOVE = 'verwijder lijst item'; Blockly.Msg.REPL_STARTING_COMPANION_ON_PHONE = 'Bezig het opstarten van de Companion App op de aangesloten telefoon.'; Blockly.Msg.ARRANGE_S = 'Rangschik blokken diagonaal'; Blockly.ERROR_COMPONENT_DOES_NOT_EXIST = 'Component bestaat niet'; Blockly.Msg.LANG_MATH_COMPARE_LTE = '≤'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT = 'bevat tekst %1 stuk %2'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN = 'min'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT = 'Formatteer als decimaal getal %1 plaatsen %2'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_TEST = ''; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP = ''; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_TAN = 'Geeft de tangens van de gegeven hoek in graden.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO = 'tot'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.HELP = 'Hulp'; Blockly.Msg.LANG_LISTS_POSITION_IN_TITLE_POSITION = 'positie in lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE = 'toepassing sluiten'; Blockly.Msg.LANG_COLOUR_GREEN = 'groen'; Blockly.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF = 'Markeer Procedure'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE = 'krijg startwaarde'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP = 'van lus'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX = 'roep op '; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE = 'Verkrijg gewone starttekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP = 'Roep een procedure op die geen waarde teruggeeft.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV = 'lijst van een csv tabel'; Blockly.Msg.LANG_LISTS_INSERT_TITLE_INSERT_LIST = 'voeg een lijst element toe'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST1 = 'lijst1'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST2 = 'lijst2'; Blockly.Msg.REPL_UPDATE_INFO = 'De update wordt nu geïnstalleerd op je toestel. Hou je scherm (of emulator) in het oog en keur de installatie goed wanneer je dat gevraagd wordt.<br /><br />BELANGRIJK: Wanneer de update afloopt, kies "VOLTOOID" (klik niet op "open"). Ga dan naar App Inventor in je web browser, klik op het "Connecteer" menu en kies "Herstart Verbinding". Verbind dan het toestel.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LTE = 'Geeft waar terug als het eerste getal kleiner is\nof gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_COLLAPSED_TEXT = 'sluit scherm met platte tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_COLLAPSED_TEXT = 'herhaal tot'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_KEY = 'sleutel'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_CREATEWITH = 'maak tekst met'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TOOLTIP = 'Interpreteert de lijst als een rij van een tabel en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de rij representeert. Elk item in de rij lijst wordt beschouwd als een veld, er wordt naar verwezen met dubbele aanhalingstekens in de CSV tekst. Items worden gescheiden door een komma. De geretourneerde rij tekst heeft geen lijn separator aan het einde.'; Blockly.Msg.LANG_TEXT_JOIN_TOOLTIP = 'Voegt alle inputs samen tot 1 enkele tekst.\nAls er geen inputs zijn, wordt een lege tekst gemaakt.'; Blockly.Msg.LANG_COLOUR_WHITE = 'Wit'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE = 'Geeft het quotiënt van twee getallen.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT = 'voeg items to lijst lijst %1 item %2'; Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE = 'onwaar'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_INDEX = 'index'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. een door komma\'s gescheiden waarde) opgemaakte tabel om een ​​lijst van rijen te produceren, elke rij is een lijst van velden. Rijen kunnen worden gescheiden door nieuwe lijnen (n) of CRLF (rn).'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN = 'anders'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TOOLTIP = 'Opent een nieuw scherm in een meer-schermen app en geeft de startwaarde mee aan dat scherm.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ASIN = 'Geeft een hoek tussen [-90,+90]\ngraden met de gegeven sinus waarde.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_GETTER_TITLE_OF_COMPONENT = 'van component'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM = 'stel willekeurige seed in'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO = 'doe'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TITLE_LOOKUP_IN_PAIRS = 'zoek op in paren'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_STARTS_AT = 'begint bij'; Blockly.Msg.REPL_NOT_NOW = 'Niet Nu. Later, misschien ...'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT = 'voor component'; Blockly.Msg.HIDE_WARNINGS = 'Waarschuwingen Verbergen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'decimaal naar hexadecimaal'; Blockly.Msg.REPL_CONNECT_TO_COMPANION = 'Connecteer met de Companion'; Blockly.Msg.LANG_COLOUR_PICKER_TOOLTIP = 'Klik op de rechthoek om een kleur te kiezen.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_TO = ' tot'; Blockly.Msg.REPL_SOFTWARE_UPDATE = 'Software bijwerken'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TOOLTIP = 'Als de voorwaarde die wordt getest waar is,retourneer dan het resultaat verbonden aan het \'dan-teruggave\' veld, indien niet, geef dan het resultaat terug van het \'zoneen-teruggave\' veld, op zijn minst een van de resultaten verbonden aan beide teruggave velden wordt weergegeven.'; Blockly.MSG_RENAME_VARIABLE_TITLE = 'Hernoem alle "%1" variabelen naar:'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_FALSE = 'Geeft booleaanse niet waar terug.'; Blockly.Msg.REPL_TRY_AGAIN1 = 'Connecteren met de AI2 Companion is mislukt, probeer het eens opnieuw.'; Blockly.Msg.REPL_VERIFYING_COMPANION = 'Kijken of de Companion gestart is...'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_LISTS_POSITION_IN_TOOLTIP = 'Zoek de positie van het ding op in de lijst. Als het ding niet in de lijst zit, geef 0 terug.'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Waarschuwing:\nDit blok mag alleen\ngebruikt worden in een lus.'; Blockly.Msg.REPL_AI_NO_SEE_DEVICE = 'AI2 ziet je toestel niet, zorg ervoor dat de kabel is aangesloten en dat de besturingsprogramma\'s juist zijn.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_DEG_TO_RAD = 'Geeft de waarde in radialen terug volgens een schaal van\n[-π, +π) overeenkomstig met de graden.'; Blockly.Msg.REPL_STARTING_EMULATOR = 'Bezig met opstarten van de Android Emulator<br/>Even geduld: Dit kan een minuutje of twee duren (of koop snellere computer, grapke Pol! :p).'; Blockly.Msg.REPL_RUNTIME_ERROR = 'Uitvoeringsfout'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_COLLAPSED_TEXT = 'open scherm'; Blockly.Msg.REPL_FACTORY_RESET = 'Deze probeert jouw Emulator te herstellen in zijn initiële staat. Als je eerder je AI Companion had geupdate in de emulator, ga je dit waarschijnlijk op nieuw moeten doen. '; Blockly.Msg.LANG_LISTS_ADD_ITEM_TITLE = 'item'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE = 'als'; Blockly.Msg.LANG_CATEGORY_LISTS = 'Lijsten'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GT = 'Geeft waar terug als het eerste getal groter is\ndan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_COLLAPSED_TEXT = 'sluit toepassing'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_COLLAPSED_TEXT = 'Krijg start waarde'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_COLLAPSED_TEXT = 'sluit scherm'; Blockly.Msg.REMOVE_COMMENT = 'Commentaar Verwijderen'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.REPL_OK_LOWER = 'OK'; Blockly.Msg.LANG_MATH_SINGLE_OP_LN = 'log'; Blockly.Msg.LANG_MATH_IS_A_BINARY_TOOLTIP = 'Test of iets een tekst is die een binair getal voorstelt.'; Blockly.Msg.REPL_UNABLE_TO_UPDATE = 'Het is niet gelukt een update naar het toestel/emulator te sturen.'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO = 'tot'; Blockly.Msg.LANG_MATH_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP = 'bij'; Blockly.Msg.LANG_MATH_COMPARE_GTE = '≥'; Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_ACOS = 'acos'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN = 'Geeft een hoek tussen [-90, +90]\ngraden met de gegeven tangens.'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS = '-'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_1 = 'Als een waarde waar is, voer dan enkele stappen uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_3 = 'Als de eerste waarde waar is, voer dan het eerste codeblok uit.\nAnders, als de tweede waarde waar is, voer het tweede codeblok uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_2 = 'Als de waarde waar is, voer dan het eerste codeblok uit.\nAnders, voer het tweede codeblok uit.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR = 'naar beneden afgerond'; Blockly.Msg.LANG_TEXT_APPEND_TO = 'naar'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TOOLTIP = 'Voeg een test toe aan het als blok.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT = 'herhaal'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_WITH = 'tel met'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP = 'Maakt een globale variabele en geeft die de waarde van de geconnecteerde blokken'; Blockly.Msg.CLEAR_DO_IT_ERROR = 'Wis Fout'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV = 'lijst to csv rij'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_EXP = 'Geef e (2.71828...) tot de macht terug'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME = 'naam'; Blockly.Msg.LANG_MATH_ARITHMETIC_MULTIPLY = '*'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TOOLTIP = 'Sluit al de schermen af in deze app en stopt de app.'; Blockly.Msg.MISSING_SOCKETS_WARNINGS = 'Je moet alle connecties opvullen met blokken'; Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE = '/'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TOOLTIP = 'Sluit het huidige scherm'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TOOLTIP = 'Interpreteert de lijst als een tabel in rij-eerst formaat en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de tabel voorstelt. Elk element in de lijst zou op zijn beurt zelf een lijst moeten zijn die een rij van de CSV tabel voorstelt. Elk element in de rij lijst wordt beschouwd als een veld, waarvan de uiteindelijke CSV tekst zich binnen dubbele aanhalingstekens bevindt. In de teruggegeven tekst worden de elementen in de rijen gescheiden door komma\'s en worden de rijen zelf gescheiden door CRLF (\\r\\n).'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE = 'sluit venster met waarde'; Blockly.Msg.LANG_TEXT_SPLIT_AT_TOOLTIP = 'Splitst de tekst in stukjes bij elke spatie.'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_TOOLTIP = 'Test of iets een getal is.'; Blockly.Msg.LANG_LISTS_IS_LIST_TOOLTIP = 'Test of iets in een lijst zit.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ACOS = 'Geeft een hoek tussen [0, 180]\ngraden met de gegeven cosinus waarde.'; Blockly.Msg.LANG_MATH_RANDOM_INT_TITLE_RANDOM = 'willekeurig getal'; Blockly.ERROR_BLOCK_CANNOT_BE_IN_DEFINTION = 'Dit blok kan niet in een definitie'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_REMAINDER = 'Geef de rest terug.'; Blockly.Msg.REPL_CONNECTING_USB_CABLE = 'Aan het connecteren via USB kabel'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_PLACES = 'plaatsen'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_COLLAPSED_TEXT = 'open scherm met waarde'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TOOLTIP = 'Voeg alle elementen van list2 achteraan toe bij lijst1. Na deze toevoegoperatie zal lijst1 de toegevoegde elementen bevatten, lijst2 zal niet gewijzigd zijn.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE_IMMEDIATE = 'Je gebrukt een oude Companion. Je zou zo snel mogelijk moeten upgraden naar MIT AI2 Companion. Als je automatisch updaten hebt ingesteld in de store, gebeurt de update binnenkort vanzelf.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_COS = 'Geeft de cosinus van een gegeven hoek in graden.'; Blockly.Msg.LANG_TEXT_SEGMENT_TITLE_SEGMENT = 'segment'; Blockly.Msg.BACKPACK_GET = 'Plak Alle Blokken van Rugzak'; Blockly.MSG_PROCEDURE_CATEGORY = 'Procedures'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_TO = ' tot'; Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY = 'copieer lijst'; Blockly.Msg.LANG_LISTS_LENGTH_TOOLTIP = 'Telt het aantal elementen van een lijst'; Blockly.Msg.LANG_VARIABLES_GET_TOOLTIP = 'Geeft de waarde van deze variabele terug.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_INPUT_DO = 'doe'; Blockly.Msg.LANG_TEXT_APPEND_VARIABLE = 'item'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY = 'Geeft het product van twee getallen terug.'; Blockly.Msg.REPL_OK = 'OK'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_ATAN2_Y = 'j'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DO = 'doe'; Blockly.Msg.REPL_HELPER_NOT_RUNNING = 'De aiStarter helper lijkt niet opgestart<br /><a href="http://appinventor.mit.edu" target="_blank">hulp nodig?</a>'; Blockly.Msg.LANG_TEXT_SEGMENT_AT_TOOLTIP = 'Haalt een deel van gegeven lengte uit de gegeven tekst\nstartend van de gegeven tekst op de gegeven positie. Positie \n1 betekent het begin van de tekst.'; Blockly.Msg.LANG_LOGIC_OPERATION_OR = 'of'; Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS = 'Dit blok moet worden geconnecteerd met een gebeurtenisblok of de definitie van een procedure'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS = 'Geeft het verschil tussen twee getallen terug.'; Blockly.Msg.LANG_TEXT_APPEND_TOOLTIP = 'Voeg wat tekst toe aan variabele "%1".'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TITLE_REPLACE_ALL = 'vervang allemaal'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_TEST = 'test'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX = 'tot '; Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM = 'trim'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR = 'getal'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_NUM = 'getal'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN2 = 'Geeft een hoek in tussen [-180, +180]\ngraden met de gegeven rechthoekcoordinaten.'; Blockly.Msg.REPL_YOUR_CODE_IS = 'Jouw code is'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT = 'splits'; Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF = 'als'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_DO = 'doe'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME = 'initializeer lokaal in return'; Blockly.Msg.REPL_EMULATOR_STARTED = 'Emulator gestart, wachten '; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST = 'splits aan de eerste'; Blockly.Msg.LANG_COLOUR_LIGHT_GRAY = 'lichtgrijs'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_1 = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.DUPLICATE_BLOCK = 'Dupliceer'; Blockly.Msg.SORT_H = 'Soorteer Blokken op Hoogte'; Blockly.Msg.ARRANGE_V = 'Organizeer Blokken Vertikaal'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT = 'willekeurig getal tussen %1 en %2'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_EQ = 'Test of twee dingen gelijk zijn. \nDe dingen die worden vergeleken kunnen vanalles zijn, niet enkel getallen. \nGetallen worden als gelijk beschouwd aan hun tekstvorm, \nbijvoorbeeld, het getal 0 is gelijk aan de tekst "0". Ook two tekstvelden \ndie getallen voorstellen zijn gelijk aan elkaar als de getallen gelijk zijn aan mekaar. \n"1" is gelijk aan "01".'; Blockly.Msg.LANG_LOGIC_COMPARE_EQ = '='; Blockly.MSG_RENAME_VARIABLE = 'Geef variabele een andere naam...'; Blockly.Msg.LANG_MATH_RANDOM_INT_TOOLTIP = 'Geeft een willekeurige geheel getal tussen de boven en de\nondergrens. De grenzen worden afgerond tot getallen kleiner\ndan 2**30.'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE = 'waar'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM = 'voor elk'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TOOLTIP = 'Neem een willekeurig element van de lijst.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE = 'Sluit het venster met gewone tekst'; Blockly.Msg.REPL_UNABLE_TO_LOAD_NO_RESPOND = 'Kan geen update laden van de App Inventor server (de server antwoordt niet)'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_START = 'start'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE = 'doe resultaat'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP = 'Een procedure die geen waarde teruggeeft.'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_TOOLTIP = 'Tests of iets een tekst is die een hexadecimaal getal voorstelt.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TOOLTIP = 'Geeft een nieuwe tekst terug door alle stukjes tekst zoals het segment\nte vervangen door de vervangtekst.'; Blockly.Msg.LANG_VARIABLES_SET_TOOLTIP = 'Zet deze variabele gelijk aan de input.'; Blockly.Msg.REPL_ERROR_FROM_COMPANION = 'Fout van de Companion'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_NEQ = 'Geef waar terug als beide inputs niet gelijk zijn aan elkaar.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT = 'van de component'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP = 'Voeg een element toe aan de lijst.'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE = 'naar kleine letters'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT = 'voor element in lijst'; Blockly.Msg.COLLAPSE_ALL = 'Klap blokken dicht'; Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Waarschuwing:\nDeze procedure heeft\ndubbele inputs.'; Blockly.Msg.LANG_CONTROLS_CHOOSE_COLLAPSED_TEXT = 'als'; Blockly.Msg.REPL_NETWORK_ERROR = 'Netwerkfout'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'zet getal om'; Blockly.Msg.COLLAPSE_BLOCK = 'Klap blok dicht'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD = 'voeg dingen toe aan lijst'; Blockly.Msg.REPL_COMPANION_STARTED_WAITING = 'Companion start op, effe wachten ...'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Neemt een tekst die een binair getal voorstelt en geeft de tekst terug die dat getal decimaal voorstelt'; Blockly.Msg.LANG_LOGIC_NEGATE_TOOLTIP = 'Geeft waar terug wanneer de input niet waar is.\nGeeft niet waar terug waneer de input waar is.'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER = 'de rest van'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY = 'splits bij de eerste van'; Blockly.Msg.SHOW_WARNINGS = 'Toon Waarschuwingen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'decimaal naar binair'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT = 'initializeer lokaal'; Blockly.Msg.REPL_DEVICES = 'apparaten'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN = 'dan'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT = 'op'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT = 'voor getal in een zeker bereik'; Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT = 'vierkantswortel'; Blockly.Msg.LANG_MATH_COMPARE_EQ = '='; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Geeft het kleinste van zijn argumenten terug..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Geeft het grootste van zijn argumenten terug..'; Blockly.Msg.TIME_YEARS = "Jaren"; Blockly.Msg.TIME_MONTHS = "Maanden"; Blockly.Msg.TIME_WEEKS = "Weken"; Blockly.Msg.TIME_DAYS = "Dagen"; Blockly.Msg.TIME_HOURS = "Uren"; Blockly.Msg.TIME_MINUTES = "Minuten"; Blockly.Msg.TIME_SECONDS = "Seconden"; Blockly.Msg.TIME_DURATION = "Duurtijd"; Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION = "Toon Rugzak informatie"; Blockly.Msg.ENABLE_GRID = 'Toon Werkruimte raster'; Blockly.Msg.DISABLE_GRID = 'Werkruimte raster verbergen'; Blockly.Msg.ENABLE_SNAPPING = 'Uitlijnen op raster aanzetten'; Blockly.Msg.DISABLE_SNAPPING = 'Uitlijnen op raster uitzetten'; } }; // Initalize language definition to Dutch Blockly.Msg.nl.switch_blockly_language_to_nl.init(); Blockly.Msg.nl.switch_language_to_dutch.init();
holyokecodes/appinventor-sources
appinventor/blocklyeditor/src/msg/nl/_messages.js
764
/* * Copyright 2010 Gauthier Van Damme for COSIC * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package be.cosic.android.eid.gui; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateEncodingException; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.smartcard.CardException; import android.util.Log; import android.view.Gravity; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import be.cosic.android.eid.exceptions.InvalidPinException; import be.cosic.android.eid.exceptions.InvalidResponse; import be.cosic.android.eid.exceptions.SignatureGenerationException; import be.cosic.android.util.TextUtils; public class Functions extends Activity { private Intent intent; private String old_pin; private String new_pin_1; private String new_pin_2; static final int GET_PIN_FOR_TEST_REQUEST = 0; static final int GET_PIN_FOR_CHANGE_REQUEST_1 = 1; static final int GET_PIN_FOR_CHANGE_REQUEST_2 = 2; static final int GET_PIN_FOR_CHANGE_REQUEST_3 = 3; static final int GET_PIN_FOR_SIGN_REQUEST = 4; static final int GET_RAW_FILE_LOCATION_REQUEST = 5; static final int GET_SIGNED_FILE_LOCATION_REQUEST = 6; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //intent = new Intent().setClass(this, PathQuery.class); } //Note: onResume is also called after onCreate! Do not duplicate code. public void onResume() { super.onResume(); if(MainActivity.own_id == true){ setContentView(R.layout.own_functions); intent = new Intent().setClass(this, PinQuery.class); final Button test_pin = (Button) findViewById(R.id.test_pin); test_pin.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //start new activity intent.putExtra("requestCode", GET_PIN_FOR_TEST_REQUEST); Functions.this.startActivityForResult(intent, GET_PIN_FOR_TEST_REQUEST); //get the pin from the input and check it: see on activity result method } }); final Button change_pin = (Button) findViewById(R.id.change_pin); change_pin.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //get old pin intent.putExtra("requestCode", GET_PIN_FOR_CHANGE_REQUEST_1); Functions.this.startActivityForResult(intent, GET_PIN_FOR_CHANGE_REQUEST_1); } }); final Button sign = (Button) findViewById(R.id.sign_data); sign.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Get the PIN to enable signing intent.putExtra("requestCode", GET_PIN_FOR_SIGN_REQUEST); Functions.this.startActivityForResult(intent, GET_PIN_FOR_SIGN_REQUEST); } }); final Button authenticate = (Button) findViewById(R.id.authenticate); authenticate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //TODO: need to use SSL for client authentication //also: does eID card implement the PKCS11 standard? used for client authentication //and do we use PKCS11 on both application side (this side) and token side (smart card)? Context context = getApplicationContext(); int duration = Toast.LENGTH_LONG; Toast toast; toast = Toast.makeText(context, "Function not implemented yet.", duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } }); try { setEidData();//TODO : dit niet in een specifieke functie zetten? } catch (CardException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } //TextView firstnames = (TextView) findViewById(R.id.firstnames); //firstnames.setText("jaja, nu wel ja"); }else { setContentView(R.layout.external_functions); final Button verify = (Button) findViewById(R.id.verify); intent = new Intent().setClass(this, PathQuery.class); verify.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //start new activity Functions.this.startActivityForResult(intent, GET_SIGNED_FILE_LOCATION_REQUEST); //get the pin from the input and check it: see on activity result method } }); } } //Called when a child activity returns. protected void onActivityResult(int requestCode, int resultCode, Intent data) { Context context = getApplicationContext(); int duration = Toast.LENGTH_LONG; Toast toast; switch (requestCode){ //If the return value is a PIN for testing: case GET_PIN_FOR_TEST_REQUEST: if (resultCode == RESULT_OK) { try{ //validate pin MainActivity.belpic.pinValidationEngine(data.getStringExtra("PIN")); CharSequence text = "PIN ok"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } catch (InvalidPinException e) { CharSequence text = "Invalid PIN: "+ e.getMessage() + " tries left."; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "Exception in PIN validation: " + e.getMessage()); } catch (CardException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else ; break; //If the return value is a PIN for changing: case GET_PIN_FOR_CHANGE_REQUEST_1: if (resultCode == RESULT_OK) { old_pin = data.getStringExtra("PIN"); //get new pin intent.putExtra("requestCode", GET_PIN_FOR_CHANGE_REQUEST_2); Functions.this.startActivityForResult(intent, GET_PIN_FOR_CHANGE_REQUEST_2); }else ; break; //If the return value is a PIN for changing: case GET_PIN_FOR_CHANGE_REQUEST_2: if (resultCode == RESULT_OK) { new_pin_1 = data.getStringExtra("PIN"); //get new pin intent.putExtra("requestCode", GET_PIN_FOR_CHANGE_REQUEST_3); Functions.this.startActivityForResult(intent, GET_PIN_FOR_CHANGE_REQUEST_3); //get the pin from the input and change it: see on activity result method }else ; break; //If the return value is a PIN for changing: case GET_PIN_FOR_CHANGE_REQUEST_3: if (resultCode == RESULT_OK) { try{ new_pin_2 = data.getStringExtra("PIN"); if(!new_pin_1.equals(new_pin_2) || new_pin_1.length() != 4){ CharSequence text = "New PIN incorrect"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); break; } //get the pin from the input and change it: see on activity result method MainActivity.belpic.changeThisPin(old_pin, new_pin_1); //clear the pins old_pin = new_pin_1 = new_pin_2 = ""; CharSequence text = "PIN changed"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } catch (InvalidPinException e) { CharSequence text = "Invalid old PIN: "+ e.getMessage() + " tries left."; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "Exception in PIN validation: " + e.getMessage()); } catch (CardException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else ; break; case GET_SIGNED_FILE_LOCATION_REQUEST: if (resultCode == RESULT_OK) { String[] files = data.getStringExtra("path").split(File.separator); String dir = Environment.getExternalStorageDirectory().getAbsolutePath(); String path = dir + File.separator + data.getStringExtra("path"); //Get the directory path for(int i =0;i<(files.length-1);i++){ dir = dir + File.separator + files[i] ; } try { //TODO !!!!!!!!!!!!!!!!! //Check if an extension was added. If not or a false one, correct. //Not everything is checked but other things should be checked by OS // if(!path.endsWith(".crt")) path=path + ".crt"; else if(!path.endsWith(".crt")) throw new UnsupportedEncodingException(); // //We make new directories where necessary // new File(dir).mkdirs(); // // //Now we store the file // //openFileOutput can not contain path separators in its name!!!!!!! // //FileOutputStream fos = openFileOutput(path, Context.MODE_WORLD_READABLE); // FileOutputStream fos = new FileOutputStream(path); // fos.write(currentCert.getEncoded()); // fos.close(); } catch (IOException e) { //TODO e.printStackTrace(); } }else ;//Do nothing break; case GET_PIN_FOR_SIGN_REQUEST: if (resultCode == RESULT_OK) { //try{ //Prepare for signature //MainActivity.belpic.prepareForNonRepudiationSignature(); //MainActivity.belpic.pinValidationEngine(data.getStringExtra("PIN")); //STore PIN old_pin = data.getStringExtra("PIN"); //Ask the path of the file to be signed intent = new Intent().setClass(this, PathQuery.class); Functions.this.startActivityForResult(intent, GET_RAW_FILE_LOCATION_REQUEST); //} }else ;//Do nothing break; case GET_RAW_FILE_LOCATION_REQUEST: if (resultCode == RESULT_OK) { String[] files = data.getStringExtra("path").split(File.separator); String dir = Environment.getExternalStorageDirectory().getAbsolutePath(); String path = dir + File.separator + data.getStringExtra("path"); //Get the directory path for(int i =0;i<(files.length-1);i++){ dir = dir + File.separator + files[i] ; } try { //TODO Make an xml signature??? and imbed reference to document/in document/... //For now, just a signature is created and stored under 'filename.signature' //Encode the file into a byte array byte[] encodedData = TextUtils.getBytesFromFile(path); //Calculate hash MessageDigest hash = MessageDigest.getInstance("SHA-1"); byte[] hashValue = hash.digest(encodedData); //Calculate the signature inside the eID card byte[] signature = MainActivity.belpic.generateNonRepudiationSignature(hashValue, old_pin); //Clear pin: old_pin = ""; //Now we store the signature FileOutputStream fos = new FileOutputStream(path + ".signature"); fos.write(signature); fos.close(); //If everything went fine, let the user know the signature was stored under 'filename_signature.signature' CharSequence text = "Signature saved under: '" + path +".signature'"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } catch (IOException e) { CharSequence text = "IO Exception"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "IOException: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { CharSequence text = "NoSuchAlgorithmException"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "NoSuchAlgorithmException: " + e.getMessage()); } catch (InvalidResponse e) { CharSequence text = "InvalidResponse"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "InvalidResponse: " + e.getMessage()); } catch (CardException e) { CharSequence text = "CardException"; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "CardException: " + e.getMessage()); } catch (SignatureGenerationException e) { CharSequence text = "SignatureGenerationException: " + e.getMessage(); toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "SignatureGenerationException: " + e.getMessage()); } catch (InvalidPinException e) { CharSequence text = "Invalid PIN: "+ e.getMessage() + " tries left."; toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Log.e(MainActivity.LOG_TAG, "Exception in PIN validation: " + e.getMessage()); } }else ;//Do nothing break; default: Log.e(MainActivity.LOG_TAG, "Problem in PINquery return result: Invalid return request code."); } } public void setEidData() throws CardException, Exception{ byte[] data = MainActivity.belpic.getCardInfo(); ((TextView) findViewById(R.id.card_data_value)).setText(TextUtils.hexDump(data, data.length - 12, 12)); } }
seek-for-android/pool
applications/EidForAndroid/src/be/cosic/android/eid/gui/Functions.java
765
// jDownloader - Downloadmanager // Copyright (C) 2013 JD-Team [email protected] // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. package jd.plugins.hoster; import java.io.IOException; import java.net.MalformedURLException; import java.security.InvalidKeyException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import org.appwork.storage.JSonMapperException; import org.appwork.storage.JSonStorage; import org.appwork.storage.TypeRef; import org.appwork.utils.ReflectionUtils; import org.appwork.utils.StringUtils; import org.appwork.utils.net.httpconnection.HTTPConnection; import org.appwork.utils.net.httpconnection.SSLSocketStreamOptions; import org.appwork.utils.net.httpconnection.SSLSocketStreamOptionsModifier; import org.jdownloader.downloader.hls.HLSDownloader; import org.jdownloader.downloader.hls.M3U8Playlist; import org.jdownloader.gui.translate._GUI; import org.jdownloader.logging.LogController; import org.jdownloader.net.BCSSLSocketStreamFactory; import org.jdownloader.plugins.components.hls.HlsContainer; import org.jdownloader.plugins.controller.LazyPlugin; import org.jdownloader.scripting.JavaScriptEngineFactory; import jd.PluginWrapper; import jd.config.ConfigContainer; import jd.config.ConfigEntry; import jd.config.SubConfiguration; import jd.controlling.AccountController; import jd.controlling.downloadcontroller.SingleDownloadController; import jd.controlling.linkcrawler.LinkCrawlerDeepInspector; import jd.http.Browser; import jd.http.Cookies; import jd.http.Request; import jd.http.URLConnectionAdapter; import jd.nutils.encoding.Base64; import jd.nutils.encoding.Encoding; import jd.parser.Regex; import jd.parser.html.Form; import jd.parser.html.Form.MethodType; import jd.plugins.Account; import jd.plugins.Account.AccountType; import jd.plugins.AccountInfo; import jd.plugins.AccountInvalidException; import jd.plugins.AccountRequiredException; import jd.plugins.DownloadLink; import jd.plugins.DownloadLink.AvailableStatus; import jd.plugins.HostPlugin; import jd.plugins.LinkStatus; import jd.plugins.Plugin; import jd.plugins.PluginDependencies; import jd.plugins.PluginException; import jd.plugins.PluginForHost; import jd.plugins.decrypter.PornHubComVideoCrawler; @HostPlugin(revision = "$Revision$", interfaceVersion = 3, names = {}, urls = {}) @PluginDependencies(dependencies = { PornHubComVideoCrawler.class }) public class PornHubCom extends PluginForHost { /* Connection stuff */ // private static final boolean FREE_RESUME = true; // private static final int FREE_MAXCHUNKS = 0; private static final int FREE_MAXDOWNLOADS = 5; private static final boolean ACCOUNT_FREE_RESUME = true; private static final int ACCOUNT_FREE_MAXCHUNKS = 0; private static final int ACCOUNT_FREE_MAXDOWNLOADS = 5; public static final boolean use_download_workarounds = true; private static final String type_photo = "(?i).+/photo/\\d+"; private static final String type_gif_webm = "(?i).+/(embed)?gif/\\d+"; private static final String type_modelhub = "(?i).+modelhub\\.com/.+"; public static final String html_privatevideo = "id=\"iconLocked\""; public static final String html_privateimage = "profile/private-lock\\.png"; public static final String html_purchase_only = "(?i)'Buy on video player'"; public static final String html_premium_only = "(?i)<h2>\\s*Upgrade to Pornhub Premium to enjoy this video\\.</h2>"; private String dlUrl = null; /* Note: Video bitrates and resolutions are not exact, they can vary. */ /* Quality, { videoCodec, videoBitrate, videoResolution, audioCodec, audioBitrate } */ public static LinkedHashMap<String, String[]> formats = new LinkedHashMap<String, String[]>(new LinkedHashMap<String, String[]>() { { put("240", new String[] { "AVC", "400", "420x240", "AAC LC", "54" }); put("480", new String[] { "AVC", "600", "850x480", "AAC LC", "54" }); put("720", new String[] { "AVC", "1500", "1280x720", "AAC LC", "54" }); put("1080", new String[] { "AVC", "4000", "1920x1080", "AAC LC", "96" }); put("1440", new String[] { "AVC", "6000", " 2560x1440", "AAC LC", "96" }); put("2160", new String[] { "AVC", "8000", "3840x2160", "AAC LC", "128" }); } }); public static final String BEST_ONLY = "BEST_ONLY"; public static final String BEST_SELECTION_ONLY = "BEST_SELECTION_ONLY"; public static final String CRAWL_VIDEO_HLS = "CRAWL_VIDEO_HLS"; public static final String CRAWL_VIDEO_MP4 = "CRAWL_VIDEO_MP4"; public static final String CRAWL_THUMBNAIL = "CRAWL_THUMBNAIL"; public static final String FAST_LINKCHECK = "FAST_LINKCHECK"; private static final String USE_ORIGINAL_SERVER_FILENAME = "USE_ORIGINAL_SERVER_FILENAME"; public static final String GIFS_WEBM = "GIFS_WEBM"; private final String REMOVED_VIDEO = ">\\s*This video has been removed\\s*<"; public static final String PROPERTY_FORMAT = "format"; public static final String PROPERTY_QUALITY = "quality"; public static final String PROPERTY_DIRECTLINK = "directlink"; public static final String PROPERTY_DATE = "date"; public static final String PROPERTY_CATEGORIES_COMMA_SEPARATED = "categories_comma_separated"; public static final String PROPERTY_TAGS_COMMA_SEPARATED = "tags_comma_separated"; public static final String PROPERTY_ACTORS_COMMA_SEPARATED = "actors_comma_separated"; public static final String PROPERTY_USERNAME = "username"; public static final String PROPERTY_VIEWKEY = "viewkey"; public static final String PROPERTY_ACCOUNT_is_cookie_login_only = "is_cookie_login_only"; public static List<String[]> getPluginDomains() { return PornHubComVideoCrawler.getPluginDomains(); } @Override public LazyPlugin.FEATURE[] getFeatures() { return new LazyPlugin.FEATURE[] { LazyPlugin.FEATURE.XXX }; } @Override public String rewriteHost(String host) { return this.rewriteHost(getPluginDomains(), host, new String[0]); } public static String[] getAnnotationNames() { return buildAnnotationNames(getPluginDomains()); } @Override public String[] siteSupportedNames() { return buildSupportedNames(getPluginDomains()); } public static String[] getAnnotationUrls() { return buildAnnotationUrls(getPluginDomains()); } public static String[] buildAnnotationUrls(final List<String[]> pluginDomains) { final List<String> ret = new ArrayList<String>(); for (final String[] domains : pluginDomains) { String urlPattern = "https?://(?:www\\.|[a-z]{2}\\.)?" + buildHostsPatternPart(domains) + "/(?:photo|(embed)?gif)/\\d+"; urlPattern += "|https://pornhubdecrypted/.+"; ret.add(urlPattern); } return ret.toArray(new String[0]); } private boolean isSupportedDomain(final String domain) { for (final String domainTmp : getAnnotationNames()) { if (domainTmp.equalsIgnoreCase(domain)) { return true; } } return false; } @SuppressWarnings("deprecation") public PornHubCom(final PluginWrapper wrapper) { super(wrapper); this.enablePremium("https://www.pornhub.com/create_account"); this.setConfigElements(); } public static void setSSLSocketStreamOptions(Browser br) { br.setSSLSocketStreamOptions(new SSLSocketStreamOptionsModifier() { @Override public SSLSocketStreamOptions modify(SSLSocketStreamOptions sslSocketStreamOptions, HTTPConnection httpConnection) { final SSLSocketStreamOptions ret = new SSLSocketStreamOptions(sslSocketStreamOptions) { public org.appwork.utils.net.httpconnection.SSLSocketStreamFactory getSSLSocketStreamFactory() { return new BCSSLSocketStreamFactory(); }; }; ret.getDisabledCipherSuites().clear(); // ret.getCustomFactorySettings().add("JSSE_TLS1.3_ENABLED"); ret.getCustomFactorySettings().add("BC_TLS1.3_ENABLED"); return ret; } }); } @Override public Browser createNewBrowserInstance() { final Browser ret = super.createNewBrowserInstance(); setSSLSocketStreamOptions(ret); return ret; } @Override public void init() { for (String domain : domainsFree) { Browser.setRequestIntervalLimitGlobal(domain, 333); } for (String domain : domainsPremium) { Browser.setRequestIntervalLimitGlobal(domain, 333); } } public void correctDownloadLink(final DownloadLink link) throws MalformedURLException { try { String url = link.getPluginPatternMatcher(); url = correctAddedURL(this.getHost(), url); link.setPluginPatternMatcher(url); } catch (final PluginException e) { } } @Override public String getMirrorID(final DownloadLink link) { final String quality = link.getStringProperty(PROPERTY_QUALITY); final String viewkey = link.getStringProperty(PROPERTY_VIEWKEY); if (quality != null && viewkey != null) { final StringBuilder sb = new StringBuilder(32); sb.append("pornhub://"); sb.append(viewkey); sb.append("_"); sb.append(getFormat(link)); sb.append("_"); sb.append(quality); return sb.toString(); } else { return super.getMirrorID(link); } } @Override public String getLinkID(final DownloadLink link) { final String quality = link.getStringProperty(PROPERTY_QUALITY); final String viewkey = link.getStringProperty(PROPERTY_VIEWKEY); if (quality != null && viewkey != null) { final StringBuilder sb = new StringBuilder(32); sb.append("pornhub://"); sb.append(viewkey); sb.append("_"); sb.append(getFormat(link)); sb.append("_"); sb.append(quality); return sb.toString(); } else { return super.getLinkID(link); } } public static int getUrlCrawlLanguageHandlingMode() { return SubConfiguration.getConfig("pornhub.com").getIntegerProperty(PornHubCom.SETTING_URL_CRAWL_LANGUAGE_HANDLING, default_SETTING_URL_CRAWL_LANGUAGE_HANDLING); } public static String getPreferredSubdomain(final String url) throws MalformedURLException { final String originalSubdomain = Browser.getSubdomain(url, false); if (getUrlCrawlLanguageHandlingMode() == 1 && originalSubdomain != null) { return originalSubdomain; } else { return "www."; } } /** * Corrects single video/gif URL based on given/not and user preference. * * @throws MalformedURLException */ public static String correctAddedURL(final String pluginDomain, final String url) throws PluginException, MalformedURLException { final String viewKey = getViewkeyFromURL(url); final String urlDomain = Browser.getHost(url); if ("pornhubdecrypted".equals(urlDomain)) { /* do not modify pornhubdecrypted URLs */ return url; } else if (url.matches(type_modelhub)) { /* Do not modify modelhub URLs */ return url; } final String preferredSubdomain = getPreferredSubdomain(url); if (url.matches(type_photo)) { return createPornhubImageLink(pluginDomain, preferredSubdomain, urlDomain, viewKey, null); } else if (url.matches(type_gif_webm)) { return createPornhubGifLink(pluginDomain, preferredSubdomain, urlDomain, viewKey, null); } else { return createPornhubVideoLink(pluginDomain, preferredSubdomain, urlDomain, viewKey, null); } } private String getFormat(final DownloadLink link) { return link.getStringProperty(PROPERTY_FORMAT, "mp4"); } public static boolean requiresPremiumAccount(final String url) { if (url == null) { return false; } else if (url.matches(PornHubComVideoCrawler.PATTERN_MODELHUB_USER_PHOTO_ALBUMS)) { return false; } else if (url.matches(type_modelhub)) { return true; } else { return false; } } @Override public String getAGBLink() { return "https://www.pornhub.com/terms"; } public static Object RNKEYLOCK = new Object(); public static Request getPage(Browser br, final Request request) throws Exception { br.getPage(request); String RNKEY = evalRNKEY(br); if (RNKEY != null) { int maxLoops = 8;// up to 3 loops in tests synchronized (RNKEYLOCK) { while (true) { if (RNKEY == null) { return br.getRequest(); } else if (--maxLoops > 0) { br.setCookie(br.getHost(), "RNKEY", RNKEY); Thread.sleep(1000 + ((8 - maxLoops) * 500)); br.getPage(request.cloneRequest()); RNKEY = evalRNKEY(br); } else { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } } } } else { return br.getRequest(); } } public static Request getPage(Browser br, final String url) throws Exception { return getPage(br, br.createGetRequest(url)); } public static Request getFirstPageWithAccount(final PornHubCom plg, final Account account, final String url) throws Exception { if (account == null) { return getPage(plg.getBrowser(), url); } else { synchronized (account) { final boolean verifiedLogin = plg.login(account, false); final Request request = getPage(plg.getBrowser(), url); if (!isLoggedInHtml(plg.getBrowser())) { plg.getLogger().info("Not logged in?|VerifiedLogin:" + verifiedLogin); plg.login(account, true); return getPage(plg.getBrowser(), url); } else { return request; } } } } public static boolean isGeoRestricted(final Browser br) { final String[] errorMessages = new String[] { "Dieser Inhalt ist in deinem Land nicht verfügbar", "Ce contenu n'est pas disponible dans votre pays", "Este contenido no está disponible en tu país", "Questo contenuto non è disponibile nel tuo Paese", "Este conteúdo não está disponível no seu país", "Ten materiał jest niedostępny w Twoim kraju", "Этот контент не доступен в Вашей стране", "このコンテンツはあなたの国ではご利用いただけません。", "Deze content is niet beschikbaar in je land", "Tento Obsah není ve vaší zemi dostupný", "此内容在您的国家不可播放。" }; for (final String errorMessage : errorMessages) { if (br.containsHTML(">\\s*" + Pattern.quote(errorMessage) + "\\.?\\s*<")) { return true; } } return br.containsHTML("class\\s*=\\s*\"geoBlocked\"") || br.containsHTML(">\\s*This (?:video|content) is unavailable in your country.?\\s*<"); } public static boolean isFlagged(final Browser br) { return br.containsHTML(">\\s*Video has been flagged for verification in accordance with our trust and safety policy.?\\s*<"); } public static boolean hasOfflineRemovedVideoText(final Browser br) { return br.containsHTML("<span[^>]*>\\s*Video has been removed at the request of") || br.containsHTML("<span[^>]*>\\s*This video has been removed\\s*</span>") || br.containsHTML("<span[^>]*>\\s*This video is currently unavailable\\s*</span>"); } public static boolean hasOfflineVideoNotice(final Browser br) { return br.containsHTML("<div[^>]*class[^>]*video-notice[^>]*>\\s*<p>\\s*<span>\\s*This video has been disabled") || br.containsHTML("<h2 style[^>]*>\\s*(This video has been disabled|Dieses Video wurde deaktiviert|Cette vidéo a été désactivée|Este vídeo ha sido deshabilitado|Questo video è stato disattivato|O vídeo foi desativado|Ten film został zablokowany|Это видео было отключено|このビデオは利用できません|Deze video werd uitgeschakeld|Video bylo deaktivováno|此视频已下架)\\.?\\s*</h2>"); } public static boolean hasPendingReview(final Browser br) { return br.containsHTML("<h2 style[^>]*>\\s*(GIF is unavailable pending review|La GIF è ancora in fase di verifica e non è al momento disponibile|GIF está indisponível com revisão pendente|GIF is niet beschikbaar in afwachting van review)\\.?\\s*</h2>"); } private void checkAvailability(final DownloadLink link, final Browser br) throws PluginException { if (StringUtils.containsIgnoreCase(br.getURL(), "/premium/login")) { throw new AccountRequiredException(); } else if (isFlagged(br)) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND, "Video has been flagged"); } else if (isGeoRestricted(br)) { throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "This content is unavailable in your country", 24 * 60 * 60 * 1000l); } else if (hasOfflineRemovedVideoText(br)) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND, "Video has been removed"); } else if (hasOfflineVideoNotice(br)) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND, "Video has been disabled"); } else if (br.getHttpConnection().getResponseCode() == 404) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } else if (hasPendingReview(br)) { throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Unavailable due to pending review"); } } @Override public AvailableStatus requestFileInformation(final DownloadLink link) throws Exception { final Account account = AccountController.getInstance().getValidAccount(this.getHost()); return requestFileInformation(link, account); } public AvailableStatus requestFileInformation(final DownloadLink link, final Account account) throws Exception { prepBr(br); final String source_url = link.getStringProperty("mainlink"); String viewKey = null; try { final String url = link.getPluginPatternMatcher(); viewKey = getViewkeyFromURL(url); } catch (PluginException e) { viewKey = getViewkeyFromURL(source_url); } /* User-chosen quality, set in decrypter */ String html_filename = null; String server_filename = null; boolean isVideo = false; final String quality = link.getStringProperty(PROPERTY_QUALITY, null); /* * TODO account handling: Prefer account from handlePremium to be sure not to use ANY account for downloading but the account the * upper handling is using! */ dlUrl = null; boolean cachedURLFlag = false; if (link.getPluginPatternMatcher().matches(type_photo)) { final String linkHost = Browser.getHost(link.getPluginPatternMatcher()); /* Offline links should also have nice filenames */ link.setName(viewKey + ".jpg"); br.setFollowRedirects(true); getPage(br, createPornhubImageLink(this.getHost(), getPreferredSubdomain(link.getPluginPatternMatcher()), linkHost, viewKey, null)); if (br.containsHTML(html_privateimage)) { br.setFollowRedirects(true); getFirstPageWithAccount(this, account, createPornhubImageLink(this.getHost(), getPreferredSubdomain(link.getPluginPatternMatcher()), linkHost, viewKey, account)); if (br.containsHTML(html_privateimage)) { link.getLinkStatus().setStatusText("You're not authorized to watch/download this private image"); return AvailableStatus.TRUE; } } checkAvailability(link, br); String ext = null; final String gifVideoAsMp4 = br.getRegex("<video class=\"centerImageVid\"[^>]*>\\s+<source src=\"(https://[^\"]+)").getMatch(0); if (gifVideoAsMp4 != null) { /* "gif" images --> short mp4 videos without sound */ this.dlUrl = gifVideoAsMp4; ext = "mp4"; } else { /* Single image */ String photoImageSection = br.getRegex("(<div id=\"photoImageSection\">.*?</div>)").getMatch(0); if (photoImageSection != null) { dlUrl = new Regex(photoImageSection, "<img src=\"([^<>\"]+)\"").getMatch(0); } if (dlUrl == null) { dlUrl = br.getRegex("name=\"twitter:image:src\" content=\"(https?[^<>\"]*?\\.[A-Za-z]{3,5})\"").getMatch(0); } if (dlUrl != null) { ext = dlUrl.substring(dlUrl.lastIndexOf(".") + 1); } } if (dlUrl == null) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } html_filename = viewKey + "." + ext; } else if (link.getPluginPatternMatcher().matches(type_gif_webm)) { final String linkHost = Browser.getHost(link.getPluginPatternMatcher()); /* Offline links should also have nice filenames */ boolean webm = link.getBooleanProperty("webm", getPluginConfig().getBooleanProperty(GIFS_WEBM, true)); link.setName(viewKey + ".webm"); br.setFollowRedirects(true); getPage(br, createPornhubGifLink(this.getHost(), getPreferredSubdomain(link.getPluginPatternMatcher()), linkHost, viewKey, null)); checkAvailability(link, br); String title = br.getRegex("data-gif-title\\s*=\\s*\"(.*?)\"").getMatch(0); if (title == null) { title = br.getRegex("<title\\s*>\\s*(.*?)\\s*(&#124;|\\|)").getMatch(0); } if (title == null || StringUtils.containsIgnoreCase(title, "view_video.php")) { html_filename = viewKey; } else { html_filename = title + "_" + viewKey; } if (!webm) { // link or default is gif, check for gif html_filename += ".gif"; dlUrl = br.getRegex("data\\-gif\\s*=\\s*\"(https?[^\"]+" + Pattern.quote(viewKey) + "[^\\\"]*\\.gif)\"").getMatch(0); if (dlUrl == null) { logger.info("gif not found for:" + viewKey); } } if (dlUrl == null) { // gif -> don't fail but fallback to webm webm = true; html_filename += ".webm"; dlUrl = br.getRegex("data\\-webm\\s*=\\s*\"(https?[^\"]+" + Pattern.quote(viewKey) + "[^\\\"]*\\.webm)\"").getMatch(0); if (dlUrl == null) { dlUrl = br.getRegex("fileWebm\\s*=\\s*'(https?[^']+" + Pattern.quote(viewKey) + "[^']*\\.webm)'").getMatch(0); } if (dlUrl == null) { logger.info("webm not found for:" + viewKey); } } link.setProperty("webm", webm); } else { /* Required later if e.g. directurl has to be refreshed! */ isVideo = true; /* Offline links should also have nice filenames */ link.setName(viewKey + ".mp4"); html_filename = link.getStringProperty("decryptedfilename", null); dlUrl = link.getStringProperty(PROPERTY_DIRECTLINK, null); cachedURLFlag = true; if (dlUrl == null || html_filename == null) { /* This should never happen as every url goes into the decrypter first! */ throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } br.setFollowRedirects(true); getFirstPageWithAccount(this, account, createPornhubVideoLink(this.getHost(), getPreferredSubdomain(link.getPluginPatternMatcher()), Browser.getHost(source_url), viewKey, account)); checkAvailability(link, br); if (br.containsHTML(html_privatevideo)) { link.getLinkStatus().setStatusText("You're not authorized to watch/download this private video"); link.setName(html_filename); return AvailableStatus.TRUE; } else if (br.containsHTML(html_premium_only)) { throw new PluginException(LinkStatus.ERROR_PREMIUM, "Premium only File", PluginException.VALUE_ID_PREMIUM_ONLY); } else if (br.containsHTML(REMOVED_VIDEO)) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } else if (br.containsHTML(html_purchase_only)) { throw new PluginException(LinkStatus.ERROR_PREMIUM, "Premium/Purchase only File", PluginException.VALUE_ID_PREMIUM_ONLY); } else if (source_url == null || html_filename == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } } String format = link.getStringProperty(PROPERTY_FORMAT); if (format == null) { // older links format = "mp4"; } server_filename = getFilenameFromURL(dlUrl); if (this.getPluginConfig().getBooleanProperty(USE_ORIGINAL_SERVER_FILENAME, false) && server_filename != null) { link.setFinalFileName(server_filename); } else { link.setFinalFileName(html_filename); } if (!StringUtils.isEmpty(this.dlUrl)) { if (!verifyFinalURL(link, format, this.dlUrl, cachedURLFlag)) { if (!isVideo) { /* We cannot refresh directurls of e.g. photo content - final downloadurls should be static --> WTF */ throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Unknown server error"); } logger.info("Directurl has expired (?) --> Trying to generate new directurl"); final Map<String, Map<String, String>> qualities = getVideoLinks(this, br); if (qualities == null || qualities.size() == 0) { logger.warning("Failed to find any video qualities"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } this.dlUrl = qualities.containsKey(quality) ? qualities.get(quality).get(format) : null; if (this.dlUrl == null && StringUtils.equalsIgnoreCase("mp4", format)) { // 2020-01-11, only HLS available, auto check for hls logger.warning("Failed to get fresh directurl:" + format + "/" + quality + "|auto check for hls"); format = "hls"; this.dlUrl = qualities.containsKey(quality) ? qualities.get(quality).get(format) : null; } if (this.dlUrl == null) { logger.warning("Failed to get fresh directurl:" + format + "/" + quality); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } else { /* Last chance */ logger.warning("Check fresh directurl:" + format + "/" + quality + "/" + dlUrl); if (!verifyFinalURL(link, format, this.dlUrl, false)) { logger.info("Fresh directurl did not lead to downloadable content"); throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Failed to refresh directurl"); } else { link.setProperty(PROPERTY_FORMAT, format); } } } } return AvailableStatus.TRUE; } public boolean verifyFinalURL(final DownloadLink link, final String format, final String url, final boolean cachedURLFlag) throws Exception { try { if (StringUtils.equalsIgnoreCase("hls", format)) { final Browser hlsCheck = br.cloneBrowser(); hlsCheck.setFollowRedirects(true); hlsCheck.setAllowedResponseCodes(new int[] { -1 }); hlsCheck.getPage(url); if (hlsCheck.getHttpConnection().getResponseCode() != 200) { /* Directurl needs to be refreshed */ return false; } else if (!LinkCrawlerDeepInspector.looksLikeMpegURL(hlsCheck.getHttpConnection())) { /* Obligatory seconds check. */ throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } else { final List<HlsContainer> hlsContainers = HlsContainer.getHlsQualities(hlsCheck.cloneBrowser()); if (hlsContainers == null || hlsContainers.size() != 1) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } else { URLConnectionAdapter con = null; try { final List<M3U8Playlist> m3u8list = hlsContainers.get(0).getM3U8(hlsCheck); if (m3u8list == null || m3u8list.size() == 0) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } final Browser segmentCheck = br.cloneBrowser(); segmentCheck.setFollowRedirects(true); con = (Thread.currentThread() instanceof SingleDownloadController) ? segmentCheck.openGetConnection(m3u8list.get(0).getSegment(0).getUrl()) : null; if (con == null || looksLikeDownloadableContent(con)) { final HLSDownloader downloader = new HLSDownloader(link, br, br.getURL(), m3u8list); final long estimatedSize = downloader.getEstimatedSize(); if (estimatedSize > 0) { link.setDownloadSize(estimatedSize); } link.setProperty(PROPERTY_DIRECTLINK, url); return true; } else { segmentCheck.followConnection(true); } } catch (IOException e) { logger.log(e); } finally { if (con != null) { con.disconnect(); } } return false; } } } else { final Browser urlCheck = br.cloneBrowser(); urlCheck.setFollowRedirects(true); URLConnectionAdapter con = null; try { con = urlCheck.openHeadConnection(dlUrl); if (urlCheck.getHttpConnection().getResponseCode() != 200) { try { urlCheck.followConnection(true); } catch (final IOException e) { logger.log(e); } return false; } else if (StringUtils.containsIgnoreCase(urlCheck.getHttpConnection().getContentType(), "text")) { try { urlCheck.followConnection(true); } catch (final IOException e) { logger.log(e); } throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } else { if (con.getLongContentLength() > 0) { link.setDownloadSize(con.getLongContentLength()); } link.setProperty(PROPERTY_DIRECTLINK, url); return true; } } finally { if (con != null) { con.disconnect(); } } } } catch (PluginException e) { if (cachedURLFlag) { logger.log(e); return false; } else { throw e; } } } public static String getFilenameFromURL(final String url) { if (url == null) { return null; } else { /* 2019-07-15: TODO: Maybe add support for other directurls as well (e.g. pictures) */ final String ret = new Regex(url, "/([^/]+\\.mp4)").getMatch(0); if (StringUtils.isEmpty(ret)) { return null; } else { return ret; } } } @SuppressWarnings({ "unchecked" }) public static Map<String, Map<String, String>> getVideoLinks(final Plugin plugin, final Browser br) throws Exception { boolean success = false; final Map<String, Map<String, String>> qualities = new LinkedHashMap<String, Map<String, String>>(); String flashVars = br.getRegex("\\'flashvars\\' :[\t\n\r ]+\\{([^\\}]+)").getMatch(0); if (flashVars == null) { flashVars = br.getRegex("(var\\s*flashvars_\\d+.+quality_\\d+p;)\\s*playerObj").getMatch(0); if (flashVars == null) { flashVars = br.getRegex("(var\\s*flashvars_\\d+.+quality_\\d+p;)\\s+").getMatch(0); } if (flashVars == null) { /* Wider */ flashVars = br.getRegex("(var\\s*flashvars_\\d+.+\\['url'\\]\\s*=\\s*quality_\\d+p;)").getMatch(0); } if (flashVars == null) { /* Wide open - risky */ flashVars = br.getRegex("(var\\s*flashvars_\\d+.*?)(loadScriptUniqueId|</script)").getMatch(0); } boolean embed = false; if (flashVars == null) { /* Wide open - risky, embed */ flashVars = br.getRegex("(var\\s*flashvars[^_].*?)(loadScriptUniqueId|</script)").getMatch(0); embed = flashVars != null; } final String flashVarsID = new Regex(flashVars, "flashvars_(\\d+)").getMatch(0); if (flashVarsID != null || embed) { try { flashVars = flashVars.replaceFirst("(?s)(playerObjList.+)", ""); final ScriptEngineManager manager = JavaScriptEngineFactory.getScriptEngineManager(plugin); final ScriptEngine engine = manager.getEngineByName("javascript"); engine.eval("var document={};document.referrer=\"\";"); if (embed) { engine.eval(flashVars + "var result=JSON.stringify(flashvars);"); } else { engine.eval(flashVars + "var result=JSON.stringify(flashvars_" + flashVarsID + ");"); } flashVars = String.valueOf(engine.get("result")); } catch (final Exception e) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, null, e); } } } if (flashVars != null) { final Object obj = flashVars == null ? null : JavaScriptEngineFactory.jsonToJavaObject(flashVars); if (obj instanceof Map) { final Map<String, Object> values = (Map<String, Object>) obj; if (values == null || values.size() < 1) { return null; } String dllink_temp = null; // dllink_temp = (String) values.get("video_url"); final List<Object> entries = (List<Object>) values.get("mediaDefinitions"); if (entries.size() == 0) { /* * 2019-04-30: Very rare case - video is supposed to be online but ZERO qualities are available --> Video won't load in * browser either --> Offline */ return qualities; } final List<Object> medias = new ArrayList<Object>(entries); while (medias.size() > 0) { final Map<String, Object> e = (Map<String, Object>) medias.remove(0); String format = (String) e.get("format"); if (StringUtils.equalsIgnoreCase(format, "dash")) { plugin.getLogger().info("Dash not yet supported:" + JSonStorage.toString(e)); continue; } dllink_temp = (String) e.get("videoUrl"); format = format.toLowerCase(Locale.ENGLISH); Object qualityInfo = e.get("quality"); if (qualityInfo == null) { continue; } else if (qualityInfo instanceof List) { final int size = ((List) qualityInfo).size(); if (size == 1) { qualityInfo = ((List) qualityInfo).get(0); } else { if (StringUtils.equalsIgnoreCase(format, "mp4")) { final boolean mp4Workaround = MP4_WORKAROUND.get(); try { if (TRY_MP4.get()) { final Browser brc = br.cloneBrowser(); brc.setFollowRedirects(true); // no keep alive for this request brc.getHeaders().put("Connection", "close"); brc.getPage(dllink_temp); final List<Object> mp4Medias = plugin.restoreFromString(brc.toString(), TypeRef.LIST); medias.addAll(mp4Medias); } else { plugin.getLogger().info("progressive MP4 seems no longer to be supported!"); } } catch (IOException ioe) { plugin.getLogger().log(ioe); } catch (final JSonMapperException jme) { if (!mp4Workaround) { plugin.getLogger().info("Enable mp4 workaround"); MP4_WORKAROUND.set(true); } else { plugin.getLogger().info("Disable mp4 support"); TRY_MP4.set(false); } plugin.getLogger().log(jme); plugin.getLogger().info("Found invalid/broken quality: " + dllink_temp); } continue; } else if (StringUtils.equalsIgnoreCase(format, "hls")) { try { for (final Object quality : (List) qualityInfo) { final String q = quality + "P"; final String replacement = new Regex(dllink_temp, "(" + q + "_\\d+K)").getMatch(0); if (replacement != null && quality instanceof Number && qualities.get(quality.toString()) == null) { final String m3u8 = dllink_temp.replaceFirst("(\\d+/,)(.*?)(,_\\d+\\.mp4)", "$1" + replacement + "$3"); final Browser brc = br.cloneBrowser(); brc.setFollowRedirects(true); brc.getPage(m3u8); final List<HlsContainer> hlsQualities = HlsContainer.getHlsQualities(brc); if (hlsQualities.size() == 1) { Map<String, String> formatMap = qualities.get(quality.toString()); if (formatMap == null) { // prefer single quality m3u8 files, see blow formatMap = new HashMap<String, String>(); qualities.put(quality.toString(), formatMap); formatMap.put(format, dllink_temp); } } } } } catch (IOException ioe) { plugin.getLogger().log(ioe); } catch (JSonMapperException jme) { plugin.getLogger().log(jme); } continue; } plugin.getLogger().info("Skip:" + JSonStorage.toString(e)); continue; } } final Boolean encrypted = e.get("encrypted") == null ? null : ((Boolean) e.get("encrypted")).booleanValue(); if (encrypted == Boolean.TRUE) { final String decryptkey = (String) values.get("video_title"); try { dllink_temp = new BouncyCastleAESCounterModeDecrypt().decrypt(dllink_temp, decryptkey, 256); } catch (Throwable t) { /* Fallback for stable version */ dllink_temp = AESCounterModeDecrypt(dllink_temp, decryptkey, 256); } if (dllink_temp != null && (dllink_temp.startsWith("Error:") || !dllink_temp.startsWith("http"))) { success = false; } else { success = true; } } else { success = true; } final String quality = new Regex(qualityInfo.toString(), "(\\d+)").getMatch(0); Map<String, String> formatMap = qualities.get(quality); if (formatMap == null) { formatMap = new HashMap<String, String>(); qualities.put(quality, formatMap); } formatMap.put(format, dllink_temp); } } } if (!success) { String[][] var_player_quality_dp; /* 0 = match for quality, 1 = match for url */ int[] matchPlaces; if (isLoggedInHtml(br) && use_download_workarounds) { /* * 2017-02-10: Workaround - download via official downloadlinks if the user has an account. Grab official downloadlinks via * free/premium account. Keep in mind: Not all videos have official downloadlinks available for account mode - example: * ph58072cd969005 */ var_player_quality_dp = br.getRegex("href=\"(https?[^<>\"]+)\"><i></i><span>[^<]*?</span>\\s*?(\\d+)p\\s*?</a").getMatches(); matchPlaces = new int[] { 1, 0 }; } else { /* Normal stream download handling. */ /* 2017-02-07: seems they have seperated into multiple vars to block automated download tools. */ var_player_quality_dp = br.getRegex("var player_quality_(1080|720|480|360|240)p[^=]*?=\\s*('|\")(https?://.*?)\\2\\s*;").getMatches(); matchPlaces = new int[] { 0, 2 }; } if (var_player_quality_dp == null || var_player_quality_dp.length == 0) { String fvjs = br.getRegex("javascript\">\\s*(var flashvars[^;]+;)").getMatch(0); Pattern p = Pattern.compile("^\\s*?(var.*?var qualityItems_[\\d]* =.*?)$", Pattern.MULTILINE); String qualityItems = br.getRegex(p).getMatch(0); if (qualityItems != null) { String[][] qs = new Regex(qualityItems, "var (quality_([^=]+?)p)=").getMatches(); final ScriptEngineManager manager = JavaScriptEngineFactory.getScriptEngineManager(null); final ScriptEngine engine = manager.getEngineByName("javascript"); engine.eval(fvjs); engine.eval(qualityItems); for (int i = 0; i < qs.length; i++) { final String url = engine.get(qs[i][0]).toString(); final String quality = qs[i][1]; Map<String, String> formatMap = qualities.get(quality); if (formatMap == null) { formatMap = new HashMap<String, String>(); qualities.put(quality, formatMap); } if (StringUtils.isNotEmpty(url)) { if (StringUtils.containsIgnoreCase(url, "m3u8")) { formatMap.put("hls", url); } else { formatMap.put("mp4", url); } } } return qualities; } } /* * Check if we have links - if not, the video might not have any official downloadlinks available or our previous code failed * for whatever reason. */ if (var_player_quality_dp == null || var_player_quality_dp.length == 0) { /* Last chance fallback to embedded video. */ /* 2017-02-09: For embed player - usually only 480p will be available. */ /* Access embed video URL. */ /* viewkey should never be null! */ try { final String viewkey = getViewkeyFromURL(br.getURL()); if (viewkey != null) { final Browser brc = br.cloneBrowser(); getPage(brc, createPornhubVideoLinkEmbedFree(plugin.getHost(), brc, viewkey)); var_player_quality_dp = brc.getRegex("\"quality_(\\d+)p\"\\s*?:\\s*?\"(https?[^\"]+)\"").getMatches(); matchPlaces = new int[] { 0, 1 }; } } catch (PluginException e) { plugin.getLogger().log(e); } } final int matchQuality = matchPlaces[0]; final int matchUrl = matchPlaces[1]; for (final String quality : new String[] { "1080", "720", "480", "360", "240" }) { for (final String[] var : var_player_quality_dp) { // so far any of these links will work. if (var[matchQuality].equals(quality)) { String url = var[matchUrl]; url = url.replaceAll("( |\"|\\+)", ""); url = Encoding.unicodeDecode(url); Map<String, String> formatMap = qualities.get(quality); if (formatMap == null) { formatMap = new HashMap<String, String>(); qualities.put(quality, formatMap); } if (StringUtils.isNotEmpty(url)) { if (StringUtils.containsIgnoreCase(url, "m3u8")) { formatMap.put("hls", url); } else { formatMap.put("mp4", url); } } } } } } return qualities; } public static String getUserName(final Plugin plugin, final Browser br) { String ret = br.getRegex("\"author\"\\s*:\\s*(\"[^\"]+\")").getMatch(0); if (ret != null) { ret = JSonStorage.restoreFromString(ret, TypeRef.STRING); } else { ret = br.getRegex("/(?:model|users)/[^\"]+\"\\s*class\\s*=\\s*\"bolded\"\\s*>\\s*([^<>]+)\\s*</a>").getMatch(0); } return ret; } public static String getSiteTitle(final Plugin plugin, final Browser br) { String site_title = br.getRegex("<title>\\s*([^<>]*?)\\s*\\-\\s*Pornhub(\\.com)?\\s*</title>").getMatch(0); if (site_title == null) { site_title = br.getRegex("\"section_title overflow\\-title overflow\\-title\\-width\">([^<>]*?)</h1>").getMatch(0); if (site_title == null) { site_title = br.getRegex("<meta property\\s*=\\s*\"og:title\"\\s*content\\s*=\\s*\"(.*?)\"").getMatch(0); } } if (site_title != null) { site_title = Encoding.htmlDecode(site_title); site_title = plugin.encodeUnicode(site_title); } return site_title; } @Override public void handleFree(final DownloadLink link) throws Exception, PluginException { requestFileInformation(link); doFree(link); } @SuppressWarnings("deprecation") private void doFree(final DownloadLink link) throws Exception, PluginException { final String format = link.getStringProperty(PROPERTY_FORMAT); if (StringUtils.equalsIgnoreCase(format, "hls")) { if (StringUtils.isEmpty(dlUrl)) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } checkFFmpeg(link, "Download a HLS Stream"); final List<HlsContainer> hlsContainers = HlsContainer.getHlsQualities(br.cloneBrowser(), dlUrl); if (hlsContainers == null || hlsContainers.size() != 1) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } dl = new HLSDownloader(link, br, hlsContainers.get(0).getDownloadurl()); dl.startDownload(); } else { final boolean resume; final int maxchunks; if (link.getDownloadURL().matches(type_photo)) { resume = true; /* We only have small pictures --> No chunkload needed */ maxchunks = 1; requestFileInformation(link); } else { resume = ACCOUNT_FREE_RESUME; maxchunks = ACCOUNT_FREE_MAXCHUNKS; if (br.containsHTML(html_privatevideo)) { throw new PluginException(LinkStatus.ERROR_FATAL, "You're not authorized to watch/download this private video"); } if (StringUtils.isEmpty(dlUrl)) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } } dl = new jd.plugins.BrowserAdapter().openDownload(br, link, dlUrl, resume, maxchunks); if (!looksLikeDownloadableContent(dl.getConnection())) { try { br.followConnection(true); } catch (IOException e) { logger.log(e); } if (dl.getConnection().getResponseCode() == 403) { throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 403", 60 * 60 * 1000l); } else if (dl.getConnection().getResponseCode() == 404) { throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 404", 60 * 60 * 1000l); } else { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } } dl.startDownload(); } } @Override public int getMaxSimultanFreeDownloadNum() { return FREE_MAXDOWNLOADS; } public static final String COOKIE_ID_FREE = "v2_free"; public static final String COOKIE_ID_PREMIUM = "v2_premium"; public static String getPrimaryFreeDomain() { return PornHubCom.domainsFree[0]; } public static String getPrimaryPremiumDomain() { return PornHubCom.domainsPremium[0]; } private static void setAccountType(Account account, Account.AccountType type) { account.setType(type); if (Account.AccountType.PREMIUM.equals(type)) { /* Premium accounts can still have captcha */ account.setMaxSimultanDownloads(ACCOUNT_FREE_MAXDOWNLOADS); account.setConcurrentUsePossible(false); } else { /* Free accounts can still have captcha */ account.setMaxSimultanDownloads(ACCOUNT_FREE_MAXDOWNLOADS); account.setConcurrentUsePossible(false); } } @Override public String getUserInput(String title, String message, DownloadLink link) throws PluginException { try { return super.getUserInput(title, message, link); } catch (PluginException e) { if (e.getLinkStatus() == LinkStatus.ERROR_FATAL) { return null; } else { throw e; } } } public static final String[] domainsFree = new String[] { "pornhub.com", "pornhub.org" }; public static final String[] domainsPremium = new String[] { "pornhubpremium.com", "modelhub.com" }; public static final String PROPERTY_LAST_USED_LOGIN_DOMAIN = "last_used_login_domain"; public boolean login(final Account account, final boolean force) throws Exception { synchronized (account) { try { final String preferredLoginFreeDomain = getConfiguredDomainLoginFree(this.getHost()); final String preferredLoginPremiumDomain = getConfiguredDomainLoginPremium(this.getHost()); // Load cookies br.setCookiesExclusive(true); /* 2017-01-25: Important - we often have redirects! */ br.setFollowRedirects(true); prepBr(br); final String freeCookieDomain = getPreferredFreeCookieDomain(account); final Cookies freeCookies = account.loadCookies(COOKIE_ID_FREE); final Cookies premiumCookies = account.loadCookies(COOKIE_ID_PREMIUM); final boolean is_cookie_only_login = account.getBooleanProperty(PROPERTY_ACCOUNT_is_cookie_login_only, false); final boolean cookiesOk = freeCookies != null && premiumCookies != null && (isLoggedInFreeCookieFree(freeCookies) || isLoggedInPremiumCookie(premiumCookies)); if (!force && cookiesOk) { br.setCookies(freeCookieDomain, freeCookies); br.setCookies(preferredLoginPremiumDomain, premiumCookies); logger.info("Trust login cookies without check:" + account.getType()); /* We trust these cookies --> Do not check them */ return false; } if (freeCookies != null && premiumCookies != null) { /* Check cookies - only perform a full login if they're not valid anymore. */ br.setCookies(freeCookieDomain, freeCookies); br.setCookies(preferredLoginPremiumDomain, premiumCookies); if (checkLoginSetAccountTypeAndSaveCookies(br, account, true)) { logger.info("Cookie login successful"); return true; } else { br.clearCookies(null); logger.info("Cached login cookies failed"); } } if (is_cookie_only_login) { if (account.hasEverBeenValid()) { throw new AccountInvalidException(_GUI.T.accountdialog_check_cookies_expired()); } else { throw new AccountInvalidException(_GUI.T.accountdialog_check_cookies_invalid()); } } logger.info("Performing full login"); prepBr(br); // getPage(br, "https://www." + preferredLoginFreeDomain); getPage(br, getProtocolFree() + "www." + preferredLoginFreeDomain + "/login"); if (br.containsHTML("(?i)Sorry we couldn't find what you were looking for")) { /* Try again */ getPage(br, getProtocolFree() + "www." + preferredLoginFreeDomain + "/login"); } final Form loginform = br.getFormbyKey("username"); // final String login_key = br.getRegex("id=\"login_key\" value=\"([^<>\"]*?)\"").getMatch(0); // final String login_hash = br.getRegex("id=\"login_hash\" value=\"([^<>\"]*?)\"").getMatch(0); if (loginform == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } String token1 = null; if (loginform.hasInputFieldByName("token")) { token1 = loginform.getInputField("token").getValue(); } loginform.put("username", account.getUser()); loginform.put("password", Encoding.urlEncode(account.getPass())); loginform.put("remember_me", "on"); loginform.setMethod(MethodType.POST); loginform.setAction("/front/authenticate"); br.getHeaders().put("X-Requested-With", "XMLHttpRequest"); br.submitForm(loginform); Map<String, Object> entries = JSonStorage.restoreFromString(br.toString(), TypeRef.HASHMAP); // final String success = PluginJSonUtils.getJsonValue(br, "success"); final Number twoStepVerification = ((Number) entries.get("twoStepVerification")); if (twoStepVerification != null && twoStepVerification.intValue() == 1) { /* At this point we know that username and password are correct! */ final String authyId = (String) entries.get("authyId"); final String authyIdHashed = (String) entries.get("authyIdHashed"); final String token2 = (String) entries.get("autoLoginParameter"); final String phoneNumber = (String) entries.get("phoneNumber"); if (StringUtils.isEmpty(authyId) || StringUtils.isEmpty(token2) || StringUtils.isEmpty(phoneNumber)) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } logger.info("2FA code required"); String twoFACode = this.getUserInput("Enter 2-Factor SMS Authentication code for number " + phoneNumber, null); if (twoFACode != null) { twoFACode = twoFACode.trim(); } /* 2021-03-08: I also got 7-digit codes... */ if (twoFACode == null || !twoFACode.matches("^\\d{4,}$")) { if ("de".equalsIgnoreCase(System.getProperty("user.language"))) { throw new PluginException(LinkStatus.ERROR_PREMIUM, "\r\nUngültiges Format der 2-faktor-Authentifizierung!", PluginException.VALUE_ID_PREMIUM_DISABLE); } else { throw new PluginException(LinkStatus.ERROR_PREMIUM, "\r\nInvalid 2-factor-authentication code format!", PluginException.VALUE_ID_PREMIUM_DISABLE); } } final Form loginform2 = new Form(); loginform2.setAction(br.getURL()); loginform2.setMethod(MethodType.POST); loginform2.put("username", Encoding.urlEncode(account.getUser())); loginform2.put("token2", Encoding.urlEncode(token2)); loginform2.put("verification_modal", "1"); loginform2.put("authyId", authyId); loginform2.put("authyIdHashed", StringUtils.valueOrEmpty(authyIdHashed)); if (token1 != null) { loginform2.put("token", Encoding.urlEncode(token1)); } loginform2.put("verification_code", twoFACode); br.submitForm(loginform2); entries = JSonStorage.restoreFromString(br.toString(), TypeRef.HASHMAP); } final String redirect = (String) entries.get("redirect"); final Boolean expiredPremiumUser = (Boolean) entries.get("expiredPremiumUser"); /* * 2022-06-27: remember_me is always "false" even though we check the "remember_me" checkbox/field. It's the same in browser * though! */ // final Boolean rememberMe = (Boolean) entries.get("remember_me"); // final String username = (String) entries.get("username"); if ((Integer) ReflectionUtils.cast(entries.get("success"), Integer.class) != 1) { throw new AccountInvalidException(); } if (redirect != null && (redirect.startsWith("http") || redirect.startsWith("/"))) { /* Required to get the (premium) cookies (multiple redirects). */ final boolean premiumExpired; if (expiredPremiumUser != null && expiredPremiumUser == Boolean.TRUE) { premiumExpired = true; } else { premiumExpired = isPremiumFromURL(redirect) && redirect.contains("expired"); } getPage(br, redirect); if (premiumExpired && !isPremiumDomain(br.getHost())) { /** * Expired pornhub premium --> It should still be a valid free account --> We might need to access a special url * which redirects us to the pornhub free mainpage and sets the cookies. </br> * 2022-06-27: Old code but let's leave it in for now as we can't know if it is still needed. */ logger.info("Expired premium --> Free account (?)"); final String pornhubMainpageCookieRedirectUrl = br.getRegex("\\'pornhubLink\\'\\s*?:\\s*?(?:\"|\\')(https?://(?:www\\.)?pornhub\\.(?:com|org)/[^<>\"\\']+)(?:\"|\\')").getMatch(0); if (pornhubMainpageCookieRedirectUrl != null) { getPage(br, pornhubMainpageCookieRedirectUrl); } else { logger.info("Failed to find pornhubMainpageCookieRedirectUrl"); } } } else { /* Fallback */ getPage(br, getProtocolFree() + "www." + preferredLoginFreeDomain); } if (!isLoggedInHtml(br)) { if (twoStepVerification != null && twoStepVerification.intValue() == 1) { throw new PluginException(LinkStatus.ERROR_PREMIUM, "Invalid 2-factor-authentication code", PluginException.VALUE_ID_PREMIUM_DISABLE); } else { throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); } } /* Check if we're really logged in and set account type. */ if (!checkLoginSetAccountTypeAndSaveCookies(br, account, false)) { if (isAccountAgeVerificationRequired(br, account)) { throw new AccountInvalidException("Please verify your age to access Pornhub Premium"); } else { /* This should never happen */ logger.warning("Invalid logins although full login seemed to be successful"); throw new AccountInvalidException(); } } return true; } catch (final PluginException e) { if (e.getLinkStatus() == LinkStatus.ERROR_PREMIUM) { account.clearCookies(COOKIE_ID_FREE); account.clearCookies(COOKIE_ID_PREMIUM); } throw e; } } } private boolean isAccountAgeVerificationRequired(final Browser br, final Account account) { final String[] errorMessages = new String[] { "Please verify your age to access Pornhub Premium", "Bitte überprüfen Sie Ihr Alter, um auf Pornhub Premium zugreifen zu können", "Veuillez vérifier votre âge pour accéder à Pornhub Premium" }; for (final String errorMessage : errorMessages) { if (br.containsHTML("title\\s*:\\s*'" + Pattern.quote(errorMessage) + "'")) { return true; } } return false; } /** * Checks login and sets account-type. </br> * Expects browser instance to be logged in already (cookies need to be there). * * @throws Exception */ private boolean checkLoginSetAccountTypeAndSaveCookies(final Browser br, final Account account, final boolean accessMainpage) throws Exception { final String preferredLoginFreeDomain = getConfiguredDomainLoginFree(this.getHost()); final String preferredLoginPremiumDomain = getConfiguredDomainLoginPremium(this.getHost()); final String freeCookieDomain = getPreferredFreeCookieDomain(account); final boolean useNewHandling = true; if (useNewHandling) { /* 2022-06-27: New simpler handling */ if (accessMainpage) { getPage(br, (getProtocolFree() + "www." + preferredLoginFreeDomain)); } final String hopefullyFreeDomain = br.getHost(); final String premiumAuthURL = br.getRegex("(?i)(/authenticate/goToLoggedIn)\"\\s*>\\s*Access your Pornhub Premium").getMatch(0); if (premiumAuthURL != null) { /* This will redirect to pornhub premium website and set required cookies */ logger.info("Looks like account is premium"); getPage(br, premiumAuthURL); } if (!isLoggedInHtml(br)) { return false; } if (isLoggedInHtmlPremium(br)) { setAccountType(account, AccountType.PREMIUM); } else { setAccountType(account, AccountType.FREE); } if (isFreeDomain(hopefullyFreeDomain)) { /* Free cookies shall be available and we're currently on a free domain -> Get cookies from that domain */ account.saveCookies(br.getCookies(hopefullyFreeDomain), COOKIE_ID_FREE); logger.info("User preferred free domain: " + preferredLoginFreeDomain + " | Actually used free domain: " + hopefullyFreeDomain); if (!account.getStringProperty(PROPERTY_LAST_USED_LOGIN_DOMAIN, freeCookieDomain).equals(hopefullyFreeDomain)) { /* This is needed so when we check the login cookies next time, cookies will be set on the correct domain. */ logger.info("Old free domain: " + freeCookieDomain + " | New free domain: " + hopefullyFreeDomain); account.setProperty(PROPERTY_LAST_USED_LOGIN_DOMAIN, hopefullyFreeDomain); } } else { /* No free cookies available --> This should never happen --> Use user defined domain to get cookies from */ logger.warning("Failed to find current free domain"); account.saveCookies(br.getCookies(freeCookieDomain), COOKIE_ID_FREE); } account.saveCookies(br.getCookies(preferredLoginPremiumDomain), COOKIE_ID_PREMIUM); return true; } else { /* Old handling */ if (AccountType.PREMIUM.equals(account.getType())) { /* fast check */ getPage(br, (getProtocolPremium() + preferredLoginPremiumDomain + "/user/login_status?ajax=1")); if (br.containsHTML("\"success\"\\s*:\\s*(\"1\"|true)") && isLoggedInPremiumCookie(br.getCookies(br.getHost()))) { setAccountType(account, AccountType.PREMIUM); logger.info("Verified(fast) premium->premium login cookies:" + account.getType()); account.saveCookies(br.getCookies(freeCookieDomain), COOKIE_ID_FREE); account.saveCookies(br.getCookies(preferredLoginPremiumDomain), COOKIE_ID_PREMIUM); return true; } else { /* slow check */ getPage(br, (getProtocolPremium() + preferredLoginPremiumDomain)); if (isLoggedInHtmlPremium(br)) { setAccountType(account, AccountType.PREMIUM); logger.info("Verified(slow) premium->premium login cookies:"); account.saveCookies(br.getCookies(freeCookieDomain), COOKIE_ID_FREE); account.saveCookies(br.getCookies(preferredLoginPremiumDomain), COOKIE_ID_PREMIUM); return true; } else if (isLoggedInHtmlFree(br)) { setAccountType(account, AccountType.FREE); logger.info("Verified(slow) premium->free login cookies:" + account.getType()); account.saveCookies(br.getCookies(freeCookieDomain), COOKIE_ID_FREE); account.saveCookies(br.getCookies(preferredLoginPremiumDomain), COOKIE_ID_PREMIUM); return true; } } } else { getPage(br, (getProtocolFree() + "www." + preferredLoginFreeDomain)); if (br.containsHTML("(?i)/authenticate/goToLoggedIn\"\\s*>\\s*Access your Pornhub Premium")) { // 2020-12-29 - no auto redirect to pornhub premium getPage(br, "/authenticate/goToLoggedIn"); } if (isLoggedInHtmlFree(br)) { setAccountType(account, AccountType.FREE); logger.info("Verified(slow) free->free login cookies:" + account.getType()); account.saveCookies(br.getCookies(freeCookieDomain), COOKIE_ID_FREE); account.saveCookies(br.getCookies(preferredLoginPremiumDomain), COOKIE_ID_PREMIUM); return true; } else { getPage(br, (getProtocolPremium() + preferredLoginPremiumDomain + "/user/login_status?ajax=1")); if (br.containsHTML("\"success\"\\s*:\\s*(\"1\"|true)") && isLoggedInPremiumCookie(br.getCookies(preferredLoginPremiumDomain))) { setAccountType(account, AccountType.PREMIUM); logger.info("Verified(fast) free->premium login cookies:" + account.getType()); account.saveCookies(br.getCookies(freeCookieDomain), COOKIE_ID_FREE); account.saveCookies(br.getCookies(preferredLoginPremiumDomain), COOKIE_ID_PREMIUM); return true; } } } } return false; } public static boolean isLoggedInHtml(final Browser br) { return br != null && (br.containsHTML("(?i)class\\s*=\\s*\"signOut\"|/premium/lander\"\\s*>\\s*Log ?out\\s*<") || br.containsHTML("class\\s*=\\s*\"[^\"]*ph-icon-logout[^\"]*\"[^>]*>[^<]*</i>\\s*<span[^>]*>\\s*Log ?Out\\s*<")); } public static boolean isLoggedInHtmlPremium(final Browser br) { return br != null && br.getURL() != null && PornHubCom.isPremiumDomain(br.getHost()) && isLoggedInPremiumCookie(br.getCookies(br.getHost())) && isLoggedInHtml(br); } public static boolean isLoggedInHtmlFree(final Browser br) { return br != null && br.getURL() != null && !PornHubCom.isPremiumDomain(br.getHost()) && isLoggedInFreeCookieFree(br.getCookies(br.getHost())) && isLoggedInHtml(br); } public static boolean isLoggedInFreeCookieFree(final Cookies cookies) { return isLoggedInCookie(cookies); } public static boolean isLoggedInPremiumCookie(final Cookies cookies) { return isLoggedInCookie(cookies); } public static boolean isLoggedInCookie(final Cookies cookies) { return cookies != null && (cookies.get("gateway_security_key", Cookies.NOTDELETEDPATTERN) != null || cookies.get("il", Cookies.NOTDELETEDPATTERN) != null); } @Override public AccountInfo fetchAccountInfo(final Account account) throws Exception { final AccountInfo ai = new AccountInfo(); synchronized (account) { final boolean isCookieLoginOnly = account.getBooleanProperty(PROPERTY_ACCOUNT_is_cookie_login_only, false); login(account, true); ai.setUnlimitedTraffic(); if (AccountType.PREMIUM.equals(account.getType())) { if (isCookieLoginOnly) { /* Never modify previous AccountInfo if we're logged in via cookies only! */ return account.getAccountInfo(); } else { return ai; } } else { return ai; } } } @Override public void handlePremium(final DownloadLink link, final Account account) throws Exception { requestFileInformation(link); /* No need to login as we're already logged in. */ doFree(link); } @Override public int getMaxSimultanPremiumDownloadNum() { return ACCOUNT_FREE_MAXDOWNLOADS; } /** * AES CTR(Counter) Mode for Java ported from AES-CTR-Mode implementation in JavaScript by Chris Veness * * @see <a href= * "http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf">"Recommendation for Block Cipher Modes of Operation - Methods and Techniques"</a> */ public static String AESCounterModeDecrypt(String cipherText, String key, int nBits) throws Exception { if (!(nBits == 128 || nBits == 192 || nBits == 256)) { return "Error: Must be a key mode of either 128, 192, 256 bits"; } if (cipherText == null || key == null) { return "Error: cipher and/or key equals null"; } String res = null; nBits = nBits / 8; byte[] data = Base64.decode(cipherText.toCharArray()); /* CHECK: we should always use getBytes("UTF-8") or with wanted charset, never system charset! */ byte[] k = Arrays.copyOf(key.getBytes(), nBits); Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); SecretKey secretKey = generateSecretKey(k, nBits); byte[] nonceBytes = Arrays.copyOf(Arrays.copyOf(data, 8), nBits / 2); IvParameterSpec nonce = new IvParameterSpec(nonceBytes); cipher.init(Cipher.ENCRYPT_MODE, secretKey, nonce); /* CHECK: we should always use new String (bytes,charset) to avoid issues with system charset and utf-8 */ res = new String(cipher.doFinal(data, 8, data.length - 8)); return res; } public static SecretKey generateSecretKey(byte[] keyBytes, int nBits) throws Exception { try { SecretKey secretKey = new SecretKeySpec(keyBytes, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); keyBytes = cipher.doFinal(keyBytes); } catch (InvalidKeyException e) { throw new PluginException(LinkStatus.ERROR_FATAL, "Unlimited Strength JCE Policy Files needed!", e); } catch (Throwable e1) { LogController.CL().log(e1); } System.arraycopy(keyBytes, 0, keyBytes, nBits / 2, nBits / 2); return new SecretKeySpec(keyBytes, "AES"); } public static class BouncyCastleAESCounterModeDecrypt { private String decrypt(String cipherText, String key, int nBits) throws Exception { if (!(nBits == 128 || nBits == 192 || nBits == 256)) { return "Error: Must be a key mode of either 128, 192, 256 bits"; } if (cipherText == null || key == null) { return "Error: cipher and/or key equals null"; } byte[] decrypted; nBits = nBits / 8; byte[] data = Base64.decode(cipherText.toCharArray()); /* CHECK: we should always use getBytes("UTF-8") or with wanted charset, never system charset! */ byte[] k = Arrays.copyOf(key.getBytes(), nBits); /* AES/CTR/NoPadding (SIC == CTR) */ org.bouncycastle.crypto.BufferedBlockCipher cipher = new org.bouncycastle.crypto.BufferedBlockCipher(new org.bouncycastle.crypto.modes.SICBlockCipher(new org.bouncycastle.crypto.engines.AESEngine())); cipher.reset(); SecretKey secretKey = generateSecretKey(k, nBits); byte[] nonceBytes = Arrays.copyOf(Arrays.copyOf(data, 8), nBits / 2); IvParameterSpec nonce = new IvParameterSpec(nonceBytes); /* true == encrypt; false == decrypt */ cipher.init(true, new org.bouncycastle.crypto.params.ParametersWithIV(new org.bouncycastle.crypto.params.KeyParameter(secretKey.getEncoded()), nonce.getIV())); decrypted = new byte[cipher.getOutputSize(data.length - 8)]; int decLength = cipher.processBytes(data, 8, data.length - 8, decrypted, 0); cipher.doFinal(decrypted, decLength); /* CHECK: we should always use new String (bytes,charset) to avoid issues with system charset and utf-8 */ return new String(decrypted); } private SecretKey generateSecretKey(byte[] keyBytes, int nBits) throws Exception { try { SecretKey secretKey = new SecretKeySpec(keyBytes, "AES"); /* AES/ECB/NoPadding */ org.bouncycastle.crypto.BufferedBlockCipher cipher = new org.bouncycastle.crypto.BufferedBlockCipher(new org.bouncycastle.crypto.engines.AESEngine()); cipher.init(true, new org.bouncycastle.crypto.params.KeyParameter(secretKey.getEncoded())); keyBytes = new byte[cipher.getOutputSize(secretKey.getEncoded().length)]; int decLength = cipher.processBytes(secretKey.getEncoded(), 0, secretKey.getEncoded().length, keyBytes, 0); cipher.doFinal(keyBytes, decLength); } catch (Throwable e) { return null; } System.arraycopy(keyBytes, 0, keyBytes, nBits / 2, nBits / 2); return new SecretKeySpec(keyBytes, "AES"); } } private static final AtomicBoolean MP4_WORKAROUND = new AtomicBoolean(false); private static final AtomicBoolean TRY_MP4 = new AtomicBoolean(true); public static Browser prepBr(final Browser br) { if (TRY_MP4.get() && MP4_WORKAROUND.get()) { br.setCookie("http://pornhub.com/", "platform", "mac"); br.getHeaders().put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15"); } br.getHeaders().put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); br.getHeaders().put("Accept-Language", "en-US,en;q=0.8,de;q=0.6"); br.getHeaders().put("Accept-Charset", null); for (String domain : domainsFree) { br.setCookie(domain, "age_verified", "1"); } for (String domain : domainsPremium) { br.setCookie(domain, "age_verified", "1"); } if (getUrlCrawlLanguageHandlingMode() == 0) { // make sure that english language will be used in this mode for (String domain : domainsFree) { br.setCookie(domain, "lang", "en"); } for (String domain : domainsPremium) { br.setCookie(domain, "lang", "en"); } } br.setLoadLimit(br.getDefaultLoadLimit() * 4); /* Mandatory since 2023-03-23 */ br.setCookie("pornhub.com", "cookiesBannerSeen", "1"); br.setCookie("pornhub.com", "accessAgeDisclaimerPH", "1"); return br; } public static String createPornhubImageLink(final String pluginDomain, final String subdomain, final String urlDomain, final String viewkey, final Account acc) { if (PornHubCom.isPremiumDomain(urlDomain)) { /* Premium url */ return getProtocolPremium() + subdomain + getConfiguredDomainURL(pluginDomain, urlDomain) + "/photo/" + viewkey; } else { /* Free url */ return getProtocolFree() + subdomain + getConfiguredDomainURL(pluginDomain, urlDomain) + "/photo/" + viewkey; } } public static String createPornhubGifLink(final String pluginDomain, final String subdomain, final String urlDomain, final String viewkey, final Account acc) { if (PornHubCom.isPremiumDomain(urlDomain)) { /* Premium url */ return getProtocolPremium() + subdomain + getConfiguredDomainURL(pluginDomain, urlDomain) + "/gif/" + viewkey; } else { /* Free url */ return getProtocolFree() + subdomain + getConfiguredDomainURL(pluginDomain, urlDomain) + "/gif/" + viewkey; } } public static String createPornhubVideoLink(final String pluginDomain, final String subdomain, final String urlDomain, final String viewkey, final Account acc) { if (PornHubCom.isPremiumDomain(urlDomain)) { /* Premium url */ return getProtocolPremium() + subdomain + getConfiguredDomainURL(pluginDomain, urlDomain) + "/view_video.php?viewkey=" + viewkey; } else { /* Free url */ return getProtocolFree() + subdomain + getConfiguredDomainURL(pluginDomain, urlDomain) + "/view_video.php?viewkey=" + viewkey; } } public static String createPornhubVideoLinkEmbedFree(final String pluginDomain, final Browser br, final String viewkey) { if (isLoggedInHtmlPremium(br)) { return createPornhubVideoLinkEmbedPremium(pluginDomain, viewkey); } else { return createPornhubVideoLinkEmbedFree(pluginDomain, viewkey); } } /** Returns embed url for free- and free account mode. */ public static String createPornhubVideoLinkEmbedFree(final String pluginDomain, final String viewkey) { return String.format("https://www.%s/embed/%s", getConfiguredDomainURL(pluginDomain, getPrimaryFreeDomain()), viewkey); } /** Returns embed url for premium account mode. */ public static String createPornhubVideoLinkEmbedPremium(final String pluginDomain, final String viewkey) { // return String.format("https://www.%s/embed/%s", getConfiguredDomainURL(pluginDomain, DOMAIN_PORNHUB_PREMIUM), viewkey); return createPornhubVideoLinkEmbedFree(pluginDomain, viewkey); } public static boolean isPremiumFromURL(final String url) { return isPremiumDomain(Browser.getHost(url)); } /** Checks if given domain is a <b>supported</b> premium domain. */ public static boolean isPremiumDomain(final String domain) { if (domain == null) { return false; } else { for (final String premiumDomain : domainsPremium) { if (StringUtils.containsIgnoreCase(domain, premiumDomain)) { return true; } } return false; } } public static boolean isFreeDomain(final String domain) { if (!isPremiumDomain(domain)) { return true; } else { return false; } } public static String getViewkeyFromURL(final String url) throws PluginException { if (StringUtils.isEmpty(url)) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } else { final String ret; if (url.matches(type_photo)) { ret = new Regex(url, "photo/([A-Za-z0-9\\-_]+)$").getMatch(0); } else if (url.matches(type_gif_webm)) { ret = new Regex(url, "gif/([A-Za-z0-9\\-_]+)$").getMatch(0); } else if (url.matches("(?i).+/embed/.+")) { ret = new Regex(url, "/embed/([a-z0-9]+)").getMatch(0); } else if (url.matches(".+/video/ph[a-f0-9]+$")) { ret = new Regex(url, "(ph[a-f0-9]+)").getMatch(0); } else if (url.matches(".+/pornhubdecrypted/ph[a-f0-9]+.+")) { ret = new Regex(url, "pornhubdecrypted/(ph[a-f0-9]+)").getMatch(0); } else { ret = new Regex(url, "viewkey=([a-z0-9]+)").getMatch(0); } if (StringUtils.isEmpty(ret) || "null".equals(ret)) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } else { return ret; } } } private boolean isVideo(final String url) { return url != null && url.contains("viewkey="); } @Override public String buildExternalDownloadURL(final DownloadLink downloadLink, final PluginForHost buildForThisPlugin) { if (buildForThisPlugin != null && !StringUtils.equals(this.getHost(), buildForThisPlugin.getHost())) { return downloadLink.getStringProperty("mainlink", null); } else { return super.buildExternalDownloadURL(downloadLink, buildForThisPlugin); } } @Override public boolean allowHandle(final DownloadLink link, final PluginForHost plugin) { if (!link.isEnabled() && "".equals(link.getPluginPatternMatcher())) { /* * setMultiHostSupport uses a dummy DownloadLink, with isEnabled == false. we must set to true for the host to be added to the * supported host array. */ return true; } else { if ("debrid-link.fr".equals(plugin.getHost())) { // only supports 360p return false; } else { /* Original plugin can handle every kind of URL! */ final boolean downloadViaSourcePlugin = link.getHost().equalsIgnoreCase(plugin.getHost()); /* MOCHs can only handle video URLs! */ final boolean downloadViaMOCH = !link.getHost().equalsIgnoreCase(plugin.getHost()) && isVideo(link.getStringProperty("mainlink", null)); return downloadViaSourcePlugin || downloadViaMOCH; } } } public static String getProtocolPremium() { return "https://"; } public static String getProtocolFree() { return "https://"; } public final static String evalRNKEY(Browser br) throws ScriptException { if (br.containsHTML("document.cookie=\"RNKEY") && br.containsHTML("leastFactor")) { ScriptEngineManager mgr = JavaScriptEngineFactory.getScriptEngineManager(null); ScriptEngine engine = mgr.getEngineByName("JavaScript"); String js = br.toString(); js = new Regex(js, "<script.*?>(?:<!--)?(.*?)(?://-->)?</script>").getMatch(0); js = js.replace("document.cookie=", "return "); js = js.replaceAll("(/\\*.*?\\*/)", ""); engine.eval(js + " var ret=go();"); final String answer = (engine.get("ret").toString()); return new Regex(answer, "RNKEY=(.+)").getMatch(0); } else { return null; } } @Override public String getDescription() { return "JDownloader's Pornhub plugin helps downloading videoclips from pornhub(premium).com."; } public static final String SELECTED_DOMAIN = "selected_domain2"; public static final int default_SELECTED_DOMAIN = 0; public static final String[] DOMAINS = new String[] { "pornhub.com & pornhubpremium.com", "pornhub.org & pornhubpremium.com" }; public static final String SETTING_URL_CRAWL_LANGUAGE_HANDLING = "url_crawl_language_handling"; public static final int default_SETTING_URL_CRAWL_LANGUAGE_HANDLING = 0; public static final String[] SETTING_URL_CRAWL_LANGUAGE_HANDLING_OPTIONS = new String[] { "Replace subdomain in url with 'www.' -> Title language English", "Do not touch subdomain -> Title language can vary depending on URL" }; /** Returns user configured domain based on domain given in URL we want to access. */ public static String getConfiguredDomainURL(final String pluginDomain, final String domainFromURL) { if (domainFromURL == null) { throw new IllegalArgumentException("domainFromURL is null!"); } if (!domainCanBeChanged(domainFromURL)) { return domainFromURL; } final SubConfiguration cfg = SubConfiguration.getConfig(pluginDomain); switch (cfg.getIntegerProperty(SELECTED_DOMAIN, default_SELECTED_DOMAIN)) { case 1: return domainFromURL.replaceFirst("\\.com$", ".org"); case 0: default: return domainFromURL.replaceFirst("\\.org$", ".com"); } } public static boolean domainCanBeChanged(final String domain) { if (domain.equalsIgnoreCase("modelhub.com") || domain.equalsIgnoreCase("pornhubpremium.com")) { /* E.g. modelhub.org / pornhubpremium.org does not exist. */ return false; } else { return true; } } private String getPreferredFreeCookieDomain(final Account account) { final String lastUsedLoginDomain = account.getStringProperty(PROPERTY_LAST_USED_LOGIN_DOMAIN); if (lastUsedLoginDomain != null && !isPremiumDomain(lastUsedLoginDomain)) { /* Return stored domain. */ return lastUsedLoginDomain; } else { return getConfiguredDomainLoginFree(this.getHost()); } } /** Returns user configured domain for login process free account. */ public static String getConfiguredDomainLoginFree(final String pluginDomain) { return getConfiguredDomainURL(pluginDomain, getPrimaryFreeDomain()); } /** Returns user configured domain for login process premium account. */ public static String getConfiguredDomainLoginPremium(final String pluginDomain) { if (true) { /* right now https://pornhubpremium.org does not work */ return getPrimaryPremiumDomain(); } else { return getConfiguredDomainURL(pluginDomain, getPrimaryPremiumDomain()); } } private void setConfigElements() { final ConfigEntry best = new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), BEST_ONLY, "Always only grab the best resolution available?").setDefaultValue(false); getConfig().addEntry(best); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), BEST_SELECTION_ONLY, "Only grab best of selected resolutions below?").setDefaultValue(false).setEnabledCondidtion(best, false)); final Iterator<Entry<String, String[]>> it = formats.entrySet().iterator(); while (it.hasNext()) { /* * Format-name:videoCodec, videoBitrate, videoResolution, audioCodec, audioBitrate */ String usertext = "Load "; final Entry<String, String[]> videntry = it.next(); final String internalname = videntry.getKey(); final String[] vidinfo = videntry.getValue(); final String videoCodec = vidinfo[0]; final String videoBitrate = vidinfo[1]; final String videoResolution = vidinfo[2]; final String audioCodec = vidinfo[3]; final String audioBitrate = vidinfo[4]; if (videoCodec != null) { usertext += videoCodec + " "; } if (videoBitrate != null) { usertext += videoBitrate + " "; } if (videoResolution != null) { usertext += videoResolution + " "; } if (audioCodec != null || audioBitrate != null) { usertext += "with audio "; if (audioCodec != null) { usertext += audioCodec + " "; } if (audioBitrate != null) { usertext += audioBitrate; } } if (usertext.endsWith(" ")) { usertext = usertext.substring(0, usertext.lastIndexOf(" ")); } final ConfigEntry vidcfg = new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), internalname, usertext).setDefaultValue(true).setEnabledCondidtion(best, false); getConfig().addEntry(vidcfg); } getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), CRAWL_VIDEO_HLS, "Crawl video (HLS)?").setDefaultValue(true)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), CRAWL_VIDEO_MP4, "Crawl video (HTTP)?").setDefaultValue(true)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), CRAWL_THUMBNAIL, "Crawl video thumbnail?").setDefaultValue(false)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), FAST_LINKCHECK, "Enable fast linkcheck?\r\nNOTE: If enabled, links will appear faster but filesize won't be shown before downloadstart.").setDefaultValue(false)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), USE_ORIGINAL_SERVER_FILENAME, "Use original server filename?").setDefaultValue(false)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_CHECKBOX, getPluginConfig(), GIFS_WEBM, "Prefer webm over old gif format?").setDefaultValue(true)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_COMBOBOX_INDEX, getPluginConfig(), SELECTED_DOMAIN, DOMAINS, "Select preferred domain").setDefaultValue(default_SELECTED_DOMAIN)); getConfig().addEntry(new ConfigEntry(ConfigContainer.TYPE_COMBOBOX_INDEX, getPluginConfig(), SETTING_URL_CRAWL_LANGUAGE_HANDLING, SETTING_URL_CRAWL_LANGUAGE_HANDLING_OPTIONS, "URL crawl handling").setDefaultValue(default_SETTING_URL_CRAWL_LANGUAGE_HANDLING)); } @Override public void reset() { } @Override public void resetDownloadlink(final DownloadLink link) { if (link != null) { // link.removeProperty("webm"); } } }
mirror/jdownloader
src/jd/plugins/hoster/PornHubCom.java
766
/****************************************************************************** * $URL: $ * $Id: $ ****************************************************************************** * * Copyright (c) 2003-2014 The Apereo Foundation * * Licensed under the Educational Community License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://opensource.org/licenses/ecl2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *****************************************************************************/ package org.sakaiproject.config.impl; import java.lang.IllegalArgumentException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; import org.jasypt.encryption.pbe.PBEStringEncryptor; import org.sakaiproject.component.api.ServerConfigurationService; import org.sakaiproject.component.api.ServerConfigurationService.ConfigData; import org.sakaiproject.component.api.ServerConfigurationService.ConfigItem; import org.sakaiproject.component.api.ServerConfigurationService.ConfigurationListener; import org.sakaiproject.component.api.ServerConfigurationService.ConfigurationProvider; import org.sakaiproject.component.impl.ConfigItemImpl; import org.sakaiproject.config.api.HibernateConfigItem; import org.sakaiproject.config.api.HibernateConfigItemDao; /** * KNL-1063 * Manages the persistence details of a ConfigItem in the form of a HibernateConfigItem. * This service does take into consideration multiple application servers and partitions * the properties appropriately using the serverId. * <p/> * DO NOT USE THIS SERVICE to change properties use ServerConfigurationService. * <p/> * Once SCS has been updated with property changes they will then persisted no need to * do anything else. * * @author Earle Nietzel * Created on Mar 8, 2013 */ @Slf4j public class StoredConfigService implements ConfigurationListener, ConfigurationProvider { // enables persistence of ConfigItems that SCS knows about public static final String SAKAI_CONFIG_STORE_ENABLE = "sakai.config.store.enable"; // registers with SCS as a provider of config public static final String SAKAI_CONFIG_PROVIDE_ENABLE = "sakai.config.provide.enable"; public static final boolean SAKAI_CONFIG_PROVIDE_ENABLE_DEFAULT = true; // enables the database poller to provide config during a running system public static final String SAKAI_CONFIG_POLL_ENABLE = "sakai.config.poll.enable"; // how often to poll for config public static final String SAKAI_CONFIG_POLL_SECONDS = "sakai.config.poll.seconds"; // use unexpanded values hence raw public static final String SAKAI_CONFIG_USE_RAW = "sakai.config.use.raw"; // config that should never be persisted public static final String SAKAI_CONFIG_NEVER_PERSIST = "sakai.config.never.persist"; private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm:ss"); private ScheduledExecutorService scheduler; private ServerConfigurationService serverConfigurationService; private HibernateConfigItemDao dao; private PBEStringEncryptor textEncryptor; private Set<String> neverPersistItems; private String node; public void init() { node = serverConfigurationService.getServerId(); if (StringUtils.isBlank(node)) { log.error("node cannot be blank, StoredConfigService is disabled"); return; } // get configured config to skip String[] doNotPersistConfig = serverConfigurationService.getStrings(SAKAI_CONFIG_NEVER_PERSIST); List<String> tmpdoNotPersist; if (doNotPersistConfig == null) { // SCS can return a null here if config is not found tmpdoNotPersist = new ArrayList<>(); } else { tmpdoNotPersist = Arrays.asList(doNotPersistConfig); } // always add [email protected] tmpdoNotPersist.add("[email protected]"); // TODO add more stuff here like serverId, DB password // Setup list of items we should never persist neverPersistItems = Collections.unmodifiableSet(new HashSet<>(tmpdoNotPersist)); // delete items that should never persisted for (String item : neverPersistItems) { deleteHibernateConfigItem(item); } // enables storing of all config that SCS knows about if (serverConfigurationService.getBoolean(SAKAI_CONFIG_STORE_ENABLE, false)) { learnConfig(serverConfigurationService.getConfigData().getItems()); serverConfigurationService.registerListener(this); } if (serverConfigurationService.getBoolean(SAKAI_CONFIG_POLL_ENABLE, false)) { final int pollDelaySeconds = serverConfigurationService.getInt(SAKAI_CONFIG_POLL_SECONDS, 60); // setup an ExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); // schedule task for every pollDelaySeconds scheduler.scheduleWithFixedDelay( new Runnable() { ZonedDateTime pollDate; @Override public void run() { pollDate = storedConfigPoller(pollDelaySeconds, pollDate); } }, pollDelaySeconds < 120 ? 120 : pollDelaySeconds, // minimally wait 120 seconds for sakai to start pollDelaySeconds, TimeUnit.SECONDS ); log.info("{} is enabled and polling every {} seconds", SAKAI_CONFIG_POLL_ENABLE, pollDelaySeconds); } } public void destroy() { // terminate the scheduler if (scheduler != null) { scheduler.shutdown(); } } private ZonedDateTime storedConfigPoller(int delay, ZonedDateTime then) { ZonedDateTime now = ZonedDateTime.now(); if (then == null) { // on start set then now.minusSeconds(delay); then = now; } List<HibernateConfigItem> polled = findPollOn(then, now); int registered = 0; for (HibernateConfigItem item : polled) { if (item.isRegistered()) { // registering items that are not marked as registered leads to bad things in SCS ConfigItem cItem = serverConfigurationService.getConfigItem(item.getName()); if (!item.similar(cItem)) { // only register items that are not similar, reduces history on items in SCS serverConfigurationService.registerConfigItem(createConfigItem(item)); registered++; } } else { log.warn("Item {} is not registered skipping", item.getName()); } } if (log.isDebugEnabled()) { log.debug("storedConfigPoller() Polling found {} config item(s) (from {} to {}), {} item(s) registered", polled.size(), dtf.format(then), dtf.format(now), registered); } return now; } /** * Creates a HibernateConfigItem for every item in the list and persists it for this node. * * @param items List of ConfigItem */ private void learnConfig(List<ConfigItem> items) { if (items == null) { return; } int total = items.size(); int updated = 0; int created = 0; for (ConfigItem item : items) { if (item == null) { continue; // skip this item } HibernateConfigItem hItem = null; int rows = countByName(item.getName()); if (rows == 0) { // new item, create it hItem = createHibernateConfigItem(item); created++; } else { // sync config with files when store enabled and not provide enabled if (!serverConfigurationService.getBoolean(SAKAI_CONFIG_PROVIDE_ENABLE, SAKAI_CONFIG_PROVIDE_ENABLE_DEFAULT)) { hItem = findByName(item.getName()); hItem = updateHibernateConfigItem(hItem, item); if (hItem != null) { // if hItem is not null it was updated updated++; } } } saveOrUpdate(hItem); } log.info("processed {} config items, updated {} created {}", total, updated, created); } /** * Persists or updates (if it already exists) a HibernateConfigItem to the database for this node * * @param hItem a HibernateConfigItem */ public void saveOrUpdate(HibernateConfigItem hItem) { if (hItem == null) { return; } String name = hItem.getName(); String type = hItem.getType(); if (name == null || name.isEmpty()) { log.warn("item name is missing"); return; } else if (!(ServerConfigurationService.TYPE_STRING.equals(type) || ServerConfigurationService.TYPE_INT.equals(type) || ServerConfigurationService.TYPE_BOOLEAN.equals(type) || ServerConfigurationService.TYPE_ARRAY.equals(type))) { log.warn("item type is incorrect"); return; } dao.saveOrUpdate(hItem); } /** * Get all registered HibernateConfigItem as ConfigItems for this node * * @return a List of ConfigItem */ public List<ConfigItem> getConfigItems() { List<ConfigItem> configItems = new ArrayList<ConfigItem>(); List<HibernateConfigItem> regItems = findRegistered(); for (HibernateConfigItem hItem : regItems) { ConfigItem item = createConfigItem(hItem); if (item != null) { configItems.add(item); log.debug("{}", item); } } return configItems; } /** * Creates an equivalent ConfigItem from a HibernateConfigItem * * @param hItem a HibernateConfigItem * @return a ConfigItem * @throws IllegalArgumentException this can occur during deserialization when creating a ConfigItem */ public ConfigItem createConfigItem(HibernateConfigItem hItem) throws IllegalArgumentException { if (hItem == null) { return null; } String value; if (serverConfigurationService.getBoolean(SAKAI_CONFIG_USE_RAW, false) && StringUtils.isNotBlank(hItem.getRawValue()) ) { value = hItem.getRawValue(); } else { value = hItem.getValue(); } // create new ConfigItem ConfigItem item = new ConfigItemImpl( hItem.getName(), deSerializeValue(value, hItem.getType(), hItem.isSecured()), hItem.getType(), hItem.getDescription(), this.getClass().getName(), deSerializeValue(hItem.getDefaultValue(), hItem.getType(), hItem.isSecured()), 0, // requested 0, // changed null, // history hItem.isRegistered(), hItem.isDefaulted(), hItem.isSecured(), hItem.isDynamic() ); log.debug("{}", item); return item; } /** * Creates an equivalent HibernateConfigItem from a ConfigItem * * @param item a ConfigItem * @return a HibernateConfigItem * @throws IllegalArgumentException thrown when the item.getValue doesn't return the right type */ public HibernateConfigItem createHibernateConfigItem(ConfigItem item) throws IllegalArgumentException { if (item == null || neverPersistItems.contains(item.getName())) { return null; } log.debug("New ConfigItem = {}", item); String serialValue; String serialDefaultValue; String serialRawValue; try { serialValue = serializeValue(item.getValue(), item.getType(), item.isSecured()); serialDefaultValue = serializeValue(item.getDefaultValue(), item.getType(), item.isSecured()); serialRawValue = serializeValue(getRawProperty(item.getName()), ServerConfigurationService.TYPE_STRING, item.isSecured()); } catch (IllegalArgumentException ice) { log.error("Skip ConfigItem {}, {}", item, ice.getMessage()); return null; } HibernateConfigItem hItem = new HibernateConfigItem(node, item.getName(), serialValue, serialRawValue, item.getType(), item.getDescription(), item.getSource(), serialDefaultValue, item.isRegistered(), item.isDefaulted(), item.isSecured(), item.isDynamic()); log.debug("Created HibernateConfigItem = {}", hItem); return hItem; } /** * Updates a HibernateConfigItem with a ConfigItem's data; the name, node * * @param hItem a HibernateConfigItem * @param item a ConfigItem * @return a HibernateConfigItem if it was updated or null if it was not updated * @throws IllegalArgumentException thrown when the item.getValue doesn't return the right type */ public HibernateConfigItem updateHibernateConfigItem(HibernateConfigItem hItem, ConfigItem item) throws IllegalArgumentException { if (hItem == null || item == null) { return null; } HibernateConfigItem updatedItem = null; // check if updating is needed, update it if (!hItem.similar(item)) { // if they are not similar update it log.debug("Before = {}", hItem); Object value = deSerializeValue(hItem.getValue(), hItem.getType(), hItem.isSecured()); Object defaultValue = deSerializeValue(hItem.getDefaultValue(), hItem.getType(), hItem.isSecured()); try { if (value == null) { if (item.getValue() != null) { // different update hItem.setValue(serializeValue(item.getValue(), item.getType(), item.isSecured())); } } else if (!value.equals(item.getValue())) { // different update hItem.setValue(serializeValue(item.getValue(), item.getType(), item.isSecured())); } if (defaultValue == null) { if (item.getDefaultValue() != null) { // different update hItem.setDefaultValue(serializeValue(item.getDefaultValue(), item.getType(), item.isSecured())); } } else if (!defaultValue.equals(item.getDefaultValue())) { // different update hItem.setDefaultValue(serializeValue(item.getDefaultValue(), item.getType(), item.isSecured())); } } catch (IllegalArgumentException ice) { log.error("Skip ConfigItem = {}, {}", item, ice.getMessage()); return null; } hItem.setType(item.getType()); hItem.setDefaulted(item.isDefaulted()); hItem.setSecured(item.isSecured()); hItem.setRegistered(item.isRegistered()); hItem.setSource(item.getSource()); hItem.setDescription(item.getDescription()); hItem.setDynamic(item.isDynamic()); hItem.setModified(new Date()); log.debug("After = {}", hItem); updatedItem = hItem; } // check if raw value needs updating // raw values are always strings String rawValue = (String) deSerializeValue(hItem.getRawValue(), ServerConfigurationService.TYPE_STRING, hItem.isSecured()); if (!StringUtils.equals(rawValue, getRawProperty(hItem.getName()))) { // different update hItem.setRawValue(serializeValue(getRawProperty(hItem.getName()), ServerConfigurationService.TYPE_STRING, item.isSecured())); updatedItem = hItem; } // only return a hItem if it was updated return updatedItem; } /** * Delete a HibernateConfigItem * * @param name The HibernateConfigItem that should be deleted */ public void deleteHibernateConfigItem(String name) { if (StringUtils.isBlank(name)) { return; } HibernateConfigItem hItem = findByName(name); if (hItem != null) { log.info("Delete HibernateConfigItem = {}", hItem); dao.delete(hItem); } } /* (non-Javadoc) * @see org.sakaiproject.component.api.ServerConfigurationService.ConfigurationListener#changed(org.sakaiproject.component.api.ServerConfigurationService.ConfigItem, org.sakaiproject.component.api.ServerConfigurationService.ConfigItem) */ @Override public void changed(ConfigItem item, ConfigItem previous) { // a ConfigItem has changed if (item == null) { return; } HibernateConfigItem hItem = findByName(item.getName()); if (hItem == null) { // new hItem hItem = createHibernateConfigItem(item); } else { // existing hItem, update it hItem = updateHibernateConfigItem(hItem, item); } saveOrUpdate(hItem); } /* (non-Javadoc) * @see org.sakaiproject.component.api.ServerConfigurationService.ConfigurationListener#changing(org.sakaiproject.component.api.ServerConfigurationService.ConfigItem, org.sakaiproject.component.api.ServerConfigurationService.ConfigItem) */ @Override public ConfigItem changing(ConfigItem currentConfigItem, ConfigItem newConfigItem) { // no need to do anything before item has changed return null; } @Override public List<ConfigItem> registerConfigItems(ConfigData configData) { if (serverConfigurationService.getBoolean(SAKAI_CONFIG_PROVIDE_ENABLE, SAKAI_CONFIG_PROVIDE_ENABLE_DEFAULT)) { return getConfigItems(); } return Collections.emptyList(); } /** * Find a HibernateConfigItem with a matching name for this node * * @param name the name of the item to find * @return a HibernateConfigItem matching the name for this node or null if none found */ public HibernateConfigItem findByName(String name) { HibernateConfigItem item = null; List<HibernateConfigItem> list = dao.findAllByCriteriaByNode(node, name, null, null, null, null); if (list.size() == 1) { item = list.get(0); } return item; } /** * Number of properties with a matching name on this node * * @param name the name of the item to count * @return a positive integer or -1 if name or node is null */ public int countByName(String name) { return dao.countByNodeAndName(node, name); } /** * Number of all properties on this node * * @return a positive integer or -1 if node is null */ public int countAll() { return dao.countByNode(node); } /** * Find all HibernateConfigItem(s) for this node * * @return a List of HibernateConfigItem(s) */ public List<HibernateConfigItem> findAll() { return dao.findAllByCriteriaByNode(node, null, null, null, null, null); } /** * Find all Secured HibernateConfigItem(s) for this node * * @return a List of HibernateConfigItem(s) */ public List<HibernateConfigItem> findSecured() { return dao.findAllByCriteriaByNode(node, null, null, null, null, true); } /** * Find all Registered HibernateConfigItem(s) for this node * * @return a List of HibernateConfigItem(s) */ public List<HibernateConfigItem> findRegistered() { return dao.findAllByCriteriaByNode(node, null, null, true, null, null); } /** * Find all Dynamic HibernateConfigItem(s) for this node * * @return a List of HibernateConfigItem(s) */ public List<HibernateConfigItem> findDynamic() { return dao.findAllByCriteriaByNode(node, null, null, null, true, null); } /** * Find all Defaulted HibernateConfigItem(s) for this node * * @return a List of HibernateConfigItem(s) */ public List<HibernateConfigItem> findDefaulted() { return dao.findAllByCriteriaByNode(node, null, true, null, null, null); } /** * Find all HibernateConfigItem(s) that have a pollOn during a specified time * If a date is null then that date is left open then time is unbounded in that direction * If both dates are null then every config item that has a pollOn date is returned * * @param after select items after this timestamp * @param before select items before this timestamp * @return a List of HibernateConfigItem(s) */ public List<HibernateConfigItem> findPollOn(ZonedDateTime after, ZonedDateTime before) { return dao.findPollOnByNode(node, Date.from(after.toInstant()), Date.from(before.toInstant())); } private String getRawProperty(String name) { if (StringUtils.isBlank(name)) { return null; } String value = null; ConfigItem ci = serverConfigurationService.getConfigItem(name); // null if it does not exist if (ci != null) { String rawValue = serverConfigurationService.getRawProperty(name); value = StringUtils.trimToNull(rawValue); } return value; } private Object deSerializeValue(String value, String type, boolean secured) throws IllegalArgumentException { if (value == null || type == null) { return null; } String string; if (secured) { // sanity check should be Base64 encoded if (Base64.isBase64(value)) { string = textEncryptor.decrypt(value); } else { log.warn("Invalid value found attempting to decrypt a secured property, check your secured properties"); string = value; } } else { string = value; } Object obj; if (ServerConfigurationService.TYPE_STRING.equals(type)) { obj = string; } else if (ServerConfigurationService.TYPE_INT.equals(type)) { obj = Integer.valueOf(string); } else if (ServerConfigurationService.TYPE_BOOLEAN.equals(type)) { obj = Boolean.valueOf(string); } else if (ServerConfigurationService.TYPE_ARRAY.equals(type)) { obj = string.split(HibernateConfigItem.ARRAY_SEPARATOR); } else { throw new IllegalArgumentException("deSerializeValue() invalid TYPE, while deserializing"); } return obj; } private String serializeValue(Object obj, String type, boolean secured) throws IllegalArgumentException { if (obj == null || type == null) { return null; } String string; if (ServerConfigurationService.TYPE_STRING.equals(type)) { if (obj instanceof String) { string = String.valueOf(obj); } else { throw new IllegalArgumentException("Expected String, but got " + obj.getClass().getSimpleName()); } } else if (ServerConfigurationService.TYPE_INT.equals(type)) { if (obj instanceof Integer) { string = Integer.toString((Integer) obj); } else { throw new IllegalArgumentException("Expected Integer, but got " + obj.getClass().getSimpleName()); } } else if (ServerConfigurationService.TYPE_BOOLEAN.equals(type)) { if (obj instanceof Boolean) { string = Boolean.toString((Boolean) obj); } else { throw new IllegalArgumentException("Expected Boolean, but got " + obj.getClass().getSimpleName()); } } else if (ServerConfigurationService.TYPE_ARRAY.equals(type)) { if (obj instanceof String[]) { string = StringUtils.join((String[]) obj, HibernateConfigItem.ARRAY_SEPARATOR); } else { throw new IllegalArgumentException("serializeValue() expected an array of type String[]"); } } else { throw new IllegalArgumentException("serializeValue() invalid TYPE, while serializing"); } if (secured) { string = textEncryptor.encrypt(string); } return string; } public void setServerConfigurationService(ServerConfigurationService serverConfigurationService) { this.serverConfigurationService = serverConfigurationService; } public void setDao(HibernateConfigItemDao dao) { this.dao = dao; } public void setTextEncryptor(PBEStringEncryptor textEncryptor) { this.textEncryptor = textEncryptor; } }
sakaiproject/sakai
kernel/kernel-impl/src/main/java/org/sakaiproject/config/impl/StoredConfigService.java
767
/** * Copyright (c) 2003-2015 The Apereo Foundation * * Licensed under the Educational Community License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://opensource.org/licenses/ecl2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.sakaiproject.util; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; /** * @author Earle Nietzel * ([email protected]) * */ public class MapResourceBundle extends ResourceBundle { /** * The store */ private Map<String, Object> map; /** * The locale for this bundle. */ private Locale locale; /** * The base bundle name for this bundle. */ private String name; /** * Creates a property resource bundle from an {@link java.util.Map}. * * @param properties a Map<String, Object> that represents a properties * to read from. * @param name a <code>String</code> represents the <code>name</code> of * the <code>ResourceBundle</code>. * @param locale a <code>Locale</code> represents the locale if the * <code>ResourceBundle</code>. * @throws NullPointerException if <code>properties</code>, <code>name</code>, * <code>locale</code> is null. */ public MapResourceBundle(Map<String, Object> properties, String name, Locale locale) throws NullPointerException { if (properties == null || name == null || locale == null) { throw new NullPointerException("Params cannot be null"); } this.map = new HashMap<String, Object>(properties); this.name = name; this.locale = locale; } @Override protected Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); } return map.get(key); } @Override public Enumeration<String> getKeys() { Set<String> allKeysSet = new HashSet<String>(map.keySet()); if (parent != null) { Enumeration<String> parentKeys = parent.getKeys(); if (parentKeys != null) { while (parentKeys.hasMoreElements()) { String next = parentKeys.nextElement(); if (!allKeysSet.contains(next)) { allKeysSet.add(next); } } } } return Collections.enumeration(allKeysSet); } protected Set<String> handleKeySet() { return map.keySet(); } @Override public String getBaseBundleName() { return name; } @Override public Locale getLocale() { return locale; } }
sakaiproject/sakai
kernel/api/src/main/java/org/sakaiproject/util/MapResourceBundle.java
768
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 11 "Parser.y" package decaf.frontend; import decaf.tree.Tree; import decaf.tree.Tree.*; import decaf.error.*; import java.util.*; //#line 25 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short VOID=257; public final static short BOOL=258; public final static short INT=259; public final static short STRING=260; public final static short CLASS=261; public final static short NULL=262; public final static short EXTENDS=263; public final static short THIS=264; public final static short WHILE=265; public final static short FOR=266; public final static short IF=267; public final static short ELSE=268; public final static short RETURN=269; public final static short BREAK=270; public final static short NEW=271; public final static short PRINT=272; public final static short READ_INTEGER=273; public final static short READ_LINE=274; public final static short LITERAL=275; public final static short IDENTIFIER=276; public final static short AND=277; public final static short OR=278; public final static short STATIC=279; public final static short INSTANCEOF=280; public final static short NUMINSTANCES=281; public final static short LESS_EQUAL=282; public final static short GREATER_EQUAL=283; public final static short EQUAL=284; public final static short NOT_EQUAL=285; public final static short DOUBLE_PLUS=286; public final static short DOUBLE_MINUS=287; public final static short FI=288; public final static short TRIBLE_OR=289; public final static short DO=290; public final static short OD=291; public final static short UMINUS=292; public final static short EMPTY=293; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 4, 5, 5, 5, 5, 5, 5, 2, 6, 6, 7, 7, 7, 9, 9, 10, 10, 8, 8, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 23, 25, 25, 21, 22, 14, 14, 14, 28, 28, 26, 26, 27, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 30, 30, 29, 29, 31, 31, 16, 17, 20, 15, 32, 32, 18, 18, 19, }; final static short yylen[] = { 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 6, 2, 0, 2, 2, 0, 1, 0, 3, 1, 7, 6, 3, 2, 0, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 3, 1, 3, 3, 3, 3, 1, 0, 2, 0, 2, 4, 5, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 4, 5, 6, 5, 2, 2, 2, 2, 5, 4, 1, 1, 1, 0, 3, 1, 5, 9, 1, 6, 2, 0, 2, 1, 4, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 2, 0, 0, 13, 17, 0, 7, 8, 6, 9, 0, 0, 12, 15, 0, 0, 16, 10, 0, 4, 0, 0, 0, 0, 11, 0, 21, 0, 0, 0, 0, 5, 0, 0, 0, 26, 23, 20, 22, 0, 84, 72, 0, 0, 0, 0, 91, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 24, 27, 35, 25, 0, 29, 30, 31, 0, 0, 0, 36, 37, 0, 0, 0, 0, 53, 0, 0, 0, 39, 0, 0, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 32, 33, 34, 0, 0, 0, 0, 0, 0, 77, 79, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 70, 71, 0, 0, 42, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 40, 73, 0, 0, 97, 0, 82, 0, 49, 0, 0, 0, 89, 0, 0, 74, 0, 0, 76, 0, 50, 0, 0, 92, 75, 0, 93, 0, 90, }; final static short yydgoto[] = { 2, 3, 4, 67, 20, 33, 8, 11, 22, 34, 35, 68, 45, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 87, 79, 89, 90, 91, 82, 179, 83, 140, 192, }; final static short yysindex[] = { -253, -252, 0, -253, 0, -229, 0, -233, -77, 0, 0, -92, 0, 0, 0, 0, -218, -44, 0, 0, 3, -86, 0, 0, -82, 0, 23, -16, 40, -44, 0, -44, 0, -78, 41, 42, 43, 0, -35, -44, -35, 0, 0, 0, 0, 2, 0, 0, 47, 49, 131, 151, 0, 189, 51, 53, 54, 0, 58, 64, 151, 151, 151, 151, 151, 91, 0, 0, 0, 0, 50, 0, 0, 0, 52, 57, 60, 0, 0, 754, 34, 0, -170, 0, 151, 151, 91, 0, 466, -270, 0, 0, 754, 68, 21, 151, 81, 85, 151, -159, -31, -31, -266, -42, -42, -148, 490, 0, 0, 0, 0, 151, 151, 151, 151, 151, 151, 0, 0, 151, 151, 151, 151, 151, 151, 151, 0, 151, 151, 151, 89, 502, 71, 526, 36, 0, 151, 92, 111, 754, -12, 0, 0, 553, 93, 0, 94, 0, 901, 889, -6, -6, 913, 913, -36, -36, -42, -42, -42, -6, -6, 564, 588, 754, 151, 36, 151, 70, 0, 0, 0, 626, 151, 0, -144, 0, 151, 0, 151, 98, 96, 0, 839, -127, 0, 754, 102, 0, 754, 0, 151, 36, 0, 0, 104, 0, 36, 0, }; final static short yyrindex[] = { 0, 0, 0, 147, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 112, 0, 112, 0, 0, 0, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, -57, 0, 0, 0, 0, -124, -56, 0, 0, 0, 0, 0, 0, 0, 0, -124, -124, -124, -124, -124, -124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 877, 455, 0, 0, -124, -57, -124, 0, 0, 0, 0, 0, 99, 0, 0, -124, 0, 0, -124, 0, 940, 964, 0, 1005, 1034, 0, 0, 0, 0, 0, 0, -124, -124, -124, -124, -124, -124, 0, 0, -124, -124, -124, -124, -124, -124, -124, 0, -124, -124, -124, 398, 0, 0, 0, -57, 0, -124, 0, -124, 15, 0, 0, 0, 0, 0, 0, 0, 0, 7, 55, 1240, 1251, 9, 79, 1087, 1215, 1043, 1168, 1192, 1288, 1290, 0, 0, -21, -27, -57, -124, 425, 0, 0, 0, 0, -124, 0, 0, 0, -124, 0, -124, 0, 116, 0, 0, -33, 0, 30, 0, 0, -14, 0, -24, -57, 0, 0, 0, 0, -57, 0, }; final static short yygindex[] = { 0, 0, 157, 150, 76, 11, 0, 0, 0, 132, 0, 35, 0, -113, -69, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1492, 100, 12, 16, 0, 0, 0, 6, 0, }; final static int YYTABLESIZE=1670; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 94, 123, 45, 96, 126, 27, 121, 94, 1, 27, 126, 122, 94, 27, 86, 126, 132, 45, 135, 136, 43, 168, 21, 136, 5, 145, 94, 81, 24, 173, 81, 123, 172, 18, 7, 64, 121, 119, 43, 120, 126, 122, 65, 9, 81, 81, 10, 63, 65, 127, 59, 65, 181, 59, 183, 127, 88, 80, 23, 88, 127, 81, 25, 29, 94, 65, 65, 59, 59, 64, 65, 87, 59, 42, 87, 44, 65, 30, 195, 81, 31, 63, 38, 197, 40, 127, 39, 84, 41, 85, 94, 95, 94, 96, 97, 129, 66, 80, 98, 66, 65, 81, 59, 64, 99, 32, 130, 32, 137, 107, 65, 108, 138, 66, 66, 43, 109, 144, 66, 110, 60, 194, 141, 60, 64, 41, 142, 66, 146, 164, 166, 65, 186, 170, 175, 176, 63, 60, 60, 189, 172, 191, 60, 193, 64, 196, 80, 1, 66, 14, 81, 65, 47, 19, 5, 18, 63, 85, 95, 41, 6, 19, 102, 36, 64, 12, 13, 14, 15, 16, 180, 86, 60, 169, 0, 0, 63, 80, 0, 80, 0, 81, 0, 81, 64, 0, 0, 17, 0, 0, 26, 65, 0, 41, 28, 0, 63, 0, 37, 0, 0, 0, 80, 80, 30, 0, 81, 81, 80, 0, 0, 0, 81, 12, 13, 14, 15, 16, 0, 47, 47, 0, 0, 0, 94, 94, 94, 94, 94, 94, 0, 94, 94, 94, 94, 0, 94, 94, 94, 94, 94, 94, 94, 94, 117, 118, 0, 94, 94, 47, 117, 118, 47, 94, 94, 94, 94, 94, 94, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 117, 118, 58, 59, 65, 65, 59, 59, 60, 61, 0, 0, 62, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 59, 0, 0, 0, 0, 60, 61, 0, 0, 62, 12, 13, 14, 15, 16, 46, 66, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 59, 105, 46, 0, 47, 60, 60, 0, 0, 62, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 46, 0, 47, 0, 60, 61, 0, 0, 0, 53, 0, 55, 56, 57, 0, 0, 0, 0, 58, 59, 0, 0, 48, 0, 60, 61, 48, 48, 48, 48, 48, 48, 48, 12, 13, 14, 15, 16, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 67, 0, 0, 93, 0, 67, 67, 0, 67, 67, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 45, 67, 0, 67, 67, 48, 0, 48, 52, 0, 0, 0, 44, 52, 52, 0, 52, 52, 52, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 44, 52, 67, 52, 52, 0, 0, 0, 0, 0, 134, 0, 125, 123, 124, 128, 0, 147, 121, 119, 0, 120, 126, 122, 0, 123, 0, 0, 0, 165, 121, 119, 52, 120, 126, 122, 125, 0, 124, 128, 0, 0, 0, 127, 0, 0, 0, 0, 125, 123, 124, 128, 0, 167, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 125, 0, 124, 128, 123, 0, 0, 127, 0, 121, 119, 174, 120, 126, 122, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 125, 0, 124, 128, 127, 0, 0, 0, 0, 0, 0, 125, 123, 124, 128, 0, 0, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 178, 0, 125, 0, 124, 128, 0, 0, 0, 127, 0, 177, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 48, 48, 0, 0, 127, 48, 48, 48, 48, 48, 48, 125, 0, 124, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 67, 67, 0, 0, 0, 67, 67, 67, 67, 67, 67, 0, 0, 0, 0, 127, 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 52, 0, 0, 0, 52, 52, 52, 52, 52, 52, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 125, 0, 124, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 111, 112, 0, 0, 127, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 123, 0, 0, 0, 0, 121, 119, 0, 120, 126, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190, 125, 0, 124, 128, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 51, 0, 0, 0, 0, 51, 51, 0, 51, 51, 51, 0, 123, 0, 0, 0, 127, 121, 119, 0, 120, 126, 122, 51, 123, 51, 51, 0, 0, 121, 119, 0, 120, 126, 122, 125, 123, 124, 0, 0, 0, 121, 119, 0, 120, 126, 122, 125, 0, 124, 0, 0, 0, 0, 51, 0, 0, 0, 0, 125, 0, 124, 0, 78, 0, 0, 127, 78, 78, 78, 78, 78, 0, 78, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 78, 78, 78, 80, 78, 78, 127, 80, 80, 80, 80, 80, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 80, 80, 0, 80, 80, 0, 0, 0, 111, 112, 78, 0, 0, 113, 114, 115, 116, 117, 118, 68, 0, 0, 0, 68, 68, 68, 68, 68, 0, 68, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 68, 68, 68, 0, 68, 68, 0, 0, 69, 0, 0, 0, 69, 69, 69, 69, 69, 56, 69, 0, 0, 56, 56, 56, 56, 56, 0, 56, 0, 69, 69, 69, 0, 69, 69, 68, 0, 0, 56, 56, 56, 0, 56, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 0, 0, 0, 113, 114, 115, 116, 117, 118, 69, 54, 0, 54, 54, 54, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, 0, 54, 54, 0, 0, 0, 51, 51, 0, 0, 0, 51, 51, 51, 51, 51, 51, 0, 111, 0, 0, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 54, 0, 0, 113, 114, 115, 116, 117, 118, 0, 0, 0, 0, 0, 0, 113, 114, 0, 0, 117, 118, 0, 0, 0, 0, 57, 0, 0, 0, 57, 57, 57, 57, 57, 0, 57, 0, 78, 78, 0, 0, 0, 78, 78, 78, 78, 57, 57, 57, 58, 57, 57, 0, 58, 58, 58, 58, 58, 0, 58, 0, 80, 80, 0, 0, 0, 80, 80, 80, 80, 58, 58, 58, 0, 58, 58, 55, 0, 55, 55, 55, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 0, 55, 55, 0, 0, 63, 68, 68, 63, 58, 0, 68, 68, 68, 68, 0, 64, 0, 0, 64, 0, 0, 63, 63, 0, 0, 0, 63, 0, 0, 0, 0, 55, 64, 64, 69, 69, 0, 64, 0, 69, 69, 69, 69, 56, 56, 0, 0, 0, 56, 56, 56, 56, 62, 0, 61, 62, 63, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 62, 62, 61, 61, 0, 62, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 0, 0, 0, 54, 54, 54, 54, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 57, 0, 0, 0, 57, 57, 57, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, 58, 58, 58, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 0, 0, 0, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 63, 0, 0, 0, 0, 0, 63, 63, 0, 0, 64, 64, 0, 0, 0, 0, 0, 64, 64, 0, 0, 0, 0, 0, 88, 92, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 88, 103, 104, 106, 0, 0, 0, 0, 0, 0, 0, 62, 62, 61, 61, 0, 0, 0, 62, 62, 61, 61, 131, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 149, 150, 151, 152, 153, 0, 0, 154, 155, 156, 157, 158, 159, 160, 0, 161, 162, 163, 0, 0, 0, 0, 0, 0, 88, 0, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 182, 0, 0, 0, 0, 0, 185, 0, 0, 0, 187, 0, 188, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 37, 59, 59, 46, 91, 42, 40, 261, 91, 46, 47, 45, 91, 41, 46, 85, 41, 288, 289, 41, 134, 11, 289, 276, 291, 59, 41, 17, 41, 44, 37, 44, 125, 263, 33, 42, 43, 59, 45, 46, 47, 40, 276, 58, 59, 123, 45, 41, 91, 41, 44, 165, 44, 167, 91, 41, 45, 276, 44, 91, 45, 59, 40, 53, 58, 59, 58, 59, 33, 63, 41, 63, 38, 44, 40, 40, 93, 191, 93, 40, 45, 41, 196, 41, 91, 44, 40, 123, 40, 123, 40, 125, 40, 40, 61, 41, 85, 40, 44, 93, 85, 93, 33, 40, 29, 276, 31, 40, 59, 40, 59, 91, 58, 59, 39, 59, 276, 63, 59, 41, 190, 41, 44, 33, 123, 41, 125, 276, 40, 59, 40, 276, 41, 41, 41, 45, 58, 59, 41, 44, 268, 63, 41, 33, 41, 134, 0, 93, 123, 134, 40, 276, 41, 59, 41, 45, 41, 59, 123, 3, 11, 62, 31, 33, 257, 258, 259, 260, 261, 164, 40, 93, 136, -1, -1, 45, 165, -1, 167, -1, 165, -1, 167, 33, -1, -1, 279, -1, -1, 276, 40, -1, 123, 276, -1, 45, -1, 276, -1, -1, -1, 190, 191, 93, -1, 190, 191, 196, -1, -1, -1, 196, 257, 258, 259, 260, 261, -1, 276, 276, -1, -1, -1, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, 276, 286, 287, -1, 280, 281, 276, 286, 287, 276, 286, 287, 288, 289, 290, 291, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, 286, 287, 280, 281, 277, 278, 277, 278, 286, 287, -1, -1, 290, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, 281, -1, -1, -1, -1, 286, 287, -1, -1, 290, 257, 258, 259, 260, 261, 262, 278, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, 281, 261, 262, -1, 264, 277, 278, -1, -1, 290, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, 262, -1, 264, -1, 286, 287, -1, -1, -1, 271, -1, 273, 274, 275, -1, -1, -1, -1, 280, 281, -1, -1, 37, -1, 286, 287, 41, 42, 43, 44, 45, 46, 47, 257, 258, 259, 260, 261, -1, -1, -1, -1, -1, 58, 59, 60, 61, 62, 63, 37, -1, -1, 276, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, 91, -1, 93, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, 59, 60, 91, 62, 63, -1, -1, -1, -1, -1, 58, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, 91, 45, 46, 47, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, -1, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, 63, 37, -1, -1, 91, -1, 42, 43, 44, 45, 46, 47, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 60, -1, 62, 63, 91, -1, -1, -1, -1, -1, -1, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 91, -1, 58, -1, 60, -1, 62, 63, -1, -1, -1, 91, -1, 93, -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 277, 278, -1, -1, 91, 282, 283, 284, 285, 286, 287, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 276, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, 91, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 277, 278, -1, -1, 91, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, -1, 62, 63, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 91, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, 60, 37, 62, -1, -1, -1, 42, 43, -1, 45, 46, 47, 60, -1, 62, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, -1, 37, -1, -1, 91, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, 58, 59, 60, 37, 62, 63, 91, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, 277, 278, 93, -1, -1, 282, 283, 284, 285, 286, 287, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, 93, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 37, -1, -1, -1, 41, 42, 43, 44, 45, 37, 47, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 58, 59, 60, -1, 62, 63, 93, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, 93, 41, -1, 43, 44, 45, -1, -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, 277, -1, -1, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, 93, -1, -1, 282, 283, 284, 285, 286, 287, -1, -1, -1, -1, -1, -1, 282, 283, -1, -1, 286, 287, -1, -1, -1, -1, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 58, 59, 60, 37, 62, 63, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, 58, 59, 60, -1, 62, 63, 41, -1, 43, 44, 45, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 41, 277, 278, 44, 93, -1, 282, 283, 284, 285, -1, 41, -1, -1, 44, -1, -1, 58, 59, -1, -1, -1, 63, -1, -1, -1, -1, 93, 58, 59, 277, 278, -1, 63, -1, 282, 283, 284, 285, 277, 278, -1, -1, -1, 282, 283, 284, 285, 41, -1, 41, 44, 93, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, 58, 59, 58, 59, -1, 63, -1, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, -1, -1, 284, 285, -1, -1, 277, 278, -1, -1, -1, -1, -1, 284, 285, -1, -1, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, 60, 61, 62, 63, 64, 65, -1, -1, -1, -1, -1, -1, -1, 277, 278, 277, 278, -1, -1, -1, 284, 285, 284, 285, 84, -1, 86, -1, -1, -1, -1, -1, -1, -1, -1, 95, -1, -1, 98, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 111, 112, 113, 114, 115, 116, -1, -1, 119, 120, 121, 122, 123, 124, 125, -1, 127, 128, 129, -1, -1, -1, -1, -1, -1, 136, -1, 138, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 164, -1, 166, -1, -1, -1, -1, -1, 172, -1, -1, -1, 176, -1, 178, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=293; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'","'?'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING", "CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK", "NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR", "STATIC","INSTANCEOF","NUMINSTANCES","LESS_EQUAL","GREATER_EQUAL","EQUAL", "NOT_EQUAL","DOUBLE_PLUS","DOUBLE_MINUS","FI","TRIBLE_OR","DO","OD","UMINUS", "EMPTY", }; final static String yyrule[] = { "$accept : Program", "Program : ClassList", "ClassList : ClassList ClassDef", "ClassList : ClassDef", "VariableDef : Variable ';'", "Variable : Type IDENTIFIER", "Type : INT", "Type : VOID", "Type : BOOL", "Type : STRING", "Type : CLASS IDENTIFIER", "Type : Type '[' ']'", "ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'", "ExtendsClause : EXTENDS IDENTIFIER", "ExtendsClause :", "FieldList : FieldList VariableDef", "FieldList : FieldList FunctionDef", "FieldList :", "Formals : VariableList", "Formals :", "VariableList : VariableList ',' Variable", "VariableList : Variable", "FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock", "FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock", "StmtBlock : '{' StmtList '}'", "StmtList : StmtList Stmt", "StmtList :", "Stmt : VariableDef", "Stmt : SimpleStmt ';'", "Stmt : IfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "Stmt : ReturnStmt ';'", "Stmt : PrintStmt ';'", "Stmt : BreakStmt ';'", "Stmt : StmtBlock", "Stmt : GuardedIFStmt", "Stmt : GuaededDOStmt", "GuardedES : Expr ':' Stmt", "GuardedStmts : GuardedES", "GuardedStmts : GuardedStmts TRIBLE_OR GuardedES", "GuardedIFStmt : IF GuardedStmts FI", "GuaededDOStmt : DO GuardedStmts OD", "SimpleStmt : LValue '=' Expr", "SimpleStmt : Call", "SimpleStmt :", "Receiver : Expr '.'", "Receiver :", "LValue : Receiver IDENTIFIER", "LValue : Expr '[' Expr ']'", "Call : Receiver IDENTIFIER '(' Actuals ')'", "Expr : LValue", "Expr : Call", "Expr : Constant", "Expr : Expr '+' Expr", "Expr : Expr '-' Expr", "Expr : Expr '*' Expr", "Expr : Expr '/' Expr", "Expr : Expr '%' Expr", "Expr : Expr EQUAL Expr", "Expr : Expr NOT_EQUAL Expr", "Expr : Expr '<' Expr", "Expr : Expr '>' Expr", "Expr : Expr LESS_EQUAL Expr", "Expr : Expr GREATER_EQUAL Expr", "Expr : Expr AND Expr", "Expr : Expr OR Expr", "Expr : '(' Expr ')'", "Expr : '-' Expr", "Expr : '!' Expr", "Expr : READ_INTEGER '(' ')'", "Expr : READ_LINE '(' ')'", "Expr : THIS", "Expr : NEW IDENTIFIER '(' ')'", "Expr : NEW Type '[' Expr ']'", "Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'", "Expr : '(' CLASS IDENTIFIER ')' Expr", "Expr : Expr DOUBLE_PLUS", "Expr : DOUBLE_PLUS Expr", "Expr : Expr DOUBLE_MINUS", "Expr : DOUBLE_MINUS Expr", "Expr : Expr '?' Expr ':' Expr", "Expr : NUMINSTANCES '(' IDENTIFIER ')'", "Constant : LITERAL", "Constant : NULL", "Actuals : ExprList", "Actuals :", "ExprList : ExprList ',' Expr", "ExprList : Expr", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt", "BreakStmt : BREAK", "IfStmt : IF '(' Expr ')' Stmt ElseClause", "ElseClause : ELSE Stmt", "ElseClause :", "ReturnStmt : RETURN Expr", "ReturnStmt : RETURN", "PrintStmt : PRINT '(' ExprList ')'", }; //#line 487 "Parser.y" /** * 打印当前归约所用的语法规则<br> * 请勿修改。 */ public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 741 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 58 "Parser.y" { tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc); } break; case 2: //#line 64 "Parser.y" { yyval.clist.add(val_peek(0).cdef); } break; case 3: //#line 68 "Parser.y" { yyval.clist = new ArrayList<Tree.ClassDef>(); yyval.clist.add(val_peek(0).cdef); } break; case 5: //#line 78 "Parser.y" { yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc); } break; case 6: //#line 84 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc); } break; case 7: //#line 88 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc); } break; case 8: //#line 92 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc); } break; case 9: //#line 96 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc); } break; case 10: //#line 100 "Parser.y" { yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc); } break; case 11: //#line 104 "Parser.y" { yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc); } break; case 12: //#line 110 "Parser.y" { yyval.cdef = new Tree.ClassDef(val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc); } break; case 13: //#line 116 "Parser.y" { yyval.ident = val_peek(0).ident; } break; case 14: //#line 120 "Parser.y" { yyval = new SemValue(); } break; case 15: //#line 126 "Parser.y" { yyval.flist.add(val_peek(0).vdef); } break; case 16: //#line 130 "Parser.y" { yyval.flist.add(val_peek(0).fdef); } break; case 17: //#line 134 "Parser.y" { yyval = new SemValue(); yyval.flist = new ArrayList<Tree>(); } break; case 19: //#line 142 "Parser.y" { yyval = new SemValue(); yyval.vlist = new ArrayList<Tree.VarDef>(); } break; case 20: //#line 149 "Parser.y" { yyval.vlist.add(val_peek(0).vdef); } break; case 21: //#line 153 "Parser.y" { yyval.vlist = new ArrayList<Tree.VarDef>(); yyval.vlist.add(val_peek(0).vdef); } break; case 22: //#line 160 "Parser.y" { yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 23: //#line 164 "Parser.y" { yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 24: //#line 170 "Parser.y" { yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc); } break; case 25: //#line 176 "Parser.y" { yyval.slist.add(val_peek(0).stmt); } break; case 26: //#line 180 "Parser.y" { yyval = new SemValue(); yyval.slist = new ArrayList<Tree>(); } break; case 27: //#line 187 "Parser.y" { yyval.stmt = val_peek(0).vdef; } break; case 28: //#line 192 "Parser.y" { if (yyval.stmt == null) { yyval.stmt = new Tree.Skip(val_peek(0).loc); } } break; case 38: //#line 209 "Parser.y" { yyval.guardedES = new Tree.GuardedES(val_peek(2).expr , val_peek(0).stmt , val_peek(1).loc); } break; case 39: //#line 215 "Parser.y" { yyval.myList = new ArrayList<Tree.GuardedES>(); yyval.myList.add(val_peek(0).guardedES); } break; case 40: //#line 222 "Parser.y" { yyval.myList.add(val_peek(0).guardedES); } break; case 41: //#line 229 "Parser.y" { yyval.stmt = new Tree.GuardedIFStmt(val_peek(1).myList , val_peek(2).loc); } break; case 42: //#line 235 "Parser.y" { yyval.stmt = new Tree.GuardedDOStmt(val_peek(1).myList , val_peek(2).loc); } break; case 43: //#line 241 "Parser.y" { yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc); } break; case 44: //#line 245 "Parser.y" { yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc); } break; case 45: //#line 249 "Parser.y" { yyval = new SemValue(); } break; case 47: //#line 256 "Parser.y" { yyval = new SemValue(); } break; case 48: //#line 262 "Parser.y" { yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc); if (val_peek(1).loc == null) { yyval.loc = val_peek(0).loc; } } break; case 49: //#line 269 "Parser.y" { yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc); } break; case 50: //#line 275 "Parser.y" { yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc); if (val_peek(4).loc == null) { yyval.loc = val_peek(3).loc; } } break; case 51: //#line 284 "Parser.y" { yyval.expr = val_peek(0).lvalue; } break; case 54: //#line 290 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 55: //#line 294 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 56: //#line 298 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 57: //#line 302 "Parser.y" { yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 58: //#line 306 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 59: //#line 310 "Parser.y" { yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 60: //#line 314 "Parser.y" { yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 61: //#line 318 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 62: //#line 322 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 63: //#line 326 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 64: //#line 330 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 65: //#line 334 "Parser.y" { yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 66: //#line 338 "Parser.y" { yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 67: //#line 342 "Parser.y" { yyval = val_peek(1); } break; case 68: //#line 346 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc); } break; case 69: //#line 350 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc); } break; case 70: //#line 354 "Parser.y" { yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc); } break; case 71: //#line 358 "Parser.y" { yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc); } break; case 72: //#line 362 "Parser.y" { yyval.expr = new Tree.ThisExpr(val_peek(0).loc); } break; case 73: //#line 366 "Parser.y" { yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc); } break; case 74: //#line 370 "Parser.y" { yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc); } break; case 75: //#line 374 "Parser.y" { yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc); } break; case 76: //#line 378 "Parser.y" { yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc); } break; case 77: //#line 382 "Parser.y" { yyval.expr = new Tree.Unary(Tree.POSTINC, val_peek(1).expr, val_peek(0).loc); } break; case 78: //#line 386 "Parser.y" { yyval.expr = new Tree.Unary(Tree.PREINC, val_peek(0).expr, val_peek(1).loc); } break; case 79: //#line 390 "Parser.y" { yyval.expr = new Tree.Unary(Tree.POSTDEC, val_peek(1).expr, val_peek(0).loc); } break; case 80: //#line 394 "Parser.y" { yyval.expr = new Tree.Unary(Tree.PREDEC, val_peek(0).expr, val_peek(1).loc); } break; case 81: //#line 398 "Parser.y" { yyval.expr = new Tree.QuestionAndColon(Tree.QUESTION_COLON, val_peek(4).expr, val_peek(2).expr, val_peek(0).expr, val_peek(4).loc); } break; case 82: //#line 402 "Parser.y" { yyval.expr = new Tree.NumTest(val_peek(1).ident, val_peek(3).loc); } break; case 83: //#line 408 "Parser.y" { yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc); } break; case 84: //#line 412 "Parser.y" { yyval.expr = new Null(val_peek(0).loc); } break; case 86: //#line 419 "Parser.y" { yyval = new SemValue(); yyval.elist = new ArrayList<Tree.Expr>(); } break; case 87: //#line 426 "Parser.y" { yyval.elist.add(val_peek(0).expr); } break; case 88: //#line 430 "Parser.y" { yyval.elist = new ArrayList<Tree.Expr>(); yyval.elist.add(val_peek(0).expr); } break; case 89: //#line 437 "Parser.y" { yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc); } break; case 90: //#line 443 "Parser.y" { yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc); } break; case 91: //#line 449 "Parser.y" { yyval.stmt = new Tree.Break(val_peek(0).loc); } break; case 92: //#line 455 "Parser.y" { yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc); } break; case 93: //#line 461 "Parser.y" { yyval.stmt = val_peek(0).stmt; } break; case 94: //#line 465 "Parser.y" { yyval = new SemValue(); } break; case 95: //#line 471 "Parser.y" { yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc); } break; case 96: //#line 475 "Parser.y" { yyval.stmt = new Tree.Return(null, val_peek(0).loc); } break; case 97: //#line 481 "Parser.y" { yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc); } break; //#line 1397 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
stellarkey/912_project
6 复试/2 笔试/4 编译原理/编原/hw/2015_刘智峰_PA/PA1/src/decaf/frontend/Parser.java
769
package com.hbm.inventory.material; import static com.hbm.inventory.OreDictManager.*; import static com.hbm.inventory.material.MaterialShapes.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import com.hbm.inventory.OreDictManager.DictFrame; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.material.NTMMaterial.SmeltingBehavior; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemScraps; import com.hbm.util.I18nUtil; import com.hbm.util.ItemStackUtil; import net.minecraft.item.ItemStack; /* with every new rewrite, optimization and improvement, the code becomes more gregian */ /** * Defines materials that wrap around DictFrames to more accurately describe that material. * Direct uses are the crucible and possibly item auto-gen, depending on what traits are set. * @author hbm */ public class Mats { public static List<NTMMaterial> orderedList = new ArrayList(); public static HashMap<String, MaterialShapes> prefixByName = new HashMap(); public static HashMap<Integer, NTMMaterial> matById = new HashMap(); public static HashMap<String, NTMMaterial> matByName = new HashMap(); public static HashMap<ComparableStack, List<MaterialStack>> materialEntries = new HashMap(); public static HashMap<String, List<MaterialStack>> materialOreEntries = new HashMap(); /* * ItemStacks are saved with their metadata being truncated to a short, so the max meta is 32767 * Format for elements: Atomic number *100, plus the last two digits of the mass number. Mass number is 0 for generic/undefined/mixed materials. * Vanilla numbers are in vanilla space (0-29), basic alloys use alloy space (30-99) */ /* Vanilla Space, up to 30 materials, */ public static final int _VS = 0; /* Alloy Space, up to 70 materials. Use >20_000 as an extension.*/ public static final int _AS = 30; //Vanilla and vanilla-like public static final NTMMaterial MAT_STONE = makeSmeltable(_VS + 00, df("Stone"), 0x7F7F7F, 0x353535, 0x4D2F23).n(); public static final NTMMaterial MAT_CARBON = makeAdditive( 1499, df("Carbon"), 0x363636, 0x030303, 0x404040).n(); public static final NTMMaterial MAT_COAL = make( 1400, COAL) .setConversion(MAT_CARBON, 2, 1).n(); public static final NTMMaterial MAT_LIGNITE = make( 1401, LIGNITE) .setConversion(MAT_CARBON, 3, 1).n(); public static final NTMMaterial MAT_COALCOKE = make( 1410, COALCOKE) .setConversion(MAT_CARBON, 4, 3).n(); public static final NTMMaterial MAT_PETCOKE = make( 1411, PETCOKE) .setConversion(MAT_CARBON, 4, 3).n(); public static final NTMMaterial MAT_LIGCOKE = make( 1412, LIGCOKE) .setConversion(MAT_CARBON, 4, 3).n(); public static final NTMMaterial MAT_GRAPHITE = make( 1420, GRAPHITE) .setConversion(MAT_CARBON, 1, 1).n(); public static final NTMMaterial MAT_DIAMOND = make( 1430, DIAMOND) .setConversion(MAT_CARBON, 1, 1).n(); public static final NTMMaterial MAT_IRON = makeSmeltable(2600, IRON, 0xFFFFFF, 0x353535, 0xFFA259).setShapes(PIPE, CASTPLATE, WELDEDPLATE).m(); public static final NTMMaterial MAT_GOLD = makeSmeltable(7900, GOLD, 0xFFFF8B, 0xC26E00, 0xE8D754).setShapes(DENSEWIRE, CASTPLATE).m(); public static final NTMMaterial MAT_REDSTONE = makeSmeltable(_VS + 01, REDSTONE, 0xE3260C, 0x700E06, 0xFF1000).n(); public static final NTMMaterial MAT_OBSIDIAN = makeSmeltable(_VS + 02, df("Obsidian"), 0x3D234D).n(); public static final NTMMaterial MAT_HEMATITE = makeAdditive( 2601, HEMATITE, 0xDFB7AE, 0x5F372E, 0x6E463D).m(); public static final NTMMaterial MAT_WROUGHTIRON = makeSmeltable(2602, df("WroughtIron"), 0xFAAB89).m(); public static final NTMMaterial MAT_PIGIRON = makeSmeltable(2603, df("PigIron"), 0xFF8B59).m(); public static final NTMMaterial MAT_METEORICIRON = makeSmeltable(2604, df("MeteoricIron"), 0x715347).m(); public static final NTMMaterial MAT_MALACHITE = makeAdditive( 2901, MALACHITE, 0xA2F0C8, 0x227048, 0x61AF87).m(); //Radioactive public static final NTMMaterial MAT_URANIUM = makeSmeltable(9200, U, 0xC1C7BD, 0x2B3227, 0x9AA196).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_U233 = makeSmeltable(9233, U233, 0xC1C7BD, 0x2B3227, 0x9AA196).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_U235 = makeSmeltable(9235, U235, 0xC1C7BD, 0x2B3227, 0x9AA196).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_U238 = makeSmeltable(9238, U238, 0xC1C7BD, 0x2B3227, 0x9AA196).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_THORIUM = makeSmeltable(9032, TH232, 0xBF825F, 0x1C0000, 0xBF825F).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_PLUTONIUM = makeSmeltable(9400, PU, 0x9AA3A0, 0x111A17, 0x78817E).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_RGP = makeSmeltable(9401, PURG, 0x9AA3A0, 0x111A17, 0x78817E).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_PU238 = makeSmeltable(9438, PU238, 0xFFBC59, 0xFF8E2B, 0x78817E).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_PU239 = makeSmeltable(9439, PU239, 0x9AA3A0, 0x111A17, 0x78817E).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_PU240 = makeSmeltable(9440, PU240, 0x9AA3A0, 0x111A17, 0x78817E).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_PU241 = makeSmeltable(9441, PU241, 0x9AA3A0, 0x111A17, 0x78817E).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_RGA = makeSmeltable(9501, AMRG, 0x93767B).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_AM241 = makeSmeltable(9541, AM241, 0x93767B).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_AM242 = makeSmeltable(9542, AM242, 0x93767B).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_NEPTUNIUM = makeSmeltable(9337, NP237, 0x647064).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_POLONIUM = makeSmeltable(8410, PO210, 0x563A26).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_TECHNIETIUM = makeSmeltable(4399, TC99, 0xFAFFFF, 0x576C6C, 0xCADFDF).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_RADIUM = makeSmeltable(8826, RA226, 0xE9FAF6).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_ACTINIUM = makeSmeltable(8927, AC227, 0x958989).setShapes(NUGGET, BILLET, INGOT).m(); public static final NTMMaterial MAT_CO60 = makeSmeltable(2760, CO60, 0xC2D1EE, 0x353554, 0x8F72AE).setShapes(NUGGET, BILLET, INGOT, DUST).m(); public static final NTMMaterial MAT_AU198 = makeSmeltable(7998, AU198, 0xFFFF8B, 0xC26E00, 0xE8D754).setShapes(NUGGET, BILLET, INGOT, DUST).m(); public static final NTMMaterial MAT_PB209 = makeSmeltable(8209, PB209, 0x7B535D).setShapes(NUGGET, BILLET, INGOT, DUST).m(); public static final NTMMaterial MAT_SCHRABIDIUM = makeSmeltable(12626, SA326, 0x32FFFF, 0x005C5C, 0x32FFFF).setShapes(NUGGET, WIRE, BILLET, INGOT, DUST, DENSEWIRE, PLATE, CASTPLATE, BLOCK).m(); public static final NTMMaterial MAT_SOLINIUM = makeSmeltable(12627, SA327, 0xA2E6E0, 0x00433D, 0x72B6B0).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); public static final NTMMaterial MAT_SCHRABIDATE = makeSmeltable(12600, SBD, 0x77C0D7, 0x39005E, 0x6589B4).setShapes(INGOT, DUST, DENSEWIRE, BLOCK).m(); public static final NTMMaterial MAT_SCHRARANIUM = makeSmeltable(12601, SRN, 0x2B3227, 0x2B3227, 0x24AFAC).setShapes(INGOT, BLOCK).m(); public static final NTMMaterial MAT_GHIORSIUM = makeSmeltable(12836, GH336, 0xF4EFE1, 0x2A3306, 0xC6C6A1).setShapes(NUGGET, BILLET, INGOT, BLOCK).m(); //Base metals public static final NTMMaterial MAT_TITANIUM = makeSmeltable(2200, TI, 0xF7F3F2, 0x4F4C4B, 0xA99E79).setShapes(INGOT, DUST, PLATE, CASTPLATE, WELDEDPLATE, SHELL, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_COPPER = makeSmeltable(2900, CU, 0xFDCA88, 0x601E0D, 0xC18336).setShapes(WIRE, INGOT, DUST, PLATE, CASTPLATE, WELDEDPLATE, SHELL, PIPE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_TUNGSTEN = makeSmeltable(7400, W, 0x868686, 0x000000, 0x977474).setShapes(WIRE, BOLT, INGOT, DUST, DENSEWIRE, CASTPLATE, WELDEDPLATE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_ALUMINIUM = makeSmeltable(1300, AL, 0xFFFFFF, 0x344550, 0xD0B8EB).setShapes(WIRE, INGOT, DUST, PLATE, CASTPLATE, WELDEDPLATE, SHELL, PIPE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_LEAD = makeSmeltable(8200, PB, 0xA6A6B2, 0x03030F, 0x646470).setShapes(NUGGET, INGOT, DUST, PLATE, CASTPLATE, PIPE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_BISMUTH = makeSmeltable(8300, BI, 0xB200FF).setShapes(NUGGET, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_ARSENIC = makeSmeltable(3300, AS, 0x6CBABA, 0x242525, 0x558080).setShapes(NUGGET, INGOT).m(); public static final NTMMaterial MAT_TANTALIUM = makeSmeltable(7300, TA, 0xFFFFFF, 0x1D1D36, 0xA89B74).setShapes(NUGGET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_NEODYMIUM = makeSmeltable(6000, ND, 0xE6E6B6, 0x1C1C00, 0x8F8F5F).setShapes(NUGGET, DUSTTINY, INGOT, DUST, DENSEWIRE, BLOCK).m(); public static final NTMMaterial MAT_NIOBIUM = makeSmeltable(4100, NB, 0xB76EC9, 0x2F2D42, 0xD576B1).setShapes(NUGGET, DUSTTINY, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_BERYLLIUM = makeSmeltable(400, BE, 0xB2B2A6, 0x0F0F03, 0xAE9572).setShapes(NUGGET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_EMERALD = make( 401, EMERALD) .setConversion(MAT_BERYLLIUM, 4, 3).n(); public static final NTMMaterial MAT_COBALT = makeSmeltable(2700, CO, 0xC2D1EE, 0x353554, 0x8F72AE).setShapes(NUGGET, DUSTTINY, BILLET, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_BORON = makeSmeltable(500, B, 0xBDC8D2, 0x29343E, 0xAD72AE).setShapes(DUSTTINY, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_ZIRCONIUM = makeSmeltable(4000, ZR, 0xE3DCBE, 0x3E3719, 0xADA688).setShapes(NUGGET, DUSTTINY, BILLET, INGOT, DUST, CASTPLATE, WELDEDPLATE, BLOCK).m(); public static final NTMMaterial MAT_SODIUM = makeSmeltable(1100, NA, 0xD3BF9E, 0x3A5A6B, 0x7E9493).setShapes(DUST).m(); public static final NTMMaterial MAT_CALCIUM = makeSmeltable(2000, CA, 0xCFCFA6, 0x747F6E, 0xB7B784).setShapes(INGOT, DUST).m(); public static final NTMMaterial MAT_LITHIUM = makeSmeltable(300, LI, 0xFFFFFF, 0x818181, 0xD6D6D6).setShapes(INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_CADMIUM = makeSmeltable(4800, CD, 0xFFFADE, 0x350000, 0xA85600).setShapes(INGOT, DUST).m(); public static final NTMMaterial MAT_SILICON = makeSmeltable(1400, SI, 0xD1D7DF, 0x1A1A3D, 0x878B9E).setShapes(NUGGET, BILLET, INGOT).m(); public static final NTMMaterial MAT_OSMIRIDIUM = makeSmeltable(7699, OSMIRIDIUM, 0xDBE3EF, 0x7891BE, 0xACBDD9).setShapes(NUGGET, INGOT, CASTPLATE, WELDEDPLATE).m(); //Alloys public static final NTMMaterial MAT_STEEL = makeSmeltable(_AS + 0, STEEL, 0xAFAFAF, 0x0F0F0F, 0x4A4A4A).setShapes(DUSTTINY, BOLT, INGOT, DUST, PLATE, CASTPLATE, WELDEDPLATE, SHELL, PIPE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_MINGRADE = makeSmeltable(_AS + 1, MINGRADE, 0xFFBA7D, 0xAF1700, 0xE44C0F).setShapes(WIRE, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_ALLOY = makeSmeltable(_AS + 2, ALLOY, 0xFF8330, 0x700000, 0xFF7318).setShapes(WIRE, INGOT, DUST, DENSEWIRE, PLATE, CASTPLATE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_DURA = makeSmeltable(_AS + 3, DURA, 0x183039, 0x030B0B, 0x376373).setShapes(BOLT, INGOT, DUST, PIPE, BLOCK).m(); public static final NTMMaterial MAT_SATURN = makeSmeltable(_AS + 4, BIGMT, 0x4DA3AF, 0x00000C, 0x4DA3AF).setShapes(INGOT, DUST, PLATE, CASTPLATE, BLOCK).m(); public static final NTMMaterial MAT_DESH = makeSmeltable(_AS + 12, DESH, 0xFF6D6D, 0x720000, 0xF22929).setShapes(INGOT, DUST, CASTPLATE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_STAR = makeSmeltable(_AS + 5, STAR, 0xCCCCEA, 0x11111A, 0xA5A5D3).setShapes(INGOT, DUST, DENSEWIRE, BLOCK).m(); public static final NTMMaterial MAT_FERRO = makeSmeltable(_AS + 7, FERRO, 0xB7B7C9, 0x101022, 0x6B6B8B).setShapes(INGOT).m(); public static final NTMMaterial MAT_TCALLOY = makeSmeltable(_AS + 6, TCALLOY, 0xD4D6D6, 0x323D3D, 0x9CA6A6).setShapes(INGOT, DUST, CASTPLATE, WELDEDPLATE, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_CDALLOY = makeSmeltable(_AS + 13, CDALLOY, 0xF7DF8F, 0x604308, 0xFBD368).setShapes(INGOT, CASTPLATE, WELDEDPLATE, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_BBRONZE = makeSmeltable(_AS + 16, BBRONZE, 0xE19A69, 0x485353, 0x987D65).setShapes(INGOT, CASTPLATE).m(); public static final NTMMaterial MAT_ABRONZE = makeSmeltable(_AS + 17, ABRONZE, 0xDB9462, 0x203331, 0x77644D).setShapes(INGOT, CASTPLATE).m(); public static final NTMMaterial MAT_MAGTUNG = makeSmeltable(_AS + 8, MAGTUNG, 0x22A2A2, 0x0F0F0F, 0x22A2A2).setShapes(INGOT, DUST, DENSEWIRE, BLOCK).m(); public static final NTMMaterial MAT_CMB = makeSmeltable(_AS + 9, CMB, 0x6F6FB4, 0x000011, 0x6F6FB4).setShapes(INGOT, DUST, PLATE, CASTPLATE, WELDEDPLATE, BLOCK).m(); public static final NTMMaterial MAT_DNT = makeSmeltable(_AS + 15, DNT, 0x7582B9, 0x16000E, 0x455289).setShapes(INGOT, DUST, DENSEWIRE, BLOCK).m(); public static final NTMMaterial MAT_FLUX = makeAdditive(_AS + 10, df("Flux"), 0xF1E0BB, 0x6F6256, 0xDECCAD).setShapes(DUST).n(); public static final NTMMaterial MAT_SLAG = makeSmeltable(_AS + 11, SLAG, 0x554940, 0x34281F, 0x6C6562).setShapes(BLOCK).n(); public static final NTMMaterial MAT_MUD = makeSmeltable(_AS + 14, MUD, 0xBCB5A9, 0x481213, 0x96783B).setShapes(INGOT).n(); @Deprecated public static NTMMaterial makeSmeltable(int id, DictFrame dict, int color) { return makeSmeltable(id, dict, color, color, color); } @Deprecated public static NTMMaterial makeAdditive(int id, DictFrame dict, int color) { return makeAdditive(id, dict, color, color, color); } public static NTMMaterial make(int id, DictFrame dict) { return new NTMMaterial(id, dict); } public static NTMMaterial makeSmeltable(int id, DictFrame dict, int solidColorLight, int solidColorDark, int moltenColor) { return new NTMMaterial(id, dict).smeltable(SmeltingBehavior.SMELTABLE).setSolidColor(solidColorLight, solidColorDark).setMoltenColor(moltenColor); } public static NTMMaterial makeAdditive(int id, DictFrame dict, int solidColorLight, int solidColorDark, int moltenColor) { return new NTMMaterial(id, dict).smeltable(SmeltingBehavior.ADDITIVE).setSolidColor(solidColorLight, solidColorDark).setMoltenColor(moltenColor); } public static DictFrame df(String string) { return new DictFrame(string); } /** will not respect stacksizes - all stacks will be treated as a singular */ public static List<MaterialStack> getMaterialsFromItem(ItemStack stack) { List<MaterialStack> list = new ArrayList(); List<String> names = ItemStackUtil.getOreDictNames(stack); if(!names.isEmpty()) { outer: for(String name : names) { List<MaterialStack> oreEntries = materialOreEntries.get(name); if(oreEntries != null) { list.addAll(oreEntries); break outer; } for(Entry<String, MaterialShapes> prefixEntry : prefixByName.entrySet()) { String prefix = prefixEntry.getKey(); if(name.startsWith(prefix)) { String materialName = name.substring(prefix.length()); NTMMaterial material = matByName.get(materialName); if(material != null) { list.add(new MaterialStack(material, prefixEntry.getValue().q(1))); break outer; } } } } } List<MaterialStack> entries = materialEntries.get(new ComparableStack(stack).makeSingular()); if(entries != null) { list.addAll(entries); } if(stack.getItem() == ModItems.scraps) { list.add(ItemScraps.getMats(stack)); } return list; } public static List<MaterialStack> getSmeltingMaterialsFromItem(ItemStack stack) { List<MaterialStack> baseMats = getMaterialsFromItem(stack); List<MaterialStack> smelting = new ArrayList(); baseMats.forEach(x -> smelting.add(new MaterialStack(x.material.smeltsInto, (int) (x.amount * x.material.convOut / x.material.convIn)))); return smelting; } public static class MaterialStack { //final fields to prevent accidental changing public final NTMMaterial material; public int amount; public MaterialStack(NTMMaterial material, int amount) { this.material = material; this.amount = amount; } public MaterialStack copy() { return new MaterialStack(material, amount); } } public static String formatAmount(int amount, boolean showInMb) { if(showInMb) { return (amount * 2) + "mB"; } String format = ""; int blocks = amount / BLOCK.q(1); amount -= BLOCK.q(blocks); int ingots = amount / INGOT.q(1); amount -= INGOT.q(ingots); int nuggets = amount / NUGGET.q(1); amount -= NUGGET.q(nuggets); int quanta = amount; if(blocks > 0) format += (blocks == 1 ? I18nUtil.resolveKey("matshape.block", blocks) : I18nUtil.resolveKey("matshape.blocks", blocks)) + " "; if(ingots > 0) format += (ingots == 1 ? I18nUtil.resolveKey("matshape.ingot", ingots) : I18nUtil.resolveKey("matshape.ingots", ingots)) + " "; if(nuggets > 0) format += (nuggets == 1 ? I18nUtil.resolveKey("matshape.nugget", nuggets) : I18nUtil.resolveKey("matshape.nuggets", nuggets)) + " "; if(quanta > 0) format += (quanta == 1 ? I18nUtil.resolveKey("matshape.quantum", quanta) : I18nUtil.resolveKey("matshape.quanta", quanta)) + " "; return format.trim(); } }
HbmMods/Hbm-s-Nuclear-Tech-GIT
src/main/java/com/hbm/inventory/material/Mats.java
770
/* * Copyright 2010 Aalto University, ComNet * Released under GPLv3. See LICENSE.txt for details. */ package routing; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import routing.util.RoutingInfo; import util.Tuple; import core.Connection; import core.DTNHost; import core.Message; import core.Settings; import core.SimClock; /** * Implementation of PRoPHET router as described in * <I>Probabilistic routing in intermittently connected networks</I> by * Anders Lindgren et al. * * * This version tries to estimate a good value of protocol parameters from * a timescale parameter given by the user, and from the encounters the node * sees during simulation. * Refer to Karvo and Ott, <I>Time Scales and Delay-Tolerant Routing * Protocols</I> Chants, 2008 * */ public class ProphetRouterWithEstimation extends ActiveRouter { /** delivery predictability initialization constant*/ public static final double P_INIT = 0.75; /** delivery predictability transitivity scaling constant default value */ public static final double DEFAULT_BETA = 0.25; /** delivery predictability aging constant */ public static final double GAMMA = 0.98; /** default P target */ public static final double DEFAULT_PTARGET = .2; /** Prophet router's setting namespace ({@value})*/ public static final String PROPHET_NS = "ProphetRouterWithEstimation"; /** * Number of seconds in time scale.*/ public static final String TIME_SCALE_S ="timeScale"; /** * Target P_avg * */ public static final String P_AVG_TARGET_S = "targetPavg"; /** * Transitivity scaling constant (beta) -setting id ({@value}). * Default value for setting is {@link #DEFAULT_BETA}. */ public static final String BETA_S = "beta"; /** values of parameter settings */ private double beta; private double gamma; private double pinit; /** value of time scale variable */ private int timescale; private double ptavg; /** delivery predictabilities */ private Map<DTNHost, Double> preds; /** last meeting time with a node */ private Map<DTNHost, Double> meetings; private int nrofSamples; private double meanIET; /** last delivery predictability update (sim)time */ private double lastAgeUpdate; /** * Constructor. Creates a new message router based on the settings in * the given Settings object. * @param s The settings object */ public ProphetRouterWithEstimation(Settings s) { super(s); Settings prophetSettings = new Settings(PROPHET_NS); timescale = prophetSettings.getInt(TIME_SCALE_S); if (prophetSettings.contains(P_AVG_TARGET_S)) { ptavg = prophetSettings.getDouble(P_AVG_TARGET_S); } else { ptavg = DEFAULT_PTARGET; } if (prophetSettings.contains(BETA_S)) { beta = prophetSettings.getDouble(BETA_S); } else { beta = DEFAULT_BETA; } gamma = GAMMA; pinit = P_INIT; initPreds(); initMeetings(); } /** * Copyconstructor. * @param r The router prototype where setting values are copied from */ protected ProphetRouterWithEstimation(ProphetRouterWithEstimation r) { super(r); this.timescale = r.timescale; this.ptavg = r.ptavg; this.beta = r.beta; initPreds(); initMeetings(); } /** * Initializes predictability hash */ private void initPreds() { this.preds = new HashMap<DTNHost, Double>(); } /** * Initializes inter-encounter time estimator */ private void initMeetings() { this.meetings = new HashMap<DTNHost, Double>(); this.meanIET = 0; this.nrofSamples = 0; } @Override public void changedConnection(Connection con) { super.changedConnection(con); if (con.isUp()) { DTNHost otherHost = con.getOtherNode(getHost()); if (updateIET(otherHost)) { updateParams(); } updateDeliveryPredFor(otherHost); updateTransitivePreds(otherHost); } } /** * Updates the interencounter time estimates * @param host */ private boolean updateIET(DTNHost host) { /* First estimate the mean InterEncounter Time */ double currentTime = SimClock.getTime(); if (meetings.containsKey(host)) { double timeDiff = currentTime - meetings.get(host); // System.out.printf("current time: %f\t last time: %f\n",currentTime,meetings.get(host)); nrofSamples++; meanIET = (((double)nrofSamples -1) / (double)nrofSamples) * meanIET + (1 / (double)nrofSamples) * timeDiff; meetings.put(host, currentTime); return true; } else { /* nothing to update */ meetings.put(host,currentTime); return false; } } /** * update PROPHET parameters * */ private void updateParams() { double b; double zeta; double err; boolean cond; int ntarg; double zetadiff; int ozeta; double pstable; double pavg; double ee; double bdiff; int ob; int zcount; boolean bcheck; double pnzero; double pnone; double eezero; double eeone; /* * the estimation algorith does not work for timescales * shorter than the mean IET - so use defaults */ if (meanIET > (double)timescale) { System.out.printf("meanIET %f > %d timescale\n",meanIET,timescale); return; } if (meanIET == 0) { System.out.printf("Mean IET == 0\n"); return; } System.out.printf("prophetfindparams(%d,%f,%f);\n",timescale,ptavg,meanIET); b = 1e-5; zeta = .9; err = 0.005; zetadiff = .1; ozeta = 0; cond = false; ntarg = (int)Math.ceil((double)timescale/(double)meanIET); while (cond == false) { pstable = (1-zeta)/(Math.exp(b*meanIET)-zeta); pavg = (1/(b*meanIET)) * (1-zeta*(1-pstable)) * (1- Math.exp( -b*meanIET)); if (Double.isNaN(pavg)) { pavg = 1; } if (pavg > ptavg) { //System.out.printf("PAVG %f > %f PTAVG\n", pavg,ptavg); if (ozeta == 2) { zetadiff = zetadiff / 2.0; } ozeta = 1; zeta = zeta + zetadiff; if (zeta >= 1) { zeta = 1-zetadiff; zetadiff = zetadiff / 2.0; ozeta = 0; } } else { if (pavg < ptavg * (1-err)) { // System.out.printf("PAVG %f < %f PTAVG\n", pavg,ptavg); if (ozeta == 1) { zetadiff = zetadiff / 2.0; } ozeta = 2; zeta = zeta-zetadiff; if (zeta <= 0) { zeta = 0 + zetadiff; zetadiff = zetadiff / 2.0; ozeta = 0; } } else { cond = true; } } //System.out.printf("Zeta: %f Zetadiff: %f\n",zeta,zetadiff); ee = 1; bdiff = .1; ob = 0; zcount = 0; // if 100 iterations won't help, lets increase zeta... bcheck = false; while (bcheck == false) { pstable = (1-zeta)/(Math.exp(b*meanIET)-zeta); pnzero = Math.exp(-b*meanIET) * (1-zeta) * ((1-Math.pow(zeta*Math.exp(-b*meanIET),ntarg-1))/ (1-zeta*Math.exp(-b*meanIET))); pnone = Math.pow(zeta*Math.exp(-b*meanIET),ntarg) + pnzero; eezero = Math.abs(pnzero-pstable); eeone = Math.abs(pnone -pstable); ee = Math.max(eezero,eeone); // System.out.printf("Zeta: %f\n", zeta); // System.out.printf("Ptarget: %f \t Pstable: %f\n",ptavg,pstable); // System.out.printf("Pnzero: %f \tPnone: %f\n", pnzero,pnone); // System.out.printf("eezero: %f\t eeone: %f\n", eezero, eeone); if (ee > err) { if (ob == 2) { bdiff = bdiff / 2.0; } ob = 1; b = b+bdiff; } else { if (ee < (err*(1-err))) { if (ob == 1) { bdiff = bdiff / 2.0; } ob = 2; b = b-bdiff; if (b <= 0) { b = 0 + bdiff; bdiff = bdiff / 1.5; ob = 0; } } else { bcheck = true; // System.out.println("******"); } } // System.out.printf("EE: %f B: %f Bdiff: %f\n",ee,b,bdiff); zcount = zcount + 1; if (zcount > 100) { bcheck = true; ozeta = 0; } } } gamma = Math.exp(-b); pinit = 1-zeta; } /** * Updates delivery predictions for a host. * <CODE>P(a,b) = P(a,b)_old + (1 - P(a,b)_old) * P_INIT</CODE> * @param host The host we just met */ private void updateDeliveryPredFor(DTNHost host) { double oldValue = getPredFor(host); double newValue = oldValue + (1 - oldValue) * pinit; preds.put(host, newValue); } /** * Returns the current prediction (P) value for a host or 0 if entry for * the host doesn't exist. * @param host The host to look the P for * @return the current P value */ public double getPredFor(DTNHost host) { ageDeliveryPreds(); // make sure preds are updated before getting if (preds.containsKey(host)) { return preds.get(host); } else { return 0; } } /** * Updates transitive (A->B->C) delivery predictions. * <CODE>P(a,c) = P(a,c)_old + (1 - P(a,c)_old) * P(a,b) * P(b,c) * BETA * </CODE> * @param host The B host who we just met */ private void updateTransitivePreds(DTNHost host) { MessageRouter otherRouter = host.getRouter(); assert otherRouter instanceof ProphetRouterWithEstimation : "PRoPHET only works " + " with other routers of same type"; double pForHost = getPredFor(host); // P(a,b) Map<DTNHost, Double> othersPreds = ((ProphetRouterWithEstimation)otherRouter).getDeliveryPreds(); for (Map.Entry<DTNHost, Double> e : othersPreds.entrySet()) { if (e.getKey() == getHost()) { continue; // don't add yourself } double pOld = getPredFor(e.getKey()); // P(a,c)_old double pNew = pOld + ( 1 - pOld) * pForHost * e.getValue() * beta; preds.put(e.getKey(), pNew); } } /** * Ages all entries in the delivery predictions. * <CODE>P(a,b) = P(a,b)_old * (GAMMA ^ k)</CODE>, where k is number of * time units that have elapsed since the last time the metric was aged. * @see #SECONDS_IN_UNIT_S */ private void ageDeliveryPreds() { double timeDiff = (SimClock.getTime() - this.lastAgeUpdate); if (timeDiff == 0) { return; } double mult = Math.pow(gamma, timeDiff); for (Map.Entry<DTNHost, Double> e : preds.entrySet()) { e.setValue(e.getValue()*mult); } this.lastAgeUpdate = SimClock.getTime(); } /** * Returns a map of this router's delivery predictions * @return a map of this router's delivery predictions */ private Map<DTNHost, Double> getDeliveryPreds() { ageDeliveryPreds(); // make sure the aging is done return this.preds; } @Override public void update() { super.update(); if (!canStartTransfer() ||isTransferring()) { return; // nothing to transfer or is currently transferring } // try messages that could be delivered to final recipient if (exchangeDeliverableMessages() != null) { return; } tryOtherMessages(); } /** * Tries to send all other messages to all connected hosts ordered by * their delivery probability * @return The return value of {@link #tryMessagesForConnected(List)} */ private Tuple<Message, Connection> tryOtherMessages() { List<Tuple<Message, Connection>> messages = new ArrayList<Tuple<Message, Connection>>(); Collection<Message> msgCollection = getMessageCollection(); /* for all connected hosts collect all messages that have a higher probability of delivery by the other host */ for (Connection con : getConnections()) { DTNHost other = con.getOtherNode(getHost()); ProphetRouterWithEstimation othRouter = (ProphetRouterWithEstimation)other.getRouter(); if (othRouter.isTransferring()) { continue; // skip hosts that are transferring } for (Message m : msgCollection) { if (othRouter.hasMessage(m.getId())) { continue; // skip messages that the other one has } if (othRouter.getPredFor(m.getTo()) > getPredFor(m.getTo())) { // the other node has higher probability of delivery messages.add(new Tuple<Message, Connection>(m,con)); } } } if (messages.size() == 0) { return null; } // sort the message-connection tuples Collections.sort(messages, new TupleComparator()); return tryMessagesForConnected(messages); // try to send messages } /** * Comparator for Message-Connection-Tuples that orders the tuples by * their delivery probability by the host on the other side of the * connection (GRTRMax) */ private class TupleComparator implements Comparator <Tuple<Message, Connection>> { public int compare(Tuple<Message, Connection> tuple1, Tuple<Message, Connection> tuple2) { // delivery probability of tuple1's message with tuple1's connection double p1 = ((ProphetRouterWithEstimation)tuple1.getValue(). getOtherNode(getHost()).getRouter()).getPredFor( tuple1.getKey().getTo()); // -"- tuple2... double p2 = ((ProphetRouterWithEstimation)tuple2.getValue(). getOtherNode(getHost()).getRouter()).getPredFor( tuple2.getKey().getTo()); // bigger probability should come first if (p2-p1 == 0) { /* equal probabilities -> let queue mode decide */ return compareByQueueMode(tuple1.getKey(), tuple2.getKey()); } else if (p2-p1 < 0) { return -1; } else { return 1; } } } @Override public RoutingInfo getRoutingInfo() { ageDeliveryPreds(); RoutingInfo top = super.getRoutingInfo(); RoutingInfo ri = new RoutingInfo(preds.size() + " delivery prediction(s)"); for (Map.Entry<DTNHost, Double> e : preds.entrySet()) { DTNHost host = e.getKey(); Double value = e.getValue(); ri.addMoreInfo(new RoutingInfo(String.format("%s : %.6f", host, value))); } ri.addMoreInfo(new RoutingInfo(String.format("meanIET: %f\t from %d samples",meanIET,nrofSamples))); ri.addMoreInfo(new RoutingInfo(String.format("current gamma: %f",gamma))); ri.addMoreInfo(new RoutingInfo(String.format("current Pinit: %f",pinit))); top.addMoreInfo(ri); return top; } @Override public MessageRouter replicate() { ProphetRouterWithEstimation r = new ProphetRouterWithEstimation(this); return r; } }
cpf871744029/wsnc
routing/ProphetRouterWithEstimation.java
771
//jDownloader - Downloadmanager //Copyright (C) 2009 JD-Team [email protected] // //This program is free software: you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program. If not, see <http://www.gnu.org/licenses/>. package jd.plugins.hoster; import java.io.ByteArrayInputStream; import java.util.HashMap; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import jd.PluginWrapper; import jd.http.Browser; import jd.http.URLConnectionAdapter; import jd.nutils.encoding.Encoding; import jd.plugins.DownloadLink; import jd.plugins.DownloadLink.AvailableStatus; import jd.plugins.HostPlugin; import jd.plugins.LinkStatus; import jd.plugins.PluginException; import jd.plugins.PluginForHost; import jd.plugins.download.DownloadInterface; import org.jdownloader.downloader.hds.HDSDownloader; import org.jdownloader.downloader.hls.HLSDownloader; import org.jdownloader.plugins.components.hls.HlsContainer; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /* * vrt.be network * new content handling --> data-video-src */ @HostPlugin(revision = "$Revision$", interfaceVersion = 3, names = { "deredactie.be", "sporza.be" }, urls = { "http://(www\\.)?deredactiedecrypted\\.be/(permalink/\\d\\.\\d+(\\?video=\\d\\.\\d+)?|cm/vrtnieuws([^/]+)?/(mediatheek|videozone).+)", "http://(www\\.)?sporzadecrypted\\.be/(permalink/\\d\\.\\d+|cm/(vrtnieuws|sporza)([^/]+)?/(mediatheek|videozone).+)" }) public class DeredactieBe extends PluginForHost { public DeredactieBe(PluginWrapper wrapper) { super(wrapper); } @Override public String getAGBLink() { return "http://deredactie.be/"; } private Browser ajax = null; private String finalurl = null; private static enum protocol { HTTP, RTMP, HDS, HLS; } private protocol ptcrl = null; @Override public void correctDownloadLink(DownloadLink link) { link.setUrlDownload(link.getDownloadURL().replace("decrypted.be/", ".be/")); // not sure what this does! -raz link.setUrlDownload(link.getDownloadURL().replaceAll("/cm/vrtnieuws/mediatheek/[^/]+/[^/]+/[^/]+/([0-9\\.]+)(.+)?", "/permalink/$1")); link.setUrlDownload(link.getDownloadURL().replaceAll("/cm/vrtnieuws([^/]+)?/mediatheek(\\w+)?/([0-9\\.]+)(.+)?", "/permalink/$3")); } @Override public AvailableStatus requestFileInformation(DownloadLink downloadLink) throws Exception { this.setBrowserExclusive(); br.setFollowRedirects(true); br.getPage(downloadLink.getDownloadURL()); // Link offline if (br.containsHTML("(>Pagina \\- niet gevonden<|>De pagina die u zoekt kan niet gevonden worden)")) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } HashMap<String, String> mediaValue = new HashMap<String, String>(); for (String[] s : br.getRegex("data\\-video\\-([^=]+)=\"([^\"]+)\"").getMatches()) { mediaValue.put(s[0], s[1]); } // Nothing to download if (mediaValue == null || mediaValue.size() == 0) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } finalurl = mediaValue.get("src"); final String filename = mediaValue.get("title"); if (finalurl == null || filename == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } if (finalurl.contains("youtube")) { /* Therefore a decrypter would be needed! */ throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } String ext = getFileNameExtensionFromString(finalurl, ".mp4"); if (ext == null || ext.length() > 5 || ext.equals(".m3u8")) { ext = ".mp4"; } downloadLink.setFinalFileName(Encoding.htmlDecode(filename.trim()).replaceAll("\"", "").replace("/", "-") + ext); if (finalurl.contains("vod.stream.vrt.be") && finalurl.endsWith(".m3u8")) { // <div class="video" // data-video-id="2138237_1155250086" // data-video-type="video" // data-video-src="http://vod.stream.vrt.be/deredactie/_definst_/2014/11/1210141103430708821_Polopoly_16x9_DV25_NGeo.mp4" // data-video-title="Reyers Laat - 3/11/14" // data-video-iphone-server="http://vod.stream.vrt.be/deredactie/_definst_" // data-video-iphone-path="mp4:2014/11/1210141103430708821_Polopoly_16x9_DV25_NGeo.mp4/playlist.m3u8" // data-video-rtmp-server="" // data-video-rtmp-path="" // data-video-sitestat-program="reyers_laat_-_31114_id_1-2138237" // data-video-sitestat-playlist="" // data-video-sitestat-site="deredactie-be" // data-video-sitestat-pubdate="1415048604184" // data-video-sitestat-cliptype="FULL_EPISODE" // data-video-sitestat-duration="2564" // data-video-autoplay="true" // data-video-whatsonid="" // data-video-geoblocking="false" // data-video-prerolls-enabled="false" // data-video-preroll-category="senieuws" // data-video-duration="2564000"> try { // Request // URL:http://vod.stream.vrt.be/deredactie/_definst_/mp4:2014/11/1210141103430708821_Polopoly_16x9_DV25_NGeo.mp4/manifest.f4m ajaxGetPage(finalurl + "/manifest.f4m"); final DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); final XPath xPath = XPathFactory.newInstance().newXPath(); Document d = parser.parse(new ByteArrayInputStream(ajax.toString().getBytes("UTF-8"))); NodeList mediaUrls = (NodeList) xPath.evaluate("/manifest/media", d, XPathConstants.NODESET); Node media; for (int j = 0; j < mediaUrls.getLength(); j++) { media = mediaUrls.item(j); // System.out.println(new String(Base64.decode(xPath.evaluate("/manifest/media[" + (j + 1) + "]/metadata", d).trim()))); String temp = getAttByNamedItem(media, "url"); if (temp != null) { finalurl = finalurl + "/" + temp; break; } } ptcrl = protocol.HDS; return AvailableStatus.TRUE; } catch (Throwable t) { t.printStackTrace(); } } if (finalurl.endsWith(".m3u8")) { ptcrl = protocol.HLS; } else { final Browser br2 = br.cloneBrowser(); URLConnectionAdapter con = null; try { con = br2.openGetConnection(finalurl); if (!con.getContentType().contains("html")) { downloadLink.setDownloadSize(con.getLongContentLength()); ptcrl = protocol.HTTP; } else { br2.followConnection(); finalurl = mediaValue.get("rtmp-server"); finalurl = finalurl != null && mediaValue.get("rtmp-path") != null ? finalurl + "@" + mediaValue.get("rtmp-path") : null; if (finalurl == null) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } ptcrl = protocol.RTMP; } } finally { try { con.disconnect(); } catch (Throwable e) { } } } return AvailableStatus.TRUE; } private void ajaxGetPage(final String url) throws Exception { ajax = br.cloneBrowser(); ajax.getHeaders().put("Accept", "*/*"); ajax.getPage(url); } /** * lets try and prevent possible NPE from killing the progress. * * @author raztoki * @param n * @param item * @return */ private String getAttByNamedItem(final Node n, final String item) { final String t = n.getAttributes().getNamedItem(item).getTextContent(); return (t != null ? t.trim() : null); } @Override public void handleFree(DownloadLink downloadLink) throws Exception { requestFileInformation(downloadLink); if (protocol.HDS.equals(ptcrl)) { dl = new HDSDownloader(downloadLink, br, finalurl); dl.startDownload(); return; } else if (protocol.HLS.equals(ptcrl)) { this.br.getPage(finalurl); if (this.br.getHttpConnection().getResponseCode() == 403) { throw new PluginException(LinkStatus.ERROR_FATAL, "This content is GEO-blocked in your country"); } else if (this.br.getHttpConnection().getResponseCode() == 404) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } final HlsContainer hlsbest = HlsContainer.findBestVideoByBandwidth(HlsContainer.getHlsQualities(this.br)); if (hlsbest == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } final String url_hls = hlsbest.getDownloadurl(); checkFFmpeg(downloadLink, "Download a HLS Stream"); dl = new HLSDownloader(downloadLink, br, url_hls); dl.startDownload(); return; } else if (protocol.RTMP.equals(ptcrl)) { dl = new RTMPDownload(this, downloadLink, finalurl); setupRTMPConnection(dl); ((RTMPDownload) dl).startDownload(); } else { dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, finalurl, false, 1); if (dl.getConnection().getContentType().contains("html")) { br.followConnection(); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } dl.startDownload(); } } private void setupRTMPConnection(final DownloadInterface dl) { final jd.network.rtmp.url.RtmpUrlConnection rtmp = ((RTMPDownload) dl).getRtmpConnection(); rtmp.setPlayPath(finalurl.split("@")[1]); rtmp.setUrl(finalurl.split("@")[0]); rtmp.setSwfVfy("http://www.deredactie.be/html/flash/common/player.5.10.swf"); rtmp.setResume(true); rtmp.setRealTime(); } @Override public int getMaxSimultanFreeDownloadNum() { return -1; } @Override public void reset() { } @Override public void resetPluginGlobals() { } @Override public void resetDownloadlink(DownloadLink link) { if (link != null) { link.removeProperty(HDSDownloader.RESUME_FRAGMENT); } } }
substanc3-dev/jdownloader2
src/jd/plugins/hoster/DeredactieBe.java
772
public class Main{ public static class Node{ int data; Node next; Node(int data,Node next){ this.data = data; this.next = next; } } public class LinkedList{ Node head ,tail; int size; void addLast(int val) { Node node = new Node(); node.data = val; if(size == 0){ head = tail = node; }else{ tail.next = node; tail = node; } size++; } public int size(){ return size; } public void display(){ Node tmp = head; while(tmp != null){ System.out.print(tmp.data+" "); tmp = tmp.next; } System.out.println(); } public void removeFirst(){ if(size == 0){ System.out.println("List is empty"); }else if(size == 1){ head = tail = null; size = 0; }else{ Node nbr = head.next; // nbr -> new head head.next = null; // connection break head = nbr; size--; } } public int getFirst(){ if(size == 0){ System.out.println("List is empty"); return -1; }else{ return head.data; } } public int getLast(){ if(size == 0){ System.out.println("List is empty"); return -1; }else{ return tail.data; } } public int getAt(int idx){ if(size == 0){ System.out.println("List is empty"); return -1; }else if(idx < 0 || idx >= size){ System.out.println("Invalid arguments"); return -1; }else{ Node tmp = head; while(idx != 0){ idx--; tmp = tmp.next; } return tmp.data; } } public void addFirst(int val) { Node node = new Node(); node.data = val; if(size == 0){ head = tail = node; }else{ node.next = head; head = node; } size++; } public void addAt(int idx, int val){ if(idx < 0 || idx > size){ System.out.println("Invalid arguments"); }else { if(idx == 0){ addFirst(val); }else if(idx == size){ addLast(val); }else{ Node node = new Node(); node.data = val; Node tmp = head; while(idx > 1){ idx--; tmp = tmp.next; } Node nbr = tmp.next; tmp.next = node; node.next = nbr; size++; } } public void removeAt(int idx) { if(size == 0){ System.out.println("List is empty"); }else if(idx < 0 || idx >= size){ System.out.println("Invalid arguments"); }else{ if(idx == 0){ removeFirst(); }else if(idx == size-1){ removeLast(); }else{ Node tmp = head; while(idx > 1){ tmp = tmp.next; idx--; } Node nbr = tmp.next; tmp.next = nbr.next; nbr.next = null; size--; } } } } public static void main(String args[]){ LinkedList list = new LinkedList(); } }
Khandagale-Saurabh/pepBatches
NIET/LinkedList.java
773
package com.sixtyfour.basicshell; import java.util.concurrent.Future; import com.sixtyfour.Basic; import com.sixtyfour.config.CompilerConfig; import com.sixtyfour.extensions.graphics.GraphicsBasic; import com.sixtyfour.extensions.textmode.ConsoleSupport; import com.sixtyfour.plugins.CodeEnhancer; import com.sixtyfour.plugins.MemoryListener; /** * Runs the program that's inside the editor. * * @author nietoperz809 */ public class Runner implements Runnable { private final Basic olsenBasic; private boolean running; private Basic runningBasic = null; private CompilerConfig config = new CompilerConfig(); private MemoryListener memListener; private String initCommand=null; public Runner(String[] program, BasicShell shellFrame) { this(program, shellFrame, null); } public Runner(String[] program, BasicShell shellFrame, String initCommand) { Basic.registerExtension(new GraphicsBasic()); Basic.registerExtension(new ConsoleSupport()); this.olsenBasic = new Basic(program); olsenBasic.setOutputChannel(new ShellOutputChannel(shellFrame)); olsenBasic.setInputProvider(new ShellInputProvider(shellFrame)); memListener = new ShellMemoryListener(shellFrame); this.initCommand = initCommand; } public void dispose() { if (olsenBasic != null) { olsenBasic.resetMemory(); } } public void registerKey(Character key) { if (olsenBasic.getInputProvider() instanceof ShellInputProvider) { ((ShellInputProvider) olsenBasic.getInputProvider()).setCurrentKey(key); } } /** * Start BASIC task and blocks starter until task ends */ public void synchronousStart() { Future<?> f = BasicShell.executor.submit(this); try { f.get(); } catch (Exception e) { e.printStackTrace(); } } /** * Executes a command in "direct mode" by shoehorning it into a one line * program. * * @param command the command the execute */ public void executeDirectCommand(final String command) { Future<?> f = BasicShell.executor.submit(new Runnable() { @Override public void run() { running = true; Basic imm = new Basic("0" + command, olsenBasic.getMachine()); // imm.setLoopMode(LoopMode.REMOVE); setRunningBasic(imm); imm.compile(config, false); imm.start(config); running = false; removeRunningBasic(); } }); try { f.get(); } catch (Exception e) { e.printStackTrace(); } } public boolean isRunning() { return running; } public Basic getOlsenBasic() { return olsenBasic; } public Basic getRunningBasic() { return runningBasic; } /** * Start BASIC task * * @param synchronous if true the caller is blocked */ public void start(boolean synchronous) { Future<?> f = BasicShell.executor.submit(this); if (!synchronous) return; try { f.get(); } catch (Exception e) { e.printStackTrace(); } } @Override public void run() { running = true; setRunningBasic(olsenBasic); olsenBasic.run(config); running = false; removeRunningBasic(); } private void setRunningBasic(Basic basic) { basic.setMemoryListener(memListener); if (initCommand!=null) { olsenBasic.setCodeEnhancer(new CodeEnhancer() { @Override public String getFirstCommand() { return initCommand.replace("run", "goto"); } @Override public String getLastCommand() { return null; } }); } runningBasic = basic; } private void removeRunningBasic() { runningBasic.setMemoryListener(null); olsenBasic.setCodeEnhancer(null); runningBasic = null; } }
EgonOlsen71/basicv2
src/main/java/com/sixtyfour/basicshell/Runner.java
774
/* * Copyright (C) 2016 B3Partners B.V. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package nl.b3p.viewer.util; import java.io.IOException; import java.security.Principal; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.persistence.EntityManager; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpSession; import nl.b3p.viewer.config.security.User; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Hibernate; import org.stripesstuff.stripersist.Stripersist; /** * * @author Meine Toonen [email protected] */ public class IPAuthenticationFilter implements Filter { private static final Log log = LogFactory.getLog(IPAuthenticationFilter.class); // The filter configuration object we are associated with. If // this value is null, this filter instance is not currently // configured. private FilterConfig filterConfig = null; private static final String IP_CHECK = IPAuthenticationFilter.class + "_IP_CHECK"; private static final String USER_CHECK = IPAuthenticationFilter.class + "_USER_CHECK"; private static final String TIME_USER_CHECKED = IPAuthenticationFilter.class + "_TIME_USER_CHECKED"; private static final int MAX_TIME_USER_CACHE = 20000; public IPAuthenticationFilter() { } /** * * @param r The servlet request we are processing * @param response The servlet response we are creating * @param chain The filter chain we are processing * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ @Override public void doFilter(ServletRequest r, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) r; HttpSession session = request.getSession(); if(request.getUserPrincipal() != null){ chain.doFilter(request, response); }else{ User u = null; if((session.getAttribute(IP_CHECK) == null && session.getAttribute(USER_CHECK) == null) || isCacheValid(session)){ String ipAddress = getIp(request); session.setAttribute(IP_CHECK, ipAddress); Stripersist.requestInit(); EntityManager em = Stripersist.getEntityManager(); List<User> users = em.createQuery("from User", User.class).getResultList(); List<User> possibleUsers = new ArrayList<User>(); for (User user : users) { if(checkValidIpAddress(request, user)){ possibleUsers.add(user); } } if(possibleUsers.isEmpty()){ log.debug("No eligible users found for ip"); }else if( possibleUsers.size() == 1){ u = possibleUsers.get(0); u.setAuthenticatedByIp(true); Hibernate.initialize(u.getGroups()); Hibernate.initialize(u.getDetails()); session.setAttribute(IP_CHECK, ipAddress); session.setAttribute(USER_CHECK, u); session.setAttribute(TIME_USER_CHECKED, System.currentTimeMillis()); }else{ log.debug("Too many eligible users found for ip."); } Stripersist.requestComplete(); }else{ u = (User) session.getAttribute(USER_CHECK); } final User user = u; RequestWrapper wrappedRequest = new RequestWrapper((HttpServletRequest) request){ @Override public Principal getUserPrincipal() { if(user != null){ return user; }else{ return super.getUserPrincipal(); } } @Override public String getRemoteUser() { if(user != null){ return user.getName(); }else{ return super.getRemoteUser(); } } @Override public boolean isUserInRole(String role) { if(user != null){ return user.checkRole(role); }else{ return super.isUserInRole(role); } } }; Throwable problem = null; try { chain.doFilter(wrappedRequest, response); } catch (IOException | ServletException t) { log.error("Error processing chain", problem); throw t; } } } /** * Return the filter configuration object for this filter. * @return filter configuration object */ public FilterConfig getFilterConfig() { return (this.filterConfig); } /** * Set the filter configuration object for this filter. * * @param filterConfig The filter configuration object */ public void setFilterConfig(FilterConfig filterConfig) { this.filterConfig = filterConfig; } /** * Destroy method for this filter */ @Override public void destroy() { } /** * Init method for this filter. * * @param filterConfig filter configuration object */ @Override public void init(FilterConfig filterConfig) { this.filterConfig = filterConfig; } /** * Return a String representation of this object. */ @Override public String toString() { if (filterConfig == null) { return ("IPAuthenticationFilter()"); } StringBuilder sb = new StringBuilder("IPAuthenticationFilter("); sb.append(filterConfig); sb.append(")"); return (sb.toString()); } private boolean checkValidIpAddress(HttpServletRequest request, User user) { String remoteAddress = getIp(request); /* remoteaddress controleren tegen ip adressen van user. * Ip ranges mogen ook via een asterisk */ for(String ipAddress: (Set<String>)user.getIps()) { log.debug("Check ip: " + ipAddress + " against: " + remoteAddress); if (ipAddress.contains("*")) { if (isRemoteAddressWithinIpRange(ipAddress, remoteAddress)) { return true; } } if (ipAddress.equalsIgnoreCase(remoteAddress)) { return true; } } log.info("IP address " + remoteAddress + " not allowed for user " + user.getName()); return false; } private String getIp(HttpServletRequest request){ String remoteAddress = request.getRemoteAddr(); String forwardedFor = request.getHeader("X-Forwarded-For"); if (forwardedFor != null) { int endIndex = forwardedFor.contains(",") ? forwardedFor.indexOf(",") : forwardedFor.length(); remoteAddress = forwardedFor.substring(0, endIndex); } return remoteAddress; } /* This function should only be called when ip contains an asterisk. This is the case when someone has given an ip to a user with an asterisk eq. 10.0.0.* */ protected boolean isRemoteAddressWithinIpRange(String ip, String remote) { if (ip == null || remote == null) { return false; } String[] arrIp = ip.split("\\."); String[] arrRemote = remote.split("\\."); if (arrIp == null || arrIp.length < 1 || arrRemote == null || arrRemote.length < 1) { return false; } /* kijken of het niet asteriks gedeelte overeenkomt met hetzelfde gedeelte uit remote address */ for (int i = 0; i < arrIp.length; i++) { if (!arrIp[i].equalsIgnoreCase("*")) { if (!arrIp[i].equalsIgnoreCase(arrRemote[i])) { return false; } } } return true; } private boolean isCacheValid(HttpSession session){ if(session == null){ return true; } if( session.getAttribute(TIME_USER_CHECKED) == null){ return true; } long prev = (long)session.getAttribute(TIME_USER_CHECKED); long now = System.currentTimeMillis(); if(now - prev > MAX_TIME_USER_CACHE){ return true; } return false; } /** * This request wrapper class extends the support class * HttpServletRequestWrapper, which implements all the methods in the * HttpServletRequest interface, as delegations to the wrapped request. You * only need to override the methods that you need to change. You can get * access to the wrapped request using the method getRequest() */ class RequestWrapper extends HttpServletRequestWrapper { public RequestWrapper(HttpServletRequest request) { super(request); } // You might, for example, wish to add a setParameter() method. To do this // you must also override the getParameter, getParameterValues, getParameterMap, // and getParameterNames methods. protected Hashtable localParams = null; public void setParameter(String name, String[] values) { if (localParams == null) { localParams = new Hashtable(); // Copy the parameters from the underlying request. Map wrappedParams = getRequest().getParameterMap(); Set keySet = wrappedParams.keySet(); for (Iterator it = keySet.iterator(); it.hasNext();) { Object key = it.next(); Object value = wrappedParams.get(key); localParams.put(key, value); } } localParams.put(name, values); } @Override public String getParameter(String name) { if (localParams == null) { return getRequest().getParameter(name); } Object val = localParams.get(name); if (val instanceof String) { return (String) val; } if (val instanceof String[]) { String[] values = (String[]) val; return values[0]; } return (val == null ? null : val.toString()); } @Override public String[] getParameterValues(String name) { if (localParams == null) { return getRequest().getParameterValues(name); } return (String[]) localParams.get(name); } @Override public Enumeration getParameterNames() { if (localParams == null) { return getRequest().getParameterNames(); } return localParams.keys(); } @Override public Map getParameterMap() { if (localParams == null) { return getRequest().getParameterMap(); } return localParams; } } }
B3Partners/tailormap
viewer/src/main/java/nl/b3p/viewer/util/IPAuthenticationFilter.java
775
// -*- mode: java; c-basic-offset: 2; -*- // Copyright 2016 Massachusetts Institute of Technology. All rights reserved. /** * @fileoverview Dutch (Flanders (Belgium)/the Netherlands) strings. * @author [email protected] (volunteers from the Flemish Coderdojo Community) */ 'use strict'; goog.require('Blockly.Msg.nl'); goog.provide('AI.Blockly.Msg.nl'); /** * Due to the frequency of long strings, the 80-column wrap rule need not apply * to message files. */ Blockly.Msg.nl.switch_language_to_dutch = { // Switch language to Dutch. category: '', helpUrl: '', init: function() { Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT = 'Zoek op per paar sleutel %1 paren %2 nietGevonden %3'; Blockly.MSG_VARIABLE_CATEGORY = 'Variabelen'; Blockly.Msg.ADD_COMMENT = 'Commentaar toevoegen'; Blockly.Msg.EXPAND_BLOCK = 'Blok uitbreiden'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TITLE_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT = 'Verdeelt tekst in stukken met de tekst \'op\' als splitspunt en levert een lijst van de resultaten. \n"één,twee,drie,vier" splitsen op "," (komma) geeft de lijst "(één twee drie vier)" terug. \n"één-aardappel,twee-aardappel,drie-aardappel,vier" splitsen op "-aardappel," geeft ook de lijst "(één twee drie vier)" terug.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TOOLTIP = 'Geeft de waarde terug die was doorgegeven bij het openen van het scherm, meestal door een ander scherm in een app met meerdere schermen. Als er geen waarde was meegegeven, wordt er een lege tekst teruggegeven.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TITLE = 'item'; Blockly.Msg.DELETE_BLOCK = 'Verwijder blok'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TOOLTIP = 'Geeft het nummer terug in decimale notatie\nmet een bepaald aantal getallen achter de komma.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE = 'terwijl'; Blockly.Msg.LANG_COLOUR_PINK = 'roze'; Blockly.Msg.CONNECT_TO_DO_IT = 'U moet verbonden zijn met de AI Companion app of emulator om "Doe het" te gebruiken'; Blockly.Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT = 'krijg'; Blockly.Msg.LANG_MATH_TRIG_SIN = 'sin'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = 'ga verder met volgende iteratie'; Blockly.Msg.DISABLE_BLOCK = 'Schakel Blok uit'; Blockly.Msg.REPL_HELPER_Q = 'Helper?'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT = 'Vervang alle tekst %1 stukje tekst %2 vervangingstekst %3'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN = 'wanneer'; Blockly.Msg.LANG_COLOUR_CYAN = 'Lichtblauw'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_COLLAPSED_TEXT = 'sluit scherm met waarde'; Blockly.Msg.LANG_MATH_TRIG_ASIN = 'asin'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV = 'lijst naar .csv tabel'; Blockly.Msg.REPL_NOW_DOWNLOADING = 'We downloaden nu een update van de App Inventor server. Even geduld aub.'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TOOLTIP = 'specificeert een numerieke seed waarde\nvoor de willekeurige nummer maker'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT = 'zet om'; Blockly.Msg.LANG_MATH_SINGLE_OP_EXP = 'e^'; Blockly.Msg.LANG_TEXT_COMPARE_EQUAL = ' ='; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ROOT = 'Geeft de vierkantswortel van een getal.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TOOLTIP = 'Voeg items toe aan het einde van een lijst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_TEXT_COMPARE_GT = ' >'; Blockly.Msg.REPL_USB_CONNECTED_WAIT = 'USB verbonden, effe wachten aub'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES = 'lokale namen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR = 'maak kleur'; Blockly.Msg.LANG_MATH_DIVIDE = '÷'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP = 'Voert alle blokken uit in \'do\' en geeft een statement terug. Handig wanneer je een procedure wil uitvoeren voor een waarde terug te geven aan een variabele.'; Blockly.Msg.COPY_ALLBLOCKS = 'Kopieer alle blokken naar de rugzak'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT_LIST = 'op (lijst)'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT = 'globaal'; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE = 'invoer:'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_NOT_FOUND = 'nietGevonden'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP = 'Laat je toe variabelen te maken die enkel toegankelijk zijn in het doe deel van dit blok.'; Blockly.Msg.REPL_PLUGGED_IN_Q = 'Aangesloten?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP = ''; Blockly.Msg.HORIZONTAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST = 'is een lijst?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE = 'invoer'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_FROM = 'van'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TITLE_APPEND = 'voeg toe aan lijst'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX = ' binnen bereik'; Blockly.MSG_NEW_VARIABLE_TITLE = 'Nieuwe variabelenaam:'; Blockly.Msg.VERTICAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TITLE_REPLACE = 'vervang element in de lijst'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_ANY = 'Verdeelt de gegeven tekst in een lijst, waarbij elk element in de lijst \'\'op\'\' als het\nverdeelpunt, en geeft een lijst terug van het resultaat. \nSplitsen van "sinaasappel,banaan,appel,hondenvoer" met als "op" een lijst van 2 elementen met als eerste \nelement een komma en als tweede element "pel" geeft een lijst van 4 elementen: \n"(sinaasap banaan ap hondenvoer)".'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN = 'in'; Blockly.Msg.DO_IT = 'Voer uit'; Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE = 'absoluut'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME = 'functie die niets teruggeeft'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_TOOLTIP = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.BACKPACK_DOCUMENTATION = 'De Rugzak is een knip/plak functie. Het laat toe om blokken te kopieren van een project of scherm en ze in een ander scherm of project te plakken. Om te kopieren sleep je de blokken in de rugzak. Om te plakken klik je op het Rugzak icoon en sleep je de blokken in de werkplaats.</p><p> De inhoud van de Rugzak blijft behouden tijdens de ganse App Inventor sessie. Als je de App Inventor dicht doet, of als je je browser herlaadt, wordt de Rugzak leeggemaakt.</p><p>Voor meer info en een video, bekijk:</p><p><a href="http://ai2.appinventor.mit.edu/reference/other/backpack.html" target="_blank">http://ai2.appinventor.mit.edu/reference/other/backpack.html</a>'; Blockly.Msg.LANG_MATH_TRIG_ATAN2 = 'atan2'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX = 'aanroep '; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSEIF = 'of als'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN = 'resultaat'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_CALL = 'roep aan'; Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE = 'splits bij spaties'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV = 'lijst van .csv rij'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE = 'x'; Blockly.Msg.REPL_CONNECTION_FAILURE1 = 'Verbindingsfout'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST_OF_ANY = 'Splitst een gegeven tekst in een lijst met twee elementen. De eerste plaats van eender welk item in de lijst "aan" is het \'\'splitsingspunt\'\'. \n\nBijvoorbeeld als je "Ik hou van appels, bananen en ananas" splitst volgens de lijst "(ba,ap)", dan geeft dit \neen lijst van 2 elementen terug. Het eerste item is "Ik hou van" en het tweede item is \n"pels, bananen en ananas."'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE = 'open een ander scherm'; Blockly.Msg.LANG_LISTS_IS_LIST_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties om dit lijst blok opnieuw te configureren. '; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GTE = 'Geef waar terug als het eerste getal groter is\ndan of gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_FOR_TOOLTIP = 'Tel van een start- tot een eindnummer.\nZet het huidige nummer, voor iedere tel, op\nvariabele "%1", en doe erna een aantal dingen.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TOOLTIP = 'Geef een willekeurig getal tussen 0 en 1 terug.'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_VARIABLE = ' variabele'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.WARNING_DELETE_X_BLOCKS = 'Weet u zeker dat u alle %1 van deze blokken wilt verwijderen?'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TOOLTIP = ''; Blockly.Msg.LANG_LISTS_INSERT_INPUT_ITEM = 'item'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE = 'sluit scherm'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_EQUAL = 'Test of stukken tekst identiek zijn, of ze dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale=\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn=\nmaar niet tekst =.'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_ROUND = 'Rond een nummer af naar boven of beneden.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_END = 'tot'; Blockly.Msg.LANG_COLOUR_ORANGE = 'oranje'; Blockly.Msg.REPL_STARTING_COMPANION_IN_EMULATOR = 'AI Companion App wordt opgestart in de emulator.'; Blockly.Msg.LANG_MATH_COMPARE_LT = '<'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ABS = 'Geef de absolute waarde van een getal terug.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM = 'item'; Blockly.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN = 'Selecteer een geldig item uit de drop down.'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD = 'graden naar radialen'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TOOLTIP = 'Geeft de platte tekst terug die doorgegeven werd toen dit scherm werd gestart door een andere app. Als er geen waarde werd doorgegeven, geeft deze functie een lege tekst terug. Voor multischerm apps, gebruik dan neem start waarde in plaats van neem platte start tekst.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM = 'voor elk'; Blockly.Msg.BACKPACK_DOC_TITLE = 'Rugzak informatie'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN = 'samenvoegen'; Blockly.Msg.LANG_TEXT_LENGTH_TOOLTIP = 'Geeft het aantal letters (inclusief spaties)\nterug in de meegegeven tekst.'; Blockly.Msg.LANG_CONTROLS_IF_IF_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties\nom dit blok opnieuw te configureren.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1 = 'De AI Companion die je op je smartphone gebruikt, is verouderd.<br/><br/>Deze versie van de App Inventor moet gebruikt worden met Companion versie'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE = 'hoofdletters'; Blockly.Msg.LANG_MATH_ARITHMETIC_ADD = '+'; Blockly.Msg.REPL_COMPANION_VERSION_CHECK = 'Versie controle van de AI Companion'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP = 'Een procedure die een resultaat teruggeeft.'; Blockly.Msg.LANG_MATH_TRIG_ATAN2_X = 'x'; Blockly.Msg.EXPAND_ALL = 'Blok uitbreiden'; Blockly.MSG_CHANGE_VALUE_TITLE = 'Wijzig waarde:'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TOOLTIP = 'Opent een nieuw scherm in een app met meerdere schermen.'; Blockly.Msg.LANG_TEXT_ISEMPTY_TOOLTIP = 'Geeft waar terug als de lengte van de\ntekst gelijk is aan 0, anders wordt niet waar teruggegeven.'; Blockly.Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT = 'ingesteld'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM = 'willekeurig deel'; Blockly.Msg.LANG_COLOUR_BLUE = 'blauw'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = 'tot'; Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET = 'krijg'; Blockly.Msg.REPL_APPROVE_UPDATE = ' scherm omdat je gevraagd gaat worden om een update goed te keuren.'; Blockly.Msg.LANG_TEXT_TRIM_TOOLTIP = 'Geeft een kopie terug van de tekst argumenten met elke\nspatie vooraan en achteraan verwijderd.'; Blockly.Msg.REPL_EMULATORS = 'emulators'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM = 'is een getal?'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX = 'to '; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE = 'vergelijk teksten'; Blockly.Msg.LANG_MATH_NUMBER_TOOLTIP = 'Rapporteer het getoonde getal.'; Blockly.Msg.LANG_TEXT_COMPARE_LT = ' <'; Blockly.Msg.LANG_LISTS_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TOOLTIP = 'Verwijdert het element op de gegeven positie uit de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_TITLE_IS_IN = 'staat in een lijst?'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_CEILING = 'Rond de input af tot het kleinste\ngetal dat niet kleiner is dan de input'; Blockly.Msg.LANG_COLOUR_YELLOW = 'geel'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_FLOOR = 'Rond de input af tot het grootste\ngetal dat niet groter is dan de input'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_MODULO = 'Geeft de gehele deling terug.'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TITLE_ITEM = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_STARTS_AT_TOOLTIP = 'Geeft de beginpositie terug van het stukje in de tekst\nwaar index 1 het begin van de tekst aangeeft. Geeft 0 terug wanneer\nhet stuk tekst niet voorkomt.'; Blockly.Msg.SORT_W = 'Sorteer blokken op breedte'; Blockly.Msg.ENABLE_BLOCK = 'Schakel blok aan'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_COLLAPSED_TEXT = 'evalueer maar negeer'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_ADD = 'Geeft de som van twee getallen terug.'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT = 'index in lijst item %1 lijst %2'; Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING = ' seconden om er zeker van te zijn dat alles draait.'; Blockly.Msg.REPL_NO_ERROR_FIVE_SECONDS = '<br/><i>Merk op:</i>&nbsp,Je zal geen andere foutmeldingen zien gedurende de volgende 5 seconden.'; Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT = 'niet'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CATEGORY_CONTROLS = 'Bediening'; Blockly.Msg.LANG_COLOUR_MAGENTA = 'magenta'; Blockly.Msg.LANG_LISTS_IS_IN_TOOLTIP = 'Geeft waar terug als het ding een item is dat in de lijst zit, anders wordt onwaar teruggegeven.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT = 'vervang lijst item lijst %1 index %2 vervanging %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Neemt een positief geheel decimaal getal en geeft de tekst weer die dat getal voorstelt in binair'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex naar dec'; Blockly.Msg.LANG_LOGIC_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME = 'naam'; Blockly.MSG_NEW_VARIABLE = 'Nieuwe variabele ...'; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_OR = 'Geef waar terug als de invoer waar is.'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP = ''; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_CONTAINS = 'bevat'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT = 'verwijder lijstitem lijst %1 index %2'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT = 'segment tekst %1 start %2 lengte %3'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT = 'lengte van de lijst lijst %1'; Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP = 'Test of het stukje voorkomt in de tekst.'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_RAD_TO_DEG = 'Geeft de graden terug tussen\n(0,360) die overeenkomt met het argument in radialen.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_COLLAPSED_TEXT = 'Neem platte start tekst'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_SEGMENT = 'segment'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_LIST = ' lijst'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_TAN = 'tan'; Blockly.Msg.LANG_MATH_TRIG_ATAN = 'atan'; Blockly.Msg.LANG_MATH_RANDOM_SEED_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = 'Terwijl een waarde onwaar is, doe enkele andere stappen.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_INPUT_RESULT = 'resultaat'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG = 'radialen naar graden'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_SELECT = 'kies een item uit de lijst'; Blockly.Msg.LANG_CATEGORY_TEXT = 'Tekst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT = 'voeg toe aan lijst lijst1 %1 lijst2 %2'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR = 'splits kleur'; Blockly.Msg.LANG_CONTROLS_IF_MSG_IF = 'als'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP = 'Roep een procedure op die iets teruggeeft.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND = 'rond af'; Blockly.Msg.REPL_DISMISS = 'Negeer'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TOOLTIP = 'Vervangt het n\'de item in een lijst.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_GT = 'Geeft aan of tekst1 lexicologisch groter is dan tekst2.\nAls een tekst het eerste deel is van de andere, dan wordt de kortere tekst aanzien als kleiner.\nHoofdletters hebben voorrang op kleine letters.'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR = 'item'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO = 'tot'; Blockly.Msg.LANG_COLOUR_RED = 'rood'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_TO = 'tot'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.REPL_KEEP_TRYING = 'Blijf Proberen'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST = 'maak een lijst'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING = 'afrondenNaarBoven'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_SET = 'zet'; Blockly.Msg.EXTERNAL_INPUTS = 'Externe ingangen'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_PAIRS = 'paren'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE = 'open ander scherm met startwaarde'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Neemt een tekst die een hexadecimaal getal voorstelt en geeft een tekst terug die dat nummer voorstelt als decimaal getal.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_SIN = 'Geeft de sinus van de gegeven hoek (in graden).'; Blockly.Msg.REPL_GIVE_UP = 'Opgeven'; Blockly.Msg.LANG_CATEGORY_LOGIC = 'Logica'; Blockly.Msg.LANG_LISTS_COPY_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_INSERT_INPUT = 'voeg lijstitem toe lijst %1 index %2 item %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Neemt een positief decimaal getal en geeft een tekst terug die dat getal voorstelt in hexadecimale notatie.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_START = 'van'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = 'breek uit'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. door komma\'s gescheiden waarde) opgemaakte rij om een ​​lijst met velden te produceren. Als de rij tekst meerdere onbeschermde nieuwe regels (meerdere lijnen) bevat in de velden, krijg je een foutmelding. Je moet de rij tekst laten eindigen in een nieuwe regel of CRLF.'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_POWER = 'Geeft het eerste getal verheven tot\nde macht van het tweede getal.'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET = 'zet'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_DO = 'doe'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_COLOUR_GRAY = 'grijs'; Blockly.Msg.REPL_NETWORK_ERROR_RESTART = 'Netwerk Communicatie Fout met de AI Companion. <br />Probeer eens de smartphone te herstarten en opnieuw te connecteren.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM = 'kies een willekeurig item'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_LT = 'Controleert of tekst1 lexicografisch kleiner is dan text2. \ NAls een stuk tekst het voorvoegsel is van de andere, dan wordt de kortere tekst \ nals kleiner beschouwd. Kleine letters worden voorafgegaan door hoofdletters.'; Blockly.Msg.LANG_TEXT_APPEND_APPENDTEXT = 'voeg tekst toe'; Blockly.Msg.REPL_CANCEL = 'Annuleren'; Blockly.Msg.LANG_CATEGORY_MATH = 'Wiskunde'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE_TOOLTIP = 'Produceert tekst, zoals een tekstblok. Het verschil is dat de \ntekst niet gemakkelijk te detecteren is door de APK van de app te onderzoeken. Gebruik deze functie daarom bij het maken van apps \n die vertrouwelijke informatie bevatten, zoals API sleutels. \nWaarschuwing: tegen complexe security-aanvallen biedt deze functie slechts een zeer lage bescherming.'; Blockly.Msg.SORT_C = 'Sorteer blokken op categorie'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TOOLTIP = 'Geeft het item op positie index in de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH = 'lengte van de lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME = 'naam'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TITLE = 'maak op als decimaal'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = 'Zolang een waarde waar is, do dan enkele regels code.'; Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE = 'maak lege lijst'; Blockly.Msg.LANG_MATH_ARITHMETIC_POWER = '^'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TOOLTIP = 'Voert het aangesloten blok code uit en negeert de return waarde (indien aanwezig). Deze functie is handig wanneer je een procedure wil aanroepen die een return waarde heeft, zonder dat je die waarde zelf nodig hebt.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TOOLTIP = 'Maak een lijst met een bepaald aantal items.'; Blockly.ERROR_DUPLICATE_EVENT_HANDLER = 'Dit een een copy van een signaalafhandelaar voor deze component.'; Blockly.Msg.LANG_MATH_TRIG_COS = 'cos'; Blockly.Msg.BACKPACK_CONFIRM_EMPTY = 'Weet u zeker dat u de rugzak wil ledigen?'; Blockly.Msg.LANG_LISTS_IS_EMPTY_TOOLTIP = 'Geeft \'waar\' terug als de lijst leeg is.'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME = 'oproep weergave'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_LN = 'Teruggave van het natuurlijke logaritme van een getal, d.w.z. het logaritme met het grondtal e (2,71828 ...)'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_UPPERCASE = 'Geeft een kopie van de meegegeven tekst omgezet in hoofdletters.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TOOLTIP = 'Toevoegen, verwijderen of herschikken van secties om dit lijstblok te herconfigureren.'; Blockly.Msg.LANG_COLOUR_DARK_GRAY = 'donkergrijs'; Blockly.Msg.ARRANGE_H = 'Rangschik blokken horizontaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF = 'anders als'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TOOLTIP = 'Sluit het huidig scherm en geeft een resultaat terug aan het scherm dat deze opende.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_4 = 'Als de eerste waarde \'waar\' is, voer dan het eerste blok met opdrachten uit.\nAnders, als de tweede waarde \'waar\' is, voer dan het tweede blok met opdrachten uit.\nAls geen van de waarden \'waar\' is, voer dan het laatste blok met opdrachten uit.'; Blockly.Msg.REPL_NETWORK_CONNECTION_ERROR = 'Fout netwerkverbinding'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX = ' in lijst'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT = 'is in lijst? item %1 lijst %2'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_VAR = 'x'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM = 'is decimaal?'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_TOOLTIP = 'Een lijst van vier elementen, elk op een schaal van 0 tot 255, die de rode, groene, blauwe en alfa componenten voorstellen.'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE = 'evalueer maar negeer het resultaat'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_INPUT_LIST = 'lijst'; Blockly.Msg.CAN_NOT_DO_IT = 'Kan dit niet doen'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME = 'initialiseer lokale variable in doe'; Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE = '“'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = 'Sla de rest van deze loop over en \n begin met de volgende iteratie.'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_FROM = 'van'; Blockly.Msg.COPY_TO_BACKPACK = 'Voeg toe aan rugzak'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY = 'is leeg'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY = 'splits bij elk'; Blockly.Msg.EXPORT_IMAGE = 'Download blokken als afbeelding'; Blockly.Msg.REPL_GOT_IT = 'Begrepen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP = 'Een kleur met de gegeven rood, groen, blauw en optionele alfa componenten.'; Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY = 'is de lijst leeg?'; Blockly.Msg.LANG_MATH_SINGLE_OP_NEG = 'negatief'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET = 'stel in'; Blockly.Msg.INLINE_INPUTS = 'Inlijn invulveld'; Blockly.Msg.LANG_LISTS_INSERT_TOOLTIP = 'Voeg een element toe op een specifieke plaats in een lijst.'; Blockly.Msg.REPL_CONNECTING = 'Verbinden ...'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TOOLTIP = 'Geeft de waarde terug die hoort bij de sleutel in een lijst van paren'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_NEG = 'Geeft het negatief van een getal.'; Blockly.Msg.REPL_UNABLE_TO_LOAD = 'Opladen naar de App Inventor server mislukt'; Blockly.Msg.LANG_LISTS_COPY_TOOLTIP = 'Maakt een kopie van een lijst. Sublijsten worden ook gekopieerd'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_TRUE = 'Geeft de booleaanse waar terug.'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE = 'Onleesbaar gemaakte Tekst'; Blockly.Msg.LANG_TEXT_TEXT_TOOLTIP = 'Een tekst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT = 'Selecteer een element uit lijst %1 index %2'; Blockly.Msg.REPL_DO_YOU_REALLY_Q = 'Wil Je Dit Echt? Echt echt?'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP = 'Laat je toe om variabelen te maken die je alleen kan gebruiken in het deel van dit blok dat iets teruggeeft.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT = 'Initializeer globaal'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM = 'is hexadecimaal?'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_QUOTIENT = 'Berekent het quotient.'; Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM = 'is binair?'; Blockly.Msg.LANG_CONTROLS_FOREACH_TOOLTIP = 'Voert de blokken in het \'doe\' deel uit voor elk element van de lijst. Gebruik de opgegeven naam van de variabele om te verwijzen naar het huidige element.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE = '”'; Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN = 'dan'; Blockly.Msg.LANG_CONTROLS_WHILE_TITLE = 'terwijl'; Blockly.Msg.LANG_MATH_COMPARE_GT = '>'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_TOOLTIP = 'Test of iets een string is die een positief integraal grondgetal 10 voorstelt.'; Blockly.Msg.LANG_MATH_MUTATOR_ITEM_INPUT_NUMBER = 'getal'; Blockly.Msg.LANG_LISTS_ADD_ITEM_TOOLTIP = 'Voeg een item toe aan de lijst.'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO = 'in'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LT = 'Geeft Waar terug als het eerste nummer\nkleiner is dan het tweede nummer.'; Blockly.Msg.LANG_COLOUR_BLACK = 'zwart'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TOOLTIP = 'Sluit het huidige scherm af en geeft de tekst terug aan de app die dit scherm geopend heeft. Deze functie is bedoeld om tekst te retourneren aan activiteiten die niet gerelateerd zijn aan App Inventor en niet om naar App Inventor schermen terug te keren. Voor App Inventor apps met meerdere schermen, gebruik de functie Sluit Scherm met Waarde, niet Sluit Scherm met Gewone Tekst.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE = 'Jouw Companion App is te oud. Klik "OK" om bijwerken te starten. Bekijk jouw '; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_AND = 'Geef Waar terug als alle invoer Waar is.'; Blockly.Msg.REPL_NO_START_EMULATOR = 'Het is niet gelukt de MIT AI Companion te starten in de Emulator'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = 'Breek uit de omliggende lus.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_EQ = 'Geef Waar terug als beide getallen gelijk zijn aan elkaar.'; Blockly.Msg.LANG_LOGIC_OPERATION_AND = 'en'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST = 'Verdeelt de opgegeven tekst in twee delen en gebruikt hiervoor de plaats het eerste voorkomen \nvan de tekst \'aan\' als splitser, en geeft een lijst met twee elementen terug. Deze lijst bestaat \nuit het deel voor de splitser en het deel achter de splitser. \nHet splitsen van "appel,banaan,kers,hondeneten" met als een komma als splitser geeft een lijst \nterug met twee elementen: het eerste is de tekst "appel" en het tweede is de tekst \n"banaan,kers,hondeneten". \nMerk op de de komma achter "appel\' niet in het resultaat voorkomt, omdat dit de splitser is.'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binair naar decimaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TOOLTIP = 'Voeg een finaal, vang-alles-op conditie toe aan het als blok.'; Blockly.Msg.GENERATE_YAIL = 'Genereer Yail'; Blockly.Msg.LANG_LOGIC_COMPARE_TRANSLATED_NAME = 'logische is gelijk'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_DOWNCASE = 'Geeft een kopie terug van de tekst in kleine letters.'; Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT = 'quotiënt van'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_NEQ = 'Geef Waar terug als beide getallen niet gelijk zijn aan elkaar.'; Blockly.Msg.DELETE_X_BLOCKS = 'Verwijder %1 blokken'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'rest van'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT = 'start op tekst %1 stuk %2'; Blockly.Msg.BACKPACK_EMPTY = 'Maak de Rugzak leeg'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST = 'in lijst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP = 'Voert de blokken in \'\'doe\'\' uit en geeft een statement terug. Handig als je een procedure wil uitvoeren alvorens een waarde terug te geven aan een variabele.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP = 'Voert de blokken in de \'doe\' sectie uit voor elke numerieke waarde van begin tot eind, telkens verdergaand met de volgende waarde. Gebruik de gegeven naam van de variabele om te verwijzen naar de actuele waarde.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TITLE_REMOVE = 'verwijder lijst item'; Blockly.Msg.REPL_STARTING_COMPANION_ON_PHONE = 'Bezig het opstarten van de Companion App op de aangesloten telefoon.'; Blockly.Msg.ARRANGE_S = 'Rangschik blokken diagonaal'; Blockly.ERROR_COMPONENT_DOES_NOT_EXIST = 'Component bestaat niet'; Blockly.Msg.LANG_MATH_COMPARE_LTE = '≤'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT = 'bevat tekst %1 stuk %2'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN = 'min'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT = 'Formatteer als decimaal getal %1 plaatsen %2'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_TEST = ''; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP = ''; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_TAN = 'Geeft de tangens van de gegeven hoek in graden.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO = 'tot'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.HELP = 'Hulp'; Blockly.Msg.LANG_LISTS_POSITION_IN_TITLE_POSITION = 'positie in lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE = 'toepassing sluiten'; Blockly.Msg.LANG_COLOUR_GREEN = 'groen'; Blockly.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF = 'Markeer Procedure'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE = 'krijg startwaarde'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP = 'van lus'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX = 'roep op '; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE = 'Verkrijg gewone starttekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP = 'Roep een procedure op die geen waarde teruggeeft.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV = 'lijst van een csv tabel'; Blockly.Msg.LANG_LISTS_INSERT_TITLE_INSERT_LIST = 'voeg een lijst element toe'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST1 = 'lijst1'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST2 = 'lijst2'; Blockly.Msg.REPL_UPDATE_INFO = 'De update wordt nu geïnstalleerd op je toestel. Hou je scherm (of emulator) in het oog en keur de installatie goed wanneer je dat gevraagd wordt.<br /><br />BELANGRIJK: Wanneer de update afloopt, kies "VOLTOOID" (klik niet op "open"). Ga dan naar App Inventor in je web browser, klik op het "Connecteer" menu en kies "Herstart Verbinding". Verbind dan het toestel.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LTE = 'Geeft waar terug als het eerste getal kleiner is\nof gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_COLLAPSED_TEXT = 'sluit scherm met platte tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_COLLAPSED_TEXT = 'herhaal tot'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_KEY = 'sleutel'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_CREATEWITH = 'maak tekst met'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TOOLTIP = 'Interpreteert de lijst als een rij van een tabel en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de rij representeert. Elk item in de rij lijst wordt beschouwd als een veld, er wordt naar verwezen met dubbele aanhalingstekens in de CSV tekst. Items worden gescheiden door een komma. De geretourneerde rij tekst heeft geen lijn separator aan het einde.'; Blockly.Msg.LANG_TEXT_JOIN_TOOLTIP = 'Voegt alle inputs samen tot 1 enkele tekst.\nAls er geen inputs zijn, wordt een lege tekst gemaakt.'; Blockly.Msg.LANG_COLOUR_WHITE = 'Wit'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE = 'Geeft het quotiënt van twee getallen.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT = 'voeg items to lijst lijst %1 item %2'; Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE = 'onwaar'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_INDEX = 'index'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. een door komma\'s gescheiden waarde) opgemaakte tabel om een ​​lijst van rijen te produceren, elke rij is een lijst van velden. Rijen kunnen worden gescheiden door nieuwe lijnen (n) of CRLF (rn).'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN = 'anders'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TOOLTIP = 'Opent een nieuw scherm in een meer-schermen app en geeft de startwaarde mee aan dat scherm.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ASIN = 'Geeft een hoek tussen [-90,+90]\ngraden met de gegeven sinus waarde.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_GETTER_TITLE_OF_COMPONENT = 'van component'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM = 'stel willekeurige seed in'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO = 'doe'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TITLE_LOOKUP_IN_PAIRS = 'zoek op in paren'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_STARTS_AT = 'begint bij'; Blockly.Msg.REPL_NOT_NOW = 'Niet Nu. Later, misschien ...'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT = 'voor component'; Blockly.Msg.HIDE_WARNINGS = 'Waarschuwingen Verbergen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'decimaal naar hexadecimaal'; Blockly.Msg.REPL_CONNECT_TO_COMPANION = 'Connecteer met de Companion'; Blockly.Msg.LANG_COLOUR_PICKER_TOOLTIP = 'Klik op de rechthoek om een kleur te kiezen.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_TO = ' tot'; Blockly.Msg.REPL_SOFTWARE_UPDATE = 'Software bijwerken'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TOOLTIP = 'Als de voorwaarde die wordt getest waar is,retourneer dan het resultaat verbonden aan het \'dan-teruggave\' veld, indien niet, geef dan het resultaat terug van het \'zoneen-teruggave\' veld, op zijn minst een van de resultaten verbonden aan beide teruggave velden wordt weergegeven.'; Blockly.MSG_RENAME_VARIABLE_TITLE = 'Hernoem alle "%1" variabelen naar:'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_FALSE = 'Geeft booleaanse niet waar terug.'; Blockly.Msg.REPL_TRY_AGAIN1 = 'Connecteren met de AI2 Companion is mislukt, probeer het eens opnieuw.'; Blockly.Msg.REPL_VERIFYING_COMPANION = 'Kijken of de Companion gestart is...'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_LISTS_POSITION_IN_TOOLTIP = 'Zoek de positie van het ding op in de lijst. Als het ding niet in de lijst zit, geef 0 terug.'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Waarschuwing:\nDit blok mag alleen\ngebruikt worden in een lus.'; Blockly.Msg.REPL_AI_NO_SEE_DEVICE = 'AI2 ziet je toestel niet, zorg ervoor dat de kabel is aangesloten en dat de besturingsprogramma\'s juist zijn.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_DEG_TO_RAD = 'Geeft de waarde in radialen terug volgens een schaal van\n[-π, +π) overeenkomstig met de graden.'; Blockly.Msg.REPL_STARTING_EMULATOR = 'Bezig met opstarten van de Android Emulator<br/>Even geduld: Dit kan een minuutje of twee duren (of koop snellere computer, grapke Pol! :p).'; Blockly.Msg.REPL_RUNTIME_ERROR = 'Uitvoeringsfout'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_COLLAPSED_TEXT = 'open scherm'; Blockly.Msg.REPL_FACTORY_RESET = 'Deze probeert jouw Emulator te herstellen in zijn initiële staat. Als je eerder je AI Companion had geupdate in de emulator, ga je dit waarschijnlijk op nieuw moeten doen. '; Blockly.Msg.LANG_LISTS_ADD_ITEM_TITLE = 'item'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE = 'als'; Blockly.Msg.LANG_CATEGORY_LISTS = 'Lijsten'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GT = 'Geeft waar terug als het eerste getal groter is\ndan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_COLLAPSED_TEXT = 'sluit toepassing'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_COLLAPSED_TEXT = 'Krijg start waarde'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_COLLAPSED_TEXT = 'sluit scherm'; Blockly.Msg.REMOVE_COMMENT = 'Commentaar Verwijderen'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.REPL_OK_LOWER = 'OK'; Blockly.Msg.LANG_MATH_SINGLE_OP_LN = 'log'; Blockly.Msg.LANG_MATH_IS_A_BINARY_TOOLTIP = 'Test of iets een tekst is die een binair getal voorstelt.'; Blockly.Msg.REPL_UNABLE_TO_UPDATE = 'Het is niet gelukt een update naar het toestel/emulator te sturen.'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO = 'tot'; Blockly.Msg.LANG_MATH_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP = 'bij'; Blockly.Msg.LANG_MATH_COMPARE_GTE = '≥'; Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_ACOS = 'acos'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN = 'Geeft een hoek tussen [-90, +90]\ngraden met de gegeven tangens.'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS = '-'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_1 = 'Als een waarde waar is, voer dan enkele stappen uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_3 = 'Als de eerste waarde waar is, voer dan het eerste codeblok uit.\nAnders, als de tweede waarde waar is, voer het tweede codeblok uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_2 = 'Als de waarde waar is, voer dan het eerste codeblok uit.\nAnders, voer het tweede codeblok uit.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR = 'naar beneden afgerond'; Blockly.Msg.LANG_TEXT_APPEND_TO = 'naar'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TOOLTIP = 'Voeg een test toe aan het als blok.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT = 'herhaal'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_WITH = 'tel met'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP = 'Maakt een globale variabele en geeft die de waarde van de geconnecteerde blokken'; Blockly.Msg.CLEAR_DO_IT_ERROR = 'Wis Fout'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV = 'lijst to csv rij'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_EXP = 'Geef e (2.71828...) tot de macht terug'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME = 'naam'; Blockly.Msg.LANG_MATH_ARITHMETIC_MULTIPLY = '*'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TOOLTIP = 'Sluit al de schermen af in deze app en stopt de app.'; Blockly.Msg.MISSING_SOCKETS_WARNINGS = 'Je moet alle connecties opvullen met blokken'; Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE = '/'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TOOLTIP = 'Sluit het huidige scherm'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TOOLTIP = 'Interpreteert de lijst als een tabel in rij-eerst formaat en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de tabel voorstelt. Elk element in de lijst zou op zijn beurt zelf een lijst moeten zijn die een rij van de CSV tabel voorstelt. Elk element in de rij lijst wordt beschouwd als een veld, waarvan de uiteindelijke CSV tekst zich binnen dubbele aanhalingstekens bevindt. In de teruggegeven tekst worden de elementen in de rijen gescheiden door komma\'s en worden de rijen zelf gescheiden door CRLF (\\r\\n).'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE = 'sluit venster met waarde'; Blockly.Msg.LANG_TEXT_SPLIT_AT_TOOLTIP = 'Splitst de tekst in stukjes bij elke spatie.'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_TOOLTIP = 'Test of iets een getal is.'; Blockly.Msg.LANG_LISTS_IS_LIST_TOOLTIP = 'Test of iets in een lijst zit.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ACOS = 'Geeft een hoek tussen [0, 180]\ngraden met de gegeven cosinus waarde.'; Blockly.Msg.LANG_MATH_RANDOM_INT_TITLE_RANDOM = 'willekeurig getal'; Blockly.ERROR_BLOCK_CANNOT_BE_IN_DEFINTION = 'Dit blok kan niet in een definitie'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_REMAINDER = 'Geef de rest terug.'; Blockly.Msg.REPL_CONNECTING_USB_CABLE = 'Aan het connecteren via USB kabel'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_PLACES = 'plaatsen'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_COLLAPSED_TEXT = 'open scherm met waarde'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TOOLTIP = 'Voeg alle elementen van list2 achteraan toe bij lijst1. Na deze toevoegoperatie zal lijst1 de toegevoegde elementen bevatten, lijst2 zal niet gewijzigd zijn.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE_IMMEDIATE = 'Je gebrukt een oude Companion. Je zou zo snel mogelijk moeten upgraden naar MIT AI2 Companion. Als je automatisch updaten hebt ingesteld in de store, gebeurt de update binnenkort vanzelf.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_COS = 'Geeft de cosinus van een gegeven hoek in graden.'; Blockly.Msg.LANG_TEXT_SEGMENT_TITLE_SEGMENT = 'segment'; Blockly.Msg.BACKPACK_GET = 'Plak Alle Blokken van Rugzak'; Blockly.MSG_PROCEDURE_CATEGORY = 'Procedures'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_TO = ' tot'; Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY = 'copieer lijst'; Blockly.Msg.LANG_LISTS_LENGTH_TOOLTIP = 'Telt het aantal elementen van een lijst'; Blockly.Msg.LANG_VARIABLES_GET_TOOLTIP = 'Geeft de waarde van deze variabele terug.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_INPUT_DO = 'doe'; Blockly.Msg.LANG_TEXT_APPEND_VARIABLE = 'item'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY = 'Geeft het product van twee getallen terug.'; Blockly.Msg.REPL_OK = 'OK'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_ATAN2_Y = 'j'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DO = 'doe'; Blockly.Msg.REPL_HELPER_NOT_RUNNING = 'De aiStarter helper lijkt niet opgestart<br /><a href="http://appinventor.mit.edu" target="_blank">hulp nodig?</a>'; Blockly.Msg.LANG_TEXT_SEGMENT_AT_TOOLTIP = 'Haalt een deel van gegeven lengte uit de gegeven tekst\nstartend van de gegeven tekst op de gegeven positie. Positie \n1 betekent het begin van de tekst.'; Blockly.Msg.LANG_LOGIC_OPERATION_OR = 'of'; Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS = 'Dit blok moet worden geconnecteerd met een gebeurtenisblok of de definitie van een procedure'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS = 'Geeft het verschil tussen twee getallen terug.'; Blockly.Msg.LANG_TEXT_APPEND_TOOLTIP = 'Voeg wat tekst toe aan variabele "%1".'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TITLE_REPLACE_ALL = 'vervang allemaal'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_TEST = 'test'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX = 'tot '; Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM = 'trim'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR = 'getal'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_NUM = 'getal'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN2 = 'Geeft een hoek in tussen [-180, +180]\ngraden met de gegeven rechthoekcoordinaten.'; Blockly.Msg.REPL_YOUR_CODE_IS = 'Jouw code is'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT = 'splits'; Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF = 'als'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_DO = 'doe'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME = 'initializeer lokaal in return'; Blockly.Msg.REPL_EMULATOR_STARTED = 'Emulator gestart, wachten '; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST = 'splits aan de eerste'; Blockly.Msg.LANG_COLOUR_LIGHT_GRAY = 'lichtgrijs'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_1 = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.DUPLICATE_BLOCK = 'Dupliceer'; Blockly.Msg.SORT_H = 'Soorteer Blokken op Hoogte'; Blockly.Msg.ARRANGE_V = 'Organizeer Blokken Vertikaal'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT = 'willekeurig getal tussen %1 en %2'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_EQ = 'Test of twee dingen gelijk zijn. \nDe dingen die worden vergeleken kunnen vanalles zijn, niet enkel getallen. \nGetallen worden als gelijk beschouwd aan hun tekstvorm, \nbijvoorbeeld, het getal 0 is gelijk aan de tekst "0". Ook two tekstvelden \ndie getallen voorstellen zijn gelijk aan elkaar als de getallen gelijk zijn aan mekaar. \n"1" is gelijk aan "01".'; Blockly.Msg.LANG_LOGIC_COMPARE_EQ = '='; Blockly.MSG_RENAME_VARIABLE = 'Geef variabele een andere naam...'; Blockly.Msg.LANG_MATH_RANDOM_INT_TOOLTIP = 'Geeft een willekeurige geheel getal tussen de boven en de\nondergrens. De grenzen worden afgerond tot getallen kleiner\ndan 2**30.'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE = 'waar'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM = 'voor elk'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TOOLTIP = 'Neem een willekeurig element van de lijst.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE = 'Sluit het venster met gewone tekst'; Blockly.Msg.REPL_UNABLE_TO_LOAD_NO_RESPOND = 'Kan geen update laden van de App Inventor server (de server antwoordt niet)'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_START = 'start'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE = 'doe resultaat'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP = 'Een procedure die geen waarde teruggeeft.'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_TOOLTIP = 'Tests of iets een tekst is die een hexadecimaal getal voorstelt.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TOOLTIP = 'Geeft een nieuwe tekst terug door alle stukjes tekst zoals het segment\nte vervangen door de vervangtekst.'; Blockly.Msg.LANG_VARIABLES_SET_TOOLTIP = 'Zet deze variabele gelijk aan de input.'; Blockly.Msg.REPL_ERROR_FROM_COMPANION = 'Fout van de Companion'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_NEQ = 'Geef waar terug als beide inputs niet gelijk zijn aan elkaar.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT = 'van de component'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP = 'Voeg een element toe aan de lijst.'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE = 'naar kleine letters'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT = 'voor element in lijst'; Blockly.Msg.COLLAPSE_ALL = 'Klap blokken dicht'; Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Waarschuwing:\nDeze procedure heeft\ndubbele inputs.'; Blockly.Msg.LANG_CONTROLS_CHOOSE_COLLAPSED_TEXT = 'als'; Blockly.Msg.REPL_NETWORK_ERROR = 'Netwerkfout'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'zet getal om'; Blockly.Msg.COLLAPSE_BLOCK = 'Klap blok dicht'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD = 'voeg dingen toe aan lijst'; Blockly.Msg.REPL_COMPANION_STARTED_WAITING = 'Companion start op, effe wachten ...'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Neemt een tekst die een binair getal voorstelt en geeft de tekst terug die dat getal decimaal voorstelt'; Blockly.Msg.LANG_LOGIC_NEGATE_TOOLTIP = 'Geeft waar terug wanneer de input niet waar is.\nGeeft niet waar terug waneer de input waar is.'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER = 'de rest van'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY = 'splits bij de eerste van'; Blockly.Msg.SHOW_WARNINGS = 'Toon Waarschuwingen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'decimaal naar binair'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT = 'initializeer lokaal'; Blockly.Msg.REPL_DEVICES = 'apparaten'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN = 'dan'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT = 'op'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT = 'voor getal in een zeker bereik'; Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT = 'vierkantswortel'; Blockly.Msg.LANG_MATH_COMPARE_EQ = '='; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Geeft het kleinste van zijn argumenten terug..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Geeft het grootste van zijn argumenten terug..'; Blockly.Msg.TIME_YEARS = "Jaren"; Blockly.Msg.TIME_MONTHS = "Maanden"; Blockly.Msg.TIME_WEEKS = "Weken"; Blockly.Msg.TIME_DAYS = "Dagen"; Blockly.Msg.TIME_HOURS = "Uren"; Blockly.Msg.TIME_MINUTES = "Minuten"; Blockly.Msg.TIME_SECONDS = "Seconden"; Blockly.Msg.TIME_DURATION = "Duurtijd"; Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION = "Toon Rugzak informatie"; Blockly.Msg.ENABLE_GRID = 'Toon Werkruimte raster'; Blockly.Msg.DISABLE_GRID = 'Werkruimte raster verbergen'; Blockly.Msg.ENABLE_SNAPPING = 'Uitlijnen op raster aanzetten'; Blockly.Msg.DISABLE_SNAPPING = 'Uitlijnen op raster uitzetten'; } }; // Initalize language definition to Dutch Blockly.Msg.nl.switch_blockly_language_to_nl.init(); Blockly.Msg.nl.switch_language_to_dutch.init();
CoderDojoLX/appinventor-sources
appinventor/blocklyeditor/src/msg/nl/_messages.js
776
import java.util.*; public class Main{ public static void main(String args[]){ HashMap<String,Integer> hm = new HashMap<>(); System.out.println(hm); hm.put("India",200); System.out.println(hm); hm.put("Uk",180); System.out.println(hm); hm.put("USA",120); System.out.println(hm); hm.put("Dubai",170); System.out.println(hm); hm.put("India",180); System.out.println(hm); System.out.println(hm.get("Ind")); // hm.remove("India"); System.out.println(hm.remove("Ind")); System.out.println(hm.containsKey("India")); ArrayList<String> keys = new ArrayList(hm.keySet()); System.out.println(keys); for(String key : hm.keySet()){ System.out.println(key+" --> "+hm.get(key)); } } }
Khandagale-Saurabh/pepBatches
NIET/HashMapIntro.java
777
/* LanguageTool, a natural language style checker * Copyright (C) 2005 Daniel Naber (http://www.danielnaber.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * USA */ package org.languagetool.rules.nl; import org.languagetool.rules.AbstractWordCoherencyRule; import org.languagetool.rules.Example; import org.languagetool.rules.WordCoherencyDataLoader; import java.io.IOException; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; /** * Dutch version of {@link AbstractWordCoherencyRule}. */ public class WordCoherencyRule extends AbstractWordCoherencyRule { private static final Map<String, Set<String>> wordMap = new WordCoherencyDataLoader().loadWords("/nl/coherency.txt"); public WordCoherencyRule(ResourceBundle messages) throws IOException { super(messages); addExamplePair(Example.wrong("We raden af om in één tekst zowel <marker>organogram</marker> als <marker>organigram</marker> te schrijven."), Example.fixed("We raden af om in één tekst zowel <marker>organogram</marker> als <marker>organogram</marker> te schrijven.")); } @Override protected Map<String, Set<String>> getWordMap() { return wordMap; } @Override protected String getMessage(String word1, String word2) { return "Gebruik liever niet '" + word1 + "' en '" + word2 + "' door elkaar in een tekst."; } @Override public String getId() { return "NL_WORD_COHERENCY"; } @Override public String getDescription() { return "Consistente spelling van woorden met meerdere correcte vormen."; } }
yarons/languagetool
languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/WordCoherencyRule.java
778
/* This file is part of Juggluco, an Android app to receive and display */ /* glucose values from Freestyle Libre 2 and 3 sensors. */ /* */ /* Copyright (C) 2021 Jaap Korthals Altes <[email protected]> */ /* */ /* Juggluco is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published */ /* by the Free Software Foundation, either version 3 of the License, or */ /* (at your option) any later version. */ /* */ /* Juggluco is distributed in the hope that it will be useful, but */ /* WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* See the GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with Juggluco. If not, see <https://www.gnu.org/licenses/>. */ /* */ /* Fri Jan 27 15:31:32 CET 2023 */ package tk.glucodata.settings; import android.app.AlertDialog; import android.content.DialogInterface; import tk.glucodata.Applic; import tk.glucodata.GlucoseCurve; import tk.glucodata.Log; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import tk.glucodata.MainActivity; import tk.glucodata.Natives; import tk.glucodata.R; import yuku.ambilwarna.AmbilWarnaDialog; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static tk.glucodata.Applic.isWearable; import static tk.glucodata.Applic.usedlocale; import static tk.glucodata.settings.Settings.removeContentView; public class SetColors { private static final String LOG_ID="SetColors"; // AmbilWarnaDialog(Context context, int color, boolean supportsAlpha, OnAmbilWarnaListener listener) /* static View theview=null; public static void endcolors(MainActivity act) { View view=theview; if(view!=null) { theview=null; removeContentView(view); act.poponback(); } } */ static void show(MainActivity act) { int initialColor= 0xfff7f022; // Natives.getlastcolor(); int width=GlucoseCurve.getwidth(); int height=GlucoseCurve.getheight(); AmbilWarnaDialog dialog = new AmbilWarnaDialog(act, initialColor,c-> { Log.i(LOG_ID,String.format(usedlocale,"col=%x",c)); Natives.setlastcolor(c); tk.glucodata.Applic.app.redraw(); }, v-> { if(isWearable) { int h=v.getMeasuredHeight(); int w=v.getMeasuredWidth(); v.setX((int)(width*.97)-w); v.setY((height-h)/2); } } ); View view=dialog.getview(); /* if(!isWearable) { int vheight= (int)act.getResources().getDimension(R.dimen.ambilwarna_hsvHeight); Log.i(LOG_ID,"height="+vheight); view.setY( (GlucoseCurve.getheight()-vheight)/2); } */ view.setBackgroundColor(Applic.backgroundcolor); if(isWearable) { act.addContentView(view, new ViewGroup.LayoutParams((int)(width*0.65), (int)(height*0.65))); // theview=view; } else act.addContentView(view, new ViewGroup.LayoutParams(WRAP_CONTENT,WRAP_CONTENT)); Button close= act.findViewById(R.id.closeambi); Button help= act.findViewById(R.id.helpambi); if(close!=null) { if(isWearable) { help.setVisibility(GONE); close.setVisibility(GONE); } else { close.setOnClickListener(v->{ removeContentView(view); act.poponback(); if(tk.glucodata.Menus.on) tk.glucodata.Menus.show(act); }); help.setOnClickListener(v->{ tk.glucodata.help.help(R.string.colorhelp,act); }); } } else Log.e(LOG_ID,"findViewbByid failed"); act.setonback(()-> { //theview=null; removeContentView(view); if(tk.glucodata.Menus.on) tk.glucodata.Menus.show(act); }); } /* static void show(MainActivity act, int initialColor ) { Log.i(LOG_ID,"show"); String mess="Hallo"; AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle("Niets?"). setMessage(mess). setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }).show(); } */ }
j-kaltes/Juggluco
Common/src/main/java/tk/glucodata/settings/SetColors.java
779
package nl.digitalekabeltelevisie.html; import java.io.*; import java.text.SimpleDateFormat; import java.util.*; import nl.digitalekabeltelevisie.data.mpeg.TransportStream; import nl.digitalekabeltelevisie.data.mpeg.descriptors.*; import nl.digitalekabeltelevisie.data.mpeg.psi.*; import nl.digitalekabeltelevisie.data.mpeg.psi.SDTsection.Service; import nl.digitalekabeltelevisie.util.Utils; public class CreateHTMLListDiff implements Runnable{ private TransportStream newTransportStream; private TransportStream oldTransportStream; private static String bgColorCSS="background-color:yellow;"; private static String strikeCSS="text-decoration: line-through; background-color: orange;"; private static String outputDir="C:/Users/Eric/workspace/dktv/WebContent/techniek/"; public CreateHTMLListDiff() { super(); } /** * @param args */ public static void main(final String[] args) { final CreateHTMLListDiff inspector = new CreateHTMLListDiff(); inspector.run(); } public void run() { try { newTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 11-14 21-36-37.ts"); oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 11-02 21-32-17.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 10-24 12-32-25.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 09-12 11-26-20.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 05-16 16-03-45.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 04-01 19-32-31.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 03-29 21-12-11.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 01-28 20-18-55.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 12-24 19-58-18.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 11-29 19-16-42.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 11-16 10-41-50.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 474000 11-07 22-47-32.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 10-07 20-06-54.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Sag Oost 369000 09-24 21-23-32.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 09-12 10-14-13.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 09-01 12-34-10.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 08-23 09-16-04.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 08-01 01-55-48.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 05-09 15-30-44.ts"); //oldTransportStream = new TransportStream("d:\\ts\\Ziggo Oost 369000 04-09 19-26-48.ts"); newTransportStream.parseStream(); oldTransportStream.parseStream(); } catch (final Exception e) { e.printStackTrace(); } final String tvhome_prefix_1="<!-- tpl:insert page=\"/newstemplate.htpl\" -->\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" + "<html>\n<head>\n<meta http-equiv=\"content-language\" content=\"nl\">\n<meta name=\"owner\" content=\"[email protected]\">\n" + "<meta name=\"author\" content=\"Eric Berendsen\">\n<!-- tpl:put name=\"description\" -->\n\n<script src=\"/theme/sorttable.js\" type=\"text/javascript\">" + "</script>\n<meta name=\"description\"\ncontent=\"Overzicht gebruikte kanalen en frequenties bij Ziggo Oost (voormalig @home gebied).\">\n\n\n\n\n" + "<!-- /tpl:put -->\n<!-- tpl:put name=\"keywords\" -->\n<meta name=\"keywords\"\ncontent=\"digitale televisie, DVB-C, NIT, SDT, MPEG, frequenties\">\n" + "<!-- /tpl:put -->\n\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n" + "<link href=\"/theme/Master.css\" rel=\"stylesheet\" type=\"text/css\">\n<!-- tpl:put name=\"headarea\" -->\n<title>Zenderindeling Ziggo/@Home</title>" + "\n<!-- /tpl:put -->\n</head>\n<body>\n<table class=\"lay\" align=\"center\" border=\"0\" cellpadding=\"0\"\ncellspacing=\"0\">\n<tbody>\n" + "<tr>\n<td colspan=\"2\" class=\"kop\"\nonclick=\"location.href=\'http://www.digitalekabeltelevisie.nl/\';\"\nstyle=\"cursor: pointer;\">" + "<h1 class=\"kop\">digitale\nkabeltelevisie</h1></td>\n</tr>\n<tr>\n<td class=\"links\">\n" + "<!-- tpl:put name=\"linksboven\" --> <!-- /tpl:put --> <!--#exec cgi=\"/cgi-bin/menu.pl\" -->\n" + "<!-- tpl:put name=\"linksmidden\" --> <!-- /tpl:put --> <!--#include virtual=\"/nieuws/laatste.shtml\" -->\n<!-- tpl:put name=\"linksbeneden\" -->" + " <!-- /tpl:put -->\n\n</td>\n<td class=\"main\">\n<h1>\n<!-- tpl:put name=\"titel\" -->\nZenderindeling Ziggo/@Home\n<!-- /tpl:put -->\n" + "</h1> <!-- tpl:put name=\"bodyarea\" -->\n\n"+ "<p>\nDe indeling van kanalen zoals geldig in het voormalig @Home gebied (Enschede) van Ziggo op "; final String tvhome_prefix_2=". Wijzigingen/toevoegingen\nt.o.v. de vorige versie zijn in <span\nstyle=\"background-color: yellow;\">geel</span> aangegeven,\n" + "verwijderde zenders zijn <span\nstyle=\"text-decoration: line-through; background-color: orange;\">oranje\nen doorgestreept</span>." + " (Soms geeft Ziggo zenders een ander\nservice ID, terwijl ze alleen maar naar een andere stream\nverplaatst zijn. " + "Dan lijkt het in dit overzicht alsof de zender\nverwijderd EN tegelijk nieuw is.)\n</p>\n\n<" + "Eerst een lijst met de\nindeling in streams (de nummering is die zoals door Ziggo\ngebruikt). " + "Daarna een lijst met de frequenties van de streams voor de verschillende regio\'s.</p>\n<p>" + "Bij type staat het soort zender aangegeven.</p>\n<ul>\n<li>\"digital television service (1)\" is een gewoon standaard\ndefinition (SD) TV kanaal.</li>" + "\n<li>\"digital radio sound service (2)\" is een radiokanaal.</li>\n<li>\"user defined (128)\" is in de DVB specificatie\nvrijgelaten, " + "en wordt gebruikt voor software updates voor de\ndecoders.</li>\n<li>\"reserved for future use " + "(17)\" is HDTV in MPEG2\n(eigenlijk \"MPEG-2 HD digital television service\", in de zomer\nvan 2006 gebruikt voor het WK, en tot mei " + "2010 voor Discovery HD\nmet een datarate van 20 Mbps voor het beeld. Op dit moment niet\ngebruikt op het Ziggo Netwerk.</li>\n<li>\"" + "advanced\ncodec HD digital television service (25)\" is HDTV in MPEG4 (H.264). Nu in\ngebruik voor Sport1 HD, National Geographic Channel HD " + "en Film1\nHD. Deze hebben ongeveer een datarate van 14 Mbps voor het beeld.</li>\n</ul>\n\n<p>\nKlik <a href=\"tvhome"; final String tvhome_prefix_3=".shtml\">hier voor de vorige\nindeling</a>.\n</p>\n<p>\n<script type=\"text/javascript\">\ndocument\n\t.write(\"\\t\\t\\tOnderstaande tabel kan je sorteren door te klikken op de naam van de kolom die je wilt sorteren.\");\n</script>\n</p> <!-- /tpl:put -->\n\n"; final String tvhome_suffix="<p class=\"adsense_align\">\n<script type=\"text/javascript\">\n<!--\ngoogle_ad_client = \"pub-3413460302732065\";\ngoogle_ad_slot = \"0646833741\";\ngoogle_ad_width = 468;\ngoogle_ad_height = 60;\n//-->\n</script>\n<script type=\"text/javascript\"\nsrc=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n\n</script>\n</p> <!--#config timefmt=\"%e/%m/%Y\" -->\n<p class=\"updated\">\nDeze pagina is het laatst aangepast op\n<!--#echo var=\"LAST_MODIFIED\" -->\n</p>\n</td>\n\n</tr>\n</tbody>\n</table>\n</body>\n</html>\n<!-- /tpl:insert -->\n"; final String date_prefix_1="<!-- tpl:insert page=\"/newstemplate.htpl\" -->\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n<head>\n<meta http-equiv=\"content-language\" content=\"nl\">\n<meta name=\"owner\" content=\"[email protected]\">\n<meta name=\"author\" content=\"Eric Berendsen\">\n<!-- tpl:put name=\"description\" -->\n\n<script src=\"/theme/sorttable.js\" type=\"text/javascript\"></script>\n<meta name=\"description\"\ncontent=\"Overzicht gebruikte kanalen en frequenties bij Ziggo Oost (voormalig @home gebied).\">\n\n\n\n\n<!-- /tpl:put -->\n<!-- tpl:put name=\"keywords\" -->\n<meta name=\"keywords\"\ncontent=\"digitale televisie, DVB-C, NIT, SDT, MPEG, frequenties\">\n<!-- /tpl:put -->\n\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n<link href=\"/theme/Master.css\" rel=\"stylesheet\" type=\"text/css\">\n<!-- tpl:put name=\"headarea\" -->\n<title>Zenderindeling Ziggo/@Home</title>\n<!-- /tpl:put -->\n</head>\n<body>\n<table class=\"lay\" align=\"center\" border=\"0\" cellpadding=\"0\"\ncellspacing=\"0\">\n<tbody>\n<tr>\n<td colspan=\"2\" class=\"kop\"\nonclick=\"location.href=\'http://www.digitalekabeltelevisie.nl/\';\"\nstyle=\"cursor: pointer;\"><h1 class=\"kop\">digitale\nkabeltelevisie</h1></td>\n</tr>\n<tr>\n<td class=\"links\">\n<!-- tpl:put name=\"linksboven\" --> <!-- /tpl:put --> <!--#exec cgi=\"/cgi-bin/menu.pl\" -->\n<!-- tpl:put name=\"linksmidden\" --> <!-- /tpl:put --> <!--#include virtual=\"/nieuws/laatste.shtml\" -->\n<!-- tpl:put name=\"linksbeneden\" --> <!-- /tpl:put -->\n\n</td>\n<td class=\"main\">\n<h1>\n<!-- tpl:put name=\"titel\" -->\nZenderindeling Ziggo/@Home\n<!-- /tpl:put -->\n</h1> <!-- tpl:put name=\"bodyarea\" -->\n\n<p>\nDe indeling van kanalen zoals geldig in het voormalig @Home gebied\n(Enschede) van Ziggo op "; final String date_prefix_2=". Wijzigingen/toevoegingen t.o.v. de vorige versie\nzijn in <span style=\"background-color: yellow;\">geel</span>\naangegeven, verwijderde zenders zijn <span\nstyle=\"text-decoration: line-through; background-color: orange;\">oranje\nen doorgestreept</span>. (Soms geeft Ziggo zenders onnodig een ander\nservice ID, terwijl ze alleen maar naar een andere stream\nverplaatst zijn. Dan lijkt het in dit overzicht alsof de zender\nverwijderd EN tegelijk nieuw is.)\n</p>\n\n\n<p>\nKlik <a href=\"tvhome"; final String date_prefix_3=".shtml\">hier voor de vorige\nindeling</a>.\n</p>\n<p>\n<script type=\"text/javascript\">\ndocument.write(\"\\t\\t\\tOnderstaande tabel kan je sorteren door te klikken op de naam van de kolom die je wilt sorteren.\");\n</script>\n</p> <!-- /tpl:put -->"; final String date_sufffix="\n<p class=\"adsense_align\">\n<script type=\"text/javascript\">\n<!--\ngoogle_ad_client = \"pub-3413460302732065\";\ngoogle_ad_slot = \"0646833741\";\ngoogle_ad_width = 468;\ngoogle_ad_height = 60;\n//-->\n</script>\n<script type=\"text/javascript\"\nsrc=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n\n</script>\n</p> <!--#config timefmt=\"%e/%m/%Y\" -->\n<p class=\"updated\">\nDeze pagina is het laatst aangepast op\n<!--#echo var=\"LAST_MODIFIED\" -->\n</p>\n</td>\n\n</tr>\n</tbody>\n</table>\n</body>\n</html>\n<!-- /tpl:insert -->\n"; //find date final Date newDate= getDate(newTransportStream); final Date oldDate= getDate(oldTransportStream); //newTransportStream.namePIDs(); System.out.println(newTransportStream); final String tables = getHTMLTables(newTransportStream,oldTransportStream); // actual file String filename1=outputDir+"tvhome.shtml"; FileWriter fstream; try { fstream = new FileWriter(filename1); fstream.write(tvhome_prefix_1); fstream.write(new SimpleDateFormat("YYYY-MM-dd").format(newDate)); fstream.write(tvhome_prefix_2); fstream.write(new SimpleDateFormat("YYYYMMdd").format(oldDate)); fstream.write(tvhome_prefix_3); fstream.write(tables); fstream.write(tvhome_suffix); fstream.close(); } catch (final IOException e1) { e1.printStackTrace(); } // old file for archive, same contents but shorter intro final String filename="tvhome" +new SimpleDateFormat("YYYYMMdd").format(newDate)+".shtml"; try { fstream = new FileWriter(outputDir+filename); fstream.write(date_prefix_1); fstream.write(new SimpleDateFormat("YYYY-MM-dd").format(newDate)); fstream.write(date_prefix_2); fstream.write(new SimpleDateFormat("YYYYMMdd").format(oldDate)); fstream.write(date_prefix_3); fstream.write(tables); fstream.write(date_sufffix); fstream.close(); } catch (final IOException e1) { e1.printStackTrace(); } if( !java.awt.Desktop.isDesktopSupported() ) { System.err.println( "Desktop is not supported (fatal)" ); System.exit( 1 ); } final java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { System.err.println( "Desktop doesn't support the browse action (fatal)" ); System.exit( 1 ); } filename1 = "file:///"+filename1.replaceAll(" ","%20"); try { final java.net.URI uri = new java.net.URI( filename1 ); desktop.browse( uri ); } catch ( final Exception e ) { System.err.println( e.getMessage() ); } System.out.println("Klaar!!"); } private String getHTMLTables(final TransportStream newStream,final TransportStream oldStream) { final StringWriter out = new StringWriter(); try { //final String filename=newStream.getFile().getName(); // final FileWriter fstream = new FileWriter("d:\\eric\\diff"+filename+".html"); out.write("<table class=\"sortable\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n"); out.write("<thead><tr><th>Transport Stream</th><th>Zender</th><th>Type (TV/Radio) - (RAW)</th><th>Service-ID</th><th>logical channel</th></tr></thead>\n"); out.write("<tbody>\n"); final SDT sdt = newStream.getPsi().getSdt(); final SDT oldSDT = oldStream.getPsi().getSdt(); final Map<Integer, SDTsection[]> streams = sdt.getTransportStreams(); final Map<Integer, SDTsection[]> oldStreams = oldSDT.getTransportStreams(); final TreeSet<Integer> s = new TreeSet<Integer>(streams.keySet()); for(final Integer transportStreamID: s){ //out.write("<tr><th colspan=\"4\">"+transportStreamID+"</th></tr>\n"); final SDTsection [] sections = streams.get(transportStreamID); final SDTsection [] oldSDTsections = oldStreams.get(transportStreamID); final ArrayList<Service> sdtServiceList = getSortedSdtServices(sections); final ArrayList<Service> oldSdtServiceList = getSortedSdtServices(oldSDTsections); int currentServiceIndex = 0; int oldServiceIndex = 0; //while ((currentService<sdtServiceList.size())&&(oldService<oldSdtServiceList.size())) for (currentServiceIndex=0; currentServiceIndex < sdtServiceList.size(); currentServiceIndex++) { final Service element = sdtServiceList.get(currentServiceIndex); final int sid=element.getServiceID(); while((oldServiceIndex<oldSdtServiceList.size())&&(oldSdtServiceList.get(oldServiceIndex).getServiceID()<sid)){ // oldService does not exist in new SDT in this stream, maybe somewhere else final Service oldService = oldSdtServiceList.get(oldServiceIndex); // is this service somewhere else in the new SDT? If not, it was removed if(sdt.getService(oldService.getServiceID())==null){ // it was removed, so print it with strike writeService(oldStream, out, oldSDT, transportStreamID, oldService); } oldServiceIndex++; } // OLD SERVICE IN SAME STREAM AS new one if((oldServiceIndex<oldSdtServiceList.size())&&(oldSdtServiceList.get(oldServiceIndex).getServiceID()==sid)){ oldServiceIndex++; } final Service oldService=oldSDT.getService(sid); final int lcn = newStream.getPsi().getNit().getLCN(1536, transportStreamID, sid); //final int lcn = newStream.getPsi().getNit().getLCN(43136, transportStreamID, sid); String lcnString = (lcn > 0) ? Integer.toString(lcn) : "-"; final int hdLCN = newStream.getPsi().getNit().getHDSimulcastLCN(1536, transportStreamID, sid); final String hdlcnString = (hdLCN > 0) ? (" / " + Integer.toString(hdLCN)) : ""; lcnString += hdlcnString; final String newName= sdt.getServiceName(sid); final String safeName= Utils.escapeHTML(newName); String style=""; if(oldService==null){ //service is new, mark whole line style="style=\""+bgColorCSS+"\""; } out.write("<tr "+style+">"); style=""; // if service moved to other stream only highlight stream ID if((oldService!=null)&&(transportStreamID!=oldSDT.getTransportStreamID(sid))){ style=bgColorCSS; } out.write("<td style=\"text-align: left;" +style+"\">\n"+transportStreamID+"</td>"); style=""; if ((oldService != null) && (newName != null) && (!newName.equals(oldSDT.getServiceName(sid)))) { style=bgColorCSS; } out.write("<td style=\"text-align: left;" +style+"\">\n"+safeName+"</td>\n"); style=""; if((oldService!=null)&&(sdt.getServiceType(sid)!=oldSDT.getServiceType(sid))){ style=bgColorCSS; } out.write("<td style=\"text-align: left;" +style+"\">"+Descriptor.getServiceTypeString(sdt.getServiceType(sid))+" ("+sdt.getServiceType(sid)+") </td>\n"); style=""; // LCN changed ? final int oldLCN = oldStream.getPsi().getNit().getLCN(1000, oldSDT.getTransportStreamID(sid), sid); String old = ""; if ((oldService != null) && (lcn != oldLCN)&&(oldLCN!=-1)) { style="style=\""+bgColorCSS+"\""; old = " [" + oldLCN + "] "; } out.write("<td style=\"text-align: left;\">" + sid + " </td><td " + style + ">" + lcnString + old + "</td></tr>\n"); } // new Services processed, maybe some old ones with higher sid left while(oldServiceIndex<oldSdtServiceList.size()){ // oldService does not exist in new SDT in this stream, maybe somewhere else final Service oldService = oldSdtServiceList.get(oldServiceIndex); // is this service somewhere else in the new SDT? If not, it was removed if(sdt.getService(oldService.getServiceID())==null){ // it was removed, so print it with strike writeService(oldStream, out, oldSDT, transportStreamID, oldService); } oldServiceIndex++; } } out.write(" \n"); out.write(" \n"); out.write(" </tbody></table>\n"); out.write(" <p><br></p><p>Onderstaande lijst bevat alle frequenties zoals ze gebruikt worden per regionaal netwerk.</p>\n"); out.write(" <p><br></p>\n"); out.write(" <table class=\"content\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\"><thead><tr><th>Transportstream-ID</th><th>Frequentie</th><th>Modulatie</th><th>Symbol Rate</th></tr></thead><tbody>\n"); final NIT nit = newStream.getPsi().getNit(); final NIT oldNIT = oldStream.getPsi().getNit(); final Map<Integer, NITsection []> networks = nit.getNetworks(); final Map<Integer, NITsection []> oldNetworks = oldNIT.getNetworks(); final TreeSet<Integer> t = new TreeSet<Integer>(networks.keySet()); final Iterator<Integer> j = t.iterator(); while(j.hasNext()){ final int networkNo=j.next(); out.write("<tr><th colspan=\"4\">"+networkNo+" : "+nit.getNetworkName(networkNo)+"</th></tr>\n"); final ArrayList<nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream> newStreams = new ArrayList<nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream>(); final NITsection [] sections = networks.get(networkNo); oldNetworks.get(networkNo); for(final NITsection section: sections){ if(section!= null){ newStreams.addAll(section.getTransportStreamList()); } } Collections.sort(newStreams, new Comparator<nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream>(){ public int compare(final nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream s1, final nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream s2){ return(s1.getTransportStreamID()-s2.getTransportStreamID()); } }); for (final nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream stream: newStreams) { final int streamID=stream.getTransportStreamID(); final Iterator<Descriptor> descs=stream.getDescriptorList().iterator(); String freq=""; int mod=-1; String modulation = ""; String symbolrate = ""; CableDeliverySystemDescriptor newDelivery = null; while(descs.hasNext()){ final Descriptor d=descs.next(); if(d instanceof CableDeliverySystemDescriptor) { newDelivery = (CableDeliverySystemDescriptor)d; freq = Descriptor.formatCableFrequencyList(((CableDeliverySystemDescriptor)d).getFrequency()); mod = ((CableDeliverySystemDescriptor)d).getModulation(); modulation = CableDeliverySystemDescriptor.getModulationString(mod); symbolrate = Descriptor.formatSymbolRate(((CableDeliverySystemDescriptor)d).getSymbol_rate()); } } String style=""; final nl.digitalekabeltelevisie.data.mpeg.psi.NITsection.TransportStream oldNITStream = oldNIT.getTransportStream(networkNo, streamID); if(oldNITStream==null){ // new transportstream style="style=\""+bgColorCSS+"\""; } out.write("<tr " +style+">\n"); out.write("<td>"+streamID+"</td>\n"); style=""; CableDeliverySystemDescriptor oldDelivery = null; if(oldNITStream!=null){ // find deliveryDescriptor for old stream final Iterator<Descriptor> oldDescs=oldNITStream.getDescriptorList().iterator(); while(oldDescs.hasNext()){ final Descriptor d=oldDescs.next(); if(d instanceof CableDeliverySystemDescriptor) { oldDelivery = (CableDeliverySystemDescriptor)d; } } if((oldDelivery!=null)&&(!oldDelivery.getFrequency().equals(newDelivery.getFrequency()))){ style="style=\""+bgColorCSS+"\""; // tmp //freq = freq + " (" + Descriptor.formatCableFrequencyList(oldDelivery.getFrequency())+")"; } } out.write("<td " + style+">"+freq+" </td>"); style=""; if((oldNITStream!=null)&&(oldDelivery!=null)&&(oldDelivery.getModulation()!=newDelivery.getModulation())){ style="style=\""+bgColorCSS+"\""; } out.write("<td " + style+">"+modulation+ "</td><td>"+symbolrate+ "</td></tr>\n"); } } out.write("\n"); out.write(" </tbody></table>\n"); out.write("\n"); out.write("</body></html>"); } catch (final IOException e) { e.printStackTrace(); } return out.toString(); } /** * @param oldStream * @param out * @param oldSDT * @param transportStreamID * @param oldService * @throws IOException */ private String writeService(final TransportStream oldStream, final StringWriter out, final SDT oldSDT, final Integer transportStreamID, final Service oldService) throws IOException { out.write("<tr style=\""+strikeCSS+"\">"); out.write("<td style=\"text-align: left;\">\n"+transportStreamID+"</td>"); final String safeName= Utils.escapeHTML(oldSDT.getServiceName(oldService.getServiceID())); out.write("<td style=\"text-align: left;\">\n"+safeName+"</td>\n"); out.write("<td style=\"text-align: left;\">"+Descriptor.getServiceTypeString(oldSDT.getServiceType(oldService.getServiceID()))+" ("+oldSDT.getServiceType(oldService.getServiceID())+") </td>\n"); final int lcn = oldStream.getPsi().getNit().getLCN(1000, transportStreamID, oldService.getServiceID()); //final int lcn = newStream.getPsi().getNit().getLCN(43136, transportStreamID, sid); String lcnString = (lcn > 0) ? Integer.toString(lcn) : "-"; final int hdLCN = oldStream.getPsi().getNit().getHDSimulcastLCN(1000, transportStreamID, oldService.getServiceID()); final String hdlcnString = (hdLCN > 0) ? (" / " + Integer.toString(hdLCN)) : ""; lcnString += hdlcnString; out.write("<td style=\"text-align: left;\">" + oldService.getServiceID() + " </td><td>" + lcnString + "</td></tr>\n"); return out.toString(); } /** * @param sections * @return */ private ArrayList<Service> getSortedSdtServices(final SDTsection[] sections) { final ArrayList<Service> serviceList = new ArrayList<Service>(); if(sections!=null){ for (final SDTsection section: sections) { if(section!= null){ serviceList.addAll(section.getServiceList()); } } Collections.sort(serviceList, new Comparator<Service>(){ public int compare(final Service s1, final Service s2){ return(s1.getServiceID()-s2.getServiceID()); } }); } return serviceList; } public static Date getDate(final TransportStream transportStream){ Date newDate=null; final TDT tdt = transportStream.getPsi().getTdt(); if(tdt!=null){ final List<TDTsection> l = tdt.getTdtSectionList(); if(!l.isEmpty()){ final TDTsection e = l.get(0); newDate = Utils.getUTCDate(e.getUTC_time()); } } // try tot if(newDate==null){ final TOT tot = transportStream.getPsi().getTot(); if(tot!=null){ final List<TOTsection> l = tot.getTotSectionList(); if(!l.isEmpty()){ final TOTsection e = l.get(0); newDate = Utils.getUTCDate(e.getUTC_time()); } } } // try file date if(newDate==null){ newDate = new Date(transportStream.getFile().lastModified()); } return newDate; } public static String stripLeadingZero(final String s){ String f = s; while((f.length()>1)&&(f.charAt(0)=='0')&&(f.charAt(1)!='.')){ f=f.substring(1); } return f; } }
lodegaard/dvbinspector
src/main/java/nl/digitalekabeltelevisie/html/CreateHTMLListDiff.java
780
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 2 "Parser.y" package decaf.tacvm.parser; import java.util.*; //#line 22 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short EQU=257; public final static short NEQ=258; public final static short GEQ=259; public final static short LEQ=260; public final static short LAND=261; public final static short LOR=262; public final static short BRANCH=263; public final static short PARM=264; public final static short CALL=265; public final static short RETURN=266; public final static short IF=267; public final static short LABEL=268; public final static short EMPTY=269; public final static short VTABLE=270; public final static short FUNC=271; public final static short TEMP=272; public final static short ENTRY=273; public final static short INT_CONST=274; public final static short STRING_CONST=275; public final static short VTBL=276; public final static short IDENT=277; public final static short MEMO=278; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 3, 4, 4, 2, 2, 5, 8, 6, 10, 6, 9, 9, 7, 7, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, }; final static short yylen[] = { 2, 2, 2, 1, 9, 9, 3, 0, 2, 1, 3, 0, 12, 0, 11, 4, 0, 2, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 4, 3, 3, 3, 8, 8, 8, 8, 4, 2, 4, 4, 2, 2, 6, 2, 8, 8, 2, 2, 2, 2, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 0, 0, 2, 9, 18, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 17, 0, 11, 13, 48, 51, 42, 46, 45, 53, 52, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 34, 35, 36, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 41, 44, 43, 0, 0, 33, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 16, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 28, 29, 27, 30, 24, 25, 19, 20, 21, 22, 23, 26, 31, 0, 0, 0, 0, 0, 0, 0, 49, 50, 37, 38, 39, 40, 0, 0, 14, 15, 12, }; final static short yydgoto[] = { 2, 3, 7, 4, 73, 9, 10, 14, 44, 122, 45, 27, }; final static short yysindex[] = { -242, -9, 0, -244, 0, -257, -7, -234, 0, 0, 0, -3, -259, 0, -39, -84, -1, 1, -227, -229, -262, -250, 4, -12, -16, 0, 8, 0, -264, 0, 0, 0, 0, 0, 0, 0, 0, 0, -221, 0, -33, -220, -224, -223, -73, -68, -222, -256, 0, 0, 0, -4, -215, -214, 19, -212, -37, 0, 0, -217, -216, -211, -210, 0, 0, 0, -209, -13, 0, -207, 0, -208, -205, -123, -121, 28, 31, 30, 32, 10, -198, -197, -196, -195, -194, -193, -192, -191, -190, -189, -188, -187, -185, -20, 47, 48, 33, 0, 0, 0, 51, -172, -170, 0, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, -167, -166, 49, 50, 0, -38, -168, -156, -155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, -154, -153, 66, -157, 67, 0, 0, 0, 0, 0, 0, -152, 68, 0, 0, 0, }; final static short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; final static short yygindex[] = { 0, 0, 0, 118, 69, 113, 0, 0, 0, 0, 0, 0, }; final static int YYTABLESIZE=249; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 55, 144, 97, 26, 98, 42, 71, 52, 72, 54, 33, 34, 53, 43, 16, 35, 63, 64, 17, 36, 11, 65, 37, 117, 90, 118, 1, 6, 1, 88, 86, 5, 87, 12, 89, 61, 62, 6, 15, 28, 29, 31, 30, 32, 38, 40, 39, 92, 41, 91, 59, 46, 56, 57, 58, 60, 66, 67, 68, 69, 70, 75, 76, 77, 78, 93, 94, 99, 79, 95, 100, 101, 103, 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 25, 116, 119, 120, 123, 124, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 145, 141, 142, 146, 147, 148, 149, 153, 1, 150, 151, 13, 8, 155, 0, 152, 154, 156, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 0, 0, 47, 24, 143, 0, 0, 0, 0, 48, 0, 49, 50, 51, 80, 81, 82, 83, 84, 85, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 39, 125, 42, 125, 269, 43, 40, 45, 42, 272, 273, 45, 277, 273, 277, 272, 273, 277, 269, 277, 277, 272, 43, 37, 45, 270, 271, 270, 42, 43, 40, 45, 40, 47, 257, 258, 271, 41, 123, 41, 268, 41, 272, 40, 61, 58, 60, 40, 62, 123, 272, 272, 277, 277, 123, 60, 272, 272, 40, 272, 278, 278, 274, 274, 272, 274, 39, 277, 274, 39, 41, 62, 41, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 125, 272, 41, 41, 39, 263, 59, 263, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 274, 274, 277, 61, 61, 268, 268, 41, 41, 273, 0, 272, 272, 7, 3, 274, -1, 58, 58, 58, 58, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 273, -1, 273, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, 264, 265, 266, 267, 268, -1, -1, 265, 272, 272, -1, -1, -1, -1, 272, -1, 274, 275, 276, 257, 258, 259, 260, 261, 262, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=278; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,"'\\''","'('","')'","'*'","'+'", null,"'-'",null,"'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,"EQU","NEQ","GEQ","LEQ","LAND","LOR", "BRANCH","PARM","CALL","RETURN","IF","LABEL","EMPTY","VTABLE","FUNC","TEMP", "ENTRY","INT_CONST","STRING_CONST","VTBL","IDENT","MEMO", }; final static String yyrule[] = { "$accept : Program", "Program : VTables Funcs", "VTables : VTables VTable", "VTables : VTable", "VTable : VTABLE '(' IDENT ')' '{' IDENT IDENT Entrys '}'", "VTable : VTABLE '(' IDENT ')' '{' EMPTY IDENT Entrys '}'", "Entrys : Entrys ENTRY ';'", "Entrys :", "Funcs : Funcs Func", "Funcs : Func", "Func : FuncHeader Tacs '}'", "$$1 :", "FuncHeader : FUNC '(' ENTRY ')' $$1 '{' MEMO '\\'' Params '\\'' ENTRY ':'", "$$2 :", "FuncHeader : FUNC '(' IDENT ')' $$2 '{' MEMO '\\'' '\\'' IDENT ':'", "Params : Params TEMP ':' INT_CONST", "Params :", "Tacs : Tacs Tac", "Tacs :", "Tac : TEMP '=' '(' TEMP '+' TEMP ')'", "Tac : TEMP '=' '(' TEMP '-' TEMP ')'", "Tac : TEMP '=' '(' TEMP '*' TEMP ')'", "Tac : TEMP '=' '(' TEMP '/' TEMP ')'", "Tac : TEMP '=' '(' TEMP '%' TEMP ')'", "Tac : TEMP '=' '(' TEMP LAND TEMP ')'", "Tac : TEMP '=' '(' TEMP LOR TEMP ')'", "Tac : TEMP '=' '(' TEMP '>' TEMP ')'", "Tac : TEMP '=' '(' TEMP GEQ TEMP ')'", "Tac : TEMP '=' '(' TEMP EQU TEMP ')'", "Tac : TEMP '=' '(' TEMP NEQ TEMP ')'", "Tac : TEMP '=' '(' TEMP LEQ TEMP ')'", "Tac : TEMP '=' '(' TEMP '<' TEMP ')'", "Tac : TEMP '=' '!' TEMP", "Tac : TEMP '=' '-' TEMP", "Tac : TEMP '=' TEMP", "Tac : TEMP '=' INT_CONST", "Tac : TEMP '=' STRING_CONST", "Tac : TEMP '=' '*' '(' TEMP '+' INT_CONST ')'", "Tac : TEMP '=' '*' '(' TEMP '-' INT_CONST ')'", "Tac : '*' '(' TEMP '+' INT_CONST ')' '=' TEMP", "Tac : '*' '(' TEMP '-' INT_CONST ')' '=' TEMP", "Tac : TEMP '=' CALL TEMP", "Tac : CALL TEMP", "Tac : TEMP '=' CALL IDENT", "Tac : TEMP '=' CALL ENTRY", "Tac : CALL IDENT", "Tac : CALL ENTRY", "Tac : TEMP '=' VTBL '<' IDENT '>'", "Tac : BRANCH LABEL", "Tac : IF '(' TEMP EQU INT_CONST ')' BRANCH LABEL", "Tac : IF '(' TEMP NEQ INT_CONST ')' BRANCH LABEL", "Tac : PARM TEMP", "Tac : RETURN TEMP", "Tac : RETURN EMPTY", "Tac : LABEL ':'", }; //#line 232 "Parser.y" public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 365 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 4: //#line 30 "Parser.y" { createVTable(val_peek(6).sVal, val_peek(3).sVal, val_peek(2).sVal, val_peek(1).entrys); } break; case 5: //#line 34 "Parser.y" { createVTable(val_peek(6).sVal, null, val_peek(2).sVal, val_peek(1).entrys); } break; case 6: //#line 40 "Parser.y" { Entry e = new Entry(); e.name = val_peek(1).sVal; e.offset = -1; val_peek(2).entrys.add(e); } break; case 7: //#line 47 "Parser.y" { yyval.entrys = new ArrayList<Entry>(); } break; case 10: //#line 57 "Parser.y" { endFunc(); } break; case 11: //#line 63 "Parser.y" { enterFunc(val_peek(3).loc, val_peek(1).sVal); } break; case 13: //#line 68 "Parser.y" { enterFunc(val_peek(3).loc, val_peek(1).sVal); } break; case 15: //#line 75 "Parser.y" { addParam(val_peek(2).sVal, val_peek(0).iVal); } break; case 19: //#line 86 "Parser.y" { genAdd(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 20: //#line 90 "Parser.y" { genSub(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 21: //#line 94 "Parser.y" { genMul(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 22: //#line 98 "Parser.y" { genDiv(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 23: //#line 102 "Parser.y" { genMod(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 24: //#line 106 "Parser.y" { genLAnd(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 25: //#line 110 "Parser.y" { genLOr(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 26: //#line 114 "Parser.y" { genGtr(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 27: //#line 118 "Parser.y" { genGeq(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 28: //#line 122 "Parser.y" { genEqu(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 29: //#line 126 "Parser.y" { genNeq(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 30: //#line 130 "Parser.y" { genLeq(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 31: //#line 134 "Parser.y" { genLes(val_peek(2).loc, val_peek(6).sVal, val_peek(3).sVal, val_peek(1).sVal); } break; case 32: //#line 138 "Parser.y" { genLNot(val_peek(1).loc, val_peek(3).sVal, val_peek(0).sVal); } break; case 33: //#line 142 "Parser.y" { genNeg(val_peek(1).loc, val_peek(3).sVal, val_peek(0).sVal); } break; case 34: //#line 146 "Parser.y" { genAssign(val_peek(1).loc, val_peek(2).sVal, val_peek(0).sVal); } break; case 35: //#line 150 "Parser.y" { genLoadImm4(val_peek(1).loc, val_peek(2).sVal, val_peek(0).iVal); } break; case 36: //#line 154 "Parser.y" { genLoadStr(val_peek(1).loc, val_peek(2).sVal, val_peek(0).sVal); } break; case 37: //#line 158 "Parser.y" { genLoad(val_peek(6).loc, val_peek(7).sVal, val_peek(3).sVal, val_peek(1).iVal); } break; case 38: //#line 162 "Parser.y" { genLoad(val_peek(6).loc, val_peek(7).sVal, val_peek(3).sVal, -val_peek(1).iVal); } break; case 39: //#line 166 "Parser.y" { genStore(val_peek(1).loc, val_peek(0).sVal, val_peek(5).sVal, val_peek(3).iVal); } break; case 40: //#line 170 "Parser.y" { genStore(val_peek(1).loc, val_peek(0).sVal, val_peek(5).sVal, -val_peek(3).iVal); } break; case 41: //#line 174 "Parser.y" { genIndirectCall(val_peek(1).loc, val_peek(3).sVal, val_peek(0).sVal); } break; case 42: //#line 178 "Parser.y" { genIndirectCall(val_peek(1).loc, null, val_peek(0).sVal); } break; case 43: //#line 182 "Parser.y" { genDirectCall(val_peek(1).loc, val_peek(3).sVal, val_peek(0).sVal); } break; case 44: //#line 186 "Parser.y" { genDirectCall(val_peek(1).loc, val_peek(3).sVal, val_peek(0).sVal); } break; case 45: //#line 190 "Parser.y" { genDirectCall(val_peek(1).loc, null, val_peek(0).sVal); } break; case 46: //#line 194 "Parser.y" { genDirectCall(val_peek(1).loc, null, val_peek(0).sVal); } break; case 47: //#line 198 "Parser.y" { genLoadVtbl(val_peek(4).loc, val_peek(5).sVal, val_peek(1).sVal); } break; case 48: //#line 202 "Parser.y" { genBranch(val_peek(1).loc, val_peek(0).sVal); } break; case 49: //#line 206 "Parser.y" { genBeqz(val_peek(7).loc, val_peek(5).sVal, val_peek(0).sVal); } break; case 50: //#line 210 "Parser.y" { genBnez(val_peek(7).loc, val_peek(5).sVal, val_peek(0).sVal); } break; case 51: //#line 214 "Parser.y" { genParm(val_peek(1).loc, val_peek(0).sVal); } break; case 52: //#line 218 "Parser.y" { genReturn(val_peek(1).loc, val_peek(0).sVal); } break; case 53: //#line 222 "Parser.y" { genReturn(val_peek(1).loc, null); } break; case 54: //#line 226 "Parser.y" { markLabel(val_peek(1).sVal); } break; //#line 778 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
PKUanonym/REKCARC-TSC-UHT
大三上/编译原理/hw/2016_黄家晖_PA/550405220_4_decaf_PA3/tools/tacvm-dev/src/decaf/tacvm/parser/Parser.java
781
//jDownloader - Downloadmanager //Copyright (C) 2009 JD-Team [email protected] // //This program is free software: you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program. If not, see <http://www.gnu.org/licenses/>. package jd.plugins.decrypter; import java.util.ArrayList; import java.util.HashMap; import jd.PluginWrapper; import jd.controlling.ProgressController; import jd.plugins.CryptedLink; import jd.plugins.DecrypterPlugin; import jd.plugins.DownloadLink; import jd.plugins.PluginForDecrypt; @DecrypterPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "deredactie.be", "sporza.be", "cobra.canvas.be" }, urls = { "https?://([a-z0-9]+\\.)?deredactie\\.be/(permalink/\\d\\.\\d+(\\?video=\\d\\.\\d+)?|cm/vrtnieuws([^/]+)?/(mediatheek|videozone).+)", "https?://(?:[a-z0-9]+\\.)?sporza\\.be/.*?/(?:mediatheek|videozone).+", "https?://cobra\\.canvas\\.be/.*?/(?:mediatheek|videozone).+" }) public class DeredactieBe extends PluginForDecrypt { public DeredactieBe(PluginWrapper wrapper) { super(wrapper); } public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress) throws Exception { ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>(); String parameter = param.toString(); this.setBrowserExclusive(); br.setFollowRedirects(true); br.getPage(parameter); if (br.getHttpConnection().getResponseCode() == 404 || br.containsHTML("(>Pagina \\- niet gevonden<|>De pagina die u zoekt kan niet gevonden worden)")) { decryptedLinks.add(this.createOfflinelink(parameter)); return decryptedLinks; } HashMap<String, String> mediaValue = new HashMap<String, String>(); for (String[] s : br.getRegex("data\\-video\\-([^=]+)=\"([^\"]+)\"").getMatches()) { mediaValue.put(s[0], s[1]); } final String finalurl = (mediaValue == null || mediaValue.size() == 0) ? null : mediaValue.get("src"); if (finalurl == null) { try { decryptedLinks.add(this.createOfflinelink(parameter)); } catch (final Throwable t) { logger.info("Offline Link: " + parameter); } return decryptedLinks; } if (finalurl.contains("youtube.com")) { decryptedLinks.add(createDownloadlink(finalurl)); } else { decryptedLinks.add(createDownloadlink(parameter.replace(".be/", "decrypted.be/"))); } return decryptedLinks; } /* NO OVERRIDE!! */ public boolean hasCaptcha(CryptedLink link, jd.plugins.Account acc) { return false; } }
ribonuclecode/jd
src/jd/plugins/decrypter/DeredactieBe.java
782
/* * CPSDatum2.java - created: Nov 14, 2009 * Copyright (c) 2009 Clayton Carter * * This file is part of the project "Crop Planning Software". For more * information: * website: https://github.com/claytonrcarter/cropplanning * email: [email protected] * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package CPS.Data; public class CPSDatum<T> { T value; T nullValue; T blankValue; String name, dTion; int propertyNum; CPSDatumState state; public final int DATA_MODE_RAW = 0; public final int DATA_MODE_NORMAL = 1; int dataMode = DATA_MODE_NORMAL; int precision; public final int PRECISION_NA = 0; public final int PRECISION_FULL = 1; public final int PRECISION_ONE_DIGIT = 2; public final int PRECISION_TWO_DIGIT = 3; public final int PRECISION_THREE_DIGIT = 4; /* * * Constructors * */ public CPSDatum( String name, String desc, T value, T nullValue, T blankValue, int propertyNum, boolean inherited, boolean calculated ) { this( name, desc, value, nullValue, blankValue, propertyNum ); setInherited( inherited ); setCalculated( calculated ); } public CPSDatum( String name, String desc, T value, T nullValue, T blankValue, int propertyNum ) { this( name, desc, nullValue, blankValue, propertyNum ); setValue(value); } public CPSDatum( String name, String desc, T blankValue, int propertyNum ) { this( name, desc, null, blankValue, propertyNum ); } public CPSDatum( String name, T blankValue, int propertyNum ) { this( name, "", null, blankValue, propertyNum ); } public CPSDatum( String name, String desc, T nullValue, T blankValue, int propertyNum ) { this( name, nullValue, blankValue ); setDescription( desc ); setPropertyNum( propertyNum ); } public CPSDatum( String name, T nullValue, T blankValue ) { setName(name); setNullValue( nullValue ); setBlankValue( blankValue ); state = new CPSDatumState( false, false ); } /* * * Important getters and setters * */ public void setValue( T value ) { if ( value == null || value.equals( getNullValue() )) this.value = getNullValue(); else this.value = value; } public T getValue() { return getValue( false ); } public T getValue( boolean rawAccess ) { if ( ( isCalculated() || isInherited() || isNull() ) && ( getDataMode() == DATA_MODE_RAW || rawAccess ) ) { return getNullValue(); } else if ( isNull() && ! rawAccess ) { return blankValue; } else { return value; } } public boolean getValueAsBoolean() { if ( isNull() || ! ( value instanceof Boolean )) return false; else return ((Boolean) value).booleanValue(); } public int getValueAsInt() { if ( isNull() || ! ( value instanceof Integer ) && ! ( value instanceof String )) return 0; else if ( value instanceof String ) return Integer.parseInt( (String) value ); else return ((Integer) value).intValue(); } public float getValueAsFloat() { if ( isNull() || ! ( value instanceof Float ) && ! ( value instanceof String )) return 0f; else if ( value instanceof String ) return Float.parseFloat( (String) value ); else return ((Float) value).floatValue(); } /* * * Lesser getters and setters * */ /** * @return the name (or short description) of this datum */ public String getName() { return name; } public void setName( String name ) { this.name = name; } /** * @return a more verbose description of this datum */ public String getDescription() { return dTion; } public void setDescription( String desc ) { this.dTion = desc; } public int getPropertyNum() { return propertyNum; } public void setPropertyNum( int propertyNum ) { this.propertyNum = propertyNum; } public T getBlankValue() { return blankValue; } public void setBlankValue( T blankValue ) { this.blankValue = blankValue; } public T getNullValue() { return nullValue; } public void setNullValue( T nullValue ) { this.nullValue = nullValue; } public boolean isCalculated() { return getState().isCalculated(); } public void setCalculated( boolean calculated ) { getState().setCalculated( calculated ); } public boolean isInherited() { return getState().isInherited(); } public void setInherited( boolean inherited ) { getState().setInherited( inherited ); } /* * * Various metadata queries * */ /** * @return true if this datum has a value set and it is not inherited or calculated */ public boolean isConcrete() { return isNotNull() && ! isInherited() && ! isCalculated(); } /** * Convenience method to set this Datum as niether inherited nor calculated. Equivalent to calling * both setInherited(false) and setCalculated(false) */ public void setConcrete() { setInherited( false ); setCalculated( false ); } /** * @return true if this value has a value set and it is <i>either</i> inherited or calculated */ public boolean isAbstract() { return isNotNull() && ( isInherited() || isCalculated() ); } // TODO this == operation could get us into trouble; will probaly have to do // some introspection about what type we are and such public boolean isNull() { return value == null || value.equals( getNullValue() ); } public boolean isNotNull() { return ! isNull(); } public boolean isBlank() { return value.equals( getBlankValue() ); } /** * Retrieve the data access mode. Data can either be accessed in a simple, low-level * way which ignores inherited and calculated values or in a more complex, normal way * in which that higher level processing is honored. This only affects get * methods, not set methods. * * @return one of either DATA_MODE_NORMAL or DATA_MODE_RAW; default value is DATA_MODE_NORMAL */ public int getDataMode() { return dataMode; } /** * Control the data access mode. Data can either be accessed in a simple, low-level * way which ignores inherited and calculated values or in a more complex, normal way * in which that higher level processing is honored. This only affects get * methods, not set methods. * * @param dataMode one of either DATA_MODE_NORMAL or DATA_MODE_RAW; if an invalid value * is specified, the default value of DATA_MODE_NORMAL is used */ public void setDataMode( int dataMode ) { if ( dataMode == DATA_MODE_NORMAL || dataMode == DATA_MODE_RAW ) this.dataMode = dataMode; else this.dataMode = DATA_MODE_NORMAL; } public CPSDatumState getState() { return state; } public void setState( CPSDatumState c ) { this.setInherited( c.isInherited() ); this.setCalculated( c.isCalculated() ); } public class CPSDatumState { boolean inherited, calculated; public CPSDatumState( boolean inherited, boolean calculated ) { this.inherited = inherited; this.calculated = calculated; } public boolean isInherited() { return inherited; } public void setInherited( boolean inherited ) { this.inherited = inherited; } public boolean isCalculated() { return calculated; } public void setCalculated( boolean calculated ) { this.calculated = calculated; } } }
claytonrcarter/cropplanning
CropPlanning/src/CPS/Data/CPSDatum.java
783
/* * Copyright 2010 Aalto University, ComNet * Released under GPLv3. See LICENSE.txt for details. */ package routing; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import routing.maxprop.MaxPropDijkstra; import routing.maxprop.MeetingProbabilitySet; import core.Connection; import core.DTNHost; import core.Message; import core.Settings; import core.SimClock; import core.Tuple; /** * Implementation of MaxProp router as described in * <I>MaxProp: Routing for Vehicle-Based Disruption-Tolerant Networks</I> by * John Burgess et al. * * but with parameter estimation for finding an alpha based on timescale * definition: * * Extension of the protocol by adding a parameter alpha (default 1) * By new connection, the delivery likelihood is increased by alpha * and divided by 1+alpha. Using the default results in the original * algorithm. Refer to Karvo and Ott, <I>Time Scales and Delay-Tolerant Routing * Protocols</I> Chants, 2008 * * This version tries to estimate a good value of alpha from a timescale parameter * given by the user, and from the encounters the node sees during simulation. * * @version 1.0 */ public class MaxPropRouterWithEstimation extends ActiveRouter { /** probabilities of meeting hosts */ private MeetingProbabilitySet probs; /** meeting probabilities of all hosts from this host's point of view * mapped using host's network address */ private Map<Integer, MeetingProbabilitySet> allProbs; /** the cost-to-node calculator */ private MaxPropDijkstra dijkstra; /** IDs of the messages that are known to have reached the final dst */ private Set<String> ackedMessageIds; /** mapping of the current costs for all messages. This should be set to * null always when the costs should be updated (a host is met or a new * message is received) */ private Map<Integer, Double> costsForMessages; /** From host of the last cost calculation */ private DTNHost lastCostFrom; /** Over how many samples the "average number of bytes transferred per * transfer opportunity" is taken */ public static int BYTES_TRANSFERRED_AVG_SAMPLES = 10; private int[] avgSamples; private int nextSampleIndex = 0; /** current value for the "avg number of bytes transferred per transfer * opportunity" */ private int avgTransferredBytes = 0; /** MaxPROP router's setting namespace ({@value})*/ public static final String MAXPROP_NS = "MaxPropRouterWithEstimation"; /* Number of seconds in time scale.*/ public static final String TIME_SCALE_S ="timeScale"; /** The alpha variable, default = 1; */ private double alpha; /** The default value for alpha */ public static final double DEFAULT_ALPHA = 1.0; /** value of time scale variable */ private int timescale; /** last meeting time with a node */ private Map<DTNHost, Double> meetings; private int nrofSamplesIET; private double meanIET; /** number of encounters between encounters */ private Map<DTNHost, Integer> encounters; private int nrofSamplesENC; private double meanENC; private int nrofTotENC; /** * Constructor. Creates a new prototype router based on the settings in * the given Settings object. * @param settings The settings object */ public MaxPropRouterWithEstimation(Settings settings) { super(settings); Settings maxPropSettings = new Settings(MAXPROP_NS); alpha = DEFAULT_ALPHA; timescale = maxPropSettings.getInt(TIME_SCALE_S); initMeetings(); } /** * Copy constructor. Creates a new router based on the given prototype. * @param r The router prototype where setting values are copied from */ protected MaxPropRouterWithEstimation(MaxPropRouterWithEstimation r) { super(r); this.alpha = r.alpha; this.timescale = r.timescale; this.probs = new MeetingProbabilitySet( MeetingProbabilitySet.INFINITE_SET_SIZE, this.alpha); this.allProbs = new HashMap<Integer, MeetingProbabilitySet>(); this.dijkstra = new MaxPropDijkstra(this.allProbs); this.ackedMessageIds = new HashSet<String>(); this.avgSamples = new int[BYTES_TRANSFERRED_AVG_SAMPLES]; initMeetings(); } /** * Initializes interencounter estimators */ private void initMeetings() { this.meetings = new HashMap<DTNHost, Double>(); this.encounters = new HashMap<DTNHost, Integer>(); this.meanIET = 0; this.nrofSamplesIET = 0; this.meanENC = 0; this.nrofSamplesENC = 0; this.nrofTotENC = 0; } @Override public void changedConnection(Connection con) { if (con.isUp()) { // new connection this.costsForMessages = null; // invalidate old cost estimates if (con.isInitiator(getHost())) { /* initiator performs all the actions on behalf of the * other node too (so that the meeting probs are updated * for both before exchanging them) */ DTNHost otherHost = con.getOtherNode(getHost()); MessageRouter mRouter = otherHost.getRouter(); assert mRouter instanceof MaxPropRouterWithEstimation : "MaxProp only works "+ " with other routers of same type"; MaxPropRouterWithEstimation otherRouter = (MaxPropRouterWithEstimation)mRouter; /* update the estimators */ if (this.updateEstimators(otherHost)) { this.updateParam(); } if (otherRouter.updateEstimators(getHost())) { otherRouter.updateParam(); } /* exchange ACKed message data */ this.ackedMessageIds.addAll(otherRouter.ackedMessageIds); otherRouter.ackedMessageIds.addAll(this.ackedMessageIds); deleteAckedMessages(); otherRouter.deleteAckedMessages(); /* update both meeting probabilities */ probs.updateMeetingProbFor(otherHost.getAddress()); otherRouter.probs.updateMeetingProbFor(getHost().getAddress()); /* exchange the transitive probabilities */ this.updateTransitiveProbs(otherRouter.allProbs); otherRouter.updateTransitiveProbs(this.allProbs); this.allProbs.put(otherHost.getAddress(), otherRouter.probs.replicate()); otherRouter.allProbs.put(getHost().getAddress(), this.probs.replicate()); } } else { /* connection went down, update transferred bytes average */ updateTransferredBytesAvg(con.getTotalBytesTransferred()); } } /** * Updates transitive probability values by replacing the current * MeetingProbabilitySets with the values from the given mapping * if the given sets have more recent updates. * @param p Mapping of the values of the other host */ private void updateTransitiveProbs(Map<Integer, MeetingProbabilitySet> p) { for (Map.Entry<Integer, MeetingProbabilitySet> e : p.entrySet()) { MeetingProbabilitySet myMps = this.allProbs.get(e.getKey()); if (myMps == null || e.getValue().getLastUpdateTime() > myMps.getLastUpdateTime() ) { this.allProbs.put(e.getKey(), e.getValue().replicate()); } } } /** * Updates the MaxPROP estimators * @param host */ protected boolean updateEstimators(DTNHost host) { /* First estimate the mean InterEncounter Time */ double currentTime = SimClock.getTime(); if (meetings.containsKey(host)) { double timeDiff = currentTime - meetings.get(host); // System.out.printf("current time: %f\t last time: %f\n",currentTime,meetings.get(host)); nrofSamplesIET++; meanIET = (((double)nrofSamplesIET -1) / (double)nrofSamplesIET) * meanIET + (1 / (double)nrofSamplesIET) * timeDiff; meetings.put(host, currentTime); } else { /* nothing to update */ meetings.put(host,currentTime); } /* Then estimate the number of encounters * */ nrofTotENC++; // the number of encounter if (encounters.containsKey(host)) { int encounterNro = nrofTotENC - encounters.get(host); // System.out.printf("current time: %f\t last time: %f\n",currentTime,meetings.get(host)); nrofSamplesENC++; meanENC = (((double)nrofSamplesENC -1) / (double)nrofSamplesENC) * meanENC + (1 / (double)nrofSamplesENC) * (double)encounterNro; encounters.put(host,nrofTotENC); return true; } else { /* nothing to update */ encounters.put(host,nrofTotENC); return false; } } /** * update the alpha parameter based on the estimators */ protected void updateParam() { double err = .01; double ntarg = Math.ceil(timescale/meanIET); double ee = 1; double alphadiff = .1; int ob = 0; double fstable; double fnzero; double fnone; double eezero; double eeone; double A; /* * the estimation algorith does not work for timescales * shorter than the mean IET - so use defaults */ if (meanIET > (double)timescale) { System.out.printf("meanIET %f > %d timescale\n",meanIET,timescale); return; } if (meanIET == 0) { System.out.printf("Mean IET == 0\n"); return; } if (meanENC == 0) { System.out.printf("Mean ENC == 0\n"); return; } while (ee != err) { A = Math.pow(1+alpha,meanENC+1); fstable = alpha/(A-1); fnzero = (alpha/A)*(1-Math.pow(A,-ntarg))/(1-1/A); fnone = fnzero + 1/(Math.pow(A,ntarg)); eezero = Math.abs(fnzero-fstable); eeone = Math.abs(fnone -fstable); ee = Math.max(eezero,eeone); if (ee > err ) { if (ob == 2) { alphadiff = alphadiff / 2.0; } ob = 1; alpha = alpha+alphadiff; } else { if (ee < (err-err*0.001)) { if (ob == 1) { alphadiff = alphadiff / 2.0; } ob = 2; alpha = alpha - alphadiff; // double precision floating makes problems... if ((alpha <= 0) | (((1 + alpha) - 1) == 0)) { alpha = alphadiff; alphadiff = alphadiff / 2.0; ob = 0; } } else { ee = err; } } } probs.setAlpha(alpha); } /** * Deletes the messages from the message buffer that are known to be ACKed */ private void deleteAckedMessages() { for (String id : this.ackedMessageIds) { if (this.hasMessage(id) && !isSending(id)) { this.deleteMessage(id, false); } } } @Override public Message messageTransferred(String id, DTNHost from) { this.costsForMessages = null; // new message -> invalidate costs Message m = super.messageTransferred(id, from); /* was this node the final recipient of the message? */ if (isDeliveredMessage(m)) { this.ackedMessageIds.add(id); } return m; } /** * Method is called just before a transfer is finalized * at {@link ActiveRouter#update()}. MaxProp makes book keeping of the * delivered messages so their IDs are stored. * @param con The connection whose transfer was finalized */ @Override protected void transferDone(Connection con) { Message m = con.getMessage(); /* was the message delivered to the final recipient? */ if (m.getTo() == con.getOtherNode(getHost())) { this.ackedMessageIds.add(m.getId()); // yes, add to ACKed messages this.deleteMessage(m.getId(), false); // delete from buffer } } /** * Updates the average estimate of the number of bytes transferred per * transfer opportunity. * @param newValue The new value to add to the estimate */ private void updateTransferredBytesAvg(int newValue) { int realCount = 0; int sum = 0; this.avgSamples[this.nextSampleIndex++] = newValue; if(this.nextSampleIndex >= BYTES_TRANSFERRED_AVG_SAMPLES) { this.nextSampleIndex = 0; } for (int i=0; i < BYTES_TRANSFERRED_AVG_SAMPLES; i++) { if (this.avgSamples[i] > 0) { // only values above zero count realCount++; sum += this.avgSamples[i]; } } if (realCount > 0) { this.avgTransferredBytes = sum / realCount; } else { // no samples or all samples are zero this.avgTransferredBytes = 0; } } /** * Returns the next message that should be dropped, according to MaxProp's * message ordering scheme (see {@link MaxPropTupleComparator}). * @param excludeMsgBeingSent If true, excludes message(s) that are * being sent from the next-to-be-dropped check (i.e., if next message to * drop is being sent, the following message is returned) * @return The oldest message or null if no message could be returned * (no messages in buffer or all messages in buffer are being sent and * exludeMsgBeingSent is true) */ protected Message getOldestMessage(boolean excludeMsgBeingSent) { Collection<Message> messages = this.getMessageCollection(); List<Message> validMessages = new ArrayList<Message>(); for (Message m : messages) { if (excludeMsgBeingSent && isSending(m.getId())) { continue; // skip the message(s) that router is sending } validMessages.add(m); } Collections.sort(validMessages, new MaxPropComparator(this.calcThreshold())); return validMessages.get(validMessages.size()-1); // return last message } @Override public void update() { super.update(); if (!canStartTransfer() ||isTransferring()) { return; // nothing to transfer or is currently transferring } // try messages that could be delivered to final recipient if (exchangeDeliverableMessages() != null) { return; } tryOtherMessages(); } /** * Returns the message delivery cost between two hosts from this host's * point of view. If there is no path between "from" and "to" host, * Double.MAX_VALUE is returned. Paths are calculated only to hosts * that this host has messages to. * @param from The host where a message is coming from * @param to The host where a message would be destined to * @return The cost of the cheapest path to the destination or * Double.MAX_VALUE if such a path doesn't exist */ public double getCost(DTNHost from, DTNHost to) { /* check if the cached values are OK */ if (this.costsForMessages == null || lastCostFrom != from) { /* cached costs are invalid -> calculate new costs */ this.allProbs.put(getHost().getAddress(), this.probs); int fromIndex = from.getAddress(); /* calculate paths only to nodes we have messages to * (optimization) */ Set<Integer> toSet = new HashSet<Integer>(); for (Message m : getMessageCollection()) { toSet.add(m.getTo().getAddress()); } this.costsForMessages = dijkstra.getCosts(fromIndex, toSet); this.lastCostFrom = from; // store source host for caching checks } if (costsForMessages.containsKey(to.getAddress())) { return costsForMessages.get(to.getAddress()); } else { /* there's no known path to the given host */ return Double.MAX_VALUE; } } /** * Tries to send all other messages to all connected hosts ordered by * hop counts and their delivery probability * @return The return value of {@link #tryMessagesForConnected(List)} */ private Tuple<Message, Connection> tryOtherMessages() { List<Tuple<Message, Connection>> messages = new ArrayList<Tuple<Message, Connection>>(); Collection<Message> msgCollection = getMessageCollection(); /* for all connected hosts that are not transferring at the moment, * collect all the messages that could be sent */ for(Connection con : getHost()) { // for (Connection con : getConnections()) { DTNHost other = con.getOtherNode(getHost()); MaxPropRouterWithEstimation othRouter = (MaxPropRouterWithEstimation)other.getRouter(); if (othRouter.isTransferring()) { continue; // skip hosts that are transferring } for (Message m : msgCollection) { /* skip messages that the other host has or that have * passed the other host */ if (othRouter.hasMessage(m.getId()) || m.getHops().contains(other)) { continue; } messages.add(new Tuple<Message, Connection>(m,con)); } } if (messages.size() == 0) { return null; } /* sort the message-connection tuples according to the criteria * defined in MaxPropTupleComparator */ Collections.sort(messages, new MaxPropTupleComparator(calcThreshold())); return tryMessagesForConnected(messages); } /** * Calculates and returns the current threshold value for the buffer's split * based on the average number of bytes transferred per transfer opportunity * and the hop counts of the messages in the buffer. Method is public only * to make testing easier. * @return current threshold value (hop count) for the buffer's split */ public int calcThreshold() { /* b, x and p refer to respective variables in the paper's equations */ int b = this.getBufferSize(); int x = this.avgTransferredBytes; int p; if (x == 0) { /* can't calc the threshold because there's no transfer data */ return 0; } /* calculates the portion (bytes) of the buffer selected for priority */ if (x < b/2) { p = x; } else if (b/2 <= x && x < b) { p = Math.min(x, b-x); } else { return 0; // no need for the threshold } /* creates a copy of the messages list, sorted by hop count */ ArrayList<Message> msgs = new ArrayList<Message>(); msgs.addAll(getMessageCollection()); if (msgs.size() == 0) { return 0; // no messages -> no need for threshold } /* anonymous comparator class for hop count comparison */ Comparator<Message> hopCountComparator = new Comparator<Message>() { public int compare(Message m1, Message m2) { return m1.getHopCount() - m2.getHopCount(); } }; Collections.sort(msgs, hopCountComparator); /* finds the first message that is beyond the calculated portion */ int i=0; for (int n=msgs.size(); i<n && p>0; i++) { p -= msgs.get(i).getSize(); } i--; // the last round moved i one index too far /* now i points to the first packet that exceeds portion p; * the threshold is that packet's hop count + 1 (so that packet and * perhaps some more are included in the priority part) */ return msgs.get(i).getHopCount() + 1; } /** * Message comparator for the MaxProp routing module. * Messages that have a hop count smaller than the given * threshold are given priority and they are ordered by their hop count. * Other messages are ordered by their delivery cost. */ private class MaxPropComparator implements Comparator<Message> { private int threshold; private DTNHost from1; private DTNHost from2; /** * Constructor. Assumes that the host where all the costs are calculated * from is this router's host. * @param treshold Messages with the hop count smaller than this * value are transferred first (and ordered by the hop count) */ public MaxPropComparator(int treshold) { this.threshold = treshold; this.from1 = this.from2 = getHost(); } /** * Constructor. * @param treshold Messages with the hop count smaller than this * value are transferred first (and ordered by the hop count) * @param from1 The host where the cost of msg1 is calculated from * @param from2 The host where the cost of msg2 is calculated from */ public MaxPropComparator(int treshold, DTNHost from1, DTNHost from2) { this.threshold = treshold; this.from1 = from1; this.from2 = from2; } /** * Compares two messages and returns -1 if the first given message * should be first in order, 1 if the second message should be first * or 0 if message order can't be decided. If both messages' hop count * is less than the threshold, messages are compared by their hop count * (smaller is first). If only other's hop count is below the threshold, * that comes first. If both messages are below the threshold, the one * with smaller cost (determined by * {@link MaxPropRouterWithEstimation#getCost(DTNHost, DTNHost)}) is first. */ public int compare(Message msg1, Message msg2) { double p1, p2; int hopc1 = msg1.getHopCount(); int hopc2 = msg2.getHopCount(); if (msg1 == msg2) { return 0; } /* if one message's hop count is above and the other one's below the * threshold, the one below should be sent first */ if (hopc1 < threshold && hopc2 >= threshold) { return -1; // message1 should be first } else if (hopc2 < threshold && hopc1 >= threshold) { return 1; // message2 -"- } /* if both are below the threshold, one with lower hop count should * be sent first */ if (hopc1 < threshold && hopc2 < threshold) { return hopc1 - hopc2; } /* both messages have more than threshold hops -> cost of the * message path is used for ordering */ p1 = getCost(from1, msg1.getTo()); p2 = getCost(from2, msg2.getTo()); /* the one with lower cost should be sent first */ if (p1-p2 == 0) { /* if costs are equal, hop count breaks ties. If even hop counts are equal, the queue ordering is used */ if (hopc1 == hopc2) { return compareByQueueMode(msg1, msg2); } else { return hopc1 - hopc2; } } else if (p1-p2 < 0) { return -1; // msg1 had the smaller cost } else { return 1; // msg2 had the smaller cost } } } /** * Message-Connection tuple comparator for the MaxProp routing * module. Uses {@link MaxPropComparator} on the messages of the tuples * setting the "from" host for that message to be the one in the connection * tuple (i.e., path is calculated starting from the host on the other end * of the connection). */ private class MaxPropTupleComparator implements Comparator <Tuple<Message, Connection>> { private int threshold; public MaxPropTupleComparator(int threshold) { this.threshold = threshold; } /** * Compares two message-connection tuples using the * {@link MaxPropComparator#compare(Message, Message)}. */ public int compare(Tuple<Message, Connection> tuple1, Tuple<Message, Connection> tuple2) { MaxPropComparator comp; DTNHost from1 = tuple1.getValue().getOtherNode(getHost()); DTNHost from2 = tuple2.getValue().getOtherNode(getHost()); comp = new MaxPropComparator(threshold, from1, from2); return comp.compare(tuple1.getKey(), tuple2.getKey()); } } @Override public RoutingInfo getRoutingInfo() { RoutingInfo top = super.getRoutingInfo(); RoutingInfo ri = new RoutingInfo(probs.getAllProbs().size() + " meeting probabilities"); /* show meeting probabilities for this host */ for (Map.Entry<Integer, Double> e : probs.getAllProbs().entrySet()) { Integer host = e.getKey(); Double value = e.getValue(); ri.addMoreInfo(new RoutingInfo(String.format("host %d : %.6f", host, value))); } ri.addMoreInfo(new RoutingInfo(String.format("meanIET: %f\t from %d samples",meanIET,nrofSamplesIET))); ri.addMoreInfo(new RoutingInfo(String.format("meanENC: %f\t from %d samples",meanENC,nrofSamplesENC))); ri.addMoreInfo(new RoutingInfo(String.format("current alpha: %f",alpha))); top.addMoreInfo(ri); top.addMoreInfo(new RoutingInfo("Avg transferred bytes: " + this.avgTransferredBytes)); return top; } @Override public MessageRouter replicate() { MaxPropRouterWithEstimation r = new MaxPropRouterWithEstimation(this); return r; } }
knightcode/the-one-pitt
routing/MaxPropRouterWithEstimation.java
784
package com.sixtyfour.basicshell; import static java.awt.Toolkit.getDefaultToolkit; import static java.awt.datatransfer.DataFlavor.stringFlavor; import java.awt.Color; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetAdapter; import java.awt.dnd.DropTargetDropEvent; import java.io.File; import java.util.List; import javax.swing.JTextArea; import javax.swing.text.DefaultCaret; import com.sixtyfour.util.Colors; /** * @author nietoperz809 */ class ShellTextComponent extends JTextArea { private static final long serialVersionUID = 1L; private final BasicShell parent; /** * * @param sf */ public ShellTextComponent(BasicShell sf) { parent = sf; setBackground(new Color(Colors.COLORS[6])); setDoubleBuffered(true); setTabSize(10); setForeground(new Color(Colors.COLORS[14])); setCaretColor(new Color(Colors.COLORS[14])); setToolTipText("<html>Type one of:<br>" + "- cls<br>- list<br>- run<br>- new<br>" + "- save[file]<br>- load[file]<br>- compile[file]<br>- dir<br>" + "or edit your BASIC code here</html>"); BlockCaret mc = new BlockCaret(); mc.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); setCaret(mc); setFont(ResourceLoader.getFont()); new DropTarget(this, new DropTargetAdapter() { @Override public void drop(DropTargetDropEvent event) { event.acceptDrop(DnDConstants.ACTION_COPY); Transferable transferable = event.getTransferable(); DataFlavor[] flavors = transferable.getTransferDataFlavors(); for (DataFlavor flavor : flavors) { try { if (flavor.isFlavorJavaFileListType()) { @SuppressWarnings("unchecked") List<File> files = (List<File>) transferable.getTransferData(flavor); File f = files.get(0); parent.getStore().load(f.getPath()); parent.putStringUCase("Loaded: " + f.getName() + "\n" + ProgramStore.OK); return; // only one file } } catch (Exception e) { parent.putString(ProgramStore.ERROR); } } } }); } /** * */ @Override public void paste() { try { String[] lines = getClipBoardString().split("[\r\n]+"); for (String s : lines) { parent.getStore().insert(s.trim().toUpperCase()); } parent.putStringUCase("" + lines.length + " lines pasted\n" + ProgramStore.OK); } catch (Exception e) { parent.putString(ProgramStore.ERROR); e.printStackTrace(); } } private static String getClipBoardString() throws Exception { Clipboard clipboard = getDefaultToolkit().getSystemClipboard(); Transferable clipData = clipboard.getContents(clipboard); if (clipData != null) { if (clipData.isDataFlavorSupported(stringFlavor)) { return (String) (clipData.getTransferData(stringFlavor)); } } throw new Exception("no clipboard data"); } }
EgonOlsen71/basicv2
src/main/java/com/sixtyfour/basicshell/ShellTextComponent.java
785
/* * DiscordSRV - https://github.com/DiscordSRV/DiscordSRV * * Copyright (C) 2016 - 2024 Austin "Scarsz" Shapiro * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. */ package github.scarsz.discordsrv.util; import github.scarsz.configuralize.Language; import github.scarsz.discordsrv.DiscordSRV; import lombok.Getter; import java.util.HashMap; import java.util.Map; /** * <p>Made by Scarsz</p> * <p>German translations by Androkai & GerdSattler</p> * <p>Japanese translations by Ucchy</p> * <p>French translations by BrinDeNuage</p> * <p>Korean translations by Alex4386 (with MintNetwork)</p> * <p>Dutch translations by Mr Ceasar</p> * <p>Spanish translations by ZxFrankxZ</p> * <p>Russian translations by DmitryRendov</p> * <p>Estonian translations by Madis0</p> * <p>Chinese translations by Kizajan</p> * <p>Polish translations by Zabujca997</p> * <p>Danish translations by Tauses</p> * <p>Ukrainian translations by FenixInc</p> */ public class LangUtil { /** * Messages that are internal to DiscordSRV and are thus not customizable */ public enum InternalMessage { ASM_WARNING(new HashMap<Language, String>() {{ put(Language.EN, "\n" + "\n" + "You're attempting to use DiscordSRV on ASM 4. DiscordSRV requires ASM 5 to function.\n" + "DiscordSRV WILL NOT WORK without ASM 5. Blame your server software's developers for having outdated libraries.\n" + "\n" + "Instructions for updating to ASM 5:\n" + "1. Navigate to the {specialsourcefolder} folder of the server\n" + "2. Delete the SpecialSource-1.7-SNAPSHOT.jar jar file\n" + "3. Download SpecialSource v1.7.4 from https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Copy the jar file to the {specialsourcefolder} folder of the server you navigated to earlier\n" + "5. Rename the jar file you just copied to SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Restart the server\n" + "\n" + "\n"); put(Language.FR, "\n" + "\n" + "Vous essayez d'utiliser Discord SRV sur ASM 4. DiscordSRV a besoin de ASM 5 pour fonctionner.\n" + "DiscordSRV ne fonctionne pas sans ASM 5. Vos librairies ne sont pas à jour.\n" + "\n" + "Instructions pour mettre à jour ASM 5:\n" + "1. Allez sur le dossier {specialsourcefolder} du serveur\n" + "2. Supprimez le fichier SpecialSource-1.7-SNAPSHOT.jar\n" + "3. Téléchargez le fichier v1.7.4 depuis https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Copiez le fichier jar dans le dossier {specialsourcefolder} \n" + "5. Renommez le fichier de la façon suivante SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Redémarrez le serveur\n" + "\n" + "\n"); put(Language.DE, "\n" + "\n" + "Du versuchst DiscordSRV mit ASM 4 zu nuten. DiscordSRV benötigt ASM 5, um zu funktionieren.\n" + "DiscordSRV wird ohne ASM5 NICHT funktionieren. Beschuldige die Entwickler deiner Serversoftware dafür, veraltete Bibliotheken zu nutzen.\n" + "\n" + "Anleitung zum Nutzen von ASM 5:\n" + "1. Navigiere zum Ordner {specialsourcefolder} deines Servers\n" + "2. Lösche die Datei SpecialSource-1.7-SNAPSHOT.jar\n" + "3. Lade dir die Datei SpecialSource v1.7.4 von hier herunter: https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Kopiere die jar Datei in den zuvor ausgewählten Ordner {specialsourcefolder}\n" + "5. Bennen die kopierte jar Datei in SpecialSource-1.7-SNAPSHOT.jar um\n" + "6. Starte deinen Server neu\n" + "\n" + "\n"); put(Language.JA, "\n" + "\n" + "あなたは、DiscordSRV を ASM 4 で使用しようとしています。DiscordSRV を使用するには、ASM 5 が必要です。\n" + "DiscordSRV は ASM 5 でないと正しく動作しません。サーバーソフトウエア開発者に、ライブラリが古くなっていることを教えてあげてください。\n" + "\n" + "ASM 5 へのアップデート手順:\n" + "1. サーバーの {specialsourcefolder} フォルダーに移動します。\n" + "2. SpecialSource-1.7-SNAPSHOT.jar ファイルを削除します。\n" + "3. SpecialSource v1.7.4 を、次のURLからダウンロードします。https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. ダウンロードしたjarファイルを、{specialsourcefolder} フォルダーにコピーします。\n" + "5. コピーしたファイルを、SpecialSource-1.7-SNAPSHOT.jar にリネームします。\n" + "6. サーバーを起動します。\n" + "\n" + "\n"); put(Language.KO, "\n" + "\n" + "DiscordSRV를 ASM 4에서 구동 중 입니다.. DiscordSRV는 ASM 5 이상 버전에서 작동합니다.\n" + "DiscordSRV는 ASM 5없이는 작동 할 수 없습니다. 구식 라이브러리를 써서 만든 서버 소프트웨어 개발자 한테 따지세요.\n" + "\n" + "ASM 5로 업데이트 하는 방법:\n" + "1. 서버의 {specialsourcefolder} 폴더로 들어갑니다.\n" + "2. SpecialSource-1.7-SNAPSHOT.jar 파일을 삭제 합니다.\n" + "3. SpecialSource v1.7.4를 https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar 에서 다운로드 받습니다.\n" + "4. {specialsourcefolder}로 3에서 다운로드 받은 파일을 복사합니다.\n" + "5. 4에서 복사한 파일의 이름을 SpecialSource-1.7-SNAPSHOT.jar로 바꿉니다.\n" + "6. 서버를 재부팅 합니다.\n" + "\n" + "\n"); put(Language.NL, "\n" + "\n" + "Je probeerd DiscordSRV te gebruiken op ASM 4. DiscordSRV heeft ASM 5 nodig om te functioneren.\n" + "DiscordSRV WERKT NIET zonder ASM 5. Geef je server software's developers de schuld maar voor het hebben van outdated libraries.\n" + "\n" + "Instructies voor het updaten naar ASM 5:\n" + "1. Ga naar de {specialsourcefolder} folder van je server.\n" + "2. Verwijder de SpecialSource-1.7-SNAPSHOT.jar jar file.\n" + "3. Download SpecialSource v1.7.4 vanaf https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Kopieer de jar file naar de {specialsourcefolder} folder van je server waar je mee bezig bent.\n" + "5. Verander de naam van de jar file die je hebt gekopieerd naar SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Herstart je server.\n" + "\n" + "\n"); put(Language.ES, "\n" + "\n" + "Estás intentando usar DiscordSRV en ASM 4. DiscordSRV necesita ASM 5 para funcionar.\n" + "DiscordSRV NO FUNCIONARÁ sin ASM 5. Informe al desarrollador del software del servidor de que la biblioteca no está actualizada.\n" + "\n" + "Instrucciones para actualizar a ASM 5:\n" + "1. Navegue a la carpeta {specialsourcefolder} de tu servidor\n" + "2. Elimine el archivo jar de SpecialSource-1.7-SNAPSHOT.jar\n" + "3. Descargue SpecialSource v1.7.4 desde https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Copie el archivo jar en la carpeta {specialsourcefolder} del servidor al que navegaste anteriormente\n" + "5. Renombre el archivo jar que acaba de copiar a: SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Reinicie el servidor\n" + "\n" + "\n"); put(Language.RU, "\n" + "\n" + "Вы пытаетесь использовать DiscordSRV на ASM 4. DiscordSRV требует ASM 5 для работы.\n" + "DiscordSRV НЕ БУДЕТ РАБОТАТЬ без ASM 5. Обратитесь к разработчикам вашей игровой платформы, чтобы получить необходимые библиотеки.\n" + "\n" + "Инструкции для обновления до ASM 5:\n" + "1. Найдите папку {specialsourcefolder} на вашем сервере\n" + "2. Удалите SpecialSource-1.7-SNAPSHOT.jar файл\n" + "3. Скачайте SpecialSource v1.7.4.jar отсюда https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Скопируйте jar файл в папку {specialsourcefolder} вашего сервера, которую вы открыли ранее\n" + "5. Переименуйте jar файл, который вы скопировали в SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Перезапустите сервер\n" + "\n" + "\n"); put(Language.ET, "\n" + "\n" + "Sa proovid DiscordSRV'i kasutada ASM 4 peal. DiscordSRV nõuab töötamiseks ASM 5-te.\n" + "DiscordSRV EI TÖÖTA ilma ASM 5-ta. Süüdista oma serveritarkvara arendajaid vananenud teekide kasutamise eest.\n" + "\n" + "Juhised ASM 5-le täiendamiseks:\n" + "1. Mine serveris kausta {specialsourcefolder}\n" + "2. Kustuta fail SpecialSource-1.7-SNAPSHOT.jar\n" + "3. Laadi SpecialSource v1.7.4 alla saidilt https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Kopeeri saadud jar-fail eelnevalt avatud kausta {specialsourcefolder}\n" + "5. Nimeta just kopeeritud jar-fail ümber nimeks SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Taaskäivita server\n" + "\n" + "\n"); put(Language.ZH, "\n" + "\n" + "您嘗試使用ASM 4來啟動DiscordSRV。 DiscordSRV需要ASM 5來啟動。\n" + "DiscordSRV無法在缺少ASM 5的情況下啟動。 請諮詢您的伺服器軟體開發人員關於舊版函式庫。\n" + "\n" + "ASM 5 升級指南:\n" + "1. 開啟伺服器中的 {specialsourcefolder} 資料夾\n" + "2. 刪除jar檔 SpecialSource-1.7-SNAPSHOT.jar \n" + "3. 下載 SpecialSource v1.7.4 從 https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. 複製該jar檔至先前在伺服器中開啟的 {specialsourcefolder} 資料夾\n" + "5. 並將檔案重新命名為 SpecialSource-1.7-SNAPSHOT.jar\n" + "6. 重啟伺服器\n" + "\n" + "\n"); put(Language.PL, "\n" + "\n" + "Próbujesz użyć DiscordSRV na ASM 4. DiscordSRV wymaga ASM 5 do działania.\n" + "DiscordSRV NIE BĘDZIE DZIAŁAŁ bez ASM 5. wincie twórców oprogramowania serwera za posiadanie nieaktualnych bibliotek.\n" + "\n" + "Instrukcje dotyczące aktualizacji do ASM 5:\n" + "1. Przejdź do {specialsourcefolder} folder serwera\n" + "2. Usuń SpecialSource-1.7-SNAPSHOT.jar plik jar\n" + "3. Pobierz SpecialSource v1.7.4 z https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Skopiuj plik jar do {specialsourcefolder} folderu serwera, do którego nawigowałeś wcześniej\n" + "5. Zmień nazwę właśnie skopiowanego pliku jar na SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Zrestartuj serwer\n" + "\n" + "\n"); put(Language.DA, "\n" + "\n" + "Du prøver at bruge DiscordSRV på ASM 4. DiscordSRV kræver ASM 5 for at fungere.\n" + "DiscordSRV VIL IKKE VIRKE uden ASM 5. Skyd skylden på din servers software udviklere for at have uddaterede biblioteketer.\n" + "\n" + "Instruktionen til at opdatere til ASM 5:\n" + "1. Naviger til {specialsourcefolder} folder i serveren\n" + "2. Slet SpcialSource-1.7-SNAPSHOT.jar jar filen\n" + "3. Download SpecialSource v1.7.4 fra https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Kopier jar filen til {specialsourcefolder} folderen som nævnt tidligere.\n" + "5. Omdøb jar filen du lige kopierede til SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Genstart serveren\n" + "\n" + "\n"); put(Language.UK, "\n" + "\n" + "Ви намагаєтесь використовувати DiscordSRV на ASM 4. DiscordSRV вимагає ASM 5 для роботи.\n" + "DiscordSRV не працюватиме без ASM 5. Зверніться до розробників вашої ігрової платформи, щоб отримати необхідні бібліотеки.\n" + "\n" + "Інструкції для оновлення до ASM 5:\n" + "1. Знайдіть папку {special source folder} на вашому сервері\n" + "2. Видаліть SpecialSource-1.7-SNAPSHOT.JAR файл\n" + "3. Скачайте Special Source v1.7. 4.jar звідси https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Скопіюйте jar файл в папку {specialsourcefolder} вашого сервера, яку ви відкрили раніше\n" + "5. Перейменуйте jar файл, який ви скопіювали в SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Перезапустіть сервер\n" + "\n" + "\n"); }}), RESPECT_CHAT_PLUGINS_DISABLED(new HashMap<Language, String>() {{ put(Language.EN, "\n" + "\n" + "RespectChatPlugins is disabled, this option is for TESTING PURPOSES ONLY\n" + "and should NEVER be disabled on production servers.\n" + "Disabling the option will cause cancelled messages to be forwarded to Discord\n" + "including but not limited to private messages or staff chat messages without /commands\n" + "\n" + "\n"); put(Language.FR, "\n" + "\n" + "RespectChatPlugins est désactivé, cette option est UNIQUEMENT À DES FINS DE TEST\n" + "et ne doit JAMAIS être désactivé sur les serveurs de production.\n" + "La désactivation de cette option entraînera le transfert des messages annulés vers Discord\n" + "y compris, mais sans s'y limiter, les messages privés ou les messages de discussion du personnel sans commandes\n" + "\n" + "\n"); put(Language.DE, "\n" + "\n" + "RespectChatPlugins ist deaktiviert. Diese Option dient nur zum Testen von Zwecken\n" + "und sollte NIEMALS auf Produktionsservern deaktiviert werden.\n" + "Durch Deaktivieren der Option werden abgebrochene Nachrichten an Discord weitergeleitet\n" + "einschließlich, aber nicht beschränkt auf private Nachrichten oder Chat-Nachrichten von Mitarbeitern ohne / Befehle\n" + "\n" + "\n"); put(Language.JA, "\n" + "\n" + "RespectChatPluginsは無効になっています。このオプションは、目的をテストするためだけのものです\n" + "実稼働サーバーでは無効にしないでください。\n" + "オプションを無効にすると、キャンセルされたメッセージがDiscordに転送されます\n" + "/commandsを使用しないプライベートメッセージまたはスタッフチャットメッセージが含まれますが、これらに限定されません\n" + "\n" + "\n"); put(Language.KO, "\n" + "\n" + "RespectChatPlugins가 비활성화되었습니다.이 옵션은 테스트 목적으로 만 사용됩니다.\n" + "프로덕션 서버에서는 절대 비활성화하지 않아야합니다.\n" + "이 옵션을 비활성화하면 취소 된 메시지가 불일치로 전달됩니다.\n" + "/command가없는 개인 메시지 또는 직원 채팅 메시지를 포함하지만 이에 국한되지는 않습니다.\n" + "\n" + "\n"); put(Language.NL, "\n" + "\n" + "RespectChatPlugins is uitgeschakeld, deze optie is ALLEEN voor TESTEN VAN DOELEINDEN\n" + "en mag NOOIT worden uitgeschakeld op productieservers.\n" + "Als u deze optie uitschakelt, worden geannuleerde berichten doorgestuurd naar Discord\n" + "inclusief maar niet beperkt tot privéberichten of chatberichten van personeel zonder / commando's\n" + "\n" + "\n"); put(Language.ES, "\n" + "\n" + "RespectChatPlugins está deshabilitado, esta opción es SOLO PARA PROPÓSITOS\n" + "y NUNCA debe deshabilitarse en los servidores de producción.\n" + "Deshabilitar la opción hará que los mensajes cancelados se reenvíen a Discord\n" + "incluidos, entre otros, mensajes privados o mensajes de chat del personal sin / comandos\n" + "\n" + "\n"); put(Language.RU, "\n" + "\n" + "RespectChatPlugins отключен, эта опция ТОЛЬКО ДЛЯ ТЕСТИРОВАНИЯ\n" + "и никогда не должен быть отключен на производственных серверах.\n" + "Отключение этой опции приведет к тому, что отмененные сообщения будут отправлены в Discord\n" + "включая, но не ограничиваясь, личные сообщения или сообщения чата персонала без / команд\n" + "\n" + "\n"); put(Language.ET, "\n" + "\n" + "RespectChatPlugins on keelatud, see suvand on ette nähtud AINULT EESMÄRKIDE TESTIMISEKS\n" + "ja seda ei tohiks KUNAGI tootmisserverites keelata.\n" + "Selle valiku keelamisel edastatakse tühistatud kirjad Discordile\n" + "sealhulgas, kuid mitte ainult, privaatsõnumid või personali vestlussõnumid ilma / käskudeta\n" + "\n" + "\n"); put(Language.ZH, "\n" + "\n" + "RespectChatPlugins已禁用,此选项仅用于测试目的\n" + "并且永远不要在生产服务器上禁用它。\n" + "禁用该选项将导致取消的邮件转发到Discord\n" + "包括但不限于不带/ command的私人消息或员工聊天消息\n" + "\n" + "\n"); put(Language.PL, "\n" + "\n" + "RespectChatPlugins jest wyłączone, ta opcja służy TYLKO DO CELÓW TESTOWYCH\n" + "i NIGDY nie powinno być wyłączane na serwerach produkcyjnych.\n" + "Wyłączenie tej opcji spowoduje, że anulowane wiadomości będą przekazywane do Discord\n" + "w tym między innymi prywatne wiadomości lub wiadomości na czacie graczy bez /komend\n" + "\n" + "\n"); put(Language.DA, "\n" + "\n" + "RespectChatPlugins er deaktiveret, denne mulighed er KUN til TESTFORMÅL\n" + "og bør ALDRIG deaktiveres på produktionsservere.\n" + "Hvis du deaktiverer indstillingen, vil annullerede beskeder blive videresendt til Discord\n" + "inklusive men ikke begrænset til private beskeder eller personalechatbeskeder uden /kommandoer\n" + "\n" + "\n"); put(Language.UK, "\n" + "\n" + "Ви намагаєтесь використовувати DiscordSRV на ASM 4. DiscordSRV вимагає ASM 5 для роботи.\n" + "DiscordSRV не працюватиме без ASM 5. Зверніться до розробників вашої ігрової платформи, щоб отримати необхідні бібліотеки.\n" + "\n" + "Інструкції щодо оновлення до ASM 5:\n" + "1. Знайдіть папку {special source folder} на вашому сервері\n" + "2. Respect Chat Plugins вимкнено, ця опція лише для тестування\n" + "3. Скачайте Special Source v1.7. 4.jar звідси https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.7.4/SpecialSource-1.7.4.jar\n" + "4. Скопіюйте jar файл в папку {special source folder} вашого сервера, яку ви відкрили раніше\n" + "5. Перейменуйте jar файл, який ви скопіювали в SpecialSource-1.7-SNAPSHOT.jar\n" + "6. Перезапустіть сервер\n" + "\n" + "\n"); }}), INCOMPATIBLE_CLIENT(new HashMap<Language, String>() {{ put(Language.EN, "Your user experience is degraded due to using {client}, some commands may not work as expected."); put(Language.FR, "Votre expérience utilisateur est dégradée en raison de l'utilisation de {client}, certaines commandes peuvent ne pas fonctionner comme prévu."); put(Language.DE, "Ihre Benutzererfahrung ist durch die Verwendung von {client} beeinträchtigt. Einige Befehle funktionieren möglicherweise nicht wie erwartet."); put(Language.JA, "{client}を使用しているため、ユーザーエクスペリエンスが低下し、一部のコマンドが期待どおりに機能しない場合があります。 "); put(Language.KO, "{client} 사용으로 인해 사용자 경험이 저하되고 일부 명령이 예상대로 작동하지 않을 수 있습니다."); put(Language.NL, "Uw gebruikerservaring is verslechterd door het gebruik van {client}. Sommige opdrachten werken mogelijk niet zoals verwacht."); put(Language.ES, "Su experiencia de usuario se degrada debido al uso de {cliente}, es posible que algunos comandos no funcionen como se esperaba."); put(Language.RU, "Ваше взаимодействие с пользователем ухудшается из-за использования {client}, некоторые команды могут работать не так, как ожидалось."); put(Language.ET, "Teie kasutuskogemus on {client} kasutamise tõttu halvenenud, mõned käsud ei pruugi ootuspäraselt töötada."); put(Language.ZH, "您的用户体验因使用 {client} 而下降,某些命令可能无法按预期工作。"); put(Language.PL, "Twoje doświadczenie użytkownika jest pogorszone z powodu korzystania z {client}, niektóre polecenia mogą nie działać zgodnie z oczekiwaniami."); put(Language.DA, "Din brugeroplevelse er nedgraderet grundet din brug af {client}, nogle kommandoer ville ikke virke som forventet."); put(Language.UK, "Ваша взаємодія з користувачем погіршується через використання {client}, деякі команди можуть працювати не так, як очікувалося."); }}), CONSOLE_FORWARDING_ASSIGNED_TO_CHANNEL(new HashMap<Language, String>() {{ put(Language.EN, "Console forwarding assigned to channel"); put(Language.FR, "Réacheminement de la console affecté au canal"); put(Language.DE, "Konsolenausgabeweiterleitung aktiv"); put(Language.JA, "コンソールフォワーディングがチャンネルに割り当てられました"); put(Language.KO, "콘솔포워딩이 채널에 설정되었습니다"); put(Language.NL, "Console versturen verbonden aan kanaal"); put(Language.ES, "Enviar la consola al canal asignado"); put(Language.RU, "Вывод консоли успешно перенаправлен в канал"); put(Language.ET, "Konsooliedastus on kanalile määratud"); put(Language.ZH, "控制台轉送已指派至頻道"); put(Language.PL, "Przekazywanie konsoli przypisane do kanału"); put(Language.DA, "Konsol videresendelse tildelt til kanal"); put(Language.UK, "Вихід консолі успішно перенаправлений на канал"); }}), FOUND_SERVER(new HashMap<Language, String>() {{ put(Language.EN, "Found server"); put(Language.FR, "Serveur trouvé"); put(Language.DE, "Server wurde gefunden"); put(Language.JA, "見つかったサーバー"); put(Language.KO, "서버를 찾았습니다"); put(Language.NL, "Server gevonden"); put(Language.ES, "Servidor encontrado"); put(Language.RU, "Сервер найден"); put(Language.ET, "Server leitud"); put(Language.ZH, "已找到伺服器"); put(Language.PL, "Znaleziono serwer"); put(Language.DA, "Fundet server"); put(Language.UK, "Сервер знайдено"); }}), NOT_FORWARDING_CONSOLE_OUTPUT(new HashMap<Language, String>() {{ put(Language.EN, "Console channel ID was invalid, not forwarding console output"); put(Language.FR, "L'ID du channel de la console est faux, l'envoie des messages de la console ne sera pas effectué"); put(Language.DE, "Konsolenkanal-ID ist ungültig, keine Konsolenausgabe Weiterleitung aktiv"); put(Language.JA, "コンソールチャネルIDは無効であるため、コンソール転送は行われません"); put(Language.KO, "콘솔 채널 ID가 올바르지 않습니다. 콘솔 메세지를 채널로 보내지 않습니다."); put(Language.NL, "Console kanaal ID is ongeldig, de console wordt niet verzonden"); put(Language.ES, "El ID del canal de la consola no es válido, no se enviará ningún mensaje de la consola"); put(Language.RU, "Неверный ID канала для перенаправления вывода консоли, сообщения консоли не будут пересылаться"); put(Language.ET, "Konsoolikanali ID oli sobimatu, konsooli väljundit ei edastata"); put(Language.ZH, "錯誤的控制台頻道ID, 並未轉送控制台輸出。"); put(Language.PL, "Identyfikator kanału konsoli był nieprawidłowy, nie przekazuje danych wyjściowych konsoli"); put(Language.DA, "Konsol kanal ID var invalidt, videresender ikke konsole beskeder"); put(Language.UK, " невірний ID каналу для перенаправлення виводу консолі, повідомлення консолі не будуть пересилатися"); }}), SHUTDOWN_COMPLETED(new HashMap<Language, String>() {{ put(Language.EN, "Shutdown completed in {ms}ms"); put(Language.FR, "Arrêt effectué en {ms}ms"); put(Language.DE, "Herunterfahren wurde abgeschlossen in {ms}ms"); put(Language.JA, "{ms}ミリ秒でシャットダウンしました"); put(Language.KO, "서버가 {ms}ms만에 종료 됨."); put(Language.NL, "Shutdown klaar in {ms}ms"); put(Language.ES, "Apagado completado en {ms}ms"); put(Language.RU, "Отключение завершено за {ms}мс"); put(Language.ET, "Väljalülitus teostatud {ms}ms jooksul"); put(Language.ZH, "伺服器已關閉,耗時{ms}ms"); put(Language.PL, "Wyłączenie zostanie zakończone za {ms}ms"); put(Language.DA, "Nedlukning gennemført på {ms}ms"); put(Language.UK, " відключення завершено за {ms}мс"); }}), API_LISTENER_SUBSCRIBED(new HashMap<Language, String>() {{ put(Language.EN, "API listener {listenername} subscribed ({methodcount} methods)"); put(Language.FR, "API listener {listenername} associé à ({methodcount} methods)"); put(Language.DE, "API listener {listenername} Anmeldung ({methodcount} Methoden)"); put(Language.JA, "API listener {listenername} が購読を開始しました (メソッド数: {methodcount} )"); put(Language.KO, "API listener {listenername} 가 구독을 시작합니다. (Method 수: {methodcount})"); put(Language.NL, "API listener {listenername} aangemeld ({methodcount} methods)"); put(Language.ES, "API listener {listenername} suscrito a ({methodcount} métodos)"); put(Language.RU, "API listener {listenername} подписан на ({methodcount} методы)"); put(Language.ET, "API listener {listenername} on kuulamas ({methodcount} meetodit)"); put(Language.ZH, "API listener {listenername} 已訂閱 ({methodcount} 種方案)"); put(Language.PL, "Odbiornik API {listenername} zasubskrybowano ({methodcount} metodą)"); put(Language.DA, "API listener {listenername} abonneret ({methodcount} metoder)"); put(Language.UK, " API listener {listener name} підписано на ({methodcount} методи)"); }}), API_LISTENER_UNSUBSCRIBED(new HashMap<Language, String>() {{ put(Language.EN, "API listener {listenername} unsubscribed"); put(Language.FR, "API listener {listenername} n'est plus associé"); put(Language.DE, "API listener {listenername} Abmeldung"); put(Language.JA, "API listener {listenername} が購読を終了しました"); put(Language.KO, "API listener {listenername} 의 구독이 취소 되었습니다."); put(Language.NL, "API listener {listenername} afgemeld"); put(Language.ES, "API listener {listenername} anulado"); put(Language.RU, "API listener {listenername} деактивирован"); put(Language.ET, "API listener {listenername} kuulamine lõpetatud"); put(Language.ZH, "API listener {listenername} 已取消訂閱"); put(Language.PL, "Odbiornik API {listenername} odbubskrybowano"); put(Language.DA, "API listener {listenername} afmeldt abonnement"); put(Language.UK, "API listener {listener name} деактивовано"); }}), API_LISTENER_METHOD_NOT_ACCESSIBLE(new HashMap<Language, String>() {{ put(Language.EN, "DiscordSRV API Listener {listenername} method {methodname} was inaccessible despite efforts to make it accessible"); put(Language.FR, "DiscordSRV API Listener {listenername} méthode {methodname} est inaccessible malgré les efforts pour la rendre accessible"); put(Language.DE, "DiscordSRV API Listener {listenername} Methode {methodname} war unzugänglich trotz der Bemühungen, es zugänglich zu machen"); put(Language.JA, "DiscordSRV API Listener {listenername} の Method {methodname} は、アクセスすることができなくなりました"); put(Language.KO, "DiscordSRV API Listener {listenername} 의 method {methodname} 의 액세스에 실패 하였습니다."); put(Language.NL, "DiscordSRV API Listener {listenername} methode {methodname} was onberijkbaar ondanks alle moeite om het berijkbaar te maken"); put(Language.ES, "DiscordSRV API Listener {listenername} método {methodname} era inaccesible a pesar de los esfuerzos para hacerlo accesible"); put(Language.RU, "DiscordSRV API Listener {listenername} метод {methodname} был недоступен, несмотря на все наши усилия сделать его доступным"); put(Language.ET, "DiscordSRV API Listener {listenername} meetod {methodname} polnud ligipääsetav, kuigi prooviti ligipääsetavaks teha"); put(Language.ZH, "DiscordSRV API Listener {listenername} 方案 {methodname} 無法存取"); put(Language.PL, "Odbiornik DiscordSRV API {listenername} metodą {methodname} był niedostępny pomimo starań, aby był dostępny"); put(Language.DA, "DiscordSRV API Listener {listenername} metode {methodname} var utilgængelig på trods af indsats til at gøre den tilgængelig"); put(Language.UK, "DiscordSRV API Listener {listener name} метод {methodname} був недоступний, незважаючи на всі наші зусилля, щоб зробити його доступним"); }}), HTTP_FAILED_TO_FETCH_URL(new HashMap<Language, String>() {{ put(Language.EN, "Failed to fetch URL"); put(Language.FR, "Impossible de récuperer l'URL"); put(Language.DE, "Fehler beim Abrufen der URL"); put(Language.JA, "URLの取得に失敗しました"); put(Language.KO, "URL을 가져오는데 실패 하였습니다."); put(Language.NL, "Gefaald om de URL op te halen"); put(Language.ES, "Fallo al buscar la URL"); put(Language.RU, "Ошибка получения URL"); put(Language.ET, "URLi hankimine ebaõnnestus"); put(Language.ZH, "無法取得URL"); put(Language.PL, "Nie udało się pobrać adresu URL"); put(Language.DA, "Kunne ikke hente URL"); put(Language.UK, "помилка отримання URL"); }}), HTTP_FAILED_TO_DOWNLOAD_URL(new HashMap<Language, String>() {{ put(Language.EN, "Failed to download URL"); put(Language.FR, "Impossible de télécharger l'URL"); put(Language.DE, "Fehler beim Download von URL"); put(Language.JA, "URLからのダウンロードに失敗しました"); put(Language.KO, "URL 다운로드에 실패 하였습니다."); put(Language.NL, "Gefaald om de URL te downloaden"); put(Language.ES, "Fallo al descargar la URL"); put(Language.RU, "Ошибка загрузки URL"); put(Language.ET, "URLi allalaadimine ebaõnnestus"); put(Language.ZH, "自URL下載失敗"); put(Language.PL, "Nie udało się pobrać adresu URL"); put(Language.DA, "Kunne ikke downloade URL"); put(Language.UK, "Помилка завантаження URL"); }}), PLUGIN_HOOK_ENABLING(new HashMap<Language, String>() {{ put(Language.EN, "Enabling {plugin} hook"); put(Language.FR, "Activation de l'accrochage du plugin {plugin}"); put(Language.DE, "Aktiviere {plugin} Verbindung"); put(Language.JA, "{plugin} の接続を有効にしました"); put(Language.KO, "Plugin {plugin} 의 연동을 활성화합니다."); put(Language.NL, "Inschakelen {plugin} hook"); put(Language.ES, "Activando complementos de {plugin}"); put(Language.RU, "Активация {plugin} подключения"); put(Language.ET, "{plugin} haakimine lubatud"); put(Language.ZH, "啟用鉤取 {plugin}"); put(Language.PL, "Włączono {plugin} haczyk"); put(Language.DA, "Aktivere {plugin} hook"); put(Language.UK, "Активація {plugin} підключення"); }}), NO_CHAT_PLUGIN_HOOKED(new HashMap<Language, String>() {{ put(Language.EN, "No chat plugin hooks enabled"); put(Language.FR, "Aucun accrochage de plugin activé"); put(Language.DE, "Keine Pluginverbindungen aktiviert"); put(Language.JA, "チャットプラグインへの接続は一つもありません"); put(Language.KO, "활성화된 채팅 플러그인 연동 없음"); put(Language.NL, "Geen chat plugin hooks ingeschakeld"); put(Language.ES, "Sin complementos"); put(Language.RU, "Плагинов для управления игровым чатом не обнаружено"); put(Language.ET, "Ühegi vestlusplugina haakimine pole lubatud"); put(Language.ZH, "未啟用鉤取任何聊天插件"); put(Language.PL, "Żadna wtyczka czatu nie jest włączona"); put(Language.DA, "Ingen chat plugin hooks aktiveret"); put(Language.UK, "плагінів для управління ігровим чатом не виявлено"); }}), CHAT_CANCELLATION_DETECTOR_ENABLED(new HashMap<Language, String>() {{ put(Language.EN, "Chat event cancellation detector has been enabled"); put(Language.FR, "Détecteur d'annulation d'événement de chat vient d'être activé"); put(Language.DE, "Chatevent-Abbruch-Detektor wurde aktiviert"); put(Language.JA, "チャットイベントキャンセル検出機能が有効になっています"); put(Language.KO, "채팅 취소 감지기가 구동되었습니다."); put(Language.NL, "Chat gebeurtenis annulering"); put(Language.ES, "El detector de cancelación de eventos de chat ha sido activado"); put(Language.RU, "Включен детектор отмены сообщений чата"); put(Language.ET, "Vestlussündmuste tühistamise tuvastaja on lubatud"); put(Language.ZH, "聊天事件撤銷檢測器已啟動"); put(Language.PL, "Wykrywacz anulowania zdarzeń czatu został włączony"); put(Language.DA, "Detektor for annullering af events er blevet aktiveret"); put(Language.UK, "увімкнено детектор скасування повідомлень чату"); }}), BOT_NOT_IN_ANY_SERVERS(new HashMap<Language, String>() {{ put(Language.EN, "The bot is not a part of any Discord servers. Follow the installation instructions"); put(Language.FR, "Le bot ne fait partie d'aucun serveur. Suivez les instructions d'installation"); put(Language.DE, "Der Bot ist nicht Bestandteil irgendwelcher Discordserver. Folge den Installationsanweisungen"); put(Language.JA, "このBotはどのDiscordサーバーにも所属していません。インストール手順に従ってください"); put(Language.KO, "연동된 서버가 없습니다. 설치 방법을 따라 주세요."); put(Language.NL, "De bot maakt geen deel uit van een Discord server. Volg de instalatie instructies."); put(Language.ES, "El bot no es parte de ningún servidor de Discord. Siga las instrucciones de instalación"); put(Language.RU, "Этот Бот не является частью какого-либо сервера Discord. Подключите его к серверу, следуя инструкциям по установке"); put(Language.ET, "See bot ei ole ühegi Discordi serveri osa. Järgi paigaldusjuhiseid"); put(Language.ZH, "這個BOT並不屬於Discord伺服器。 請參照安裝指南。"); put(Language.PL, "Bot nie jest częścią żadnego serwera Discord. Postępuj zgodnie z instrukcjami instalacji"); put(Language.DA, "Botten er ikke en del af nogle Discord servere. Følg installations manualen"); put(Language.UK, "цей Бот не є частиною жодного сервера Discord. Підключіть його до сервера, дотримуючись інструкцій з встановлення"); }}), CONSOLE_CHANNEL_ASSIGNED_TO_LINKED_CHANNEL(new HashMap<Language, String>() {{ put(Language.EN, "The console channel was assigned to a channel that's being used for chat. Did you blindly copy/paste an ID into the channel ID config option?"); put(Language.FR, "Le channel de la console à été assigné à un channel utilisé pour le tchat. Avez vous copié aveuglement l'ID d'un channel"); put(Language.DE, "Der Konsolenkanal wurde mit einem Kanal verbunden, der auch für den Chat genutzt werden soll. Bitte korrigiere das und folge den Installationsanweisungen!"); put(Language.JA, "コンソールチャンネルは、チャットに使用されているチャンネルと同じものが指定されています。IDをチャンネルID設定オプションにそのままコピペしていませんか?"); put(Language.KO, "채팅 채널 ID가 콘솔 채널 ID와 같습니다. 정신 차리세요."); put(Language.NL, "Het console kanaal is gelinked met een kanaal dat voor chat gebruikt. Heb je het channel ID gekopieerd?? ;P"); put(Language.ES, "El canal de la consola se asignó a un canal que se está utilizando para el chat. ¿Copió/pegó a ciegas el ID en la opción de configuración de identificación del canal?"); put(Language.RU, "Канал для консоли был прикреплен к каналу серверного чата! Слепой копипаст ID канала в файле конфигурации?"); put(Language.ET, "Konsoolikanal määrati kanalile, mida kasutatakse vestluseks. Kas sa kopeerisid mõne ID pimesi kanali ID seadistusvalikusse?"); put(Language.ZH, "這個控制台頻道已指派給聊天用頻道。 請確認設定中的頻道ID是否正確。"); put(Language.PL, "Kanał konsoli został przypisany do kanału używanego do czatu. Czy na ślepo skopiowałeś / wkleiłeś identyfikator do opcji konfiguracji identyfikatora kanału?"); put(Language.DA, "Konsol kanalen er blevet tildelt til en kanal der bliver brugt til chatten. Har du indsat ID'et i den forkerte kanal i konfigurations filen?"); put(Language.UK, "Канал для консолі був прикріплений до каналу серверного чату! Сліпий копіпаст ID каналу у файлі конфігурації?"); }}), CHAT(new HashMap<Language, String>() {{ put(Language.EN, "Chat"); put(Language.FR, "Tchat"); put(Language.DE, "Chat"); put(Language.JA, "チャット"); put(Language.KO, "챗"); put(Language.NL, "Chat"); put(Language.ES, "Chat"); put(Language.RU, "Чат"); put(Language.ET, "Vestlus"); put(Language.ZH, "聊天"); put(Language.PL, "Czat"); put(Language.DA, "Chat"); put(Language.UK, "Чат"); }}), ERROR_LOGGING_CONSOLE_ACTION(new HashMap<Language, String>() {{ put(Language.EN, "Error logging console action to"); put(Language.FR, "Erreur lors de la journalisation de l'action de la console"); put(Language.DE, "Fehler beim Loggen einer Konsolenaktion nach"); put(Language.JA, "動作記録失敗"); put(Language.KO, "콘솔 로깅중 오류 발생 "); put(Language.NL, "Fout opgetreden tijdens het loggen van console acties"); put(Language.ES, "Error al iniciar sesión en la consola"); put(Language.RU, "Ошибка логирования действий консоли в"); put(Language.ET, "Esines viga konsoolitegevuse logimisel asukohta"); put(Language.ZH, "控制台記錄錯誤"); put(Language.PL, "Błąd podczas rejestrowania akcji konsoli do"); put(Language.DA, "Fejl under logning af konsolhandling"); put(Language.UK, "помилка логування дій консолі в"); }}), SILENT_JOIN(new HashMap<Language, String>() {{ put(Language.EN, "Player {player} joined with silent joining permission, not sending a join message"); put(Language.FR, "Le joueur {player} a rejoint le jeu avec une permission de silence lors de la connexion."); put(Language.DE, "Spieler {player} hat den Server mit Berechtigung zum stillen Betreten betreten, es wird keine Nachricht gesendet"); put(Language.JA, "プレイヤー {player} は discordsrv.silentjoin の権限があるので、サーバー参加メッセージが送信されません"); put(Language.KO, "플레이어 {player}가 discordsrv.slientjoin 퍼미션을 가지고 있습니다. 참가메세지를 보내지 않습니다."); put(Language.NL, "Speler {speler} joined met toestemming om stil te joinen, geen join bericht wordt verstuurd."); put(Language.ES, "Jugador {player} entró con el permiso de entrada silenciosa, no se ha enviado mensaje de entrada"); put(Language.RU, "Игрок {player} незаметно присоединился к серверу, безо всяких сообщений в чате"); put(Language.ET, "Mängija {player} liitus vaikse liitumise õigusega, liitumissõnumit ei saadeta"); put(Language.ZH, "玩家 {player} 使用靜默登入權限進入了伺服器,並未發送登入訊息。"); put(Language.PL, "Gracz {player} dołączył z uprawnieniem do cichego dołączania, bez wysyłania wiadomości o dołączeniu"); put(Language.DA, "Spilleren {player} joinede med stille join tilladelsen, sender ikke join besked"); put(Language.UK, "гравець {player} непомітно приєднався до сервера, без жодних повідомлень в чаті"); }}), SILENT_QUIT(new HashMap<Language, String>() {{ put(Language.EN, "Player {player} quit with silent quitting permission, not sending a quit message"); put(Language.FR, "Le joueur {player} a quitté le jeu avec une permission de silence lors de le déconnexion."); put(Language.DE, "Spieler {player} hat den Server mit Berechtigung zum stillen Verlassen verlassen, es wird keine Nachricht gesendet"); put(Language.JA, "プレイヤー {player} は discordsrv.silentquit の権限があるので、サーバー退出メッセージが送信されません"); put(Language.KO, "플레이어 {player} 가 discordsrv.slientquit 퍼미션을 가지고 있습니다. 퇴장메세지를 보내지 않습니다."); put(Language.NL, "Speler {speler} is weg gegaan met toestemming om stil weg te gaan, geen quit bericht wordt verstuurd."); put(Language.ES, "Jugador {player} salió con el permiso de salida silenciosa, no se ha enviado un mensaje de salida"); put(Language.RU, "Игрок {player} незаметно вышел, не попрощавшись, безо всяких сообщений в чате"); put(Language.ET, "Mängija {player} lahkus vaikse lahkumise õigusega, lahkumissõnumit ei saadeta"); put(Language.ZH, "玩家 {player} 使用靜默登出權限離開了伺服器,並未發送登出訊息。"); put(Language.PL, "Gracz {player} wyszedł z uprawnieniem do cichego wyjścia, bez wysyłania wiadomości o wyjściu"); put(Language.DA, "Spilleren {player} afsluttede med stille afslutning tilladelse, sender ikke afslutnings besked"); put(Language.UK, "гравець {player} непомітно вийшов, не попрощавшись, без жодних повідомлень в чаті"); }}), LINKED_ACCOUNTS_SAVED(new HashMap<Language, String>() {{ put(Language.EN, "Saved linked accounts in {ms}ms"); put(Language.FR, "Sauvegarde des comptes liés en {ms}ms"); put(Language.DE, "Speichern von verknüpften Accounts in {ms}ms"); put(Language.JA, "{ms}ミリ秒でリンクされたアカウントを保存しました"); put(Language.KO, "{ms}ms 만에 연동계정 저장완료"); put(Language.NL, "Gekoppelde accounts opgeslagen in {ms}ms"); put(Language.ES, "Cuentas vinculadas guardadas en {ms}ms"); put(Language.RU, "Привязанные аккаунты успешно сохранены за {ms}мс"); put(Language.ET, "Ühendatud kontod salvestati {ms}ms jooksul"); put(Language.ZH, "已儲存已連結帳號,耗時{ms}ms"); put(Language.PL, "Zapisane połączone konta w {ms}ms"); put(Language.DA, "Gemte linkede brugere det tog {ms}ms"); put(Language.UK, " Прив'язані акаунти успішно збережені за {ms}мс"); }}), LINKED_ACCOUNTS_SAVE_FAILED(new HashMap<Language, String>() {{ put(Language.EN, "Failed saving linked accounts"); put(Language.FR, "Erreur lors de la sauvegarde des comptes liés"); put(Language.DE, "Fehler beim Speichern von verknüpften Accounts"); put(Language.JA, "リンクされたアカウントの保存に失敗しました"); put(Language.KO, "연동계정 저장 실패"); put(Language.NL, "Opslaan van gekoppelde accounts is mislukt"); put(Language.ES, "Fallo al guardar las cuentas vinculadas"); put(Language.RU, "Произошла ошибка сохранения привязанных аккаунтов"); put(Language.ET, "Ühendatud kontode salvestamine ebaõnnestus"); put(Language.ZH, "儲存已連結帳號失敗"); put(Language.PL, "Nie udało się zapisać połączonych kont"); put(Language.DA, "Fejlede at gemme linkede brugere"); put(Language.UK, " Сталася помилка збереження прив'язаних акаунтів"); }}), FAILED_LOADING_PLUGIN(new HashMap<Language, String>() {{ put(Language.EN, "Failed loading plugin"); put(Language.FR, "Erreur lors du chargement du plugin"); put(Language.DE, "Fehler beim Laden des Plugins"); put(Language.JA, "プラグインの起動に失敗しました"); put(Language.KO, "플러그인 로드 실패"); put(Language.NL, "Gefaald om de plugin te laden."); put(Language.ES, "Fallo al cargar el plugin"); put(Language.RU, "Ошибка загрузки плагина"); put(Language.ET, "Plugina laadimine ebaõnnestus"); put(Language.ZH, "讀取插件失敗"); put(Language.PL, "Nie udało się załadować wtyczki"); put(Language.DA, "Fejlede at loade plugin"); put(Language.UK, "Помилка завантаження плагіна"); }}), GROUP_SYNCHRONIZATION_COULD_NOT_FIND_ROLE(new HashMap<Language, String>() {{ put(Language.EN, "Could not find role id {rolename} for use with group synchronization. Is the bot in the server?"); put(Language.FR, "Impossible de trouver le rôle {rolename} lors de la synchronisation des groupes.Le bot est il sur le serveur ?"); put(Language.DE, "Konnte keine Rolle mit id {rolename} für gruppensynchronisierung finden. Ist der Bot auf dem Server?"); put(Language.JA, "グループを同期させるために、ID「{rolename}」のロールを見つけることができませんでした。 Botはサーバ上にありますか?"); put(Language.KO, "그룹 동기화를 할 Role ID를 찾을 수 없습니다. 봇이 디스코드 서버에 있나요?"); put(Language.NL, "Kon role id {rolename} niet vinden dit word gebruikt voor groep synchronisatie. Is de bot in de server?"); put(Language.ES, "No se pudo encontrar el rol {rolename} para usar con sincronización de grupo. ¿Está el bot en el servidor?"); put(Language.RU, "Не могу найти подходящий ID роли {rolename}, чтобы произвести синхронизацию. Бот точно уже подключился к серверу?"); put(Language.ET, "Gruppide sünkroonimiseks vajalikku rolli ID-d {rolename} ei leitud. Kas bot on serveris?"); put(Language.ZH, "未能找到身分組 {rolename} 來進行群組同步。 請確認Bot是否有在伺服器中。"); put(Language.PL, "Nie udało się znaleźć identyfikatora roli {rolename} do użytku z synchronizacją grupową. Czy bot jest na serwerze?"); put(Language.DA, "Kunne ikke finde rolle id {rolename} til brug af gruppe synkronisation. Er botten i serveren?"); put(Language.UK, " Не можу знайти відповідний ID ролі {rolename}, щоб зробити синхронізацію. Бот точно вже підключився до сервера?"); }}), NO_MESSAGE_GIVEN_TO_BROADCAST(new HashMap<Language, String>() {{ put(Language.EN, "No text given to broadcast"); put(Language.FR, "Aucune langue donnée à diffuser"); put(Language.DE, "Keine Sprache für Broadcast angegeben"); put(Language.JA, "ブロードキャストするメッセージが指定されていません。"); put(Language.KO, "방송할 언어가 주어지지 않았습니다."); put(Language.NL, "Geen taal is opgegeven om uit te zenden."); put(Language.ES, "Ningún idioma dado para transmitir"); put(Language.RU, "Не найден подходящий язык для отправки уведомлений"); put(Language.ET, "Teadaande saatmiseks ei määratud keelt"); put(Language.ZH, "未給廣播指定語言"); put(Language.PL, "Brak tekstu do wysłania"); put(Language.DA, "Ingen text givet til broadcast"); put(Language.UK, " не знайдено відповідної мови для надсилання сповіщень"); }}), PLAYER_ONLY_COMMAND(new HashMap<Language, String>() {{ put(Language.EN, "Only players can execute this command."); put(Language.FR, "Seuls les joueurs peuvent effectuer cette commande."); put(Language.DE, "Nur Spieler können diesen Befehl ausführen."); put(Language.JA, "ゲーム内プレイヤーのみがこのコマンドを実行することができます。"); put(Language.KO, "플레이어만 이 명령어를 실행 할 수 있습이다."); put(Language.NL, "Alleen spelers kunnen dit command gebruiken."); put(Language.ES, "Solo los jugadores pueden ejecutar este comando"); put(Language.RU, "Только игроки могут выполнить такую команду."); put(Language.ET, "Ainult mängijad saavad seda käsklust teostada."); put(Language.ZH, "只有玩家能執行這個指令"); put(Language.PL, "Tylko gracze mogą wykonać to polecenie."); put(Language.DA, "Kun spillere kan eksekvere denne kommando."); put(Language.UK, "Тільки гравці можуть виконати таку команду."); }}), RELOADED(new HashMap<Language, String>() {{ put(Language.EN, "The DiscordSRV config & lang have been reloaded."); put(Language.FR, "La configuration et les fichiers de langage de DiscordSRV ont été rechargé."); put(Language.DE, "Die DiscordSRV Konfiguration und Sprachdatei wurden neu eingelesen."); put(Language.JA, "DiscordSRVの設定と言語が再読込されました。"); put(Language.KO, "DiscordSRV 컨피그 및 언어 설정이 리로드 되었습니다."); put(Language.NL, "De DiscordSRV config & lang is herladen."); put(Language.ES, "La configuración y el idioma de DiscordSRV han sido recargadas"); put(Language.RU, "DiscordSRV конфигурация и языковые настройки успешно перезагружены."); put(Language.ET, "DiscordSRV seadistus ja keel on uuesti laaditud."); put(Language.ZH, "DiscordSRV的設定檔與詞條已重新讀取。"); put(Language.PL, "Konfiguracja i język DiscordSRV zostały ponownie załadowane."); put(Language.DA, "DiscordSRV konfigurationen & sprog er blevet genstartet."); put(Language.UK, " DiscordSRV конфігурація та налаштування мови успішно перезавантажені."); }}), NO_UNLINK_TARGET_SPECIFIED(new HashMap<Language, String>() {{ put(Language.EN, "No player specified. It can be a player UUID, player name, or Discord ID."); put(Language.FR, "Aucune cible spécifiée. Peut être un UUID, un ID Discord ou un nom de joueur."); put(Language.DE, "Kein Spieler angegeben. Dies kann eine UUID, ein Spielername oder eine Discord-ID sein."); put(Language.JA, "プレーヤーが指定されていません。これは、UUID、プレーヤー名、またはDiscord IDです。"); put(Language.KO, "대상이 지정되지 않았습니다. 플레이어 UUID, 플레이어 이름 또는 Discord ID 일 수 있습니다."); put(Language.NL, "U moet opgeven wie u wilt ontkoppelen. Het kan een UUID, een Discord-ID of een spelersnaam zijn."); put(Language.ES, "Ningún objetivo especificado. Puede ser un UUID, una ID de Discord o un nombre de jugador."); put(Language.RU, "Ни один игрок не указан. Это может быть UUID, имя игрока или Discord ID."); put(Language.ET, "Ühtegi mängijat pole täpsustatud. See võib olla mängija UUID, mängija nimi või Discord ID."); put(Language.ZH, "沒有玩家指定。這可能是玩家的UUID,玩家名稱或Discord ID。"); put(Language.PL, "Nie określono gracza. Może to być identyfikator UUID gracza, nazwa gracza lub identyfikator Discord."); put(Language.DA, "Ingen spiller specificeret. Det kan være en spillers UUID, spillernavn, eller Discord ID."); put(Language.UK, "Жоден гравець не вказаний. Це може бути UUID, ім'я гравця або Discord ID."); }}), COMMAND_EXCEPTION(new HashMap<Language, String>() {{ put(Language.EN, "An internal error occurred while while processing your command."); put(Language.FR, "Une erreur interne š'est produite lors du traitement."); put(Language.DE, "Während der Verarbeitung Ihres Befehls ist ein interner Fehler aufgetreten."); put(Language.JA, "コマンドの処理中に内部エラーが発生しました。"); put(Language.KO, "명령을 처리하는 중 내부 오류가 발생했습니다."); put(Language.NL, "En intern feil oppstod under behandlingen av kommandoen din."); put(Language.ES, "Se produjo un error interno al procesar su comando."); put(Language.RU, "Во время обработки вашей команды произошла внутренняя ошибка."); put(Language.ET, "Käskluse töötlemisel esines sisemine viga."); put(Language.ZH, "处理命令时发生内部错误。"); put(Language.PL, "Podczas przetwarzania polecenia wystąpił błąd wewnętrzny."); put(Language.DA, "En intern fejl fandt sted imens den behandlede din kommando."); put(Language.UK, " під час обробки вашої команди сталася Внутрішня помилка."); }}), RESYNC_WHEN_GROUP_SYNC_DISABLED(new HashMap<Language, String>() {{ put(Language.EN, "Group synchonization requires valid GroupRoleSynchronizationGroupsAndRolesToSync entries in synchronization.yml"); put(Language.FR, "La synchronisation de groupe nécessite des entrées GroupRoleSynchronizationGroupsAndRolesToSync valides dans synchronization.yml"); put(Language.DE, "Für die Gruppensynchronisierung sind gültige GroupRoleSynchronizationGroupsAndRolesToSync-Einträge in synchronization.yml erforderlich"); put(Language.JA, "グループの同期には、synchronization.ymlの有効なGroupRoleSynchronizationGroupsAndRolesToSyncエントリが必要です。"); put(Language.KO, "그룹 동기화에는 동기화에 유효한 GroupRoleSynchronizationGroupsAndRolesToSync 항목이 synchronization.yml 합니다."); put(Language.NL, "Groepsynchronisatie vereist geldige GroupRoleSynchronizationGroupsAndRolesToSync-vermeldingen in synchronization.yml"); put(Language.ES, "La sincronización de grupo requiere entradas válidas de GroupRoleSynchronizationGroupsAndRolesToSync en synchronization.yml"); put(Language.RU, "Синхронизация группы требует допустимых записей GroupRoleSynchronizationGroupsAndRolesToSync в synchronization.yml"); put(Language.ET, "Grupi sünkroonimiseks on vaja kehtivaid GroupRoleSynchronizationGroupsAndRolesToSync kirjeid failis synchronization.yml"); put(Language.ZH, "群组同步需要在synchronization.yml中有效的GroupRoleSynchronizationGroupsAndRolesToSync条目"); put(Language.PL, "Synchronizacja grupowa wymaga ważnego GroupRoleSynchronizationGroupsAndRolesToSync wpisu w synchronization.yml"); put(Language.DA, "Gruppe synkronisation kræver valid GroupRoleSynchronizationGroupsAndRolesToSync entréer i synchronization.yml"); put(Language.UK, " Синхронізація групи вимагає дійсних записів GroupRoleSynchronizationGroupsAndrolestosync у synchronization.yml"); }}), PLUGIN_RELOADED(new HashMap<Language, String>() {{ put(Language.EN, "DiscordSRV has been reloaded. This is NOT supported, and issues WILL occur! Restart your server before asking for support!"); put(Language.FR, "DiscordSRV a été rechargé. Ceci n'est PAS pris en charge et des problèmes surviendront! Redémarrez votre serveur avant de demander de l'aide!"); put(Language.DE, "DiscordSRV wurde neu geladen. Dies wird NICHT unterstützt und es treten Probleme auf! Starten Sie Ihren Server neu, bevor Sie um Unterstützung bitten!"); put(Language.JA, "DiscordSRVがリロードされました。 これはサポートされておらず、問題が発生します! サポートを求める前にサーバーを再起動してください!"); put(Language.KO, "DiscordSRV가 다시로드되었습니다. 이것은 지원되지 않으며 문제가 발생합니다! 지원을 요청하기 전에 서버를 다시 시작하십시오!"); put(Language.NL, "DiscordSRV is opnieuw geladen. Dit wordt NIET ondersteund en er ZULLEN problemen optreden! Start uw server opnieuw op voordat u om ondersteuning vraagt!"); put(Language.ES, "DiscordSRV ha sido recargado. ¡Esto NO es compatible, y OCURRIRÁN problemas! ¡Reinicie su servidor antes de solicitar asistencia!"); put(Language.RU, "DiscordSRV был перезагружен. Это НЕ поддерживается, и проблемы будут происходить! Перезагрузите сервер, прежде чем обращаться за поддержкой!"); put(Language.ET, "DiscordSRV on taaslaaditud. See EI OLE toetatud ning probleemid ESINEVAD kindlalt! Enne toe küsimist taaskäivita oma server!"); put(Language.ZH, "DiscordSRV已重新加载。 不支持此功能,并且会发生问题! 在寻求支持之前,请重新启动服务器!"); put(Language.PL, "DiscordSRV został ponownie załadowany. To NIE jest obsługiwane i pojawią się problemy! Zrestartuj serwer, zanim poprosisz o wsparcie!"); put(Language.DA, "DiscordSRV er blevet genladet. Dette er IKKE understøttet, og problemer VIL OPSTÅ! Genstart din server før du spørger om hjælp!"); put(Language.UK, " DiscordSRV було перезавантажено. Це не підтримується, і проблеми будуть відбуватися! Перезавантажте сервер, перш ніж звертатися за підтримкою!"); }}); @Getter private final Map<Language, String> definitions; InternalMessage(Map<Language, String> definitions) { this.definitions = definitions; } @Override public String toString() { return definitions.getOrDefault(DiscordSRV.config().getLanguage(), definitions.get(Language.EN)); } } /** * Messages external to DiscordSRV and thus can be customized in messages.yml */ public enum Message { ACCOUNT_ALREADY_LINKED("MinecraftAccountAlreadyLinked", true), ALREADY_LINKED("DiscordAccountAlreadyLinked", false), BAN_DISCORD_TO_MINECRAFT("BanSynchronizationDiscordToMinecraftReason", true), CHAT_CHANNEL_COMMAND_ERROR("DiscordChatChannelConsoleCommandNotifyErrorsFormat", false), CHAT_CHANNEL_MESSAGE("ChatChannelHookMessageFormat", true), CHAT_CHANNEL_TOPIC("ChannelTopicUpdaterChatChannelTopicFormat", false), CHAT_CHANNEL_TOPIC_AT_SERVER_SHUTDOWN("ChannelTopicUpdaterChatChannelTopicAtServerShutdownFormat", false), CHAT_TO_DISCORD("MinecraftChatToDiscordMessageFormat", false), CHAT_TO_DISCORD_NO_PRIMARY_GROUP("MinecraftChatToDiscordMessageFormatNoPrimaryGroup", false), CHAT_TO_MINECRAFT("DiscordToMinecraftChatMessageFormat", true), CHAT_TO_MINECRAFT_ALL_ROLES_SEPARATOR("DiscordToMinecraftAllRolesSeparator", true), CHAT_TO_MINECRAFT_NO_ROLE("DiscordToMinecraftChatMessageFormatNoRole", true), CHAT_TO_MINECRAFT_REPLY("DiscordToMinecraftMessageReplyFormat", true), CODE_GENERATED("CodeGenerated", false), // colors translated with kyori CLICK_TO_COPY_CODE("ClickToCopyCode", false), // colors translated with kyori COMMAND_DOESNT_EXIST("UnknownCommandMessage", true), CONSOLE_CHANNEL_PREFIX("DiscordConsoleChannelPrefix", false), CONSOLE_CHANNEL_SUFFIX("DiscordConsoleChannelSuffix", false), CONSOLE_CHANNEL_TOPIC("ChannelTopicUpdaterConsoleChannelTopicFormat", false), CONSOLE_CHANNEL_TOPIC_AT_SERVER_SHUTDOWN("ChannelTopicUpdaterConsoleChannelTopicAtServerShutdownFormat", false), DISCORD_ACCOUNT_LINKED("DiscordAccountLinked", false), DISCORD_COMMAND("DiscordCommandFormat", true), DYNMAP_CHAT_FORMAT("DynmapChatFormat", true), DYNMAP_DISCORD_FORMAT("DynmapDiscordFormat", false), DYNMAP_NAME_FORMAT("DynmapNameFormat", true), FAILED_TO_CHECK_LINKED_ACCOUNT("DiscordLinkedAccountCheckFailed", false), INVALID_CODE("InvalidCode", false), LINKED_SUCCESS("LinkedCommandSuccess", true), LINKED_ACCOUNT_REQUIRED("DiscordLinkedAccountRequired", false), LINKED_NOBODY_FOUND("MinecraftNobodyFound", true), LINK_FAIL_NOT_ASSOCIATED_WITH_AN_ACCOUNT("MinecraftNoLinkedAccount", true), MINECRAFT_ACCOUNT_LINKED("MinecraftAccountLinked", true), NO_PERMISSION("NoPermissionMessage", true), PLAYER_LIST_COMMAND("DiscordChatChannelListCommandFormatOnlinePlayers", false), PLAYER_LIST_COMMAND_NO_PLAYERS("DiscordChatChannelListCommandFormatNoOnlinePlayers", false), PLAYER_LIST_COMMAND_PLAYER("DiscordChatChannelListCommandPlayerFormat", true), PLAYER_LIST_COMMAND_ALL_PLAYERS_SEPARATOR("DiscordChatChannelListCommandAllPlayersSeparator", false), SERVER_SHUTDOWN_MESSAGE("DiscordChatChannelServerShutdownMessage", false), SERVER_STARTUP_MESSAGE("DiscordChatChannelServerStartupMessage", false), SERVER_WATCHDOG("ServerWatchdogMessage", false), UNABLE_TO_LINK_ACCOUNTS_RIGHT_NOW("LinkingError", true), UNKNOWN_CODE("UnknownCode", false), UNLINK_SUCCESS("UnlinkCommandSuccess", true); @Getter private final String keyName; @Getter private final boolean translateColors; Message(String keyName, boolean translateColors) { this.keyName = keyName; this.translateColors = translateColors; } @Override public String toString() { return toString(translateColors); } public String toString(boolean translateColors) { String message = DiscordSRV.config().getString(this.keyName); return translateColors ? MessageUtil.translateLegacy(message) : message; } } }
DiscordSRV/DiscordSRV
src/main/java/github/scarsz/discordsrv/util/LangUtil.java
786
/* * * Copyright 2016 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.netflix.genie.web.tasks; import org.springframework.scheduling.Trigger; /** * Interface for any task that should run in the Genie system. Will be extended by more specific interfaces. * * @author tgianos * @since 3.0.0 */ public abstract class GenieTask implements Runnable { /** * Get the type of scheduling mechanism which should be used to schedule this task. * * @return The schedule type */ public abstract GenieTaskScheduleType getScheduleType(); /** * Get the Trigger which this task should be scheduled with. * * @return The trigger */ public Trigger getTrigger() { throw new UnsupportedOperationException("This task doesn't support being scheduled via Trigger."); } /** * Get how long the system should wait between invoking the run() method of this task in milliseconds. * * @return The period to wait between invocations of run for this task */ public long getFixedRate() { throw new UnsupportedOperationException("This task doesn't support being scheduled at a fixed rate."); } /** * Get how long the system should wait between invoking the run() method of this task in milliseconds after the * last successful run of the task. * * @return The time to delay between task completions */ public long getFixedDelay() { throw new UnsupportedOperationException("This task doesn't support being scheduled at a fixed delay."); } }
eric-erki/Distributed-Big-Data-Orchestration-Service-
genie-web/src/main/java/com/netflix/genie/web/tasks/GenieTask.java
787
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; import edu.berkeley.compbio.jlibsvm.ImmutableSvmParameter; import edu.berkeley.compbio.jlibsvm.ImmutableSvmParameterGrid; import edu.berkeley.compbio.jlibsvm.ImmutableSvmParameterPoint; import edu.berkeley.compbio.jlibsvm.binary.BinaryClassificationProblem; import edu.berkeley.compbio.jlibsvm.binary.BinaryModel; import edu.berkeley.compbio.jlibsvm.binary.C_SVC; import edu.berkeley.compbio.jlibsvm.binary.MutableBinaryClassificationProblemImpl; import edu.berkeley.compbio.jlibsvm.kernel.LinearKernel; import edu.berkeley.compbio.jlibsvm.util.SparseVector; public class Trainer { ImmutableSvmParameter params; private MutableBinaryClassificationProblemImpl problem; // set by // read_problem private BinaryModel model; private String input_file_name; // set by parse_command_line private String model_file_name; // set by parse_command_line private boolean crossValidation; private static final Float UNSPECIFIED_GAMMA = -1F; public Trainer(File inputFile) throws IOException { this.input_file_name = inputFile.getName(); this.model_file_name = inputFile.getName()+".model"; } public BinaryModel run() throws IOException { C_SVC svm = new C_SVC(); ImmutableSvmParameterGrid.Builder builder = ImmutableSvmParameterGrid.builder(); HashSet<Float> cSet; HashSet<LinearKernel> kernelSet; cSet = new HashSet<Float>(); cSet.add(100.0f); kernelSet = new HashSet<LinearKernel>(); kernelSet.add(new LinearKernel()); //configuring parameters builder.eps = 0.001f; builder.Cset = cSet; builder.kernelSet = kernelSet; this.params = builder.build(); read_problem(); model = svm.train(problem, params); model.save(model_file_name); return model; } private void read_problem() throws IOException { BufferedReader fp = new BufferedReader(new FileReader(input_file_name)); Vector<Float> vy = new Vector<Float>(); Vector<SparseVector> vx = new Vector<SparseVector>(); int max_index = 0; Map<Integer, SparseVector> data = new HashMap<Integer, SparseVector>(); while (true) { String line = fp.readLine(); if (line == null) { break; } StringTokenizer st = new StringTokenizer(line, " \t\n\r\f:"); vy.addElement(Float.parseFloat(st.nextToken())); int value_amount = st.countTokens() / 2; SparseVector sv = new SparseVector(value_amount); for (int i = 0; i < value_amount; i++) { sv.indexes[i] = Integer.parseInt(st.nextToken()); sv.values[i] = Float.parseFloat(st.nextToken()); } if (value_amount > 0) { max_index = Math.max(max_index, sv.indexes[value_amount-1]); } vx.addElement(sv); } problem = new MutableBinaryClassificationProblemImpl(String.class, vy.size()); for (int i = 0; i < vy.size(); i++) { problem.addExampleFloat(vx.elementAt(i), vy.elementAt(i)); } ((BinaryClassificationProblem) problem).setupLabels(); /* *** Niet nodig want geen gamma-kernel for (ImmutableSvmParameterPoint subparam : gridParams) { updateKernelWithNumExamples(subparam, max_index); } */ fp.close(); } }
rienheuver/face-antispoofing-LBP
src/Trainer.java
788
/** * Copyright (c) 2003-2017 The Apereo Foundation * * Licensed under the Educational Community License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://opensource.org/licenses/ecl2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.sakaiproject.sitemanage.impl.job; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import org.apache.commons.lang3.StringUtils; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.sakaiproject.authz.api.Member; import org.sakaiproject.authz.api.SecurityAdvisor; import org.sakaiproject.authz.api.SecurityService; import org.sakaiproject.component.api.ServerConfigurationService; import org.sakaiproject.content.api.ContentCollection; import org.sakaiproject.content.api.ContentCollectionEdit; import org.sakaiproject.content.api.ContentHostingService; import org.sakaiproject.content.api.ContentResourceEdit; import org.sakaiproject.conversations.api.ConversationsService; import org.sakaiproject.conversations.api.TopicType; import org.sakaiproject.conversations.api.beans.PostTransferBean; import org.sakaiproject.conversations.api.beans.TopicTransferBean; import org.sakaiproject.db.api.SqlService; import org.sakaiproject.entity.api.ResourceProperties; import org.sakaiproject.entity.api.ResourcePropertiesEdit; import org.sakaiproject.event.api.NotificationService; import org.sakaiproject.exception.IdInvalidException; import org.sakaiproject.exception.IdUnusedException; import org.sakaiproject.exception.IdUsedException; import org.sakaiproject.exception.InconsistentException; import org.sakaiproject.exception.PermissionException; import org.sakaiproject.exception.TypeException; import org.sakaiproject.grading.api.Assignment; import org.sakaiproject.grading.api.ConflictingAssignmentNameException; import org.sakaiproject.grading.api.GradingService; import org.sakaiproject.site.api.Site; import org.sakaiproject.site.api.SiteService; import org.sakaiproject.tool.api.Session; import org.sakaiproject.tool.api.SessionManager; import org.sakaiproject.user.api.User; import org.sakaiproject.user.api.UserAlreadyDefinedException; import org.sakaiproject.user.api.UserDirectoryService; import org.sakaiproject.user.api.UserIdInvalidException; import org.sakaiproject.user.api.UserPermissionException; import com.github.javafaker.Faker; import lombok.Setter; import lombok.extern.slf4j.Slf4j; /** * <p> * This job will create a default number of sites, students, instructors. It will then enroll * all instructors to each site and randomly enroll students to each site. * </p> * <p> * Finally it will randomly create text documents and add them randomly to the newly created * sites. * </p> * * @author Earle Nietzel ([email protected]) * @author John Bush ([email protected]) * */ @Slf4j public class SeedSitesAndUsersJob implements Job { @Setter private ServerConfigurationService serverConfigurationService; @Setter private UserDirectoryService userDirectoryService; @Setter private SiteService siteService; @Setter private SecurityAdvisor securityAdvisor; @Setter private SecurityService securityService; @Setter private SessionManager sessionManager; @Setter private ContentHostingService contentHostingService; @Setter private SqlService sqlService; @Setter private GradingService gradingService; @Setter private ConversationsService conversationsService; private int numberOfSites; private int numberOfStudents; private int numberOfEnnrollmentsPerSite; private int numberOfInstructorsPerSite; private int numberOfGradebookItems; private int numberOfConversationsQuestions; private int numberOfConversationsPosts; private String emailDomain; private boolean useEidAsPassword; private long repositorySize; private final Faker faker = new Faker(); private final Random randomGenerator = new Random(); private Map<String, User> students; private Map<String, User> instructors; private Map<String, Site> sites; public void init() { numberOfSites = serverConfigurationService.getInt("site.seed.create.sites", 5); numberOfStudents = serverConfigurationService.getInt("site.seed.create.students", 100); numberOfEnnrollmentsPerSite = serverConfigurationService.getInt("site.seed.enrollments.per.site", 50); numberOfInstructorsPerSite = serverConfigurationService.getInt("site.seed.instructors.per.site", 1); numberOfGradebookItems = serverConfigurationService.getInt("site.seed.create.gradebookitems", 10); numberOfConversationsQuestions = serverConfigurationService.getInt("site.seed.create.conversations.questions", 10); numberOfConversationsPosts = serverConfigurationService.getInt("site.seed.create.conversations.posts", 5); emailDomain = serverConfigurationService.getString("site.seed.email.domain", "mailinator.com"); useEidAsPassword = serverConfigurationService.getBoolean("site.seed.eid.password", false); try { repositorySize = Long.parseLong(serverConfigurationService.getString("site.seed.repository.size", "10485760")); } catch (NumberFormatException nfe) { repositorySize = 10485760L; } // Create our security advisor. securityAdvisor = (userId, function, reference) -> SecurityAdvisor.SecurityAdvice.ALLOWED; } private void seedData() { long totalBytes = 0; while (totalBytes < repositorySize) { log.info("current repository size: {}", totalBytes); Site site = getRandomSite(); String collectionName = getCollectionName(site); ContentCollection collection = null; try { collection = contentHostingService.getCollection(collectionName); } catch (IdUnusedException e) { collection = createCollection(collectionName); contentHostingService.commitCollection((ContentCollectionEdit) collection); } catch (TypeException te) { log.error("wrong collection type: ", te); } catch (PermissionException pe) { log.error("collection permission: ", pe); } if (collection != null) { // 5k paragraphs works out to on average docs around 1/2 MB in size byte[] rawFile = // StringUtils.join(faker.paragraphs(randomGenerator.nextInt(5000)), "\n\n").getBytes(); byte[] rawFile = StringUtils.join(faker.lorem().paragraphs(randomGenerator.nextInt(500)), "\n\n").getBytes(); String fileName = StringUtils.join(faker.lorem().words(4), "-") + "_" + randomGenerator.nextInt(5000); try { ContentResourceEdit resourceEdit = contentHostingService.addResource(collectionName + fileName + ".txt"); ResourcePropertiesEdit props = resourceEdit.getPropertiesEdit(); props.addProperty(ResourceProperties.PROP_DISPLAY_NAME, fileName); props.addProperty(ResourceProperties.PROP_DESCRIPTION, "created for testing"); props.addProperty(ResourceProperties.PROP_PUBVIEW, "false"); resourceEdit.setContent(rawFile); resourceEdit.setContentType("text/plain"); contentHostingService.commitResource(resourceEdit, NotificationService.NOTI_NONE); } catch (Exception e) { log.error("cannot add resource: {}{}.txt", collectionName, fileName, e); } totalBytes += rawFile.length; } else { log.error("could not get collection: {}", collectionName); break; } } } private void addGradebookItems() { for (Site site : sites.values()) { String siteId = site.getId(); for (int i = 0;i < numberOfGradebookItems;i++) { Assignment ass = new Assignment(); String name = "Item " + i; try { ass.setName(name); ass.setPoints(100D); Long aid = gradingService.addAssignment(siteId, ass); for (Member m : site.getMembers()) { gradingService.saveGradeAndCommentForStudent(siteId, aid, m.getUserId(), Integer.toString(randomGenerator.nextInt(101)), faker.lorem().sentence(10)); } if (i % 10 == 0) { log.info("Created {} gradebook items", i); } } catch (ConflictingAssignmentNameException cane) { // Don't know why this can happen. Transaction related, perhaps. Not // that important, anyway. log.warn("Failed to set gb item name to: {}", name); } } } } private void addConversationsPosts() { for (Site site : sites.values()) { String siteId = site.getId(); for (int i = 0; i < numberOfConversationsQuestions; i++) { TopicTransferBean topicBean = new TopicTransferBean(); topicBean.type = TopicType.QUESTION.name(); topicBean.siteId = siteId; topicBean.title = site.getTitle() + ": Question " + (i + 1); topicBean.message = "This is test topic " + (i + 1) + "for site " + siteId; try { topicBean = conversationsService.saveTopic(topicBean, false); for (int j = 0; j < numberOfConversationsPosts; j++) { PostTransferBean postBean = new PostTransferBean(); postBean.topic = topicBean.id; postBean.siteId = siteId; postBean.message = "Post " + (j + 1); conversationsService.savePost(postBean, false); } } catch (Exception e) { log.error("Failed to create topics and posts in conversations: {}", e, e); } } } } private long getSizeOfResources() { StringBuilder sb = new StringBuilder(); for (Site site : sites.values()) { if (sb.length() > 0) { sb.append(","); } sb.append("'").append(site.getId()).append("'"); } return new SizeOfResourcesQuery(sb.toString()).run().returnResult(); } private Site getRandomSite() { String[] siteIds = sites.keySet().toArray(new String[] {}); String siteId = siteIds[randomGenerator.nextInt(siteIds.length - 1)]; return sites.get(siteId); } private ContentCollectionEdit createCollection(String collectionName) { ContentCollectionEdit collectionEdit = null; try { collectionEdit = contentHostingService.addCollection(collectionName); collectionEdit.getPropertiesEdit().addProperty(ResourceProperties.PROP_DISPLAY_NAME, "searchdata"); } catch (IdUsedException iue) { log.error("existing collection: ", iue); } catch (IdInvalidException iie) { log.error("invalid collection id: ", iie); } catch (PermissionException pe) { log.error("collection permission: ", pe); } catch (InconsistentException ie) { log.error("collection inconsistent: ", ie); } return collectionEdit; } private String getCollectionName(Site site) { return "/group/" + site.getId() + "/searchdata/"; } private void createSites() throws PermissionException, IdInvalidException, IdUsedException, IdUnusedException { for (long i = 0; i < numberOfSites; i++) { try { createSite(faker.bothify("????_###?_####").toUpperCase(), "course"); } catch (IdUsedException e) { createSite(faker.bothify("????_###?_####").toUpperCase(), "course"); } } } private void createSite(String title, String type) throws IdInvalidException, IdUsedException, PermissionException, IdUnusedException { Site site = siteService.addSite(title, type); site.setPublished(true); site.setTitle(title); site.addPage().addTool("sakai.search"); site.addPage().addTool("sakai.resources"); site.addPage().addTool("sakai.siteinfo"); site.addPage().addTool("sakai.gradebookng"); site.addPage().addTool("sakai.conversations"); siteService.save(site); sites.put(site.getId(), site); log.info("created site: {}", site.getId()); } private void createStudents() { for (long i = 1; i <= numberOfStudents; i++) { User user = createUser("registered"); if (user != null) { students.put(user.getEid(), user); } if (i % 100 == 0) { log.info("created {} random student accounts", i); } } } private void createInstructors() { for (long i = 0; i < numberOfInstructorsPerSite; i++) { User user = createUser("maintain"); if (user != null) { instructors.put(user.getEid(), user); } } } private User createUser(String userType) { User user = null; String lastName = faker.name().lastName(); String eid = faker.numerify("#########"); String password = useEidAsPassword ? eid : faker.letterify("???????"); try { user = userDirectoryService.addUser(null, eid, faker.name().firstName(), lastName, eid + "@" + emailDomain, password, userType, null); } catch (UserIdInvalidException uiue) { log.error("invalid userId: ", uiue); } catch (UserAlreadyDefinedException uade) { log.error("already exists: ", uade); user = createUser(userType); } catch (UserPermissionException upe) { log.error("permission: ", upe); } return user; } private void createEnrollments() { for (String siteId : sites.keySet()) { Site site = sites.get(siteId); Set<String> enrollments = getRandomUsers(students.keySet()); for (String enrollment : enrollments) { User user = students.get(enrollment); site.addMember(user.getId(), "Student", true, false); } for (User instructor : instructors.values()) { site.addMember(instructor.getId(), "Instructor", true, false); } try { siteService.save(site); } catch (IdUnusedException iue) { log.error("site doesn't exist:", iue); } catch (PermissionException pe) { log.error("site save permission:", pe); } } } private Set<String> getRandomUsers(Set<String> pool) { if (pool.size() <= numberOfEnnrollmentsPerSite) { return pool; } List<String> randomizedPool = new ArrayList<>(pool); Collections.shuffle(randomizedPool, randomGenerator); return new HashSet<>(randomizedPool.subList(0, numberOfEnnrollmentsPerSite)); } @Override public void execute(JobExecutionContext context) throws JobExecutionException { log.info("SeedSitesAndUsersJob started."); students = new HashMap<>(); instructors = new HashMap<>(); sites = new HashMap<>(); Session session = sessionManager.getCurrentSession(); String currentUser = session.getUserId(); session.setUserId("admin"); session.setUserEid("admin"); securityService.pushAdvisor(securityAdvisor); try { createSites(); createInstructors(); createStudents(); createEnrollments(); addGradebookItems(); addConversationsPosts(); seedData(); } catch (Exception e) { log.error("executing job: ", e); } securityService.popAdvisor(securityAdvisor); session.setUserId(currentUser); session.setUserEid(currentUser); students = null; instructors = null; sites = null; log.info("SeedSitesAndUsersJob completed."); } abstract class Query<T> { Connection connection; PreparedStatement statement; ResultSet result; String sql; public Query(String sql) { this.sql = sql; } Query<T> run() { try { connection = sqlService.borrowConnection(); statement = connection.prepareStatement(sql); result = statement.executeQuery(); processResult(); } catch (Exception e) { log.error("Query.run, running query: ", e); } finally { if (result != null) { try { result.close(); } catch (SQLException e) { log.error("Query.run, releasing result: ", e); } } if (statement != null) { try { statement.close(); } catch (SQLException e) { log.error("Query.run, closing statement: ", e); } } if (connection != null) { try { connection.close(); } catch (SQLException e) { log.error("Query.run, closing connection: ", e); } } } return this; } abstract void processResult() throws SQLException; abstract T returnResult(); } class RandomSiteQuery extends Query<Site> { Site site; public RandomSiteQuery(String sql) { super("SELECT SITE_ID FROM sakai_site where TYPE = '" + sql + "' ORDER BY RAND() LIMIT 1"); } @Override public void processResult() throws SQLException { while (result.next()) { String siteId = result.getString(1); try { site = siteService.getSite(siteId); } catch (IdUnusedException e) { log.warn("RandomSiteQuery.processResult, No sites found", e); } } } @Override Site returnResult() { return site; } } class SizeOfResourcesQuery extends Query<Long> { Long size; public SizeOfResourcesQuery(String sql) { super("SELECT SUM(cr.FILE_SIZE) FROM content_resource cr JOIN sakai_site ss on (cr.CONTEXT = ss.SITE_ID) where ss.SITE_ID IN (" + sql + ")"); } @Override void processResult() throws SQLException { if (result.next()) { size = result.getLong(1); } } @Override Long returnResult() { return size; } } class CountSitesQuery extends Query<Long> { Long size; public CountSitesQuery(String sql) { super("SELECT SUM(cr.FILE_SIZE) FROM content_resource cr JOIN sakai_site ss on (cr.CONTEXT = ss.SITE_ID) where ss.TYPE IN (" + sql + ")"); } @Override void processResult() throws SQLException { if (result.next()) { size = result.getLong(1); } } @Override Long returnResult() { return size; } } class CountUsersQuery extends Query<Long> { Long count; public CountUsersQuery(String sql) { super("select COUNT(USER_ID) FROM sakai_user WHERE TYPE IN (" + sql + ")"); } @Override void processResult() throws SQLException { if (result.next()) { count = result.getLong(1); } } @Override Long returnResult() { return count; } } }
sakaiproject/sakai
site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/job/SeedSitesAndUsersJob.java
789
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 11 "Parser.y" package decaf.frontend; import decaf.tree.Tree; import decaf.tree.Tree.*; import decaf.error.*; import java.util.*; //#line 25 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short VOID=257; public final static short BOOL=258; public final static short INT=259; public final static short STRING=260; public final static short CLASS=261; public final static short NULL=262; public final static short EXTENDS=263; public final static short THIS=264; public final static short WHILE=265; public final static short FOR=266; public final static short IF=267; public final static short ELSE=268; public final static short RETURN=269; public final static short BREAK=270; public final static short NEW=271; public final static short PRINT=272; public final static short READ_INTEGER=273; public final static short READ_LINE=274; public final static short LITERAL=275; public final static short IDENTIFIER=276; public final static short AND=277; public final static short OR=278; public final static short STATIC=279; public final static short INSTANCEOF=280; public final static short LESS_EQUAL=281; public final static short GREATER_EQUAL=282; public final static short EQUAL=283; public final static short NOT_EQUAL=284; public final static short MIN_CP=285; public final static short SWITCH=286; public final static short CASE=287; public final static short DEFAULT=288; public final static short REPEAT=289; public final static short UNTIL=290; public final static short CONTINUE=291; public final static short PCLONE=292; public final static short UMINUS=293; public final static short EMPTY=294; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 4, 5, 5, 5, 5, 5, 5, 2, 6, 6, 7, 7, 7, 9, 9, 10, 10, 8, 8, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 27, 27, 24, 24, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 29, 29, 28, 28, 30, 30, 16, 17, 22, 23, 15, 18, 32, 32, 34, 33, 33, 19, 31, 31, 20, 20, 21, }; final static short yylen[] = { 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 6, 2, 0, 2, 2, 0, 1, 0, 3, 1, 7, 6, 3, 2, 0, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 3, 1, 0, 2, 0, 2, 4, 5, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 4, 5, 6, 5, 5, 3, 1, 1, 1, 0, 3, 1, 5, 9, 1, 1, 6, 8, 2, 0, 4, 3, 0, 6, 2, 0, 2, 1, 4, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 2, 0, 0, 13, 17, 0, 7, 8, 6, 9, 0, 0, 12, 15, 0, 0, 16, 10, 0, 4, 0, 0, 0, 0, 11, 0, 21, 0, 0, 0, 0, 5, 0, 0, 0, 26, 23, 20, 22, 0, 76, 68, 0, 0, 0, 0, 83, 0, 0, 0, 0, 75, 0, 0, 26, 84, 0, 0, 0, 24, 27, 38, 25, 0, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 33, 34, 35, 36, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 67, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 97, 0, 0, 0, 0, 45, 0, 0, 0, 81, 0, 0, 70, 0, 0, 88, 0, 72, 0, 46, 0, 0, 85, 71, 0, 92, 0, 93, 0, 0, 0, 87, 0, 0, 26, 86, 82, 26, 0, 0, }; final static short yydgoto[] = { 2, 3, 4, 66, 20, 33, 8, 11, 22, 34, 35, 67, 45, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 87, 80, 89, 82, 172, 83, 133, 187, 189, 195, 196, }; final static short yysindex[] = { -228, -224, 0, -228, 0, -219, 0, -214, -66, 0, 0, -91, 0, 0, 0, 0, -209, -120, 0, 0, 12, -85, 0, 0, -83, 0, 41, -10, 46, -120, 0, -120, 0, -80, 47, 45, 50, 0, -28, -120, -28, 0, 0, 0, 0, 2, 0, 0, 53, 57, 58, 871, 0, -46, 59, 60, 63, 0, 64, 67, 0, 0, 871, 871, 810, 0, 0, 0, 0, 52, 0, 0, 0, 0, 55, 62, 76, 83, 84, 48, 740, 0, -154, 0, 871, 871, 871, 0, 740, 0, 86, 32, 871, 103, 111, 871, 871, 37, -30, -30, -123, 477, 0, 0, 0, 0, 0, 0, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 0, 871, 871, 871, 122, 489, 95, 513, 124, 1022, 740, -3, 0, 0, 540, 552, 123, 130, 0, 740, 998, 948, 73, 73, 1049, 1049, -22, -22, -30, -30, -30, 73, 73, 564, 576, 3, 871, 72, 871, 72, 0, 650, 871, 0, -95, 69, 871, 871, 0, 871, 134, 138, 0, 674, -78, 0, 740, 157, 0, 824, 0, 740, 0, 871, 72, 0, 0, -208, 0, 158, 0, -232, 145, 81, 0, 72, 150, 0, 0, 0, 0, 72, 72, }; final static short yyrindex[] = { 0, 0, 0, 209, 0, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 176, 0, 176, 0, 0, 0, 177, 0, 0, 0, 0, 0, 0, 0, 0, 0, -56, 0, 0, 0, 0, 0, -54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, -55, -55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 846, 0, 447, 0, 0, -55, -56, -55, 0, 164, 0, 0, 0, -55, 0, 0, -55, -55, -56, 114, 142, 0, 0, 0, 0, 0, 0, 0, 0, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, 0, -55, -55, -55, 87, 0, 0, 0, 0, -55, 10, 0, 0, 0, 0, 0, 0, 0, 0, -20, -27, 975, 705, 918, 43, 625, 881, 905, 370, 394, 423, 943, 968, 0, 0, -40, -32, -56, -55, -56, 0, 0, -55, 0, 0, 0, -55, -55, 0, -55, 0, 205, 0, 0, -33, 0, 31, 0, 0, 0, 0, 15, 0, -31, -56, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, -56, 0, 0, 0, 0, 0, -57, 224, }; final static short yygindex[] = { 0, 0, 245, 238, -2, 11, 0, 0, 0, 239, 0, 38, -5, -101, -72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1052, 1241, 1115, 0, 0, 96, 121, 0, 0, 0, 0, }; final static int YYTABLESIZE=1412; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 94, 74, 41, 41, 74, 96, 27, 94, 27, 78, 41, 27, 94, 128, 61, 119, 122, 61, 74, 74, 117, 39, 21, 74, 122, 118, 94, 32, 24, 32, 46, 61, 61, 1, 18, 63, 61, 43, 165, 39, 119, 164, 64, 57, 7, 117, 115, 62, 116, 122, 118, 80, 5, 74, 80, 97, 73, 10, 174, 73, 176, 123, 9, 121, 91, 120, 61, 23, 90, 123, 63, 25, 79, 73, 73, 79, 42, 64, 44, 193, 194, 29, 62, 30, 55, 192, 31, 55, 38, 39, 94, 40, 94, 84, 123, 41, 201, 85, 86, 92, 93, 55, 55, 94, 95, 63, 55, 96, 73, 108, 119, 102, 64, 191, 103, 117, 115, 62, 116, 122, 118, 104, 126, 131, 44, 41, 130, 65, 44, 44, 44, 44, 44, 44, 44, 105, 55, 12, 13, 14, 15, 16, 106, 107, 134, 44, 44, 44, 44, 44, 44, 64, 135, 139, 160, 64, 64, 64, 64, 64, 41, 64, 158, 168, 123, 162, 12, 13, 14, 15, 16, 169, 64, 64, 64, 184, 64, 64, 44, 65, 44, 179, 164, 65, 65, 65, 65, 65, 17, 65, 186, 26, 180, 28, 203, 41, 37, 204, 188, 197, 65, 65, 65, 199, 65, 65, 200, 64, 202, 1, 5, 12, 13, 14, 15, 16, 14, 19, 18, 43, 43, 43, 43, 95, 94, 94, 94, 94, 94, 94, 90, 94, 94, 94, 94, 65, 94, 94, 94, 94, 94, 94, 94, 94, 43, 43, 77, 94, 6, 19, 61, 61, 74, 94, 94, 94, 94, 94, 94, 12, 13, 14, 15, 16, 46, 61, 47, 48, 49, 50, 36, 51, 52, 53, 54, 55, 56, 57, 91, 173, 109, 110, 58, 41, 111, 112, 113, 114, 59, 198, 0, 60, 0, 61, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 0, 0, 55, 55, 0, 59, 0, 0, 60, 138, 61, 12, 13, 14, 15, 16, 46, 55, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 89, 0, 0, 58, 0, 0, 0, 0, 0, 59, 0, 0, 60, 0, 61, 44, 44, 0, 0, 44, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 0, 0, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 64, 52, 0, 0, 0, 52, 52, 52, 52, 52, 0, 52, 0, 65, 65, 0, 0, 65, 65, 65, 65, 0, 52, 52, 52, 53, 52, 52, 65, 53, 53, 53, 53, 53, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 53, 53, 0, 53, 53, 0, 0, 54, 0, 0, 52, 54, 54, 54, 54, 54, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, 48, 54, 54, 53, 40, 48, 48, 0, 48, 48, 48, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 40, 48, 0, 48, 48, 89, 89, 0, 119, 0, 54, 0, 140, 117, 115, 0, 116, 122, 118, 0, 119, 0, 0, 0, 159, 117, 115, 0, 116, 122, 118, 121, 48, 120, 124, 0, 0, 0, 0, 0, 0, 0, 0, 121, 119, 120, 124, 0, 161, 117, 115, 0, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 121, 0, 120, 124, 119, 0, 0, 123, 0, 117, 115, 166, 116, 122, 118, 0, 119, 0, 0, 0, 167, 117, 115, 0, 116, 122, 118, 121, 119, 120, 124, 123, 0, 117, 115, 0, 116, 122, 118, 121, 119, 120, 124, 0, 0, 117, 115, 0, 116, 122, 118, 121, 0, 120, 124, 0, 0, 0, 123, 0, 0, 171, 0, 121, 0, 120, 124, 0, 0, 0, 123, 0, 0, 0, 52, 52, 0, 0, 52, 52, 52, 52, 123, 0, 170, 0, 0, 0, 0, 52, 0, 0, 0, 56, 123, 0, 56, 0, 53, 53, 0, 0, 53, 53, 53, 53, 0, 0, 0, 0, 56, 56, 0, 53, 119, 56, 0, 0, 0, 117, 115, 0, 116, 122, 118, 0, 0, 54, 54, 0, 0, 54, 54, 54, 54, 0, 0, 121, 119, 120, 124, 0, 54, 117, 115, 56, 116, 122, 118, 0, 0, 48, 48, 0, 0, 48, 48, 48, 48, 0, 185, 121, 0, 120, 124, 0, 48, 0, 123, 0, 177, 0, 0, 59, 0, 0, 59, 0, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 0, 59, 59, 123, 109, 110, 59, 125, 111, 112, 113, 114, 0, 0, 0, 119, 0, 0, 0, 125, 117, 115, 0, 116, 122, 118, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 59, 0, 121, 0, 120, 124, 0, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 0, 0, 0, 0, 109, 110, 123, 125, 111, 112, 113, 114, 0, 0, 0, 0, 109, 110, 63, 125, 111, 112, 113, 114, 0, 64, 0, 0, 109, 110, 62, 125, 111, 112, 113, 114, 119, 0, 0, 0, 190, 117, 115, 125, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 121, 0, 120, 124, 47, 47, 0, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 56, 56, 63, 0, 47, 0, 47, 47, 0, 64, 0, 0, 0, 123, 62, 56, 0, 0, 0, 0, 50, 0, 50, 50, 50, 109, 110, 0, 0, 111, 112, 113, 114, 0, 0, 47, 0, 50, 50, 50, 125, 50, 50, 0, 51, 0, 51, 51, 51, 109, 110, 0, 0, 111, 112, 113, 114, 60, 0, 0, 60, 51, 51, 51, 125, 51, 51, 0, 0, 0, 0, 0, 50, 0, 60, 60, 0, 0, 0, 60, 59, 59, 58, 119, 0, 58, 59, 59, 117, 115, 0, 116, 122, 118, 0, 59, 51, 0, 0, 58, 58, 0, 0, 0, 58, 0, 121, 57, 120, 60, 57, 0, 0, 0, 62, 109, 110, 62, 0, 111, 112, 113, 114, 0, 57, 57, 0, 0, 0, 57, 125, 62, 62, 119, 58, 0, 62, 123, 117, 115, 0, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 121, 0, 120, 57, 64, 0, 0, 0, 0, 62, 62, 0, 0, 100, 46, 0, 47, 0, 0, 0, 0, 0, 0, 53, 0, 55, 56, 57, 119, 0, 0, 123, 58, 117, 115, 0, 116, 122, 118, 79, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 121, 0, 120, 0, 0, 0, 30, 125, 0, 0, 0, 0, 0, 0, 47, 47, 0, 0, 47, 47, 47, 47, 0, 0, 46, 0, 47, 0, 79, 47, 0, 123, 0, 53, 0, 55, 56, 57, 0, 0, 79, 0, 58, 0, 0, 0, 0, 0, 0, 50, 50, 81, 0, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 51, 51, 0, 0, 51, 51, 51, 51, 0, 0, 0, 0, 0, 60, 60, 51, 0, 0, 81, 60, 60, 0, 0, 0, 0, 0, 0, 0, 60, 79, 81, 79, 0, 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, 109, 58, 58, 0, 111, 112, 113, 114, 0, 0, 58, 0, 79, 79, 0, 0, 0, 0, 0, 0, 57, 57, 0, 0, 79, 0, 57, 57, 62, 0, 79, 79, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 81, 0, 81, 0, 0, 111, 112, 113, 114, 0, 46, 0, 47, 0, 0, 0, 0, 0, 88, 53, 0, 55, 56, 57, 0, 0, 81, 81, 58, 98, 99, 101, 0, 0, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 81, 81, 0, 0, 0, 0, 0, 127, 0, 129, 0, 0, 111, 112, 0, 132, 0, 0, 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 0, 155, 156, 157, 0, 0, 0, 0, 0, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 0, 175, 0, 0, 0, 178, 0, 0, 0, 181, 182, 0, 183, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 41, 59, 59, 44, 59, 91, 40, 91, 41, 41, 91, 45, 85, 41, 37, 46, 44, 58, 59, 42, 41, 11, 63, 46, 47, 59, 29, 17, 31, 262, 58, 59, 261, 125, 33, 63, 39, 41, 59, 37, 44, 40, 275, 263, 42, 43, 45, 45, 46, 47, 41, 276, 93, 44, 60, 41, 123, 159, 44, 161, 91, 276, 60, 53, 62, 93, 276, 125, 91, 33, 59, 41, 58, 59, 44, 38, 40, 40, 287, 288, 40, 45, 93, 41, 186, 40, 44, 41, 44, 123, 41, 125, 40, 91, 123, 197, 40, 40, 40, 40, 58, 59, 40, 40, 33, 63, 40, 93, 61, 37, 59, 40, 185, 59, 42, 43, 45, 45, 46, 47, 59, 276, 91, 37, 123, 40, 125, 41, 42, 43, 44, 45, 46, 47, 59, 93, 257, 258, 259, 260, 261, 59, 59, 41, 58, 59, 60, 61, 62, 63, 37, 41, 276, 59, 41, 42, 43, 44, 45, 123, 47, 40, 40, 91, 41, 257, 258, 259, 260, 261, 41, 58, 59, 60, 41, 62, 63, 91, 37, 93, 276, 44, 41, 42, 43, 44, 45, 279, 47, 268, 276, 123, 276, 199, 123, 276, 202, 41, 41, 58, 59, 60, 58, 62, 63, 125, 93, 58, 0, 59, 257, 258, 259, 260, 261, 123, 41, 41, 276, 276, 276, 276, 59, 257, 258, 259, 260, 261, 262, 276, 264, 265, 266, 267, 93, 269, 270, 271, 272, 273, 274, 275, 276, 276, 276, 41, 280, 3, 11, 277, 278, 292, 286, 287, 288, 289, 290, 291, 257, 258, 259, 260, 261, 262, 292, 264, 265, 266, 267, 31, 269, 270, 271, 272, 273, 274, 275, 125, 158, 277, 278, 280, 59, 281, 282, 283, 284, 286, 193, -1, 289, -1, 291, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, -1, -1, 277, 278, -1, 286, -1, -1, 289, 290, 291, 257, 258, 259, 260, 261, 262, 292, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, 125, -1, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, 291, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 58, 59, 60, 37, 62, 63, 292, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 37, -1, -1, 93, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, 37, 62, 63, 93, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, 276, -1, -1, -1, -1, -1, 59, 60, -1, 62, 63, 287, 288, -1, 37, -1, 93, -1, 41, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 60, 91, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, 63, 37, -1, -1, 91, -1, 42, 43, 44, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, 91, -1, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, 58, -1, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 91, -1, 93, -1, -1, -1, -1, 292, -1, -1, -1, 41, 91, -1, 44, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, 58, 59, -1, 292, 37, 63, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 60, 37, 62, 63, -1, 292, 42, 43, 93, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 59, 60, -1, 62, 63, -1, 292, -1, 91, -1, 93, -1, -1, 41, -1, -1, 44, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 58, 59, 91, 277, 278, 63, 292, 281, 282, 283, 284, -1, -1, -1, 37, -1, -1, -1, 292, 42, 43, -1, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 93, -1, 60, -1, 62, 63, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, 277, 278, 91, 292, 281, 282, 283, 284, -1, -1, -1, -1, 277, 278, 33, 292, 281, 282, 283, 284, -1, 40, -1, -1, 277, 278, 45, 292, 281, 282, 283, 284, 37, -1, -1, -1, 41, 42, 43, 292, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, 60, -1, 62, 63, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, 33, -1, 60, -1, 62, 63, -1, 40, -1, -1, -1, 91, 45, 292, -1, -1, -1, -1, 41, -1, 43, 44, 45, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 91, -1, 58, 59, 60, 292, 62, 63, -1, 41, -1, 43, 44, 45, 277, 278, -1, -1, 281, 282, 283, 284, 41, -1, -1, 44, 58, 59, 60, 292, 62, 63, -1, -1, -1, -1, -1, 93, -1, 58, 59, -1, -1, -1, 63, 277, 278, 41, 37, -1, 44, 283, 284, 42, 43, -1, 45, 46, 47, -1, 292, 93, -1, -1, 58, 59, -1, -1, -1, 63, -1, 60, 41, 62, 93, 44, -1, -1, -1, 41, 277, 278, 44, -1, 281, 282, 283, 284, -1, 58, 59, -1, -1, -1, 63, 292, 58, 59, 37, 93, -1, 63, 91, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, 60, -1, 62, 93, 40, -1, -1, -1, -1, 45, 93, -1, -1, 261, 262, -1, 264, -1, -1, -1, -1, -1, -1, 271, -1, 273, 274, 275, 37, -1, -1, 91, 280, 42, 43, -1, 45, 46, 47, 45, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 60, -1, 62, -1, -1, -1, 93, 292, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 262, -1, 264, -1, 85, 292, -1, 91, -1, 271, -1, 273, 274, 275, -1, -1, 97, -1, 280, -1, -1, -1, -1, -1, -1, 277, 278, 45, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, 277, 278, 292, -1, -1, 85, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, 159, 97, 161, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 277, 283, 284, -1, 281, 282, 283, 284, -1, -1, 292, -1, 185, 186, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 197, -1, 283, 284, 278, -1, 203, 204, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, 159, -1, 161, -1, -1, 281, 282, 283, 284, -1, 262, -1, 264, -1, -1, -1, -1, -1, 51, 271, -1, 273, 274, 275, -1, -1, 185, 186, 280, 62, 63, 64, -1, -1, -1, -1, -1, -1, 197, -1, -1, -1, -1, -1, 203, 204, -1, -1, -1, -1, -1, 84, -1, 86, -1, -1, 281, 282, -1, 92, -1, -1, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, -1, 123, 124, 125, -1, -1, -1, -1, -1, 131, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 158, -1, 160, -1, -1, -1, 164, -1, -1, -1, 168, 169, -1, 171, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=294; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'","'?'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING", "CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK", "NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR", "STATIC","INSTANCEOF","LESS_EQUAL","GREATER_EQUAL","EQUAL","NOT_EQUAL","MIN_CP", "SWITCH","CASE","DEFAULT","REPEAT","UNTIL","CONTINUE","PCLONE","UMINUS","EMPTY", }; final static String yyrule[] = { "$accept : Program", "Program : ClassList", "ClassList : ClassList ClassDef", "ClassList : ClassDef", "VariableDef : Variable ';'", "Variable : Type IDENTIFIER", "Type : INT", "Type : VOID", "Type : BOOL", "Type : STRING", "Type : CLASS IDENTIFIER", "Type : Type '[' ']'", "ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'", "ExtendsClause : EXTENDS IDENTIFIER", "ExtendsClause :", "FieldList : FieldList VariableDef", "FieldList : FieldList FunctionDef", "FieldList :", "Formals : VariableList", "Formals :", "VariableList : VariableList ',' Variable", "VariableList : Variable", "FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock", "FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock", "StmtBlock : '{' StmtList '}'", "StmtList : StmtList Stmt", "StmtList :", "Stmt : VariableDef", "Stmt : SimpleStmt ';'", "Stmt : IfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "Stmt : SwitchStmt", "Stmt : RepeatStmt ';'", "Stmt : ReturnStmt ';'", "Stmt : PrintStmt ';'", "Stmt : BreakStmt ';'", "Stmt : ContinueStmt ';'", "Stmt : StmtBlock", "SimpleStmt : LValue '=' Expr", "SimpleStmt : Call", "SimpleStmt :", "Receiver : Expr '.'", "Receiver :", "LValue : Receiver IDENTIFIER", "LValue : Expr '[' Expr ']'", "Call : Receiver IDENTIFIER '(' Actuals ')'", "Expr : LValue", "Expr : Call", "Expr : Constant", "Expr : Expr '+' Expr", "Expr : Expr '-' Expr", "Expr : Expr '*' Expr", "Expr : Expr '/' Expr", "Expr : Expr '%' Expr", "Expr : Expr EQUAL Expr", "Expr : Expr NOT_EQUAL Expr", "Expr : Expr '<' Expr", "Expr : Expr '>' Expr", "Expr : Expr LESS_EQUAL Expr", "Expr : Expr GREATER_EQUAL Expr", "Expr : Expr AND Expr", "Expr : Expr OR Expr", "Expr : '(' Expr ')'", "Expr : '-' Expr", "Expr : '!' Expr", "Expr : READ_INTEGER '(' ')'", "Expr : READ_LINE '(' ')'", "Expr : THIS", "Expr : NEW IDENTIFIER '(' ')'", "Expr : NEW Type '[' Expr ']'", "Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'", "Expr : '(' CLASS IDENTIFIER ')' Expr", "Expr : Expr '?' Expr ':' Expr", "Expr : Expr PCLONE Expr", "Constant : LITERAL", "Constant : NULL", "Actuals : ExprList", "Actuals :", "ExprList : ExprList ',' Expr", "ExprList : Expr", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt", "BreakStmt : BREAK", "ContinueStmt : CONTINUE", "IfStmt : IF '(' Expr ')' Stmt ElseClause", "SwitchStmt : SWITCH '(' Expr ')' '{' CaseStmtList DefaultStmt '}'", "CaseStmtList : CaseStmtList CaseStmt", "CaseStmtList :", "CaseStmt : CASE Constant ':' StmtList", "DefaultStmt : DEFAULT ':' StmtList", "DefaultStmt :", "RepeatStmt : REPEAT StmtList UNTIL '(' Expr ')'", "ElseClause : ELSE Stmt", "ElseClause :", "ReturnStmt : RETURN Expr", "ReturnStmt : RETURN", "PrintStmt : PRINT '(' ExprList ')'", }; //#line 486 "Parser.y" /** * 打印当前归约所用的语法规则<br> * 请勿修改。 */ public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 694 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 59 "Parser.y" { tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc); } break; case 2: //#line 65 "Parser.y" { yyval.clist.add(val_peek(0).cdef); } break; case 3: //#line 69 "Parser.y" { yyval.clist = new ArrayList<Tree.ClassDef>(); yyval.clist.add(val_peek(0).cdef); } break; case 5: //#line 79 "Parser.y" { yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc); } break; case 6: //#line 85 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc); } break; case 7: //#line 89 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc); } break; case 8: //#line 93 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc); } break; case 9: //#line 97 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc); } break; case 10: //#line 101 "Parser.y" { yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc); } break; case 11: //#line 105 "Parser.y" { yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc); } break; case 12: //#line 111 "Parser.y" { yyval.cdef = new Tree.ClassDef(val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc); } break; case 13: //#line 117 "Parser.y" { yyval.ident = val_peek(0).ident; } break; case 14: //#line 121 "Parser.y" { yyval = new SemValue(); } break; case 15: //#line 127 "Parser.y" { yyval.flist.add(val_peek(0).vdef); } break; case 16: //#line 131 "Parser.y" { yyval.flist.add(val_peek(0).fdef); } break; case 17: //#line 135 "Parser.y" { yyval = new SemValue(); yyval.flist = new ArrayList<Tree>(); } break; case 19: //#line 143 "Parser.y" { yyval = new SemValue(); yyval.vlist = new ArrayList<Tree.VarDef>(); } break; case 20: //#line 150 "Parser.y" { yyval.vlist.add(val_peek(0).vdef); } break; case 21: //#line 154 "Parser.y" { yyval.vlist = new ArrayList<Tree.VarDef>(); yyval.vlist.add(val_peek(0).vdef); } break; case 22: //#line 161 "Parser.y" { yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 23: //#line 165 "Parser.y" { yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 24: //#line 171 "Parser.y" { yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc); } break; case 25: //#line 177 "Parser.y" { yyval.slist.add(val_peek(0).stmt); } break; case 26: //#line 181 "Parser.y" { yyval = new SemValue(); yyval.slist = new ArrayList<Tree>(); } break; case 27: //#line 188 "Parser.y" { yyval.stmt = val_peek(0).vdef; } break; case 28: //#line 193 "Parser.y" { if (yyval.stmt == null) { yyval.stmt = new Tree.Skip(val_peek(0).loc); } } break; case 39: //#line 211 "Parser.y" { yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc); } break; case 40: //#line 215 "Parser.y" { yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc); } break; case 41: //#line 219 "Parser.y" { yyval = new SemValue(); } break; case 43: //#line 226 "Parser.y" { yyval = new SemValue(); } break; case 44: //#line 232 "Parser.y" { yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc); if (val_peek(1).loc == null) { yyval.loc = val_peek(0).loc; } } break; case 45: //#line 239 "Parser.y" { yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc); } break; case 46: //#line 245 "Parser.y" { yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc); if (val_peek(4).loc == null) { yyval.loc = val_peek(3).loc; } } break; case 47: //#line 254 "Parser.y" { yyval.expr = val_peek(0).lvalue; } break; case 50: //#line 260 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 51: //#line 264 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 52: //#line 268 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 53: //#line 272 "Parser.y" { yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 54: //#line 276 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 55: //#line 280 "Parser.y" { yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 56: //#line 284 "Parser.y" { yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 57: //#line 288 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 58: //#line 292 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 59: //#line 296 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 60: //#line 300 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 61: //#line 304 "Parser.y" { yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 62: //#line 308 "Parser.y" { yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 63: //#line 312 "Parser.y" { yyval = val_peek(1); } break; case 64: //#line 316 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc); } break; case 65: //#line 320 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc); } break; case 66: //#line 324 "Parser.y" { yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc); } break; case 67: //#line 328 "Parser.y" { yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc); } break; case 68: //#line 332 "Parser.y" { yyval.expr = new Tree.ThisExpr(val_peek(0).loc); } break; case 69: //#line 336 "Parser.y" { yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc); } break; case 70: //#line 340 "Parser.y" { yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc); } break; case 71: //#line 344 "Parser.y" { yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc); } break; case 72: //#line 348 "Parser.y" { yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc); } break; case 73: //#line 352 "Parser.y" { yyval.expr = new Tree.Ternary(Tree.CONDEXPR, val_peek(4).expr, val_peek(2).expr, val_peek(0).expr, val_peek(3).loc); } break; case 74: //#line 356 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PCLONE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 75: //#line 362 "Parser.y" { yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc); } break; case 76: //#line 366 "Parser.y" { yyval.expr = new Null(val_peek(0).loc); } break; case 78: //#line 373 "Parser.y" { yyval = new SemValue(); yyval.elist = new ArrayList<Tree.Expr>(); } break; case 79: //#line 380 "Parser.y" { yyval.elist.add(val_peek(0).expr); } break; case 80: //#line 384 "Parser.y" { yyval.elist = new ArrayList<Tree.Expr>(); yyval.elist.add(val_peek(0).expr); } break; case 81: //#line 391 "Parser.y" { yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc); } break; case 82: //#line 397 "Parser.y" { yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc); } break; case 83: //#line 403 "Parser.y" { yyval.stmt = new Tree.Break(val_peek(0).loc); } break; case 84: //#line 409 "Parser.y" { yyval.stmt = new Tree.Continue(val_peek(0).loc); } break; case 85: //#line 415 "Parser.y" { yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc); } break; case 86: //#line 421 "Parser.y" { yyval.stmt = new Tree.Switch(val_peek(5).expr, val_peek(2).caselist, val_peek(1).slist, val_peek(7).loc); } break; case 87: //#line 427 "Parser.y" { yyval.caselist.add(val_peek(0).casedef); } break; case 88: //#line 431 "Parser.y" { yyval = new SemValue(); yyval.caselist = new ArrayList<Case>(); } break; case 89: //#line 438 "Parser.y" { yyval.casedef = new Tree.Case(val_peek(2).expr, val_peek(0).slist, val_peek(3).loc); } break; case 90: //#line 444 "Parser.y" { yyval.slist = val_peek(0).slist; } break; case 91: //#line 448 "Parser.y" { yyval = new SemValue(); } break; case 92: //#line 454 "Parser.y" { yyval.stmt = new Tree.Repeat(val_peek(1).expr, new Tree.Block(val_peek(4).slist, val_peek(5).loc), val_peek(5).loc); } break; case 93: //#line 460 "Parser.y" { yyval.stmt = val_peek(0).stmt; } break; case 94: //#line 464 "Parser.y" { yyval = new SemValue(); } break; case 95: //#line 470 "Parser.y" { yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc); } break; case 96: //#line 474 "Parser.y" { yyval.stmt = new Tree.Return(null, val_peek(0).loc); } break; case 97: //#line 480 "Parser.y" { yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc); } break; //#line 1342 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
stellarkey/912_project
6 复试/2 笔试/4 编译原理/hw/2016_黄家晖_PA/20603895_3_decaf_PA2/src/decaf/frontend/Parser.java
790
/* This file is part of Juggluco, an Android app to receive and display */ /* glucose values from Freestyle Libre 2 and 3 sensors. */ /* */ /* Copyright (C) 2021 Jaap Korthals Altes <[email protected]> */ /* */ /* Juggluco is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published */ /* by the Free Software Foundation, either version 3 of the License, or */ /* (at your option) any later version. */ /* */ /* Juggluco is distributed in the hope that it will be useful, but */ /* WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* See the GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with Juggluco. If not, see <https://www.gnu.org/licenses/>. */ /* */ /* Fri Jan 27 15:31:05 CET 2023 */ package tk.glucodata; /* long[] constatchange={0L,0L}; int constatstatus=-1; long[] wrotepass={0L,0L}; long[] charcha={0L,0L}; @Override public void onCharacteristicChanged(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic bluetoothGattCharacteristic) { Last success: Last failure: Fail Info */ import android.app.Activity; import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothManager; import android.content.Context; import android.content.DialogInterface; import android.graphics.Paint; import android.os.Build; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.Button; import android.widget.CheckBox; import android.widget.HorizontalScrollView; import android.widget.Spinner; import android.widget.TextView; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.concurrent.TimeUnit; import static android.bluetooth.BluetoothGatt.CONNECTION_PRIORITY_BALANCED; import static android.bluetooth.BluetoothGatt.CONNECTION_PRIORITY_HIGH; import static android.graphics.Color.BLACK; import static android.graphics.Color.BLUE; import static android.graphics.Color.RED; import static android.graphics.Color.WHITE; import static android.graphics.Color.YELLOW; import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static tk.glucodata.Applic.isWearable; import static tk.glucodata.NumberView.avoidSpinnerDropdownFocus; import static tk.glucodata.help.help; import static tk.glucodata.settings.Settings.removeContentView; class bluediag { static boolean returntoblue=false; final static private String LOG_ID="bluediag"; private static final DateFormat fname= new SimpleDateFormat("MM-dd HH:mm:ss", Locale.US ); public static String datestr(long tim) { return fname.format(tim); } //View view ; //int selected=0; RangeAdapter<SuperGattCallback> adap; Spinner spin=null; TextView[] contimes; TextView constatus; TextView streaming; TextView address; TextView starttimeV; TextView rssiview; Button forget; //Button reenable; Button info; void setrow(long[] times, TextView[] timeviews, TextView info) { for(int i=0;i<2;i++) { long tim= times[i]; TextView text= timeviews[i]; if(tim!=0L) { text.setText(datestr(tim)); if(tim<times[(~i)&1]) { text.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); if(i==1) info.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { text.setPaintFlags(text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); if(i==1) info.setPaintFlags(text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); } } else { text.setText(""); } } } public static void showsensorinfo(String text,MainActivity act) { help.basehelp(text,act,xzy->{ }, (l,w,h)-> { var height=GlucoseCurve.getheight(); var width=GlucoseCurve.getwidth(); if(height>h) l.setY((height-h)/2); if(width>w) l.setX((width-w)/2); return new int[] {w,h}; }, new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); } void showinfo(final SuperGattCallback gatt,MainActivity act) { starttimeV.setText(datestr(gatt.starttime)); if(gatt.streamingEnabled() ) streaming.setText(R.string.streamingenabled); else streaming.setText(R.string.streamingnotenabled); // var visi=gatt.sensorgen==3?INVISIBLE:VISIBLE; final int rssi=gatt.readrssi; if(rssi<0) { rssiview.setText("Rssi = "+rssi); } else rssiview.setText(""); if(forget!=null) { // forget.setVisibility(visi); // if(gatt.sensorgen!=3) { forget.setOnClickListener(v-> { gatt.searchforDeviceAddress(); SensorBluetooth.startscan(); act.doonback(); new bluediag(act); }); } } address.setText(gatt.mActiveDeviceAddress == null?"Address unknown":gatt.mActiveDeviceAddress); if(gatt.sensorgen == 2) { // address.setBackgroundColor(RED); address.setTextColor(BLACK); address.setTextColor(RED); } else { // address.setBackgroundColor(BLUE); address.setTextColor(WHITE); address.setTextColor(YELLOW); } constatus.setText(gatt.constatstatus>=0?("Status="+gatt.constatstatus):""); setrow(gatt.constatchange,contimes,constatus); keyinfo.setText(gatt.handshake); setrow(gatt.wrotepass,keytimes,keyinfo); setrow(gatt.charcha,glucosetimes,glucoseinfo); Log.i(LOG_ID,"info.setVisibility(VISIBLE);"); info.setVisibility(VISIBLE); info.setOnClickListener(v-> showsensorinfo(gatt.getinfo(),(MainActivity) info.getContext())); } TextView[] keytimes; TextView keyinfo; TextView[] glucosetimes; TextView glucoseinfo; TextView bluestate; private BluetoothAdapter mBluetoothAdapter=null; //boolean setwakelock=false; CheckBox usebluetooth; boolean wasuse; CheckBox priority,streamhistory; Button locationpermission; TextView scanview; MainActivity activity; static private int gattselected=0; void confirmFinish(SuperGattCallback gat) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); String serial= gat.SerialNumber; builder.setTitle(serial). setMessage(R.string.finishsensormessage). setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { gat.finishSensor(); SensorBluetooth.sensorEnded(serial); activity.requestRender(); activity.doonback(); new bluediag(activity); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }).show().setCanceledOnTouchOutside(false); } void setadapter(Activity act, final ArrayList<SuperGattCallback> gatts) { adap = new RangeAdapter<>(gatts, act, gatt -> { if (gatt != null && gatt.SerialNumber != null) return gatt.SerialNumber; return "Error"; }); spin.setAdapter(adap); } bluediag(MainActivity act) { activity=act; BluetoothManager mBluetoothManager = (BluetoothManager) act.getSystemService(Context.BLUETOOTH_SERVICE); if(mBluetoothManager != null) { mBluetoothAdapter = mBluetoothManager.getAdapter(); if(mBluetoothAdapter ==null) { Log.e(LOG_ID,"mBluetoothManager.getAdapter()==null"); return; } } else { Log.e(LOG_ID,"act.getSystemService(Context.BLUETOOTH_SERVICE)==null"); return; } LayoutInflater flater= LayoutInflater.from(act); View view = flater.inflate(R.layout.bluesensor, null, false); forget=view.findViewById(R.id.forget); scanview=view.findViewById(R.id.scan); starttimeV=view.findViewById(R.id.stage); rssiview=view.findViewById(R.id.rssi); rssiview.setPadding(0,0,0,0); CheckBox android13=view.findViewById(R.id.android13); android13.setChecked( SuperGattCallback.autoconnect); android13.setOnCheckedChangeListener( (buttonView, isChecked) -> { SensorBluetooth.setAutoconnect(isChecked); }); info=view.findViewById(R.id.info); Log.i(LOG_ID,"info.setVisibility(INVISIBLE);"); info.setVisibility(INVISIBLE); int width2=GlucoseCurve.getwidth(); HorizontalScrollView addscroll2=null; if(isWearable) { HorizontalScrollView scroll= view.findViewById(R.id.background); scroll.setSmoothScrollingEnabled(false); scroll.setVerticalScrollBarEnabled(false); scroll.setHorizontalScrollBarEnabled(false); int height=GlucoseCurve.getheight(); scroll.setMinimumHeight(height); Log.i(LOG_ID,"height="+height); } else { measuredgrid grid=view.findViewById(R.id.grid); final var addscroll= new HorizontalScrollView(act); addscroll.addView(grid); addscroll.setSmoothScrollingEnabled(false); addscroll.setVerticalScrollBarEnabled(false); addscroll.setHorizontalScrollBarEnabled(false); int heightU=GlucoseCurve.getheight(); addscroll.setMinimumHeight(heightU); grid.setmeasure((l,w,h)-> { int height=GlucoseCurve.getheight(); int width=GlucoseCurve.getwidth(); int y= height>h?((height-h)/2):0; addscroll.setY(y); int x=(width>w)?((width-w)/2):0; addscroll.setX(x); }); addscroll2=addscroll; } View showview=addscroll2!=null?addscroll2:view; final ArrayList<SuperGattCallback> gatts=SensorBluetooth.mygatts(); priority=view.findViewById(R.id.priority); streamhistory=view.findViewById(R.id.streamhistory); if(!isWearable) { Button finish = view.findViewById(R.id.finish); if (gatts != null && gatts.size() > 0) { finish.setOnClickListener(v -> { if (gatts != null && gatts.size() > 0) { if (gattselected >= gatts.size()) { Log.i(LOG_ID, "show: gattselected=" + gattselected); gattselected = 0; return; } var gat = gatts.get(gattselected); confirmFinish(gat); } }); } else { Log.i(LOG_ID,"finish.setVisibility(GONE);"); finish.setVisibility(GONE); } } if (gatts == null || gatts.size()== 0) { priority.setVisibility(GONE); forget.setVisibility(GONE); } if(!Natives.getusebluetooth()) { streamhistory.setVisibility(GONE); } contimes=new TextView[]{view.findViewById(R.id.consuccess) , view.findViewById(R.id.confail)}; constatus=view.findViewById(R.id.constatus); constatus.setTextIsSelectable(true); streaming=view.findViewById(R.id.streaming); address=view.findViewById(R.id.deviceaddress); keytimes=new TextView[]{view.findViewById(R.id.keysuccess) , view.findViewById(R.id.keyfailure)}; keyinfo=view.findViewById(R.id.keyinfo); keyinfo.setTextIsSelectable(true); glucosetimes=new TextView[]{view.findViewById(R.id.glucosesuccess) , view.findViewById(R.id.glucosefailure)}; glucoseinfo=view.findViewById(R.id.glucoseinfo); bluestate=view.findViewById(R.id.bluestate); usebluetooth=view.findViewById(R.id.usebluetooth); usebluetooth.setOnCheckedChangeListener( (buttonView, isChecked) -> { Log.i(LOG_ID,"usebluetooth "+isChecked); final boolean blueused = Natives.getusebluetooth(); if (blueused != usebluetooth.isChecked()) { act.setbluetoothmain( !blueused); act.requestRender(); act.doonback(); new bluediag(act); } else { if (isChecked != wasuse) new bluediag(act); } } ); streamhistory.setOnCheckedChangeListener( (buttonView, isChecked) -> Natives.setStreamHistory(isChecked) ); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { priority.setOnCheckedChangeListener( (buttonView, isChecked) -> { final boolean priorityused = Natives.getpriority(); if(priorityused != isChecked) { setpriorities(isChecked,gatts); } } ); } else { Log.i(LOG_ID,"priority.setVisibility(INVISIBLE);"); priority.setVisibility(INVISIBLE); } boolean hasperm=Build.VERSION.SDK_INT < 23||Applic.noPermissions(act).length==0; if(!isWearable) { locationpermission=view.findViewById(R.id.locationpermission); if(hasperm) { Log.i(LOG_ID,"locationpermission.setVisibility(GONE);"); locationpermission.setVisibility(GONE); } else { locationpermission.setOnClickListener(v-> { var noperm=Applic.noPermissions(act); if(noperm.length==0) { Log.i(LOG_ID,"locationpermission.setVisibility(GONE);"); locationpermission.setVisibility(GONE); } else { returntoblue=true; act.doonback(); act.requestPermissions(noperm, act.LOCATION_PERMISSION_REQUEST_CODE); } }); } } spin=view.findViewById(R.id.sensors); boolean[] first={true}; spin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected (AdapterView<?> parent, View view, int position, long id) { Log.i(LOG_ID,"onItemSelected"); try { if (first[0]) { first[0] = false; spin.setSelection(gattselected); } else { if (gatts != null && gatts.size() > position) { gattselected = position; Log.i(LOG_ID, "onItemSelected: gattselected=" + gattselected); SuperGattCallback gatt = gatts.get(gattselected); showinfo(gatt, act); } } } catch(Throwable e) { Log.stack(LOG_ID,e); } } @Override public void onNothingSelected (AdapterView<?> parent) { } }); avoidSpinnerDropdownFocus(spin); if(gatts!=null) { setadapter(act,gatts); } if(!isWearable) { Button help=!isWearable?view.findViewById(R.id.help):null; help.setOnClickListener(v-> help(R.string.sensorhelp,act)); Button background=view.findViewById(R.id.background); if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { background.setOnClickListener(v-> Battery.batteryscreen(act,showview)); } else { Log.i(LOG_ID,"background.setVisibility(GONE);"); background.setVisibility(GONE); } } Button close=view.findViewById(R.id.close); close.setOnClickListener(v-> act.doonback()); view.setBackgroundColor( Applic.backgroundcolor); show(act,showview); act.addContentView(showview, new ViewGroup.LayoutParams( WRAP_CONTENT, WRAP_CONTENT)); var scheduled=Applic.scheduler.scheduleAtFixedRate( ()-> { Log.i(LOG_ID,"scheduled"); act.runOnUiThread( ()-> { if(gatts!=null&&gatts.size()>0) { if(gattselected>= gatts.size()) { Log.i(LOG_ID,"show: gattselected="+ gattselected); gattselected=0; } showinfo(gatts.get(gattselected),act); } });},29,29, TimeUnit.SECONDS); act.setonback(() -> { Log.i(LOG_ID,"onback"); scheduled.cancel(false); act.setfineres(null); removeContentView(showview); if(Menus.on) { Menus.show(act); } }); } final static class Pair{ public long key; public String value; public Pair(long key, String value){ this.key = key; this.value = value; } public long getKey() { return key; } }; static void put(List<Pair> l,long key,String val) { l.add(new Pair(key,val)); } static class onkey implements Comparator<Pair> { public int compare(Pair a, Pair b) { return (int)(a.key - b.key); } } /* static void test() { final List<Pair> messages = new ArrayList<>(); put(messages,10L,"hallo"); put(messages,0L,"one 0"); put(messages,5L,"niets"); put(messages,50L,"alles"); put(messages,0L,"two 0"); Collections.sort(messages, new onkey()); for(Pair el:messages) { System.out.println("key="+el.key+" value="+ el.value); } }*/ void showall() { Log.i(LOG_ID,"showall"); // test(); SensorBluetooth blue=SensorBluetooth.blueone; if(blue!=null&&blue.scantime!=0L) { final List<Pair> messages = new ArrayList<>(); put(messages,blue.scantime,": Start search for sensors\n"); final ArrayList<SuperGattCallback> gatts=SensorBluetooth.mygatts(); if(gatts==null) { Log.i(LOG_ID,"showall gatts==null"); } else { for(SuperGattCallback gatt:gatts) { if(gatt.foundtime>0L) put(messages,gatt.foundtime,": Found "+gatt.SerialNumber +"\n"); } } if(blue.scantimeouttime>0L) put(messages,blue.scantimeouttime, ": timeout\n"); if(blue.stopscantime>0L) put(messages,blue.stopscantime, ": Stop searching\n"); Collections.sort(messages, new onkey()); StringBuilder builder= new StringBuilder(); for (Pair entry : messages) { builder.append(datestr(entry.key)); builder.append(entry.value); } builder.deleteCharAt(builder.length()-1); scanview.setText(builder); Log.i(LOG_ID,"scanview.setVisibility(VISIBLE);"); scanview.setVisibility(VISIBLE); } else { Log.i(LOG_ID,"scanview.setVisibility(GONE);"); scanview.setVisibility(GONE); } if(!isWearable) { activity.setfineres(()-> { if( Build.VERSION.SDK_INT < 23|| Applic.noPermissions(activity).length==0) { Log.i(LOG_ID,"locationpermissin.setVisibility(GONE);"); locationpermission.setVisibility(GONE); } }); } bluestate.setText( mBluetoothAdapter==null?activity.getString(R.string.nobluetooth):(mBluetoothAdapter.isEnabled()?activity.getString(R.string.bluetoothenabled): activity.getString(R.string.bluetoothdisabled))); usebluetooth.setChecked(wasuse = Natives.getusebluetooth()); priority.setChecked(Natives.getpriority()); streamhistory.setChecked(Natives.getStreamHistory( )); if(!isWearable) { if( Build.VERSION.SDK_INT < 23|| Applic.noPermissions(activity).length==0) { Log.i(LOG_ID,"locationpermissin.setVisibility(GONE);"); locationpermission.setVisibility(GONE); } } Log.i(LOG_ID,"showall end"); } private void show(MainActivity act,View view) { if(spin!=null) { SensorBluetooth.updateDevices() ; final ArrayList<SuperGattCallback> gatts=SensorBluetooth.mygatts(); setadapter(activity,gatts); if(gatts!=null&&gatts.size()>0) { if(gattselected>= gatts.size()) { Log.i(LOG_ID,"show: gattselected="+ gattselected); gattselected=0; } avoidSpinnerDropdownFocus(spin); showinfo(gatts.get(gattselected),act); } } Log.i(LOG_ID,"view.setVisibility(VISIBLE);"); view.setVisibility(VISIBLE); showall(); } private static void setpriorities(boolean isChecked,ArrayList<SuperGattCallback> gatts) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Natives.setpriority(isChecked); if(gatts!=null) { final int use_priority = isChecked ? CONNECTION_PRIORITY_HIGH : CONNECTION_PRIORITY_BALANCED; for (SuperGattCallback g : gatts) { try { var ga = g.mBluetoothGatt; if (ga != null) ga.requestConnectionPriority(use_priority); } catch (Throwable th) { Log.stack(LOG_ID, "setpriorities", th); } } } } } };
j-kaltes/Juggluco
Common/src/main/java/tk/glucodata/bluediag.java
791
//### This file created by BYACC 1.8(/Java extension 1.13) //### Java capabilities added 7 Jan 97, Bob Jamison //### Updated : 27 Nov 97 -- Bob Jamison, Joe Nieten //### 01 Jan 98 -- Bob Jamison -- fixed generic semantic constructor //### 01 Jun 99 -- Bob Jamison -- added Runnable support //### 06 Aug 00 -- Bob Jamison -- made state variables class-global //### 03 Jan 01 -- Bob Jamison -- improved flags, tracing //### 16 May 01 -- Bob Jamison -- added custom stack sizing //### 04 Mar 02 -- Yuval Oren -- improved java performance, added options //### 14 Mar 02 -- Tomas Hurka -- -d support, static initializer workaround //### 14 Sep 06 -- Keltin Leung-- ReduceListener support, eliminate underflow report in error recovery //### Please send bug reports to [email protected] //### static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; //#line 11 "Parser.y" package decaf.frontend; import decaf.tree.Tree; import decaf.tree.Tree.*; import decaf.error.*; import java.util.*; //#line 25 "Parser.java" interface ReduceListener { public boolean onReduce(String rule); } public class Parser extends BaseParser implements ReduceListener { boolean yydebug; //do I want debug output? int yynerrs; //number of errors so far int yyerrflag; //was there an error? int yychar; //the current working character ReduceListener reduceListener = null; void yyclearin () {yychar = (-1);} void yyerrok () {yyerrflag=0;} void addReduceListener(ReduceListener l) { reduceListener = l;} //########## MESSAGES ########## //############################################################### // method: debug //############################################################### void debug(String msg) { if (yydebug) System.out.println(msg); } //########## STATE STACK ########## final static int YYSTACKSIZE = 500; //maximum stack size int statestk[] = new int[YYSTACKSIZE]; //state stack int stateptr; int stateptrmax; //highest index of stackptr int statemax; //state when highest index reached //############################################################### // methods: state stack push,pop,drop,peek //############################################################### final void state_push(int state) { try { stateptr++; statestk[stateptr]=state; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = statestk.length; int newsize = oldsize * 2; int[] newstack = new int[newsize]; System.arraycopy(statestk,0,newstack,0,oldsize); statestk = newstack; statestk[stateptr]=state; } } final int state_pop() { return statestk[stateptr--]; } final void state_drop(int cnt) { stateptr -= cnt; } final int state_peek(int relative) { return statestk[stateptr-relative]; } //############################################################### // method: init_stacks : allocate and prepare stacks //############################################################### final boolean init_stacks() { stateptr = -1; val_init(); return true; } //############################################################### // method: dump_stacks : show n levels of the stacks //############################################################### void dump_stacks(int count) { int i; System.out.println("=index==state====value= s:"+stateptr+" v:"+valptr); for (i=0;i<count;i++) System.out.println(" "+i+" "+statestk[i]+" "+valstk[i]); System.out.println("======================"); } //########## SEMANTIC VALUES ########## //## **user defined:SemValue String yytext;//user variable to return contextual strings SemValue yyval; //used to return semantic vals from action routines SemValue yylval;//the 'lval' (result) I got from yylex() SemValue valstk[] = new SemValue[YYSTACKSIZE]; int valptr; //############################################################### // methods: value stack push,pop,drop,peek. //############################################################### final void val_init() { yyval=new SemValue(); yylval=new SemValue(); valptr=-1; } final void val_push(SemValue val) { try { valptr++; valstk[valptr]=val; } catch (ArrayIndexOutOfBoundsException e) { int oldsize = valstk.length; int newsize = oldsize*2; SemValue[] newstack = new SemValue[newsize]; System.arraycopy(valstk,0,newstack,0,oldsize); valstk = newstack; valstk[valptr]=val; } } final SemValue val_pop() { return valstk[valptr--]; } final void val_drop(int cnt) { valptr -= cnt; } final SemValue val_peek(int relative) { return valstk[valptr-relative]; } //#### end semantic value section #### public final static short VOID=257; public final static short BOOL=258; public final static short INT=259; public final static short STRING=260; public final static short CLASS=261; public final static short NULL=262; public final static short EXTENDS=263; public final static short THIS=264; public final static short WHILE=265; public final static short FOR=266; public final static short IF=267; public final static short ELSE=268; public final static short RETURN=269; public final static short BREAK=270; public final static short NEW=271; public final static short PRINT=272; public final static short READ_INTEGER=273; public final static short READ_LINE=274; public final static short LITERAL=275; public final static short IDENTIFIER=276; public final static short AND=277; public final static short OR=278; public final static short STATIC=279; public final static short INSTANCEOF=280; public final static short LESS_EQUAL=281; public final static short GREATER_EQUAL=282; public final static short EQUAL=283; public final static short NOT_EQUAL=284; public final static short MIN_CP=285; public final static short SWITCH=286; public final static short CASE=287; public final static short DEFAULT=288; public final static short REPEAT=289; public final static short UNTIL=290; public final static short CONTINUE=291; public final static short PCLONE=292; public final static short UMINUS=293; public final static short EMPTY=294; public final static short YYERRCODE=256; final static short yylhs[] = { -1, 0, 1, 1, 3, 4, 5, 5, 5, 5, 5, 5, 2, 6, 6, 7, 7, 7, 9, 9, 10, 10, 8, 8, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 27, 27, 24, 24, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 29, 29, 28, 28, 30, 30, 16, 17, 22, 23, 15, 18, 32, 32, 34, 33, 33, 19, 31, 31, 20, 20, 21, }; final static short yylen[] = { 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 3, 6, 2, 0, 2, 2, 0, 1, 0, 3, 1, 7, 6, 3, 2, 0, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 3, 1, 0, 2, 0, 2, 4, 5, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 4, 5, 6, 5, 5, 3, 1, 1, 1, 0, 3, 1, 5, 9, 1, 1, 6, 8, 2, 0, 4, 3, 0, 6, 2, 0, 2, 1, 4, }; final static short yydefred[] = { 0, 0, 0, 0, 3, 0, 2, 0, 0, 13, 17, 0, 7, 8, 6, 9, 0, 0, 12, 15, 0, 0, 16, 10, 0, 4, 0, 0, 0, 0, 11, 0, 21, 0, 0, 0, 0, 5, 0, 0, 0, 26, 23, 20, 22, 0, 76, 68, 0, 0, 0, 0, 83, 0, 0, 0, 0, 75, 0, 0, 26, 84, 0, 0, 0, 24, 27, 38, 25, 0, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 33, 34, 35, 36, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 67, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 97, 0, 0, 0, 0, 45, 0, 0, 0, 81, 0, 0, 70, 0, 0, 88, 0, 72, 0, 46, 0, 0, 85, 71, 0, 92, 0, 93, 0, 0, 0, 87, 0, 0, 26, 86, 82, 26, 0, 0, }; final static short yydgoto[] = { 2, 3, 4, 66, 20, 33, 8, 11, 22, 34, 35, 67, 45, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 87, 80, 89, 82, 172, 83, 133, 187, 189, 195, 196, }; final static short yysindex[] = { -228, -224, 0, -228, 0, -219, 0, -214, -66, 0, 0, -91, 0, 0, 0, 0, -209, -120, 0, 0, 12, -85, 0, 0, -83, 0, 41, -10, 46, -120, 0, -120, 0, -80, 47, 45, 50, 0, -28, -120, -28, 0, 0, 0, 0, 2, 0, 0, 53, 57, 58, 871, 0, -46, 59, 60, 63, 0, 64, 67, 0, 0, 871, 871, 810, 0, 0, 0, 0, 52, 0, 0, 0, 0, 55, 62, 76, 83, 84, 48, 740, 0, -154, 0, 871, 871, 871, 0, 740, 0, 86, 32, 871, 103, 111, 871, 871, 37, -30, -30, -123, 477, 0, 0, 0, 0, 0, 0, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 871, 0, 871, 871, 871, 122, 489, 95, 513, 124, 1022, 740, -3, 0, 0, 540, 552, 123, 130, 0, 740, 998, 948, 73, 73, 1049, 1049, -22, -22, -30, -30, -30, 73, 73, 564, 576, 3, 871, 72, 871, 72, 0, 650, 871, 0, -95, 69, 871, 871, 0, 871, 134, 138, 0, 674, -78, 0, 740, 157, 0, 824, 0, 740, 0, 871, 72, 0, 0, -208, 0, 158, 0, -232, 145, 81, 0, 72, 150, 0, 0, 0, 0, 72, 72, }; final static short yyrindex[] = { 0, 0, 0, 209, 0, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 0, 0, 176, 0, 176, 0, 0, 0, 177, 0, 0, 0, 0, 0, 0, 0, 0, 0, -56, 0, 0, 0, 0, 0, -54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, -55, -55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 846, 0, 447, 0, 0, -55, -56, -55, 0, 164, 0, 0, 0, -55, 0, 0, -55, -55, -56, 114, 142, 0, 0, 0, 0, 0, 0, 0, 0, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, 0, -55, -55, -55, 87, 0, 0, 0, 0, -55, 10, 0, 0, 0, 0, 0, 0, 0, 0, -20, -27, 975, 705, 918, 43, 625, 881, 905, 370, 394, 423, 943, 968, 0, 0, -40, -32, -56, -55, -56, 0, 0, -55, 0, 0, 0, -55, -55, 0, -55, 0, 205, 0, 0, -33, 0, 31, 0, 0, 0, 0, 15, 0, -31, -56, 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, -56, 0, 0, 0, 0, 0, -57, 224, }; final static short yygindex[] = { 0, 0, 245, 238, -2, 11, 0, 0, 0, 239, 0, 38, -5, -101, -72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1052, 1241, 1115, 0, 0, 96, 121, 0, 0, 0, 0, }; final static int YYTABLESIZE=1412; static short yytable[]; static { yytable();} static void yytable(){ yytable = new short[]{ 94, 74, 41, 41, 74, 96, 27, 94, 27, 78, 41, 27, 94, 128, 61, 119, 122, 61, 74, 74, 117, 39, 21, 74, 122, 118, 94, 32, 24, 32, 46, 61, 61, 1, 18, 63, 61, 43, 165, 39, 119, 164, 64, 57, 7, 117, 115, 62, 116, 122, 118, 80, 5, 74, 80, 97, 73, 10, 174, 73, 176, 123, 9, 121, 91, 120, 61, 23, 90, 123, 63, 25, 79, 73, 73, 79, 42, 64, 44, 193, 194, 29, 62, 30, 55, 192, 31, 55, 38, 39, 94, 40, 94, 84, 123, 41, 201, 85, 86, 92, 93, 55, 55, 94, 95, 63, 55, 96, 73, 108, 119, 102, 64, 191, 103, 117, 115, 62, 116, 122, 118, 104, 126, 131, 44, 41, 130, 65, 44, 44, 44, 44, 44, 44, 44, 105, 55, 12, 13, 14, 15, 16, 106, 107, 134, 44, 44, 44, 44, 44, 44, 64, 135, 139, 160, 64, 64, 64, 64, 64, 41, 64, 158, 168, 123, 162, 12, 13, 14, 15, 16, 169, 64, 64, 64, 184, 64, 64, 44, 65, 44, 179, 164, 65, 65, 65, 65, 65, 17, 65, 186, 26, 180, 28, 203, 41, 37, 204, 188, 197, 65, 65, 65, 199, 65, 65, 200, 64, 202, 1, 5, 12, 13, 14, 15, 16, 14, 19, 18, 43, 43, 43, 43, 95, 94, 94, 94, 94, 94, 94, 90, 94, 94, 94, 94, 65, 94, 94, 94, 94, 94, 94, 94, 94, 43, 43, 77, 94, 6, 19, 61, 61, 74, 94, 94, 94, 94, 94, 94, 12, 13, 14, 15, 16, 46, 61, 47, 48, 49, 50, 36, 51, 52, 53, 54, 55, 56, 57, 91, 173, 109, 110, 58, 41, 111, 112, 113, 114, 59, 198, 0, 60, 0, 61, 12, 13, 14, 15, 16, 46, 0, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 58, 0, 0, 55, 55, 0, 59, 0, 0, 60, 138, 61, 12, 13, 14, 15, 16, 46, 55, 47, 48, 49, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 89, 0, 0, 58, 0, 0, 0, 0, 0, 59, 0, 0, 60, 0, 61, 44, 44, 0, 0, 44, 44, 44, 44, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 0, 0, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 64, 52, 0, 0, 0, 52, 52, 52, 52, 52, 0, 52, 0, 65, 65, 0, 0, 65, 65, 65, 65, 0, 52, 52, 52, 53, 52, 52, 65, 53, 53, 53, 53, 53, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 53, 53, 0, 53, 53, 0, 0, 54, 0, 0, 52, 54, 54, 54, 54, 54, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, 48, 54, 54, 53, 40, 48, 48, 0, 48, 48, 48, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 40, 48, 0, 48, 48, 89, 89, 0, 119, 0, 54, 0, 140, 117, 115, 0, 116, 122, 118, 0, 119, 0, 0, 0, 159, 117, 115, 0, 116, 122, 118, 121, 48, 120, 124, 0, 0, 0, 0, 0, 0, 0, 0, 121, 119, 120, 124, 0, 161, 117, 115, 0, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 121, 0, 120, 124, 119, 0, 0, 123, 0, 117, 115, 166, 116, 122, 118, 0, 119, 0, 0, 0, 167, 117, 115, 0, 116, 122, 118, 121, 119, 120, 124, 123, 0, 117, 115, 0, 116, 122, 118, 121, 119, 120, 124, 0, 0, 117, 115, 0, 116, 122, 118, 121, 0, 120, 124, 0, 0, 0, 123, 0, 0, 171, 0, 121, 0, 120, 124, 0, 0, 0, 123, 0, 0, 0, 52, 52, 0, 0, 52, 52, 52, 52, 123, 0, 170, 0, 0, 0, 0, 52, 0, 0, 0, 56, 123, 0, 56, 0, 53, 53, 0, 0, 53, 53, 53, 53, 0, 0, 0, 0, 56, 56, 0, 53, 119, 56, 0, 0, 0, 117, 115, 0, 116, 122, 118, 0, 0, 54, 54, 0, 0, 54, 54, 54, 54, 0, 0, 121, 119, 120, 124, 0, 54, 117, 115, 56, 116, 122, 118, 0, 0, 48, 48, 0, 0, 48, 48, 48, 48, 0, 185, 121, 0, 120, 124, 0, 48, 0, 123, 0, 177, 0, 0, 59, 0, 0, 59, 0, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 0, 59, 59, 123, 109, 110, 59, 125, 111, 112, 113, 114, 0, 0, 0, 119, 0, 0, 0, 125, 117, 115, 0, 116, 122, 118, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 59, 0, 121, 0, 120, 124, 0, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 0, 0, 0, 0, 109, 110, 123, 125, 111, 112, 113, 114, 0, 0, 0, 0, 109, 110, 63, 125, 111, 112, 113, 114, 0, 64, 0, 0, 109, 110, 62, 125, 111, 112, 113, 114, 119, 0, 0, 0, 190, 117, 115, 125, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 121, 0, 120, 124, 47, 47, 0, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 56, 56, 63, 0, 47, 0, 47, 47, 0, 64, 0, 0, 0, 123, 62, 56, 0, 0, 0, 0, 50, 0, 50, 50, 50, 109, 110, 0, 0, 111, 112, 113, 114, 0, 0, 47, 0, 50, 50, 50, 125, 50, 50, 0, 51, 0, 51, 51, 51, 109, 110, 0, 0, 111, 112, 113, 114, 60, 0, 0, 60, 51, 51, 51, 125, 51, 51, 0, 0, 0, 0, 0, 50, 0, 60, 60, 0, 0, 0, 60, 59, 59, 58, 119, 0, 58, 59, 59, 117, 115, 0, 116, 122, 118, 0, 59, 51, 0, 0, 58, 58, 0, 0, 0, 58, 0, 121, 57, 120, 60, 57, 0, 0, 0, 62, 109, 110, 62, 0, 111, 112, 113, 114, 0, 57, 57, 0, 0, 0, 57, 125, 62, 62, 119, 58, 0, 62, 123, 117, 115, 0, 116, 122, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 121, 0, 120, 57, 64, 0, 0, 0, 0, 62, 62, 0, 0, 100, 46, 0, 47, 0, 0, 0, 0, 0, 0, 53, 0, 55, 56, 57, 119, 0, 0, 123, 58, 117, 115, 0, 116, 122, 118, 79, 0, 0, 0, 109, 110, 0, 0, 111, 112, 113, 114, 121, 0, 120, 0, 0, 0, 30, 125, 0, 0, 0, 0, 0, 0, 47, 47, 0, 0, 47, 47, 47, 47, 0, 0, 46, 0, 47, 0, 79, 47, 0, 123, 0, 53, 0, 55, 56, 57, 0, 0, 79, 0, 58, 0, 0, 0, 0, 0, 0, 50, 50, 81, 0, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 51, 51, 0, 0, 51, 51, 51, 51, 0, 0, 0, 0, 0, 60, 60, 51, 0, 0, 81, 60, 60, 0, 0, 0, 0, 0, 0, 0, 60, 79, 81, 79, 0, 0, 0, 0, 0, 0, 58, 58, 0, 0, 0, 109, 58, 58, 0, 111, 112, 113, 114, 0, 0, 58, 0, 79, 79, 0, 0, 0, 0, 0, 0, 57, 57, 0, 0, 79, 0, 57, 57, 62, 0, 79, 79, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 81, 0, 81, 0, 0, 111, 112, 113, 114, 0, 46, 0, 47, 0, 0, 0, 0, 0, 88, 53, 0, 55, 56, 57, 0, 0, 81, 81, 58, 98, 99, 101, 0, 0, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 81, 81, 0, 0, 0, 0, 0, 127, 0, 129, 0, 0, 111, 112, 0, 132, 0, 0, 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 0, 155, 156, 157, 0, 0, 0, 0, 0, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 0, 175, 0, 0, 0, 178, 0, 0, 0, 181, 182, 0, 183, }; } static short yycheck[]; static { yycheck(); } static void yycheck() { yycheck = new short[] { 33, 41, 59, 59, 44, 59, 91, 40, 91, 41, 41, 91, 45, 85, 41, 37, 46, 44, 58, 59, 42, 41, 11, 63, 46, 47, 59, 29, 17, 31, 262, 58, 59, 261, 125, 33, 63, 39, 41, 59, 37, 44, 40, 275, 263, 42, 43, 45, 45, 46, 47, 41, 276, 93, 44, 60, 41, 123, 159, 44, 161, 91, 276, 60, 53, 62, 93, 276, 125, 91, 33, 59, 41, 58, 59, 44, 38, 40, 40, 287, 288, 40, 45, 93, 41, 186, 40, 44, 41, 44, 123, 41, 125, 40, 91, 123, 197, 40, 40, 40, 40, 58, 59, 40, 40, 33, 63, 40, 93, 61, 37, 59, 40, 185, 59, 42, 43, 45, 45, 46, 47, 59, 276, 91, 37, 123, 40, 125, 41, 42, 43, 44, 45, 46, 47, 59, 93, 257, 258, 259, 260, 261, 59, 59, 41, 58, 59, 60, 61, 62, 63, 37, 41, 276, 59, 41, 42, 43, 44, 45, 123, 47, 40, 40, 91, 41, 257, 258, 259, 260, 261, 41, 58, 59, 60, 41, 62, 63, 91, 37, 93, 276, 44, 41, 42, 43, 44, 45, 279, 47, 268, 276, 123, 276, 199, 123, 276, 202, 41, 41, 58, 59, 60, 58, 62, 63, 125, 93, 58, 0, 59, 257, 258, 259, 260, 261, 123, 41, 41, 276, 276, 276, 276, 59, 257, 258, 259, 260, 261, 262, 276, 264, 265, 266, 267, 93, 269, 270, 271, 272, 273, 274, 275, 276, 276, 276, 41, 280, 3, 11, 277, 278, 292, 286, 287, 288, 289, 290, 291, 257, 258, 259, 260, 261, 262, 292, 264, 265, 266, 267, 31, 269, 270, 271, 272, 273, 274, 275, 125, 158, 277, 278, 280, 59, 281, 282, 283, 284, 286, 193, -1, 289, -1, 291, 257, 258, 259, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, -1, -1, -1, 280, -1, -1, 277, 278, -1, 286, -1, -1, 289, 290, 291, 257, 258, 259, 260, 261, 262, 292, 264, 265, 266, 267, -1, 269, 270, 271, 272, 273, 274, 275, -1, 125, -1, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, 291, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, 37, -1, -1, -1, 41, 42, 43, 44, 45, -1, 47, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 58, 59, 60, 37, 62, 63, 292, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, -1, 37, -1, -1, 93, 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, 60, 37, 62, 63, 93, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, 276, -1, -1, -1, -1, -1, 59, 60, -1, 62, 63, 287, 288, -1, 37, -1, 93, -1, 41, 42, 43, -1, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 60, 91, 62, 63, -1, -1, -1, -1, -1, -1, -1, -1, 60, 37, 62, 63, -1, 41, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, -1, -1, 60, -1, 62, 63, 37, -1, -1, 91, -1, 42, 43, 44, 45, 46, 47, -1, 37, -1, -1, -1, 41, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, 91, -1, 42, 43, -1, 45, 46, 47, 60, 37, 62, 63, -1, -1, 42, 43, -1, 45, 46, 47, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, 58, -1, 60, -1, 62, 63, -1, -1, -1, 91, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 91, -1, 93, -1, -1, -1, -1, 292, -1, -1, -1, 41, 91, -1, 44, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, 58, 59, -1, 292, 37, 63, -1, -1, -1, 42, 43, -1, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 60, 37, 62, 63, -1, 292, 42, 43, 93, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 59, 60, -1, 62, 63, -1, 292, -1, 91, -1, 93, -1, -1, 41, -1, -1, 44, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, 58, 59, 91, 277, 278, 63, 292, 281, 282, 283, 284, -1, -1, -1, 37, -1, -1, -1, 292, 42, 43, -1, 45, 46, 47, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 93, -1, 60, -1, 62, 63, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, 277, 278, 91, 292, 281, 282, 283, 284, -1, -1, -1, -1, 277, 278, 33, 292, 281, 282, 283, 284, -1, 40, -1, -1, 277, 278, 45, 292, 281, 282, 283, 284, 37, -1, -1, -1, 41, 42, 43, 292, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, 60, -1, 62, 63, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, 33, -1, 60, -1, 62, 63, -1, 40, -1, -1, -1, 91, 45, 292, -1, -1, -1, -1, 41, -1, 43, 44, 45, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 91, -1, 58, 59, 60, 292, 62, 63, -1, 41, -1, 43, 44, 45, 277, 278, -1, -1, 281, 282, 283, 284, 41, -1, -1, 44, 58, 59, 60, 292, 62, 63, -1, -1, -1, -1, -1, 93, -1, 58, 59, -1, -1, -1, 63, 277, 278, 41, 37, -1, 44, 283, 284, 42, 43, -1, 45, 46, 47, -1, 292, 93, -1, -1, 58, 59, -1, -1, -1, 63, -1, 60, 41, 62, 93, 44, -1, -1, -1, 41, 277, 278, 44, -1, 281, 282, 283, 284, -1, 58, 59, -1, -1, -1, 63, 292, 58, 59, 37, 93, -1, 63, 91, 42, 43, -1, 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, 60, -1, 62, 93, 40, -1, -1, -1, -1, 45, 93, -1, -1, 261, 262, -1, 264, -1, -1, -1, -1, -1, -1, 271, -1, 273, 274, 275, 37, -1, -1, 91, 280, 42, 43, -1, 45, 46, 47, 45, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, 60, -1, 62, -1, -1, -1, 93, 292, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, 262, -1, 264, -1, 85, 292, -1, 91, -1, 271, -1, 273, 274, 275, -1, -1, 97, -1, 280, -1, -1, -1, -1, -1, -1, 277, 278, 45, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 281, 282, 283, 284, -1, -1, -1, -1, -1, 277, 278, 292, -1, -1, 85, 283, 284, -1, -1, -1, -1, -1, -1, -1, 292, 159, 97, 161, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, -1, 277, 283, 284, -1, 281, 282, 283, 284, -1, -1, 292, -1, 185, 186, -1, -1, -1, -1, -1, -1, 277, 278, -1, -1, 197, -1, 283, 284, 278, -1, 203, 204, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, 292, -1, -1, -1, -1, -1, -1, 159, -1, 161, -1, -1, 281, 282, 283, 284, -1, 262, -1, 264, -1, -1, -1, -1, -1, 51, 271, -1, 273, 274, 275, -1, -1, 185, 186, 280, 62, 63, 64, -1, -1, -1, -1, -1, -1, 197, -1, -1, -1, -1, -1, 203, 204, -1, -1, -1, -1, -1, 84, -1, 86, -1, -1, 281, 282, -1, 92, -1, -1, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, -1, 123, 124, 125, -1, -1, -1, -1, -1, 131, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 158, -1, 160, -1, -1, -1, 164, -1, -1, -1, 168, 169, -1, 171, }; } final static short YYFINAL=2; final static short YYMAXTOKEN=294; final static String yyname[] = { "end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,"'!'",null,null,null,"'%'",null,null,"'('","')'","'*'","'+'", "','","'-'","'.'","'/'",null,null,null,null,null,null,null,null,null,null,"':'", "';'","'<'","'='","'>'","'?'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,"'['",null,"']'",null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,"'{'",null,"'}'",null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,"VOID","BOOL","INT","STRING", "CLASS","NULL","EXTENDS","THIS","WHILE","FOR","IF","ELSE","RETURN","BREAK", "NEW","PRINT","READ_INTEGER","READ_LINE","LITERAL","IDENTIFIER","AND","OR", "STATIC","INSTANCEOF","LESS_EQUAL","GREATER_EQUAL","EQUAL","NOT_EQUAL","MIN_CP", "SWITCH","CASE","DEFAULT","REPEAT","UNTIL","CONTINUE","PCLONE","UMINUS","EMPTY", }; final static String yyrule[] = { "$accept : Program", "Program : ClassList", "ClassList : ClassList ClassDef", "ClassList : ClassDef", "VariableDef : Variable ';'", "Variable : Type IDENTIFIER", "Type : INT", "Type : VOID", "Type : BOOL", "Type : STRING", "Type : CLASS IDENTIFIER", "Type : Type '[' ']'", "ClassDef : CLASS IDENTIFIER ExtendsClause '{' FieldList '}'", "ExtendsClause : EXTENDS IDENTIFIER", "ExtendsClause :", "FieldList : FieldList VariableDef", "FieldList : FieldList FunctionDef", "FieldList :", "Formals : VariableList", "Formals :", "VariableList : VariableList ',' Variable", "VariableList : Variable", "FunctionDef : STATIC Type IDENTIFIER '(' Formals ')' StmtBlock", "FunctionDef : Type IDENTIFIER '(' Formals ')' StmtBlock", "StmtBlock : '{' StmtList '}'", "StmtList : StmtList Stmt", "StmtList :", "Stmt : VariableDef", "Stmt : SimpleStmt ';'", "Stmt : IfStmt", "Stmt : WhileStmt", "Stmt : ForStmt", "Stmt : SwitchStmt", "Stmt : RepeatStmt ';'", "Stmt : ReturnStmt ';'", "Stmt : PrintStmt ';'", "Stmt : BreakStmt ';'", "Stmt : ContinueStmt ';'", "Stmt : StmtBlock", "SimpleStmt : LValue '=' Expr", "SimpleStmt : Call", "SimpleStmt :", "Receiver : Expr '.'", "Receiver :", "LValue : Receiver IDENTIFIER", "LValue : Expr '[' Expr ']'", "Call : Receiver IDENTIFIER '(' Actuals ')'", "Expr : LValue", "Expr : Call", "Expr : Constant", "Expr : Expr '+' Expr", "Expr : Expr '-' Expr", "Expr : Expr '*' Expr", "Expr : Expr '/' Expr", "Expr : Expr '%' Expr", "Expr : Expr EQUAL Expr", "Expr : Expr NOT_EQUAL Expr", "Expr : Expr '<' Expr", "Expr : Expr '>' Expr", "Expr : Expr LESS_EQUAL Expr", "Expr : Expr GREATER_EQUAL Expr", "Expr : Expr AND Expr", "Expr : Expr OR Expr", "Expr : '(' Expr ')'", "Expr : '-' Expr", "Expr : '!' Expr", "Expr : READ_INTEGER '(' ')'", "Expr : READ_LINE '(' ')'", "Expr : THIS", "Expr : NEW IDENTIFIER '(' ')'", "Expr : NEW Type '[' Expr ']'", "Expr : INSTANCEOF '(' Expr ',' IDENTIFIER ')'", "Expr : '(' CLASS IDENTIFIER ')' Expr", "Expr : Expr '?' Expr ':' Expr", "Expr : Expr PCLONE Expr", "Constant : LITERAL", "Constant : NULL", "Actuals : ExprList", "Actuals :", "ExprList : ExprList ',' Expr", "ExprList : Expr", "WhileStmt : WHILE '(' Expr ')' Stmt", "ForStmt : FOR '(' SimpleStmt ';' Expr ';' SimpleStmt ')' Stmt", "BreakStmt : BREAK", "ContinueStmt : CONTINUE", "IfStmt : IF '(' Expr ')' Stmt ElseClause", "SwitchStmt : SWITCH '(' Expr ')' '{' CaseStmtList DefaultStmt '}'", "CaseStmtList : CaseStmtList CaseStmt", "CaseStmtList :", "CaseStmt : CASE Constant ':' StmtList", "DefaultStmt : DEFAULT ':' StmtList", "DefaultStmt :", "RepeatStmt : REPEAT StmtList UNTIL '(' Expr ')'", "ElseClause : ELSE Stmt", "ElseClause :", "ReturnStmt : RETURN Expr", "ReturnStmt : RETURN", "PrintStmt : PRINT '(' ExprList ')'", }; //#line 486 "Parser.y" /** * 打印当前归约所用的语法规则<br> * 请勿修改。 */ public boolean onReduce(String rule) { if (rule.startsWith("$$")) return false; else rule = rule.replaceAll(" \\$\\$\\d+", ""); if (rule.endsWith(":")) System.out.println(rule + " <empty>"); else System.out.println(rule); return false; } public void diagnose() { addReduceListener(this); yyparse(); } //#line 694 "Parser.java" //############################################################### // method: yylexdebug : check lexer state //############################################################### void yylexdebug(int state,int ch) { String s=null; if (ch < 0) ch=0; if (ch <= YYMAXTOKEN) //check index bounds s = yyname[ch]; //now get it if (s==null) s = "illegal-symbol"; debug("state "+state+", reading "+ch+" ("+s+")"); } //The following are now global, to aid in error reporting int yyn; //next next thing to do int yym; // int yystate; //current parsing state from state table String yys; //current token string //############################################################### // method: yyparse : parse input and execute indicated items //############################################################### int yyparse() { boolean doaction; init_stacks(); yynerrs = 0; yyerrflag = 0; yychar = -1; //impossible char forces a read yystate=0; //initial state state_push(yystate); //save it while (true) //until parsing is done, either correctly, or w/error { doaction=true; //if (yydebug) debug("loop"); //#### NEXT ACTION (from reduction table) for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate]) { //if (yydebug) debug("yyn:"+yyn+" state:"+yystate+" yychar:"+yychar); if (yychar < 0) //we want a char? { yychar = yylex(); //get next token //if (yydebug) debug(" next yychar:"+yychar); //#### ERROR CHECK #### //if (yychar < 0) //it it didn't work/error // { // yychar = 0; //change it to default string (no -1!) //if (yydebug) // yylexdebug(yystate,yychar); // } }//yychar<0 yyn = yysindex[yystate]; //get amount to shift by (shift index) if ((yyn != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //if (yydebug) //debug("state "+yystate+", shifting to state "+yytable[yyn]); //#### NEXT STATE #### yystate = yytable[yyn];//we are in a new state state_push(yystate); //save it val_push(yylval); //push our lval as the input for next rule yychar = -1; //since we have 'eaten' a token, say we need another if (yyerrflag > 0) //have we recovered an error? --yyerrflag; //give ourselves credit doaction=false; //but don't process yet break; //quit the yyn=0 loop } yyn = yyrindex[yystate]; //reduce if ((yyn !=0 ) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { //we reduced! //if (yydebug) debug("reduce"); yyn = yytable[yyn]; doaction=true; //get ready to execute break; //drop down to actions } else //ERROR RECOVERY { if (yyerrflag==0) { yyerror("syntax error"); yynerrs++; } if (yyerrflag < 3) //low error count? { yyerrflag = 3; while (true) //do until break { if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } yyn = yysindex[state_peek(0)]; if ((yyn != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { //if (yydebug) //debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" "); yystate = yytable[yyn]; state_push(yystate); val_push(yylval); doaction=false; break; } else { //if (yydebug) //debug("error recovery discarding state "+state_peek(0)+" "); if (stateptr<0 || valptr<0) //check for under & overflow here { return 1; } state_pop(); val_pop(); } } } else //discard this token { if (yychar == 0) return 1; //yyabort //if (yydebug) //{ //yys = null; //if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; //if (yys == null) yys = "illegal-symbol"; //debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")"); //} yychar = -1; //read another } }//end error recovery }//yyn=0 loop if (!doaction) //any reason not to proceed? continue; //skip action yym = yylen[yyn]; //get count of terminals on rhs //if (yydebug) //debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")"); if (yym>0) //if count of rhs not 'nil' yyval = val_peek(yym-1); //get current semantic value if (reduceListener == null || reduceListener.onReduce(yyrule[yyn])) // if intercepted! switch(yyn) { //########## USER-SUPPLIED ACTIONS ########## case 1: //#line 59 "Parser.y" { tree = new Tree.TopLevel(val_peek(0).clist, val_peek(0).loc); } break; case 2: //#line 65 "Parser.y" { yyval.clist.add(val_peek(0).cdef); } break; case 3: //#line 69 "Parser.y" { yyval.clist = new ArrayList<Tree.ClassDef>(); yyval.clist.add(val_peek(0).cdef); } break; case 5: //#line 79 "Parser.y" { yyval.vdef = new Tree.VarDef(val_peek(0).ident, val_peek(1).type, val_peek(0).loc); } break; case 6: //#line 85 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.INT, val_peek(0).loc); } break; case 7: //#line 89 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.VOID, val_peek(0).loc); } break; case 8: //#line 93 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.BOOL, val_peek(0).loc); } break; case 9: //#line 97 "Parser.y" { yyval.type = new Tree.TypeIdent(Tree.STRING, val_peek(0).loc); } break; case 10: //#line 101 "Parser.y" { yyval.type = new Tree.TypeClass(val_peek(0).ident, val_peek(1).loc); } break; case 11: //#line 105 "Parser.y" { yyval.type = new Tree.TypeArray(val_peek(2).type, val_peek(2).loc); } break; case 12: //#line 111 "Parser.y" { yyval.cdef = new Tree.ClassDef(val_peek(4).ident, val_peek(3).ident, val_peek(1).flist, val_peek(5).loc); } break; case 13: //#line 117 "Parser.y" { yyval.ident = val_peek(0).ident; } break; case 14: //#line 121 "Parser.y" { yyval = new SemValue(); } break; case 15: //#line 127 "Parser.y" { yyval.flist.add(val_peek(0).vdef); } break; case 16: //#line 131 "Parser.y" { yyval.flist.add(val_peek(0).fdef); } break; case 17: //#line 135 "Parser.y" { yyval = new SemValue(); yyval.flist = new ArrayList<Tree>(); } break; case 19: //#line 143 "Parser.y" { yyval = new SemValue(); yyval.vlist = new ArrayList<Tree.VarDef>(); } break; case 20: //#line 150 "Parser.y" { yyval.vlist.add(val_peek(0).vdef); } break; case 21: //#line 154 "Parser.y" { yyval.vlist = new ArrayList<Tree.VarDef>(); yyval.vlist.add(val_peek(0).vdef); } break; case 22: //#line 161 "Parser.y" { yyval.fdef = new MethodDef(true, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 23: //#line 165 "Parser.y" { yyval.fdef = new MethodDef(false, val_peek(4).ident, val_peek(5).type, val_peek(2).vlist, (Block) val_peek(0).stmt, val_peek(4).loc); } break; case 24: //#line 171 "Parser.y" { yyval.stmt = new Block(val_peek(1).slist, val_peek(2).loc); } break; case 25: //#line 177 "Parser.y" { yyval.slist.add(val_peek(0).stmt); } break; case 26: //#line 181 "Parser.y" { yyval = new SemValue(); yyval.slist = new ArrayList<Tree>(); } break; case 27: //#line 188 "Parser.y" { yyval.stmt = val_peek(0).vdef; } break; case 28: //#line 193 "Parser.y" { if (yyval.stmt == null) { yyval.stmt = new Tree.Skip(val_peek(0).loc); } } break; case 39: //#line 211 "Parser.y" { yyval.stmt = new Tree.Assign(val_peek(2).lvalue, val_peek(0).expr, val_peek(1).loc); } break; case 40: //#line 215 "Parser.y" { yyval.stmt = new Tree.Exec(val_peek(0).expr, val_peek(0).loc); } break; case 41: //#line 219 "Parser.y" { yyval = new SemValue(); } break; case 43: //#line 226 "Parser.y" { yyval = new SemValue(); } break; case 44: //#line 232 "Parser.y" { yyval.lvalue = new Tree.Ident(val_peek(1).expr, val_peek(0).ident, val_peek(0).loc); if (val_peek(1).loc == null) { yyval.loc = val_peek(0).loc; } } break; case 45: //#line 239 "Parser.y" { yyval.lvalue = new Tree.Indexed(val_peek(3).expr, val_peek(1).expr, val_peek(3).loc); } break; case 46: //#line 245 "Parser.y" { yyval.expr = new Tree.CallExpr(val_peek(4).expr, val_peek(3).ident, val_peek(1).elist, val_peek(3).loc); if (val_peek(4).loc == null) { yyval.loc = val_peek(3).loc; } } break; case 47: //#line 254 "Parser.y" { yyval.expr = val_peek(0).lvalue; } break; case 50: //#line 260 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PLUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 51: //#line 264 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MINUS, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 52: //#line 268 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MUL, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 53: //#line 272 "Parser.y" { yyval.expr = new Tree.Binary(Tree.DIV, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 54: //#line 276 "Parser.y" { yyval.expr = new Tree.Binary(Tree.MOD, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 55: //#line 280 "Parser.y" { yyval.expr = new Tree.Binary(Tree.EQ, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 56: //#line 284 "Parser.y" { yyval.expr = new Tree.Binary(Tree.NE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 57: //#line 288 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 58: //#line 292 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GT, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 59: //#line 296 "Parser.y" { yyval.expr = new Tree.Binary(Tree.LE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 60: //#line 300 "Parser.y" { yyval.expr = new Tree.Binary(Tree.GE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 61: //#line 304 "Parser.y" { yyval.expr = new Tree.Binary(Tree.AND, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 62: //#line 308 "Parser.y" { yyval.expr = new Tree.Binary(Tree.OR, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 63: //#line 312 "Parser.y" { yyval = val_peek(1); } break; case 64: //#line 316 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NEG, val_peek(0).expr, val_peek(1).loc); } break; case 65: //#line 320 "Parser.y" { yyval.expr = new Tree.Unary(Tree.NOT, val_peek(0).expr, val_peek(1).loc); } break; case 66: //#line 324 "Parser.y" { yyval.expr = new Tree.ReadIntExpr(val_peek(2).loc); } break; case 67: //#line 328 "Parser.y" { yyval.expr = new Tree.ReadLineExpr(val_peek(2).loc); } break; case 68: //#line 332 "Parser.y" { yyval.expr = new Tree.ThisExpr(val_peek(0).loc); } break; case 69: //#line 336 "Parser.y" { yyval.expr = new Tree.NewClass(val_peek(2).ident, val_peek(3).loc); } break; case 70: //#line 340 "Parser.y" { yyval.expr = new Tree.NewArray(val_peek(3).type, val_peek(1).expr, val_peek(4).loc); } break; case 71: //#line 344 "Parser.y" { yyval.expr = new Tree.TypeTest(val_peek(3).expr, val_peek(1).ident, val_peek(5).loc); } break; case 72: //#line 348 "Parser.y" { yyval.expr = new Tree.TypeCast(val_peek(2).ident, val_peek(0).expr, val_peek(0).loc); } break; case 73: //#line 352 "Parser.y" { yyval.expr = new Tree.Ternary(Tree.CONDEXPR, val_peek(4).expr, val_peek(2).expr, val_peek(0).expr, val_peek(3).loc); } break; case 74: //#line 356 "Parser.y" { yyval.expr = new Tree.Binary(Tree.PCLONE, val_peek(2).expr, val_peek(0).expr, val_peek(1).loc); } break; case 75: //#line 362 "Parser.y" { yyval.expr = new Tree.Literal(val_peek(0).typeTag, val_peek(0).literal, val_peek(0).loc); } break; case 76: //#line 366 "Parser.y" { yyval.expr = new Null(val_peek(0).loc); } break; case 78: //#line 373 "Parser.y" { yyval = new SemValue(); yyval.elist = new ArrayList<Tree.Expr>(); } break; case 79: //#line 380 "Parser.y" { yyval.elist.add(val_peek(0).expr); } break; case 80: //#line 384 "Parser.y" { yyval.elist = new ArrayList<Tree.Expr>(); yyval.elist.add(val_peek(0).expr); } break; case 81: //#line 391 "Parser.y" { yyval.stmt = new Tree.WhileLoop(val_peek(2).expr, val_peek(0).stmt, val_peek(4).loc); } break; case 82: //#line 397 "Parser.y" { yyval.stmt = new Tree.ForLoop(val_peek(6).stmt, val_peek(4).expr, val_peek(2).stmt, val_peek(0).stmt, val_peek(8).loc); } break; case 83: //#line 403 "Parser.y" { yyval.stmt = new Tree.Break(val_peek(0).loc); } break; case 84: //#line 409 "Parser.y" { yyval.stmt = new Tree.Continue(val_peek(0).loc); } break; case 85: //#line 415 "Parser.y" { yyval.stmt = new Tree.If(val_peek(3).expr, val_peek(1).stmt, val_peek(0).stmt, val_peek(5).loc); } break; case 86: //#line 421 "Parser.y" { yyval.stmt = new Tree.Switch(val_peek(5).expr, val_peek(2).caselist, val_peek(1).slist, val_peek(7).loc); } break; case 87: //#line 427 "Parser.y" { yyval.caselist.add(val_peek(0).casedef); } break; case 88: //#line 431 "Parser.y" { yyval = new SemValue(); yyval.caselist = new ArrayList<Case>(); } break; case 89: //#line 438 "Parser.y" { yyval.casedef = new Tree.Case(val_peek(2).expr, val_peek(0).slist, val_peek(3).loc); } break; case 90: //#line 444 "Parser.y" { yyval.slist = val_peek(0).slist; } break; case 91: //#line 448 "Parser.y" { yyval = new SemValue(); } break; case 92: //#line 454 "Parser.y" { yyval.stmt = new Tree.Repeat(val_peek(1).expr, val_peek(4).slist, val_peek(5).loc); } break; case 93: //#line 460 "Parser.y" { yyval.stmt = val_peek(0).stmt; } break; case 94: //#line 464 "Parser.y" { yyval = new SemValue(); } break; case 95: //#line 470 "Parser.y" { yyval.stmt = new Tree.Return(val_peek(0).expr, val_peek(1).loc); } break; case 96: //#line 474 "Parser.y" { yyval.stmt = new Tree.Return(null, val_peek(0).loc); } break; case 97: //#line 480 "Parser.y" { yyval.stmt = new Print(val_peek(1).elist, val_peek(3).loc); } break; //#line 1342 "Parser.java" //########## END OF USER-SUPPLIED ACTIONS ########## }//switch //#### Now let's reduce... #### //if (yydebug) debug("reduce"); state_drop(yym); //we just reduced yylen states yystate = state_peek(0); //get new state val_drop(yym); //corresponding value drop yym = yylhs[yyn]; //select next TERMINAL(on lhs) if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL { //if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+""); yystate = YYFINAL; //explicitly say we're done state_push(YYFINAL); //and save it val_push(yyval); //also save the semantic value of parsing if (yychar < 0) //we want another character? { yychar = yylex(); //get next character //if (yychar<0) yychar=0; //clean, if necessary //if (yydebug) //yylexdebug(yystate,yychar); } if (yychar == 0) //Good exit (if lex returns 0 ;-) break; //quit the loop--all DONE }//if yystate else //else not done yet { //get next state and push, for next yydefred[] yyn = yygindex[yym]; //find out where to go if ((yyn != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; //get new state else yystate = yydgoto[yym]; //else go to new defred //if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+""); state_push(yystate); //going again, so push state & val... val_push(yyval); //for next action } }//main loop return 0;//yyaccept!! } //## end of method parse() ###################################### //## run() --- for Thread ####################################### //## The -Jnorun option was used ## //## end of method run() ######################################## //## Constructors ############################################### //## The -Jnoconstruct option was used ## //############################################################### } //################### END OF CLASS ##############################
stellarkey/912_project
6 复试/2 笔试/4 编译原理/hw/2016_黄家晖_PA/698609556_1_decaf_PA1A/src/decaf/frontend/Parser.java
792
/* * Copyright 2021, OpenRemote Inc. * * See the CONTRIBUTORS.txt file in the distribution for a * full listing of individual contributors. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.openremote.agent.protocol.bluetooth.mesh.utils; import java.util.HashMap; import java.util.Map; public class CompanyIdentifiers { private static final Map<Integer, String> vendorModels = new HashMap<>(); static { initVendorModels(); } /** * Initializes company identifier and names with the given key/values */ private static void initVendorModels() { vendorModels.put(0x0000, "Ericsson Technology Licensing"); vendorModels.put(0x0001, "Nokia Mobile Phones"); vendorModels.put(0x0002, "Intel Corp."); vendorModels.put(0x0003, "IBM Corp."); vendorModels.put(0x0004, "Toshiba Corp."); vendorModels.put(0x0005, "3Com"); vendorModels.put(0x0006, "Microsoft"); vendorModels.put(0x0007, "Lucent"); vendorModels.put(0x0008, "Motorola"); vendorModels.put(0x0009, "Infineon Technologies AG"); vendorModels.put(0x000A, "Cambridge Silicon Radio"); vendorModels.put(0x000B, "Silicon Wave"); vendorModels.put(0x000C, "Digianswer A/S"); vendorModels.put(0x000D, "Texas Instruments Inc."); vendorModels.put(0x000E, "Parthus Technologies Inc."); vendorModels.put(0x000F, "Broadcom Corporation"); vendorModels.put(0x0010, "Mitel Semiconductor"); vendorModels.put(0x0011, "Widcomm, Inc."); vendorModels.put(0x0012, "Zeevo, Inc."); vendorModels.put(0x0013, "Atmel Corporation"); vendorModels.put(0x0014, "Mitsubishi Electric Corporation"); vendorModels.put(0x0015, "RTX Telecom A/S"); vendorModels.put(0x0016, "KC Technology Inc."); vendorModels.put(0x0017, "Newlogic"); vendorModels.put(0x0018, "Transilica, Inc."); vendorModels.put(0x0019, "Rohde & Schwarz GmbH & Co. KG"); vendorModels.put(0x001A, "TTPCom Limited"); vendorModels.put(0x001B, "Signia Technologies, Inc."); vendorModels.put(0x001C, "Conexant Systems Inc."); vendorModels.put(0x001D, "Qualcomm"); vendorModels.put(0x001E, "Inventel"); vendorModels.put(0x001F, "AVM Berlin"); vendorModels.put(0x0020, "BandSpeed, Inc."); vendorModels.put(0x0021, "Mansella Ltd"); vendorModels.put(0x0022, "NEC Corporation"); vendorModels.put(0x0023, "WavePlus Technology Co.,Ltd."); vendorModels.put(0x0024, "Alcatel"); vendorModels.put(0x0025, "NXP Semiconductors (formerly Philips Semiconductors);"); vendorModels.put(0x0026, "C Technologies"); vendorModels.put(0x0027, "Open Interface"); vendorModels.put(0x0028, "R F Micro Devices"); vendorModels.put(0x0029, "Hitachi Ltd"); vendorModels.put(0x002A, "Symbol Technologies, Inc."); vendorModels.put(0x002B, "Tenovis"); vendorModels.put(0x002C, "Macronix International Co. Ltd."); vendorModels.put(0x002D, "GCT Semiconductor"); vendorModels.put(0x002E, "Norwood Systems"); vendorModels.put(0x002F, "MewTel Technology Inc."); vendorModels.put(0x0030, "ST Microelectronics"); vendorModels.put(0x0031, "Synopsys, Inc."); vendorModels.put(0x0032, "Red-M (Communications,Ltd"); vendorModels.put(0x0033, "Commil Ltd"); vendorModels.put(0x0034, "Computer Access Technology Corporation (CATC);"); vendorModels.put(0x0035, "Eclipse (HQ Espana,S.L."); vendorModels.put(0x0036, "Renesas Electronics Corporation"); vendorModels.put(0x0037, "Mobilian Corporation"); vendorModels.put(0x0038, "Syntronix Corporation"); vendorModels.put(0x0039, "Integrated System Solution Corp."); vendorModels.put(0x003A, "Matsushita Electric Industrial Co.,Ltd."); vendorModels.put(0x003B, "Gennum Corporation"); vendorModels.put(0x003C, "BlackBerry Limited (formerly Research In Motion);"); vendorModels.put(0x003D, "IPextreme, Inc."); vendorModels.put(0x003E, "Systems and Chips, Inc"); vendorModels.put(0x003F, "Bluetooth SIG, Inc"); vendorModels.put(0x0040, "Seiko Epson Corporation"); vendorModels.put(0x0041, "Integrated Silicon Solution Taiwan, Inc."); vendorModels.put(0x0042, "CONWISE Technology Corporation Ltd"); vendorModels.put(0x0043, "PARROT AUTOMOTIVE SAS"); vendorModels.put(0x0044, "Socket Mobile"); vendorModels.put(0x0045, "Atheros Communications, Inc."); vendorModels.put(0x0046, "MediaTek, Inc."); vendorModels.put(0x0047, "Bluegiga"); vendorModels.put(0x0048, "Marvell Technology Group Ltd."); vendorModels.put(0x0049, "3DSP Corporation"); vendorModels.put(0x004A, "Accel Semiconductor Ltd."); vendorModels.put(0x004B, "Continental Automotive Systems"); vendorModels.put(0x004C, "Apple, Inc."); vendorModels.put(0x004D, "Staccato Communications, Inc."); vendorModels.put(0x004E, "Avago Technologies"); vendorModels.put(0x004F, "APT Ltd."); vendorModels.put(0x0050, "SiRF Technology, Inc."); vendorModels.put(0x0051, "Tzero Technologies, Inc."); vendorModels.put(0x0052, "J&M Corporation"); vendorModels.put(0x0053, "Free2move AB"); vendorModels.put(0x0054, "3DiJoy Corporation"); vendorModels.put(0x0055, "Plantronics, Inc."); vendorModels.put(0x0056, "Sony Ericsson Mobile Communications"); vendorModels.put(0x0057, "Harman International Industries, Inc."); vendorModels.put(0x0058, "Vizio, Inc."); vendorModels.put(0x0059, "Nordic Semiconductor ASA"); vendorModels.put(0x005A, "EM Microelectronic-Marin SA"); vendorModels.put(0x005B, "Ralink Technology Corporation"); vendorModels.put(0x005C, "Belkin International, Inc."); vendorModels.put(0x005D, "Realtek Semiconductor Corporation"); vendorModels.put(0x005E, "Stonestreet One,LLC"); vendorModels.put(0x005F, "Wicentric, Inc."); vendorModels.put(0x0060, "RivieraWaves S.A.S"); vendorModels.put(0x0061, "RDA Microelectronics"); vendorModels.put(0x0062, "Gibson Guitars"); vendorModels.put(0x0063, "MiCommand Inc."); vendorModels.put(0x0064, "Band XI International,LLC"); vendorModels.put(0x0065, "Hewlett-Packard Company"); vendorModels.put(0x0066, "9Solutions Oy"); vendorModels.put(0x0067, "GN Netcom A/S"); vendorModels.put(0x0068, "General Motors"); vendorModels.put(0x0069, "A&D Engineering, Inc."); vendorModels.put(0x006A, "MindTree Ltd."); vendorModels.put(0x006B, "Polar Electro OY"); vendorModels.put(0x006C, "Beautiful Enterprise Co.,Ltd."); vendorModels.put(0x006D, "BriarTek, Inc"); vendorModels.put(0x006E, "Summit Data Communications, Inc."); vendorModels.put(0x006F, "Sound ID"); vendorModels.put(0x0070, "Monster,LLC"); vendorModels.put(0x0071, "connectBlue AB"); vendorModels.put(0x0072, "ShangHai Super Smart Electronics Co. Ltd."); vendorModels.put(0x0073, "Group Sense Ltd."); vendorModels.put(0x0074, "Zomm,LLC"); vendorModels.put(0x0075, "Samsung Electronics Co. Ltd."); vendorModels.put(0x0076, "Creative Technology Ltd."); vendorModels.put(0x0077, "Laird Technologies"); vendorModels.put(0x0078, "Nike, Inc."); vendorModels.put(0x0079, "lesswire AG"); vendorModels.put(0x007A, "MStar Semiconductor, Inc."); vendorModels.put(0x007B, "Hanlynn Technologies"); vendorModels.put(0x007C, "A & R Cambridge"); vendorModels.put(0x007D, "Seers Technology Co.,Ltd."); vendorModels.put(0x007E, "Sports Tracking Technologies Ltd."); vendorModels.put(0x007F, "Autonet Mobile"); vendorModels.put(0x0080, "DeLorme Publishing Company, Inc."); vendorModels.put(0x0081, "WuXi Vimicro"); vendorModels.put(0x0082, "Sennheiser Communications A/S"); vendorModels.put(0x0083, "TimeKeeping Systems, Inc."); vendorModels.put(0x0084, "Ludus Helsinki Ltd."); vendorModels.put(0x0085, "BlueRadios, Inc."); vendorModels.put(0x0086, "Equinux AG"); vendorModels.put(0x0087, "Garmin International, Inc."); vendorModels.put(0x0088, "Ecotest"); vendorModels.put(0x0089, "GN ReSound A/S"); vendorModels.put(0x008A, "Jawbone"); vendorModels.put(0x008B, "Topcon Positioning Systems,LLC"); vendorModels.put(0x008C, "Gimbal Inc. (formerly Qualcomm Labs, Inc. and Qualcomm Retail Solutions, Inc.);"); vendorModels.put(0x008D, "Zscan Software"); vendorModels.put(0x008E, "Quintic Corp"); vendorModels.put(0x008F, "Telit Wireless Solutions GmbH (formerly Stollmann E+V GmbH);"); vendorModels.put(0x0090, "Funai Electric Co.,Ltd."); vendorModels.put(0x0091, "Advanced PANMOBIL systems GmbH & Co. KG"); vendorModels.put(0x0092, "ThinkOptics, Inc."); vendorModels.put(0x0093, "Universal Electronics, Inc."); vendorModels.put(0x0094, "Airoha Technology Corp."); vendorModels.put(0x0095, "NEC Lighting,Ltd."); vendorModels.put(0x0096, "ODM Technology, Inc."); vendorModels.put(0x0097, "ConnecteDevice Ltd."); vendorModels.put(0x0098, "zero1.tv GmbH"); vendorModels.put(0x0099, "i.Tech Dynamic Global Distribution Ltd."); vendorModels.put(0x009A, "Alpwise"); vendorModels.put(0x009B, "Jiangsu Toppower Automotive Electronics Co.,Ltd."); vendorModels.put(0x009C, "Colorfy, Inc."); vendorModels.put(0x009D, "Geoforce Inc."); vendorModels.put(0x009E, "Bose Corporation"); vendorModels.put(0x009F, "Suunto Oy"); vendorModels.put(0x00A0, "Kensington Computer Products Group"); vendorModels.put(0x00A1, "SR-Medizinelektronik"); vendorModels.put(0x00A2, "Vertu Corporation Limited"); vendorModels.put(0x00A3, "Meta Watch Ltd."); vendorModels.put(0x00A4, "LINAK A/S"); vendorModels.put(0x00A5, "OTL Dynamics LLC"); vendorModels.put(0x00A6, "Panda Ocean Inc."); vendorModels.put(0x00A7, "Visteon Corporation"); vendorModels.put(0x00A8, "ARP Devices Limited"); vendorModels.put(0x00A9, "Magneti Marelli S.p.A"); vendorModels.put(0x00AA, "CAEN RFID srl"); vendorModels.put(0x00AB, "Ingenieur-Systemgruppe Zahn GmbH"); vendorModels.put(0x00AC, "Green Throttle Games"); vendorModels.put(0x00AD, "Peter Systemtechnik GmbH"); vendorModels.put(0x00AE, "Omegawave Oy"); vendorModels.put(0x00AF, "Cinetix"); vendorModels.put(0x00B0, "Passif Semiconductor Corp"); vendorModels.put(0x00B1, "Saris Cycling Group, Inc"); vendorModels.put(0x00B2, "Bekey A/S"); vendorModels.put(0x00B3, "Clarinox Technologies Pty. Ltd."); vendorModels.put(0x00B4, "BDE Technology Co.,Ltd."); vendorModels.put(0x00B5, "Swirl Networks"); vendorModels.put(0x00B6, "Meso international"); vendorModels.put(0x00B7, "TreLab Ltd"); vendorModels.put(0x00B8, "Qualcomm Innovation Center, Inc. (QuIC);"); vendorModels.put(0x00B9, "Johnson Controls, Inc."); vendorModels.put(0x00BA, "Starkey Laboratories Inc."); vendorModels.put(0x00BB, "S-Power Electronics Limited"); vendorModels.put(0x00BC, "Ace Sensor Inc"); vendorModels.put(0x00BD, "Aplix Corporation"); vendorModels.put(0x00BE, "AAMP of America"); vendorModels.put(0x00BF, "Stalmart Technology Limited"); vendorModels.put(0x00C0, "AMICCOM Electronics Corporation"); vendorModels.put(0x00C1, "Shenzhen Excelsecu Data Technology Co.);Ltd"); vendorModels.put(0x00C2, "Geneq Inc."); vendorModels.put(0x00C3, "adidas AG"); vendorModels.put(0x00C4, "LG Electronics"); vendorModels.put(0x00C5, "Onset Computer Corporation"); vendorModels.put(0x00C6, "Selfly BV"); vendorModels.put(0x00C7, "Quuppa Oy."); vendorModels.put(0x00C8, "GeLo Inc"); vendorModels.put(0x00C9, "Evluma"); vendorModels.put(0x00CA, "MC10"); vendorModels.put(0x00CB, "Binauric SE"); vendorModels.put(0x00CC, "Beats Electronics"); vendorModels.put(0x00CD, "Microchip Technology Inc."); vendorModels.put(0x00CE, "Elgato Systems GmbH"); vendorModels.put(0x00CF, "ARCHOS SA"); vendorModels.put(0x00D0, "Dexcom, Inc."); vendorModels.put(0x00D1, "Polar Electro Europe B.V."); vendorModels.put(0x00D2, "Dialog Semiconductor B.V."); vendorModels.put(0x00D3, "Taixingbang Technology (HK,Co);. LTD."); vendorModels.put(0x00D4, "Kawantech"); vendorModels.put(0x00D5, "Austco Communication Systems"); vendorModels.put(0x00D6, "Timex Group USA, Inc."); vendorModels.put(0x00D7, "Qualcomm Technologies, Inc."); vendorModels.put(0x00D8, "Qualcomm Connected Experiences, Inc."); vendorModels.put(0x00D9, "Voyetra Turtle Beach"); vendorModels.put(0x00DA, "txtr GmbH"); vendorModels.put(0x00DB, "Biosentronics"); vendorModels.put(0x00DC, "Procter & Gamble"); vendorModels.put(0x00DD, "Hosiden Corporation"); vendorModels.put(0x00DE, "Muzik LLC"); vendorModels.put(0x00DF, "Misfit Wearables Corp"); vendorModels.put(0x00E0, "Google"); vendorModels.put(0x00E1, "Danlers Ltd"); vendorModels.put(0x00E2, "Semilink Inc"); vendorModels.put(0x00E3, "inMusic Brands, Inc"); vendorModels.put(0x00E4, "L.S. Research Inc."); vendorModels.put(0x00E5, "Eden Software Consultants Ltd."); vendorModels.put(0x00E6, "Freshtemp"); vendorModels.put(0x00E7, "KS Technologies"); vendorModels.put(0x00E8, "ACTS Technologies"); vendorModels.put(0x00E9, "Vtrack Systems"); vendorModels.put(0x00EA, "Nielsen-Kellerman Company"); vendorModels.put(0x00EB, "Server Technology Inc."); vendorModels.put(0x00EC, "BioResearch Associates"); vendorModels.put(0x00ED, "Jolly Logic,LLC"); vendorModels.put(0x00EE, "Above Average Outcomes, Inc."); vendorModels.put(0x00EF, "Bitsplitters GmbH"); vendorModels.put(0x00F0, "PayPal, Inc."); vendorModels.put(0x00F1, "Witron Technology Limited"); vendorModels.put(0x00F2, "Morse Project Inc."); vendorModels.put(0x00F3, "Kent Displays Inc."); vendorModels.put(0x00F4, "Nautilus Inc."); vendorModels.put(0x00F5, "Smartifier Oy"); vendorModels.put(0x00F6, "Elcometer Limited"); vendorModels.put(0x00F7, "VSN Technologies, Inc."); vendorModels.put(0x00F8, "AceUni Corp.,Ltd."); vendorModels.put(0x00F9, "StickNFind"); vendorModels.put(0x00FA, "Crystal Code AB"); vendorModels.put(0x00FB, "KOUKAAM a.s."); vendorModels.put(0x00FC, "Delphi Corporation"); vendorModels.put(0x00FD, "ValenceTech Limited"); vendorModels.put(0x00FE, "Stanley Black and Decker"); vendorModels.put(0x00FF, "Typo Products,LLC"); vendorModels.put(0x0100, "TomTom International BV"); vendorModels.put(0x0101, "Fugoo, Inc."); vendorModels.put(0x0102, "Keiser Corporation"); vendorModels.put(0x0103, "Bang & Olufsen A/S"); vendorModels.put(0x0104, "PLUS Location Systems Pty Ltd"); vendorModels.put(0x0105, "Ubiquitous Computing Technology Corporation"); vendorModels.put(0x0106, "Innovative Yachtter Solutions"); vendorModels.put(0x0107, "William Demant Holding A/S"); vendorModels.put(0x0108, "Chicony Electronics Co.,Ltd."); vendorModels.put(0x0109, "Atus BV"); vendorModels.put(0x010A, "Codegate Ltd"); vendorModels.put(0x010B, "ERi, Inc"); vendorModels.put(0x010C, "Transducers Direct,LLC"); vendorModels.put(0x010D, "Fujitsu Ten LImited"); vendorModels.put(0x010E, "Audi AG"); vendorModels.put(0x010F, "HiSilicon Technologies Col,Ltd."); vendorModels.put(0x0110, "Nippon Seiki Co.,Ltd."); vendorModels.put(0x0111, "Steelseries ApS"); vendorModels.put(0x0112, "Visybl Inc."); vendorModels.put(0x0113, "Openbrain Technologies,Co.,Ltd."); vendorModels.put(0x0114, "Xensr"); vendorModels.put(0x0115, "e.solutions"); vendorModels.put(0x0116, "10AK Technologies"); vendorModels.put(0x0117, "Wimoto Technologies Inc"); vendorModels.put(0x0118, "Radius Networks, Inc."); vendorModels.put(0x0119, "Wize Technology Co.,Ltd."); vendorModels.put(0x011A, "Qualcomm Labs, Inc."); vendorModels.put(0x011B, "Hewlett Packard Enterprise"); vendorModels.put(0x011C, "Baidu"); vendorModels.put(0x011D, "Arendi AG"); vendorModels.put(0x011E, "Skoda Auto a.s."); vendorModels.put(0x011F, "Volkswagen AG"); vendorModels.put(0x0120, "Porsche AG"); vendorModels.put(0x0121, "Sino Wealth Electronic Ltd."); vendorModels.put(0x0122, "AirTurn, Inc."); vendorModels.put(0x0123, "Kinsa, Inc"); vendorModels.put(0x0124, "HID Global"); vendorModels.put(0x0125, "SEAT es"); vendorModels.put(0x0126, "Promethean Ltd."); vendorModels.put(0x0127, "Salutica Allied Solutions"); vendorModels.put(0x0128, "GPSI Group Pty Ltd"); vendorModels.put(0x0129, "Nimble Devices Oy"); vendorModels.put(0x012A, "Changzhou Yongse Infotech Co.,Ltd."); vendorModels.put(0x012B, "SportIQ"); vendorModels.put(0x012C, "TEMEC Instruments B.V."); vendorModels.put(0x012D, "Sony Corporation"); vendorModels.put(0x012E, "ASSA ABLOY"); vendorModels.put(0x012F, "Clarion Co. Inc."); vendorModels.put(0x0130, "Warehouse Innovations"); vendorModels.put(0x0131, "Cypress Semiconductor"); vendorModels.put(0x0132, "MADS Inc"); vendorModels.put(0x0133, "Blue Maestro Limited"); vendorModels.put(0x0134, "Resolution Products,Ltd."); vendorModels.put(0x0135, "Aireware LLC"); vendorModels.put(0x0136, "Silvair, Inc."); vendorModels.put(0x0137, "Prestigio Plaza Ltd."); vendorModels.put(0x0138, "NTEO Inc."); vendorModels.put(0x0139, "Focus Systems Corporation"); vendorModels.put(0x013A, "Tencent Holdings Ltd."); vendorModels.put(0x013B, "Allegion"); vendorModels.put(0x013C, "Murata Manufacturing Co.,Ltd."); vendorModels.put(0x013D, "WirelessWERX"); vendorModels.put(0x013E, "Nod, Inc."); vendorModels.put(0x013F, "B&B Manufacturing Company"); vendorModels.put(0x0140, "Alpine Electronics (China,Co.,Ltd"); vendorModels.put(0x0141, "FedEx Services"); vendorModels.put(0x0142, "Grape Systems Inc."); vendorModels.put(0x0143, "Bkon Connect"); vendorModels.put(0x0144, "Lintech GmbH"); vendorModels.put(0x0145, "Novatel Wireless"); vendorModels.put(0x0146, "Ciright"); vendorModels.put(0x0147, "Mighty Cast, Inc."); vendorModels.put(0x0148, "Ambimat Electronics"); vendorModels.put(0x0149, "Perytons Ltd."); vendorModels.put(0x014A, "Tivoli Audio,LLC"); vendorModels.put(0x014B, "Master Lock"); vendorModels.put(0x014C, "Mesh-Net Ltd"); vendorModels.put(0x014D, "HUIZHOU DESAY SV AUTOMOTIVE CO.,LTD."); vendorModels.put(0x014E, "Tangerine, Inc."); vendorModels.put(0x014F, "B&W Group Ltd."); vendorModels.put(0x0150, "Pioneer Corporation"); vendorModels.put(0x0151, "OnBeep"); vendorModels.put(0x0152, "Vernier Software & Technology"); vendorModels.put(0x0153, "ROL Ergo"); vendorModels.put(0x0154, "Pebble Technology"); vendorModels.put(0x0155, "NETATMO"); vendorModels.put(0x0156, "Accumulate AB"); vendorModels.put(0x0157, "Anhui Huami Information Technology Co.,Ltd."); vendorModels.put(0x0158, "Inmite s.r.o."); vendorModels.put(0x0159, "ChefSteps, Inc."); vendorModels.put(0x015A, "micas AG"); vendorModels.put(0x015B, "Biomedical Research Ltd."); vendorModels.put(0x015C, "Pitius Tec S.L."); vendorModels.put(0x015D, "Estimote, Inc."); vendorModels.put(0x015E, "Unikey Technologies, Inc."); vendorModels.put(0x015F, "Timer Cap Co."); vendorModels.put(0x0160, "AwoX"); vendorModels.put(0x0161, "yikes"); vendorModels.put(0x0162, "MADSGlobalNZ Ltd."); vendorModels.put(0x0163, "PCH International"); vendorModels.put(0x0164, "Qingdao Yeelink Information Technology Co.,Ltd."); vendorModels.put(0x0165, "Milwaukee Tool (Formally Milwaukee Electric Tools);"); vendorModels.put(0x0166, "MISHIK Pte Ltd"); vendorModels.put(0x0167, "Ascensia Diabetes Care US Inc."); vendorModels.put(0x0168, "Spicebox LLC"); vendorModels.put(0x0169, "emberlight"); vendorModels.put(0x016A, "Cooper-Atkins Corporation"); vendorModels.put(0x016B, "Qblinks"); vendorModels.put(0x016C, "MYSPHERA"); vendorModels.put(0x016D, "LifeScan Inc"); vendorModels.put(0x016E, "Volantic AB"); vendorModels.put(0x016F, "Podo Labs, Inc"); vendorModels.put(0x0170, "Roche Diabetes Care AG"); vendorModels.put(0x0171, "Amazon Fulfillment Service"); vendorModels.put(0x0172, "Connovate Technology Private Limited"); vendorModels.put(0x0173, "Kocomojo,LLC"); vendorModels.put(0x0174, "Everykey Inc."); vendorModels.put(0x0175, "Dynamic Controls"); vendorModels.put(0x0176, "SentriLock"); vendorModels.put(0x0177, "I-SYST inc."); vendorModels.put(0x0178, "CASIO COMPUTER CO.,LTD."); vendorModels.put(0x0179, "LAPIS Semiconductor Co.,Ltd."); vendorModels.put(0x017A, "Telemonitor, Inc."); vendorModels.put(0x017B, "taskit GmbH"); vendorModels.put(0x017C, "Daimler AG"); vendorModels.put(0x017D, "BatAndCat"); vendorModels.put(0x017E, "BluDotz Ltd"); vendorModels.put(0x017F, "XTel Wireless ApS"); vendorModels.put(0x0180, "Gigaset Communications GmbH"); vendorModels.put(0x0181, "Gecko Health Innovations, Inc."); vendorModels.put(0x0182, "HOP Ubiquitous"); vendorModels.put(0x0183, "Walt Disney"); vendorModels.put(0x0184, "Nectar"); vendorModels.put(0x0185, "bel'apps LLC"); vendorModels.put(0x0186, "CORE Lighting Ltd"); vendorModels.put(0x0187, "Seraphim Sense Ltd"); vendorModels.put(0x0188, "Unico RBC"); vendorModels.put(0x0189, "Physical Enterprises Inc."); vendorModels.put(0x018A, "Able Trend Technology Limited"); vendorModels.put(0x018B, "Konica Minolta, Inc."); vendorModels.put(0x018C, "Wilo SE"); vendorModels.put(0x018D, "Extron Design Services"); vendorModels.put(0x018E, "Fitbit, Inc."); vendorModels.put(0x018F, "Fireflies Systems"); vendorModels.put(0x0190, "Intelletto Technologies Inc."); vendorModels.put(0x0191, "FDK CORPORATION"); vendorModels.put(0x0192, "Cloudleaf, Inc"); vendorModels.put(0x0193, "Maveric Automation LLC"); vendorModels.put(0x0194, "Acoustic Stream Corporation"); vendorModels.put(0x0195, "Zuli"); vendorModels.put(0x0196, "Paxton Access Ltd"); vendorModels.put(0x0197, "WiSilica Inc."); vendorModels.put(0x0198, "VENGIT Korlatolt Felelossegu Tarsasag"); vendorModels.put(0x0199, "SALTO SYSTEMS S.L."); vendorModels.put(0x019A, "TRON Forum (formerly T-Engine Forum);"); vendorModels.put(0x019B, "CUBETECH s.r.o."); vendorModels.put(0x019C, "Cokiya Incorporated"); vendorModels.put(0x019D, "CVS Health"); vendorModels.put(0x019E, "Ceruus"); vendorModels.put(0x019F, "Strainstall Ltd"); vendorModels.put(0x01A0, "Channel Enterprises (HK,Ltd."); vendorModels.put(0x01A1, "FIAMM"); vendorModels.put(0x01A2, "GIGALANE.CO.);LTD"); vendorModels.put(0x01A3, "EROAD"); vendorModels.put(0x01A4, "Mine Safety Appliances"); vendorModels.put(0x01A5, "Icon Health and Fitness"); vendorModels.put(0x01A6, "Asandoo GmbH"); vendorModels.put(0x01A7, "ENERGOUS CORPORATION"); vendorModels.put(0x01A8, "Taobao"); vendorModels.put(0x01A9, "Canon Inc."); vendorModels.put(0x01AA, "Geophysical Technology Inc."); vendorModels.put(0x01AB, "Facebook, Inc."); vendorModels.put(0x01AC, "Trividia Health, Inc."); vendorModels.put(0x01AD, "FlightSafety International"); vendorModels.put(0x01AE, "Earlens Corporation"); vendorModels.put(0x01AF, "Sunrise Micro Devices, Inc."); vendorModels.put(0x01B0, "Star Micronics Co.,Ltd."); vendorModels.put(0x01B1, "Netizens Sp. z o.o."); vendorModels.put(0x01B2, "Nymi Inc."); vendorModels.put(0x01B3, "Nytec, Inc."); vendorModels.put(0x01B4, "Trineo Sp. z o.o."); vendorModels.put(0x01B5, "Nest Labs Inc."); vendorModels.put(0x01B6, "LM Technologies Ltd"); vendorModels.put(0x01B7, "General Electric Company"); vendorModels.put(0x01B8, "i+D3 S.L."); vendorModels.put(0x01B9, "HANA Micron"); vendorModels.put(0x01BA, "Stages Cycling LLC"); vendorModels.put(0x01BB, "Cochlear Bone Anchored Solutions AB"); vendorModels.put(0x01BC, "SenionLab AB"); vendorModels.put(0x01BD, "Syszone Co.,Ltd"); vendorModels.put(0x01BE, "Pulsate Mobile Ltd."); vendorModels.put(0x01BF, "Hong Kong HunterSun Electronic Limited"); vendorModels.put(0x01C0, "pironex GmbH"); vendorModels.put(0x01C1, "BRADATECH Corp."); vendorModels.put(0x01C2, "Transenergooil AG"); vendorModels.put(0x01C3, "Bunch"); vendorModels.put(0x01C4, "DME Microelectronics"); vendorModels.put(0x01C5, "Bitcraze AB"); vendorModels.put(0x01C6, "HASWARE Inc."); vendorModels.put(0x01C7, "Abiogenix Inc."); vendorModels.put(0x01C8, "Poly-Control ApS"); vendorModels.put(0x01C9, "Avi-on"); vendorModels.put(0x01CA, "Laerdal Medical AS"); vendorModels.put(0x01CB, "Fetch My Pet"); vendorModels.put(0x01CC, "Sam Labs Ltd."); vendorModels.put(0x01CD, "Chengdu Synwing Technology Ltd"); vendorModels.put(0x01CE, "HOUWA SYSTEM DESIGN,k.k."); vendorModels.put(0x01CF, "BSH"); vendorModels.put(0x01D0, "Primus Inter Pares Ltd"); vendorModels.put(0x01D1, "August Home, Inc"); vendorModels.put(0x01D2, "Gill Electronics"); vendorModels.put(0x01D3, "Sky Wave Design"); vendorModels.put(0x01D4, "Newlab S.r.l."); vendorModels.put(0x01D5, "ELAD srl"); vendorModels.put(0x01D6, "G-wearables inc."); vendorModels.put(0x01D7, "Squadrone Systems Inc."); vendorModels.put(0x01D8, "Code Corporation"); vendorModels.put(0x01D9, "Savant Systems LLC"); vendorModels.put(0x01DA, "Logitech International SA"); vendorModels.put(0x01DB, "Innblue Consulting"); vendorModels.put(0x01DC, "iParking Ltd."); vendorModels.put(0x01DD, "Koninklijke Philips Electronics N.V."); vendorModels.put(0x01DE, "Minelab Electronics Pty Limited"); vendorModels.put(0x01DF, "Bison Group Ltd."); vendorModels.put(0x01E0, "Widex A/S"); vendorModels.put(0x01E1, "Jolla Ltd"); vendorModels.put(0x01E2, "Lectronix, Inc."); vendorModels.put(0x01E3, "Caterpillar Inc"); vendorModels.put(0x01E4, "Freedom Innovations"); vendorModels.put(0x01E5, "Dynamic Devices Ltd"); vendorModels.put(0x01E6, "Technology Solutions (UK,Ltd"); vendorModels.put(0x01E7, "IPS Group Inc."); vendorModels.put(0x01E8, "STIR"); vendorModels.put(0x01E9, "Sano, Inc."); vendorModels.put(0x01EA, "Advanced Application Design, Inc."); vendorModels.put(0x01EB, "AutoMap LLC"); vendorModels.put(0x01EC, "Spreadtrum Communications Shanghai Ltd"); vendorModels.put(0x01ED, "CuteCircuit LTD"); vendorModels.put(0x01EE, "Valeo Service"); vendorModels.put(0x01EF, "Fullpower Technologies, Inc."); vendorModels.put(0x01F0, "KloudNation"); vendorModels.put(0x01F1, "Zebra Technologies Corporation"); vendorModels.put(0x01F2, "Itron, Inc."); vendorModels.put(0x01F3, "The University of Tokyo"); vendorModels.put(0x01F4, "UTC Fire and Security"); vendorModels.put(0x01F5, "Cool Webthings Limited"); vendorModels.put(0x01F6, "DJO Global"); vendorModels.put(0x01F7, "Gelliner Limited"); vendorModels.put(0x01F8, "Anyka (Guangzhou,Microelectronics Technology Co,LTD"); vendorModels.put(0x01F9, "Medtronic Inc."); vendorModels.put(0x01FA, "Gozio Inc."); vendorModels.put(0x01FB, "Form Lifting,LLC"); vendorModels.put(0x01FC, "Wahoo Fitness,LLC"); vendorModels.put(0x01FD, "Kontakt Micro-Location Sp. z o.o."); vendorModels.put(0x01FE, "Radio Systems Corporation"); vendorModels.put(0x01FF, "Freescale Semiconductor, Inc."); vendorModels.put(0x0200, "Verifone Systems Pte Ltd. Taiwan Branch"); vendorModels.put(0x0201, "AR Timing"); vendorModels.put(0x0202, "Rigado LLC"); vendorModels.put(0x0203, "Kemppi Oy"); vendorModels.put(0x0204, "Tapcentive Inc."); vendorModels.put(0x0205, "Smartbotics Inc."); vendorModels.put(0x0206, "Otter Products,LLC"); vendorModels.put(0x0207, "STEMP Inc."); vendorModels.put(0x0208, "LumiGeek LLC"); vendorModels.put(0x0209, "InvisionHeart Inc."); vendorModels.put(0x020A, "Macnica Inc."); vendorModels.put(0x020B, "Jaguar Land Rover Limited"); vendorModels.put(0x020C, "CoroWare Technologies, Inc"); vendorModels.put(0x020D, "Simplo Technology Co.,LTD"); vendorModels.put(0x020E, "Omron Healthcare Co.,LTD"); vendorModels.put(0x020F, "Comodule GMBH"); vendorModels.put(0x0210, "ikeGPS"); vendorModels.put(0x0211, "Telink Semiconductor Co. Ltd"); vendorModels.put(0x0212, "Interplan Co.,Ltd"); vendorModels.put(0x0213, "Wyler AG"); vendorModels.put(0x0214, "IK Multimedia Production srl"); vendorModels.put(0x0215, "Lukoton Experience Oy"); vendorModels.put(0x0216, "MTI Ltd"); vendorModels.put(0x0217, "Tech4home,Lda"); vendorModels.put(0x0218, "Hiotech AB"); vendorModels.put(0x0219, "DOTT Limited"); vendorModels.put(0x021A, "Blue Speck Labs,LLC"); vendorModels.put(0x021B, "Cisco Systems, Inc"); vendorModels.put(0x021C, "Mobicomm Inc"); vendorModels.put(0x021D, "Edamic"); vendorModels.put(0x021E, "Goodnet,Ltd"); vendorModels.put(0x021F, "Luster Leaf Products Inc"); vendorModels.put(0x0220, "Manus Machina BV"); vendorModels.put(0x0221, "Mobiquity Networks Inc"); vendorModels.put(0x0222, "Praxis Dynamics"); vendorModels.put(0x0223, "Philip Morris Products S.A."); vendorModels.put(0x0224, "Comarch SA"); vendorModels.put(0x0225, "Nestl Nespresso S.A."); vendorModels.put(0x0226, "Merlinia A/S"); vendorModels.put(0x0227, "LifeBEAM Technologies"); vendorModels.put(0x0228, "Twocanoes Labs,LLC"); vendorModels.put(0x0229, "Muoverti Limited"); vendorModels.put(0x022A, "Stamer Musikanlagen GMBH"); vendorModels.put(0x022B, "Tesla Motors"); vendorModels.put(0x022C, "Pharynks Corporation"); vendorModels.put(0x022D, "Lupine"); vendorModels.put(0x022E, "Siemens AG"); vendorModels.put(0x022F, "Huami (Shanghai,Culture Communication CO.,LTD"); vendorModels.put(0x0230, "Foster Electric Company,Ltd"); vendorModels.put(0x0231, "ETA SA"); vendorModels.put(0x0232, "x-Senso Solutions Kft"); vendorModels.put(0x0233, "Shenzhen SuLong Communication Ltd"); vendorModels.put(0x0234, "FengFan (BeiJing,Technology Co,Ltd"); vendorModels.put(0x0235, "Qrio Inc"); vendorModels.put(0x0236, "Pitpatpet Ltd"); vendorModels.put(0x0237, "MSHeli s.r.l."); vendorModels.put(0x0238, "Trakm8 Ltd"); vendorModels.put(0x0239, "JIN CO,Ltd"); vendorModels.put(0x023A, "Alatech Tehnology"); vendorModels.put(0x023B, "Beijing CarePulse Electronic Technology Co,Ltd"); vendorModels.put(0x023C, "Awarepoint"); vendorModels.put(0x023D, "ViCentra B.V."); vendorModels.put(0x023E, "Raven Industries"); vendorModels.put(0x023F, "WaveWare Technologies Inc."); vendorModels.put(0x0240, "Argenox Technologies"); vendorModels.put(0x0241, "Bragi GmbH"); vendorModels.put(0x0242, "16Lab Inc"); vendorModels.put(0x0243, "Masimo Corp"); vendorModels.put(0x0244, "Iotera Inc"); vendorModels.put(0x0245, "Endress+Hauser"); vendorModels.put(0x0246, "ACKme Networks, Inc."); vendorModels.put(0x0247, "FiftyThree Inc."); vendorModels.put(0x0248, "Parker Hannifin Corp"); vendorModels.put(0x0249, "Transcranial Ltd"); vendorModels.put(0x024A, "Uwatec AG"); vendorModels.put(0x024B, "Orlan LLC"); vendorModels.put(0x024C, "Blue Clover Devices"); vendorModels.put(0x024D, "M-Way Solutions GmbH"); vendorModels.put(0x024E, "Microtronics Engineering GmbH"); vendorModels.put(0x024F, "Schneider Schreibgerte GmbH"); vendorModels.put(0x0250, "Sapphire Circuits LLC"); vendorModels.put(0x0251, "Lumo Bodytech Inc."); vendorModels.put(0x0252, "UKC Technosolution"); vendorModels.put(0x0253, "Xicato Inc."); vendorModels.put(0x0254, "Playbrush"); vendorModels.put(0x0255, "Dai Nippon Printing Co.,Ltd."); vendorModels.put(0x0256, "G24 Power Limited"); vendorModels.put(0x0257, "AdBabble Local Commerce Inc."); vendorModels.put(0x0258, "Devialet SA"); vendorModels.put(0x0259, "ALTYOR"); vendorModels.put(0x025A, "University of Applied Sciences Valais/Haute Ecole Valaisanne"); vendorModels.put(0x025B, "Five Interactive,LLC dba Zendo"); vendorModels.put(0x025C, "NetEaseHangzhouNetwork co.Ltd."); vendorModels.put(0x025D, "Lexmark International Inc."); vendorModels.put(0x025E, "Fluke Corporation"); vendorModels.put(0x025F, "Yardarm Technologies"); vendorModels.put(0x0260, "SensaRx"); vendorModels.put(0x0261, "SECVRE GmbH"); vendorModels.put(0x0262, "Glacial Ridge Technologies"); vendorModels.put(0x0263, "Identiv, Inc."); vendorModels.put(0x0264, "DDS, Inc."); vendorModels.put(0x0265, "SMK Corporation"); vendorModels.put(0x0266, "Schawbel Technologies LLC"); vendorModels.put(0x0267, "XMI Systems SA"); vendorModels.put(0x0268, "Cerevo"); vendorModels.put(0x0269, "Torrox GmbH & Co KG"); vendorModels.put(0x026A, "Gemalto"); vendorModels.put(0x026B, "DEKA Research & Development Corp."); vendorModels.put(0x026C, "Domster Tadeusz Szydlowski"); vendorModels.put(0x026D, "Technogym SPA"); vendorModels.put(0x026E, "FLEURBAEY BVBA"); vendorModels.put(0x026F, "Aptcode Solutions"); vendorModels.put(0x0270, "LSI ADL Technology"); vendorModels.put(0x0271, "Animas Corp"); vendorModels.put(0x0272, "Alps Electric Co.,Ltd."); vendorModels.put(0x0273, "OCEASOFT"); vendorModels.put(0x0274, "Motsai Research"); vendorModels.put(0x0275, "Geotab"); vendorModels.put(0x0276, "E.G.O. Elektro-Gertebau GmbH"); vendorModels.put(0x0277, "bewhere inc"); vendorModels.put(0x0278, "Johnson Outdoors Inc"); vendorModels.put(0x0279, "steute Schaltgerate GmbH & Co. KG"); vendorModels.put(0x027A, "Ekomini inc."); vendorModels.put(0x027B, "DEFA AS"); vendorModels.put(0x027C, "Aseptika Ltd"); vendorModels.put(0x027D, "HUAWEI Technologies Co.,Ltd. ( );"); vendorModels.put(0x027E, "HabitAware,LLC"); vendorModels.put(0x027F, "ruwido austria gmbh"); vendorModels.put(0x0280, "ITEC corporation"); vendorModels.put(0x0281, "StoneL"); vendorModels.put(0x0282, "Sonova AG"); vendorModels.put(0x0283, "Maven Machines, Inc."); vendorModels.put(0x0284, "Synapse Electronics"); vendorModels.put(0x0285, "Standard Innovation Inc."); vendorModels.put(0x0286, "RF Code, Inc."); vendorModels.put(0x0287, "Wally Ventures S.L."); vendorModels.put(0x0288, "Willowbank Electronics Ltd"); vendorModels.put(0x0289, "SK Telecom"); vendorModels.put(0x028A, "Jetro AS"); vendorModels.put(0x028B, "Code Gears LTD"); vendorModels.put(0x028C, "NANOLINK APS"); vendorModels.put(0x028D, "IF,LLC"); vendorModels.put(0x028E, "RF Digital Corp"); vendorModels.put(0x028F, "Church & Dwight Co., Inc"); vendorModels.put(0x0290, "Multibit Oy"); vendorModels.put(0x0291, "CliniCloud Inc"); vendorModels.put(0x0292, "SwiftSensors"); vendorModels.put(0x0293, "Blue Bite"); vendorModels.put(0x0294, "ELIAS GmbH"); vendorModels.put(0x0295, "Sivantos GmbH"); vendorModels.put(0x0296, "Petzl"); vendorModels.put(0x0297, "storm power ltd"); vendorModels.put(0x0298, "EISST Ltd"); vendorModels.put(0x0299, "Inexess Technology Simma KG"); vendorModels.put(0x029A, "Currant, Inc."); vendorModels.put(0x029B, "C2 Development, Inc."); vendorModels.put(0x029C, "Blue Sky Scientific,LLC"); vendorModels.put(0x029D, "ALOTTAZS LABS,LLC"); vendorModels.put(0x029E, "Kupson spol. s r.o."); vendorModels.put(0x029F, "Areus Engineering GmbH"); vendorModels.put(0x02A0, "Impossible Camera GmbH"); vendorModels.put(0x02A1, "InventureTrack Systems"); vendorModels.put(0x02A2, "LockedUp"); vendorModels.put(0x02A3, "Itude"); vendorModels.put(0x02A4, "Pacific Lock Company"); vendorModels.put(0x02A5, "Tendyron Corporation ( );"); vendorModels.put(0x02A6, "Robert Bosch GmbH"); vendorModels.put(0x02A7, "Illuxtron international B.V."); vendorModels.put(0x02A8, "miSport Ltd."); vendorModels.put(0x02A9, "Chargelib"); vendorModels.put(0x02AA, "Doppler Lab"); vendorModels.put(0x02AB, "BBPOS Limited"); vendorModels.put(0x02AC, "RTB Elektronik GmbH & Co. KG"); vendorModels.put(0x02AD, "Rx Networks, Inc."); vendorModels.put(0x02AE, "WeatherFlow, Inc."); vendorModels.put(0x02AF, "Technicolor USA Inc."); vendorModels.put(0x02B0, "Bestechnic(Shanghai););Ltd"); vendorModels.put(0x02B1, "Raden Inc"); vendorModels.put(0x02B2, "JouZen Oy"); vendorModels.put(0x02B3, "CLABER S.P.A."); vendorModels.put(0x02B4, "Hyginex, Inc."); vendorModels.put(0x02B5, "HANSHIN ELECTRIC RAILWAY CO.);LTD."); vendorModels.put(0x02B6, "Schneider Electric"); vendorModels.put(0x02B7, "Oort Technologies LLC"); vendorModels.put(0x02B8, "Chrono Therapeutics"); vendorModels.put(0x02B9, "Rinnai Corporation"); vendorModels.put(0x02BA, "Swissprime Technologies AG"); vendorModels.put(0x02BB, "Koha.);Co.Ltd"); vendorModels.put(0x02BC, "Genevac Ltd"); vendorModels.put(0x02BD, "Chemtronics"); vendorModels.put(0x02BE, "Seguro Technology Sp. z o.o."); vendorModels.put(0x02BF, "Redbird Flight Simulations"); vendorModels.put(0x02C0, "Dash Robotics"); vendorModels.put(0x02C1, "LINE Corporation"); vendorModels.put(0x02C2, "Guillemot Corporation"); vendorModels.put(0x02C3, "Techtronic Power Tools Technology Limited"); vendorModels.put(0x02C4, "Wilson Sporting Goods"); vendorModels.put(0x02C5, "Lenovo (Singapore,Pte Ltd. ( );"); vendorModels.put(0x02C6, "Ayatan Sensors"); vendorModels.put(0x02C7, "Electronics Tomorrow Limited"); vendorModels.put(0x02C8, "VASCO Data Security International, Inc."); vendorModels.put(0x02C9, "PayRange Inc."); vendorModels.put(0x02CA, "ABOV Semiconductor"); vendorModels.put(0x02CB, "AINA-Wireless Inc."); vendorModels.put(0x02CC, "Eijkelkamp Soil & Water"); vendorModels.put(0x02CD, "BMA ergonomics b.v."); vendorModels.put(0x02CE, "Teva Branded Pharmaceutical Products R&D, Inc."); vendorModels.put(0x02CF, "Anima"); vendorModels.put(0x02D0, "3M"); vendorModels.put(0x02D1, "Empatica Srl"); vendorModels.put(0x02D2, "Afero, Inc."); vendorModels.put(0x02D3, "Powercast Corporation"); vendorModels.put(0x02D4, "Secuyou ApS"); vendorModels.put(0x02D5, "OMRON Corporation"); vendorModels.put(0x02D6, "Send Solutions"); vendorModels.put(0x02D7, "NIPPON SYSTEMWARE CO.);LTD."); vendorModels.put(0x02D8, "Neosfar"); vendorModels.put(0x02D9, "Fliegl Agrartechnik GmbH"); vendorModels.put(0x02DA, "Gilvader"); vendorModels.put(0x02DB, "Digi International Inc (R);"); vendorModels.put(0x02DC, "DeWalch Technologies, Inc."); vendorModels.put(0x02DD, "Flint Rehabilitation Devices,LLC"); vendorModels.put(0x02DE, "Samsung SDS Co.,Ltd."); vendorModels.put(0x02DF, "Blur Product Development"); vendorModels.put(0x02E0, "University of Michigan"); vendorModels.put(0x02E1, "Victron Energy BV"); vendorModels.put(0x02E2, "NTT docomo"); vendorModels.put(0x02E3, "Carmanah Technologies Corp."); vendorModels.put(0x02E4, "Bytestorm Ltd."); vendorModels.put(0x02E5, "Espressif Incorporated ( (,);"); vendorModels.put(0x02E6, "Unwire"); vendorModels.put(0x02E7, "Connected Yard, Inc."); vendorModels.put(0x02E8, "American Music Environments"); vendorModels.put(0x02E9, "Sensogram Technologies, Inc."); vendorModels.put(0x02EA, "Fujitsu Limited"); vendorModels.put(0x02EB, "Ardic Technology"); vendorModels.put(0x02EC, "Delta Systems, Inc"); vendorModels.put(0x02ED, "HTC Corporation"); vendorModels.put(0x02EE, "Citizen Holdings Co.,Ltd."); vendorModels.put(0x02EF, "SMART-INNOVATION.inc"); vendorModels.put(0x02F0, "Blackrat Software"); vendorModels.put(0x02F1, "The Idea Cave,LLC"); vendorModels.put(0x02F2, "GoPro, Inc."); vendorModels.put(0x02F3, "AuthAir, Inc"); vendorModels.put(0x02F4, "Vensi, Inc."); vendorModels.put(0x02F5, "Indagem Tech LLC"); vendorModels.put(0x02F6, "Intemo Technologies"); vendorModels.put(0x02F7, "DreamVisions co.,Ltd."); vendorModels.put(0x02F8, "Runteq Oy Ltd"); vendorModels.put(0x02F9, "IMAGINATION TECHNOLOGIES LTD"); vendorModels.put(0x02FA, "CoSTAR TEchnologies"); vendorModels.put(0x02FB, "Clarius Mobile Health Corp."); vendorModels.put(0x02FC, "Shanghai Frequen Microelectronics Co.,Ltd."); vendorModels.put(0x02FD, "Uwanna, Inc."); vendorModels.put(0x02FE, "Lierda Science & Technology Group Co.,Ltd."); vendorModels.put(0x02FF, "Silicon Laboratories"); vendorModels.put(0x0300, "World Moto Inc."); vendorModels.put(0x0301, "Giatec Scientific Inc."); vendorModels.put(0x0302, "Loop Devices, Inc"); vendorModels.put(0x0303, "IACA electronique"); vendorModels.put(0x0304, "Proxy Technologies, Inc."); vendorModels.put(0x0305, "Swipp ApS"); vendorModels.put(0x0306, "Life Laboratory Inc."); vendorModels.put(0x0307, "FUJI INDUSTRIAL CO.);LTD."); vendorModels.put(0x0308, "Surefire,LLC"); vendorModels.put(0x0309, "Dolby Labs"); vendorModels.put(0x030A, "Ellisys"); vendorModels.put(0x030B, "Magnitude Lighting Converters"); vendorModels.put(0x030C, "Hilti AG"); vendorModels.put(0x030D, "Devdata S.r.l."); vendorModels.put(0x030E, "Deviceworx"); vendorModels.put(0x030F, "Shortcut Labs"); vendorModels.put(0x0310, "SGL Italia S.r.l."); vendorModels.put(0x0311, "PEEQ DATA"); vendorModels.put(0x0312, "Ducere Technologies Pvt Ltd"); vendorModels.put(0x0313, "DiveNav, Inc."); vendorModels.put(0x0314, "RIIG AI Sp. z o.o."); vendorModels.put(0x0315, "Thermo Fisher Scientific"); vendorModels.put(0x0316, "AG Measurematics Pvt. Ltd."); vendorModels.put(0x0317, "CHUO Electronics CO.,LTD."); vendorModels.put(0x0318, "Aspenta International"); vendorModels.put(0x0319, "Eugster Frismag AG"); vendorModels.put(0x031A, "Amber wireless GmbH"); vendorModels.put(0x031B, "HQ Inc"); vendorModels.put(0x031C, "Lab Sensor Solutions"); vendorModels.put(0x031D, "Enterlab ApS"); vendorModels.put(0x031E, "Eyefi, Inc."); vendorModels.put(0x031F, "MetaSystem S.p.A."); vendorModels.put(0x0320, "SONO ELECTRONICS. CO.,LTD"); vendorModels.put(0x0321, "Jewelbots"); vendorModels.put(0x0322, "Compumedics Limited"); vendorModels.put(0x0323, "Rotor Bike Components"); vendorModels.put(0x0324, "Astro, Inc."); vendorModels.put(0x0325, "Amotus Solutions"); vendorModels.put(0x0326, "Healthwear Technologies (Changzhou);Ltd"); vendorModels.put(0x0327, "Essex Electronics"); vendorModels.put(0x0328, "Grundfos A/S"); vendorModels.put(0x0329, "Eargo, Inc."); vendorModels.put(0x032A, "Electronic Design Lab"); vendorModels.put(0x032B, "ESYLUX"); vendorModels.put(0x032C, "NIPPON SMT.CO.);Ltd"); vendorModels.put(0x032D, "BM innovations GmbH"); vendorModels.put(0x032E, "indoormap"); vendorModels.put(0x032F, "OttoQ Inc"); vendorModels.put(0x0330, "North Pole Engineering"); vendorModels.put(0x0331, "3flares Technologies Inc."); vendorModels.put(0x0332, "Electrocompaniet A.S."); vendorModels.put(0x0333, "Mul-T-Lock"); vendorModels.put(0x0334, "Corentium AS"); vendorModels.put(0x0335, "Enlighted Inc"); vendorModels.put(0x0336, "GISTIC"); vendorModels.put(0x0337, "AJP2 Holdings,LLC"); vendorModels.put(0x0338, "COBI GmbH"); vendorModels.put(0x0339, "Blue Sky Scientific,LLC"); vendorModels.put(0x033A, "Appception, Inc."); vendorModels.put(0x033B, "Courtney Thorne Limited"); vendorModels.put(0x033C, "Virtuosys"); vendorModels.put(0x033D, "TPV Technology Limited"); vendorModels.put(0x033E, "Monitra SA"); vendorModels.put(0x033F, "Automation Components, Inc."); vendorModels.put(0x0340, "Letsense s.r.l."); vendorModels.put(0x0341, "Etesian Technologies LLC"); vendorModels.put(0x0342, "GERTEC BRASIL LTDA."); vendorModels.put(0x0343, "Drekker Development Pty. Ltd."); vendorModels.put(0x0344, "Whirl Inc"); vendorModels.put(0x0345, "Locus Positioning"); vendorModels.put(0x0346, "Acuity Brands Lighting, Inc"); vendorModels.put(0x0347, "Prevent Biometrics"); vendorModels.put(0x0348, "Arioneo"); vendorModels.put(0x0349, "VersaMe"); vendorModels.put(0x034A, "Vaddio"); vendorModels.put(0x034B, "Libratone A/S"); vendorModels.put(0x034C, "HM Electronics, Inc."); vendorModels.put(0x034D, "TASER International, Inc."); vendorModels.put(0x034E, "SafeTrust Inc."); vendorModels.put(0x034F, "Heartland Payment Systems"); vendorModels.put(0x0350, "Bitstrata Systems Inc."); vendorModels.put(0x0351, "Pieps GmbH"); vendorModels.put(0x0352, "iRiding(Xiamen);Technology Co.);Ltd."); vendorModels.put(0x0353, "Alpha Audiotronics, Inc."); vendorModels.put(0x0354, "TOPPAN FORMS CO.);LTD."); vendorModels.put(0x0355, "Sigma Designs, Inc."); vendorModels.put(0x0356, "Spectrum Brands, Inc."); vendorModels.put(0x0357, "Polymap Wireless"); vendorModels.put(0x0358, "MagniWare Ltd."); vendorModels.put(0x0359, "Novotec Medical GmbH"); vendorModels.put(0x035A, "Medicom Innovation Partner a/s"); vendorModels.put(0x035B, "Matrix Inc."); vendorModels.put(0x035C, "Eaton Corporation"); vendorModels.put(0x035D, "KYS"); vendorModels.put(0x035E, "Naya Health, Inc."); vendorModels.put(0x035F, "Acromag"); vendorModels.put(0x0360, "Insulet Corporation"); vendorModels.put(0x0361, "Wellinks Inc."); vendorModels.put(0x0362, "ON Semiconductor"); vendorModels.put(0x0363, "FREELAP SA"); vendorModels.put(0x0364, "Favero Electronics Srl"); vendorModels.put(0x0365, "BioMech Sensor LLC"); vendorModels.put(0x0366, "BOLTT Sports technologies Private limited"); vendorModels.put(0x0367, "Saphe International"); vendorModels.put(0x0368, "Metormote AB"); vendorModels.put(0x0369, "littleBits"); vendorModels.put(0x036A, "SetPoint Medical"); vendorModels.put(0x036B, "BRControls Products BV"); vendorModels.put(0x036C, "Zipcar"); vendorModels.put(0x036D, "AirBolt Pty Ltd"); vendorModels.put(0x036E, "KeepTruckin Inc"); vendorModels.put(0x036F, "Motiv, Inc."); vendorModels.put(0x0370, "Wazombi Labs O"); vendorModels.put(0x0371, "ORBCOMM"); vendorModels.put(0x0372, "Nixie Labs, Inc."); vendorModels.put(0x0373, "AppNearMe Ltd"); vendorModels.put(0x0374, "Holman Industries"); vendorModels.put(0x0375, "Expain AS"); vendorModels.put(0x0376, "Electronic Temperature Instruments Ltd"); vendorModels.put(0x0377, "Plejd AB"); vendorModels.put(0x0378, "Propeller Health"); vendorModels.put(0x0379, "Shenzhen iMCO Electronic Technology Co.);Ltd"); vendorModels.put(0x037A, "Algoria"); vendorModels.put(0x037B, "Apption Labs Inc."); vendorModels.put(0x037C, "Cronologics Corporation"); vendorModels.put(0x037D, "MICRODIA Ltd."); vendorModels.put(0x037E, "lulabytes S.L."); vendorModels.put(0x037F, "Nestec S.A."); vendorModels.put(0x0380, "LLC \"MEGA-F service\""); vendorModels.put(0x0381, "Sharp Corporation"); vendorModels.put(0x0382, "Precision Outcomes Ltd"); vendorModels.put(0x0383, "Kronos Incorporated"); vendorModels.put(0x0384, "OCOSMOS Co.,Ltd."); vendorModels.put(0x0385, "Embedded Electronic Solutions Ltd. dba e2Solutions"); vendorModels.put(0x0386, "Aterica Inc."); vendorModels.put(0x0387, "BluStor PMC, Inc."); vendorModels.put(0x0388, "Kapsch TrafficCom AB"); vendorModels.put(0x0389, "ActiveBlu Corporation"); vendorModels.put(0x038A, "Kohler Mira Limited"); vendorModels.put(0x038B, "Noke"); vendorModels.put(0x038C, "Appion Inc."); vendorModels.put(0x038D, "Resmed Ltd"); vendorModels.put(0x038E, "Crownstone B.V."); vendorModels.put(0x038F, "Xiaomi Inc."); vendorModels.put(0x0390, "INFOTECH s.r.o."); vendorModels.put(0x0391, "Thingsquare AB"); vendorModels.put(0x0392, "T&D"); vendorModels.put(0x0393, "LAVAZZA S.p.A."); vendorModels.put(0x0394, "Netclearance Systems, Inc."); vendorModels.put(0x0395, "SDATAWAY"); vendorModels.put(0x0396, "BLOKS GmbH"); vendorModels.put(0x0397, "LEGO System A/S"); vendorModels.put(0x0398, "Thetatronics Ltd"); vendorModels.put(0x0399, "Nikon Corporation"); vendorModels.put(0x039A, "NeST"); vendorModels.put(0x039B, "South Silicon Valley Microelectronics"); vendorModels.put(0x039C, "ALE International"); vendorModels.put(0x039D, "CareView Communications, Inc."); vendorModels.put(0x039E, "SchoolBoard Limited"); vendorModels.put(0x039F, "Molex Corporation"); vendorModels.put(0x03A0, "IVT Wireless Limited"); vendorModels.put(0x03A1, "Alpine Labs LLC"); vendorModels.put(0x03A2, "Candura Instruments"); vendorModels.put(0x03A3, "SmartMovt Technology Co.,Ltd"); vendorModels.put(0x03A4, "Token Zero Ltd"); vendorModels.put(0x03A5, "ACE CAD Enterprise Co.,Ltd. (ACECAD);"); vendorModels.put(0x03A6, "Medela, Inc"); vendorModels.put(0x03A7, "AeroScout"); vendorModels.put(0x03A8, "Esrille Inc."); vendorModels.put(0x03A9, "THINKERLY SRL"); vendorModels.put(0x03AA, "Exon Sp. z o.o."); vendorModels.put(0x03AB, "Meizu Technology Co.,Ltd."); vendorModels.put(0x03AC, "Smablo LTD"); vendorModels.put(0x03AD, "XiQ"); vendorModels.put(0x03AE, "Allswell Inc."); vendorModels.put(0x03AF, "Comm-N-Sense Corp DBA Verigo"); vendorModels.put(0x03B0, "VIBRADORM GmbH"); vendorModels.put(0x03B1, "Otodata Wireless Network Inc."); vendorModels.put(0x03B2, "Propagation Systems Limited"); vendorModels.put(0x03B3, "Midwest Instruments & Controls"); vendorModels.put(0x03B4, "Alpha Nodus, Inc."); vendorModels.put(0x03B5, "petPOMM, Inc"); vendorModels.put(0x03B6, "Mattel"); vendorModels.put(0x03B7, "Airbly Inc."); vendorModels.put(0x03B8, "A-Safe Limited"); vendorModels.put(0x03B9, "FREDERIQUE CONSTANT SA"); vendorModels.put(0x03BA, "Maxscend Microelectronics Company Limited"); vendorModels.put(0x03BB, "Abbott Diabetes Care"); vendorModels.put(0x03BC, "ASB Bank Ltd"); vendorModels.put(0x03BD, "amadas"); vendorModels.put(0x03BE, "Applied Science, Inc."); vendorModels.put(0x03BF, "iLumi Solutions Inc."); vendorModels.put(0x03C0, "Arch Systems Inc."); vendorModels.put(0x03C1, "Ember Technologies, Inc."); vendorModels.put(0x03C2, "Snapchat Inc"); vendorModels.put(0x03C3, "Casambi Technologies Oy"); vendorModels.put(0x03C4, "Pico Technology Inc."); vendorModels.put(0x03C5, "St. Jude Medical, Inc."); vendorModels.put(0x03C6, "Intricon"); vendorModels.put(0x03C7, "Structural Health Systems, Inc."); vendorModels.put(0x03C8, "Avvel International"); vendorModels.put(0x03C9, "Gallagher Group"); vendorModels.put(0x03CA, "In2things Automation Pvt. Ltd."); vendorModels.put(0x03CB, "SYSDEV Srl"); vendorModels.put(0x03CC, "Vonkil Technologies Ltd"); vendorModels.put(0x03CD, "Wynd Technologies, Inc."); vendorModels.put(0x03CE, "CONTRINEX S.A."); vendorModels.put(0x03CF, "MIRA, Inc."); vendorModels.put(0x03D0, "Watteam Ltd"); vendorModels.put(0x03D1, "Density Inc."); vendorModels.put(0x03D2, "IOT Pot India Private Limited"); vendorModels.put(0x03D3, "Sigma Connectivity AB"); vendorModels.put(0x03D4, "PEG PEREGO SPA"); vendorModels.put(0x03D5, "Wyzelink Systems Inc."); vendorModels.put(0x03D6, "Yota Devices LTD"); vendorModels.put(0x03D7, "FINSECUR"); vendorModels.put(0x03D8, "Zen-Me Labs Ltd"); vendorModels.put(0x03D9, "3IWare Co.,Ltd."); vendorModels.put(0x03DA, "EnOcean GmbH"); vendorModels.put(0x03DB, "Instabeat, Inc"); vendorModels.put(0x03DC, "Nima Labs"); vendorModels.put(0x03DD, "Andreas Stihl AG & Co. KG"); vendorModels.put(0x03DE, "Nathan Rhoades LLC"); vendorModels.put(0x03DF, "Grob Technologies,LLC"); vendorModels.put(0x03E0, "Actions (Zhuhai,Technology Co.,Limited"); vendorModels.put(0x03E1, "SPD Development Company Ltd"); vendorModels.put(0x03E2, "Sensoan Oy"); vendorModels.put(0x03E3, "Qualcomm Life Inc"); vendorModels.put(0x03E4, "Chip-ing AG"); vendorModels.put(0x03E5, "ffly4u"); vendorModels.put(0x03E6, "IoT Instruments Oy"); vendorModels.put(0x03E7, "TRUE Fitness Technology"); vendorModels.put(0x03E8, "Reiner Kartengeraete GmbH & Co. KG."); vendorModels.put(0x03E9, "SHENZHEN LEMONJOY TECHNOLOGY CO.,LTD."); vendorModels.put(0x03EA, "Hello Inc."); vendorModels.put(0x03EB, "Evollve Inc."); vendorModels.put(0x03EC, "Jigowatts Inc."); vendorModels.put(0x03ED, "BASIC MICRO.COM);INC."); vendorModels.put(0x03EE, "CUBE TECHNOLOGIES"); vendorModels.put(0x03EF, "foolography GmbH"); vendorModels.put(0x03F0, "CLINK"); vendorModels.put(0x03F1, "Hestan Smart Cooking Inc."); vendorModels.put(0x03F2, "WindowMaster A/S"); vendorModels.put(0x03F3, "Flowscape AB"); vendorModels.put(0x03F4, "PAL Technologies Ltd"); vendorModels.put(0x03F5, "WHERE, Inc."); vendorModels.put(0x03F6, "Iton Technology Corp."); vendorModels.put(0x03F7, "Owl Labs Inc."); vendorModels.put(0x03F8, "Rockford Corp."); vendorModels.put(0x03F9, "Becon Technologies Co.);Ltd."); vendorModels.put(0x03FA, "Vyassoft Technologies Inc"); vendorModels.put(0x03FB, "Nox Medical"); vendorModels.put(0x03FC, "Kimberly-Clark"); vendorModels.put(0x03FD, "Trimble Navigation Ltd."); vendorModels.put(0x03FE, "Littelfuse"); vendorModels.put(0x03FF, "Withings"); vendorModels.put(0x0400, "i-developer IT Beratung UG"); vendorModels.put(0x0401, "Unknown"); vendorModels.put(0x0402, "Sears Holdings Corporation"); vendorModels.put(0x0403, "Gantner Electronic GmbH"); vendorModels.put(0x0404, "Authomate Inc"); vendorModels.put(0x0405, "Vertex International, Inc."); vendorModels.put(0x0406, "Airtago"); vendorModels.put(0x0407, "Swiss Audio SA"); vendorModels.put(0x0408, "ToGetHome Inc."); vendorModels.put(0x0409, "AXIS"); vendorModels.put(0x040A, "Openmatics"); vendorModels.put(0x040B, "Jana Care Inc."); vendorModels.put(0x040C, "Senix Corporation"); vendorModels.put(0x040D, "NorthStar Battery Company,LLC"); vendorModels.put(0x040E, "SKF (U.K.,Limited"); vendorModels.put(0x040F, "CO-AX Technology, Inc."); vendorModels.put(0x0410, "Fender Musical Instruments"); vendorModels.put(0x0411, "Luidia Inc"); vendorModels.put(0x0412, "SEFAM"); vendorModels.put(0x0413, "Wireless Cables Inc"); vendorModels.put(0x0414, "Lightning Protection International Pty Ltd"); vendorModels.put(0x0415, "Uber Technologies Inc"); vendorModels.put(0x0416, "SODA GmbH"); vendorModels.put(0x0417, "Fatigue Science"); vendorModels.put(0x0418, "Alpine Electronics Inc."); vendorModels.put(0x0419, "Novalogy LTD"); vendorModels.put(0x041A, "Friday Labs Limited"); vendorModels.put(0x041B, "OrthoAccel Technologies"); vendorModels.put(0x041C, "WaterGuru, Inc."); vendorModels.put(0x041D, "Benning Elektrotechnik und Elektronik GmbH & Co. KG"); vendorModels.put(0x041E, "Dell Computer Corporation"); vendorModels.put(0x041F, "Kopin Corporation"); vendorModels.put(0x0420, "TecBakery GmbH"); vendorModels.put(0x0421, "Backbone Labs, Inc."); vendorModels.put(0x0422, "DELSEY SA"); vendorModels.put(0x0423, "Chargifi Limited"); vendorModels.put(0x0424, "Trainesense Ltd."); vendorModels.put(0x0425, "Unify Software and Solutions GmbH & Co. KG"); vendorModels.put(0x0426, "Husqvarna AB"); vendorModels.put(0x0427, "Focus fleet and fuel management inc"); vendorModels.put(0x0428, "SmallLoop,LLC"); vendorModels.put(0x0429, "Prolon Inc."); vendorModels.put(0x042A, "BD Medical"); vendorModels.put(0x042B, "iMicroMed Incorporated"); vendorModels.put(0x042C, "Ticto N.V."); vendorModels.put(0x042D, "Meshtech AS"); vendorModels.put(0x042E, "MemCachier Inc."); vendorModels.put(0x042F, "Danfoss A/S"); vendorModels.put(0x0430, "SnapStyk Inc."); vendorModels.put(0x0431, "Amway Corporation"); vendorModels.put(0x0432, "Silk Labs, Inc."); vendorModels.put(0x0433, "Pillsy Inc."); vendorModels.put(0x0434, "Hatch Baby, Inc."); vendorModels.put(0x0435, "Blocks Wearables Ltd."); vendorModels.put(0x0436, "Drayson Technologies (Europe,Limited"); vendorModels.put(0x0437, "eBest IOT Inc."); vendorModels.put(0x0438, "Helvar Ltd"); vendorModels.put(0x0439, "Radiance Technologies"); vendorModels.put(0x043A, "Nuheara Limited"); vendorModels.put(0x043B, "Appside co.,ltd."); vendorModels.put(0x043C, "DeLaval"); vendorModels.put(0x043D, "Coiler Corporation"); vendorModels.put(0x043E, "Thermomedics, Inc."); vendorModels.put(0x043F, "Tentacle Sync GmbH"); vendorModels.put(0x0440, "Valencell, Inc."); vendorModels.put(0x0441, "iProtoXi Oy"); vendorModels.put(0x0442, "SECOM CO.,LTD."); vendorModels.put(0x0443, "Tucker International LLC"); vendorModels.put(0x0444, "Metanate Limited"); vendorModels.put(0x0445, "Kobian Canada Inc."); vendorModels.put(0x0446, "NETGEAR, Inc."); vendorModels.put(0x0447, "Fabtronics Australia Pty Ltd"); vendorModels.put(0x0448, "Grand Centrix GmbH"); vendorModels.put(0x0449, "1UP USA.com llc"); vendorModels.put(0x044A, "SHIMANO INC."); vendorModels.put(0x044B, "Nain Inc."); vendorModels.put(0x044C, "LifeStyle Lock,LLC"); vendorModels.put(0x044D, "VEGA Grieshaber KG"); vendorModels.put(0x044E, "Xtrava Inc."); vendorModels.put(0x044F, "TTS Tooltechnic Systems AG & Co. KG"); vendorModels.put(0x0450, "Teenage Engineering AB"); vendorModels.put(0x0451, "Tunstall Nordic AB"); vendorModels.put(0x0452, "Svep Design Center AB"); vendorModels.put(0x0453, "GreenPeak Technologies BV"); vendorModels.put(0x0454, "Sphinx Electronics GmbH & Co KG"); vendorModels.put(0x0455, "Atomation"); vendorModels.put(0x0456, "Nemik Consulting Inc"); vendorModels.put(0x0457, "RF INNOVATION"); vendorModels.put(0x0458, "Mini Solution Co.,Ltd."); vendorModels.put(0x0459, "Lumenetix, Inc"); vendorModels.put(0x045A, "2048450 Ontario Inc"); vendorModels.put(0x045B, "SPACEEK LTD"); vendorModels.put(0x045C, "Delta T Corporation"); vendorModels.put(0x045D, "Boston Scientific Corporation"); vendorModels.put(0x045E, "Nuviz, Inc."); vendorModels.put(0x045F, "Real Time Automation, Inc."); vendorModels.put(0x0460, "Kolibree"); vendorModels.put(0x0461, "vhf elektronik GmbH"); vendorModels.put(0x0462, "Bonsai Systems GmbH"); vendorModels.put(0x0463, "Fathom Systems Inc."); vendorModels.put(0x0464, "Bellman & Symfon"); vendorModels.put(0x0465, "International Forte Group LLC"); vendorModels.put(0x0466, "CycleLabs Solutions inc."); vendorModels.put(0x0467, "Codenex Oy"); vendorModels.put(0x0468, "Kynesim Ltd"); vendorModels.put(0x0469, "Palago AB"); vendorModels.put(0x046A, "INSIGMA INC."); vendorModels.put(0x046B, "PMD Solutions"); vendorModels.put(0x046C, "Qingdao Realtime Technology Co.,Ltd."); vendorModels.put(0x046D, "BEGA Gantenbrink-Leuchten KG"); vendorModels.put(0x046E, "Pambor Ltd."); vendorModels.put(0x046F, "Develco Products A/S"); vendorModels.put(0x0470, "iDesign s.r.l."); vendorModels.put(0x0471, "TiVo Corp"); vendorModels.put(0x0472, "Control-J Pty Ltd"); vendorModels.put(0x0473, "Steelcase, Inc."); vendorModels.put(0x0474, "iApartment co.,ltd."); vendorModels.put(0x0475, "Icom inc."); vendorModels.put(0x0476, "Oxstren Wearable Technologies Private Limited"); vendorModels.put(0x0477, "Blue Spark Technologies"); vendorModels.put(0x0478, "FarSite Communications Limited"); vendorModels.put(0x0479, "mywerk system GmbH"); vendorModels.put(0x047A, "Sinosun Technology Co.,Ltd."); vendorModels.put(0x047B, "MIYOSHI ELECTRONICS CORPORATION"); vendorModels.put(0x047C, "POWERMAT LTD"); vendorModels.put(0x047D, "Occly LLC"); vendorModels.put(0x047E, "OurHub Dev IvS"); vendorModels.put(0x047F, "Pro-Mark, Inc."); vendorModels.put(0x0480, "Dynometrics Inc."); vendorModels.put(0x0481, "Quintrax Limited"); vendorModels.put(0x0482, "POS Tuning Udo Vosshenrich GmbH & Co. KG"); vendorModels.put(0x0483, "Multi Care Systems B.V."); vendorModels.put(0x0484, "Revol Technologies Inc"); vendorModels.put(0x0485, "SKIDATA AG"); vendorModels.put(0x0486, "DEV TECNOLOGIA INDUSTRIA,COMERCIO E MANUTENCAO DE EQUIPAMENTOS LTDA. - ME"); vendorModels.put(0x0487, "Centrica Connected Home"); vendorModels.put(0x0488, "Automotive Data Solutions Inc"); vendorModels.put(0x0489, "Igarashi Engineering"); vendorModels.put(0x048A, "Taelek Oy"); vendorModels.put(0x048B, "CP Electronics Limited"); vendorModels.put(0x048C, "Vectronix AG"); vendorModels.put(0x048D, "S-Labs Sp. z o.o."); vendorModels.put(0x048E, "Companion Medical, Inc."); vendorModels.put(0x048F, "BlueKitchen GmbH"); vendorModels.put(0x0490, "Matting AB"); vendorModels.put(0x0491, "SOREX - Wireless Solutions GmbH"); vendorModels.put(0x0492, "ADC Technology, Inc."); vendorModels.put(0x0493, "Lynxemi Pte Ltd"); vendorModels.put(0x0494, "SENNHEISER electronic GmbH & Co. KG"); vendorModels.put(0x0495, "LMT Mercer Group, Inc"); vendorModels.put(0x0496, "Polymorphic Labs LLC"); vendorModels.put(0x0497, "Cochlear Limited"); vendorModels.put(0x0498, "METER Group, Inc. USA"); vendorModels.put(0x0499, "Ruuvi Innovations Ltd."); vendorModels.put(0x049A, "Situne AS"); vendorModels.put(0x049B, "nVisti,LLC"); vendorModels.put(0x049C, "DyOcean"); vendorModels.put(0x049D, "Uhlmann & Zacher GmbH"); vendorModels.put(0x049E, "AND!XOR LLC"); vendorModels.put(0x049F, "tictote AB"); vendorModels.put(0x04A0, "Vypin,LLC"); vendorModels.put(0x04A1, "PNI Sensor Corporation"); vendorModels.put(0x04A2, "ovrEngineered,LLC"); vendorModels.put(0x04A3, "GT-tronics HK Ltd"); vendorModels.put(0x04A4, "Herbert Waldmann GmbH & Co. KG"); vendorModels.put(0x04A5, "Guangzhou FiiO Electronics Technology Co.);Ltd"); vendorModels.put(0x04A6, "Vinetech Co.,Ltd"); vendorModels.put(0x04A7, "Dallas Logic Corporation"); vendorModels.put(0x04A8, "BioTex, Inc."); vendorModels.put(0x04A9, "DISCOVERY SOUND TECHNOLOGY,LLC"); vendorModels.put(0x04AA, "LINKIO SAS"); vendorModels.put(0x04AB, "Harbortronics, Inc."); vendorModels.put(0x04AC, "Undagrid B.V."); vendorModels.put(0x04AD, "Shure Inc"); vendorModels.put(0x04AE, "ERM Electronic Systems LTD"); vendorModels.put(0x04AF, "BIOROWER Handelsagentur GmbH"); vendorModels.put(0x04B0, "Weba Sport und Med. Artikel GmbH"); vendorModels.put(0x04B1, "Kartographers Technologies Pvt. Ltd."); vendorModels.put(0x04B2, "The Shadow on the Moon"); vendorModels.put(0x04B3, "mobike (Hong Kong,Limited"); vendorModels.put(0x04B4, "Inuheat Group AB"); vendorModels.put(0x04B5, "Swiftronix AB"); vendorModels.put(0x04B6, "Diagnoptics Technologies"); vendorModels.put(0x04B7, "Analog Devices, Inc."); vendorModels.put(0x04B8, "Soraa Inc."); vendorModels.put(0x04B9, "CSR Building Products Limited"); vendorModels.put(0x04BA, "Crestron Electronics, Inc."); vendorModels.put(0x04BB, "Neatebox Ltd"); vendorModels.put(0x04BC, "Draegerwerk AG & Co. KGaA"); vendorModels.put(0x04BD, "AlbynMedical"); vendorModels.put(0x04BE, "Averos FZCO"); vendorModels.put(0x04BF, "VIT Initiative,LLC"); vendorModels.put(0x04C0, "Statsports International"); vendorModels.put(0x04C1, "Sospitas,s.r.o."); vendorModels.put(0x04C2, "Dmet Products Corp."); vendorModels.put(0x04C3, "Mantracourt Electronics Limited"); vendorModels.put(0x04C4, "TeAM Hutchins AB"); vendorModels.put(0x04C5, "Seibert Williams Glass,LLC"); vendorModels.put(0x04C6, "Insta GmbH"); vendorModels.put(0x04C7, "Svantek Sp. z o.o."); vendorModels.put(0x04C8, "Shanghai Flyco Electrical Appliance Co.,Ltd."); vendorModels.put(0x04C9, "Thornwave Labs Inc"); vendorModels.put(0x04CA, "Steiner-Optik GmbH"); vendorModels.put(0x04CB, "Novo Nordisk A/S"); vendorModels.put(0x04CC, "Enflux Inc."); vendorModels.put(0x04CD, "Safetech Products LLC"); vendorModels.put(0x04CE, "GOOOLED S.R.L."); vendorModels.put(0x04CF, "DOM Sicherheitstechnik GmbH & Co. KG"); vendorModels.put(0x04D0, "Olympus Corporation"); vendorModels.put(0x04D1, "KTS GmbH"); vendorModels.put(0x04D2, "Anloq Technologies Inc."); vendorModels.put(0x04D3, "Queercon, Inc"); vendorModels.put(0x04D4, "5th Element Ltd"); vendorModels.put(0x04D5, "Gooee Limited"); vendorModels.put(0x04D6, "LUGLOC LLC"); vendorModels.put(0x04D7, "Blincam, Inc."); vendorModels.put(0x04D8, "FUJIFILM Corporation"); vendorModels.put(0x04D9, "RandMcNally"); vendorModels.put(0x04DA, "Franceschi Marina snc"); vendorModels.put(0x04DB, "Engineered Audio,LLC."); vendorModels.put(0x04DC, "IOTTIVE (OPC,PRIVATE LIMITED"); vendorModels.put(0x04DD, "4MOD Technology"); vendorModels.put(0x04DE, "Lutron Electronics Co., Inc."); vendorModels.put(0x04DF, "Emerson"); vendorModels.put(0x04E0, "Guardtec, Inc."); vendorModels.put(0x04E1, "REACTEC LIMITED"); vendorModels.put(0x04E2, "EllieGrid"); vendorModels.put(0x04E3, "Under Armour"); vendorModels.put(0x04E4, "Woodenshark"); vendorModels.put(0x04E5, "Avack Oy"); vendorModels.put(0x04E6, "Smart Solution Technology, Inc."); vendorModels.put(0x04E7, "REHABTRONICS INC."); vendorModels.put(0x04E8, "STABILO International"); vendorModels.put(0x04E9, "Busch Jaeger Elektro GmbH"); vendorModels.put(0x04EA, "Pacific Bioscience Laboratories, Inc"); vendorModels.put(0x04EB, "Bird Home Automation GmbH"); vendorModels.put(0x04EC, "Motorola Solutions"); vendorModels.put(0x04ED, "R9 Technology, Inc."); vendorModels.put(0x04EE, "Auxivia"); vendorModels.put(0x04EF, "DaisyWorks, Inc"); vendorModels.put(0x04F0, "Kosi Limited"); vendorModels.put(0x04F1, "Theben AG"); vendorModels.put(0x04F2, "InDreamer Techsol Private Limited"); vendorModels.put(0x04F3, "Cerevast Medical"); vendorModels.put(0x04F4, "ZanCompute Inc."); vendorModels.put(0x04F5, "Pirelli Tyre S.P.A."); vendorModels.put(0x04F6, "McLear Limited"); vendorModels.put(0x04F7, "Shenzhen Huiding Technology Co.);Ltd."); vendorModels.put(0x04F8, "Convergence Systems Limited"); vendorModels.put(0x04F9, "Interactio"); vendorModels.put(0x04FA, "Androtec GmbH"); vendorModels.put(0x04FB, "Benchmark Drives GmbH & Co. KG"); vendorModels.put(0x04FC, "SwingLync L. L. C."); vendorModels.put(0x04FD, "Tapkey GmbH"); vendorModels.put(0x04FE, "Woosim Systems Inc."); vendorModels.put(0x04FF, "Microsemi Corporation"); vendorModels.put(0x0500, "Wiliot LTD."); vendorModels.put(0x0501, "Polaris IND"); vendorModels.put(0x0502, "Specifi-Kali LLC"); vendorModels.put(0x0503, "Locoroll, Inc"); vendorModels.put(0x0504, "PHYPLUS Inc"); vendorModels.put(0x0505, "Inplay Technologies LLC"); vendorModels.put(0x0506, "Hager"); vendorModels.put(0x0507, "Yellowcog"); vendorModels.put(0x0508, "Axes System sp. z o. o."); vendorModels.put(0x0509, "myLIFTER Inc."); vendorModels.put(0x050A, "Shake-on B.V."); vendorModels.put(0x050B, "Vibrissa Inc."); vendorModels.put(0x050C, "OSRAM GmbH"); vendorModels.put(0x050D, "TRSystems GmbH"); vendorModels.put(0x050E, "Yichip Microelectronics (Hangzhou,Co.);Ltd."); vendorModels.put(0x050F, "Foundation Engineering LLC"); vendorModels.put(0x0510, "UNI-ELECTRONICS, Inc."); vendorModels.put(0x0511, "Brookfield Equinox LLC"); vendorModels.put(0x0512, "Soprod SA"); vendorModels.put(0x0513, "9974091 Canada Inc."); vendorModels.put(0x0514, "FIBRO GmbH"); vendorModels.put(0x0515, "RB Controls Co.,Ltd."); vendorModels.put(0x0516, "Footmarks"); vendorModels.put(0x0517, "Amcore AB"); vendorModels.put(0x0518, "MAMORIO.inc"); vendorModels.put(0x0519, "Tyto Life LLC"); vendorModels.put(0x051A, "Leica Camera AG"); vendorModels.put(0x051B, "Angee Technologies Ltd."); vendorModels.put(0x051C, "EDPS"); vendorModels.put(0x051D, "OFF Line Co.,Ltd."); vendorModels.put(0x051E, "Detect Blue Limited"); vendorModels.put(0x051F, "Setec Pty Ltd"); vendorModels.put(0x0520, "Target Corporation"); vendorModels.put(0x0521, "IAI Corporation"); vendorModels.put(0x0522, "NS Tech, Inc."); vendorModels.put(0x0523, "MTG Co.,Ltd."); vendorModels.put(0x0524, "Hangzhou iMagic Technology Co.,Ltd"); vendorModels.put(0x0525, "HONGKONG NANO IC TECHNOLOGIES CO.,LIMITED"); vendorModels.put(0x0526, "Honeywell International Inc."); vendorModels.put(0x0527, "Albrecht JUNG"); vendorModels.put(0x0528, "Lunera Lighting Inc."); vendorModels.put(0x0529, "Lumen UAB"); vendorModels.put(0x052A, "Keynes Controls Ltd"); vendorModels.put(0x052B, "Novartis AG"); vendorModels.put(0x052C, "Geosatis SA"); vendorModels.put(0x052D, "EXFO, Inc."); vendorModels.put(0x052E, "LEDVANCE GmbH"); vendorModels.put(0x052F, "Center ID Corp."); vendorModels.put(0x0530, "Adolene, Inc."); vendorModels.put(0x0531, "D&M Holdings Inc."); vendorModels.put(0x0532, "CRESCO Wireless, Inc."); vendorModels.put(0x0533, "Nura Operations Pty Ltd"); vendorModels.put(0x0534, "Frontiergadget, Inc."); vendorModels.put(0x0535, "Smart Component Technologies Limited"); vendorModels.put(0x0536, "ZTR Control Systems LLC"); vendorModels.put(0x0537, "MetaLogics Corporation"); vendorModels.put(0x0538, "Medela AG"); vendorModels.put(0x0539, "OPPLE Lighting Co.,Ltd"); vendorModels.put(0x053A, "Savitech Corp.);"); vendorModels.put(0x053B, "prodigy"); vendorModels.put(0x053C, "Screenovate Technologies Ltd"); vendorModels.put(0x053D, "TESA SA"); vendorModels.put(0x053E, "CLIM8 LIMITED"); vendorModels.put(0x053F, "Silergy Corp"); vendorModels.put(0x0540, "SilverPlus, Inc"); vendorModels.put(0x0541, "Sharknet srl"); vendorModels.put(0x0542, "Mist Systems, Inc."); vendorModels.put(0x0543, "MIWA LOCK CO.);Ltd"); vendorModels.put(0x0544, "OrthoSensor, Inc."); vendorModels.put(0x0545, "Candy Hoover Group s.r.l"); vendorModels.put(0x0546, "Apexar Technologies S.A."); vendorModels.put(0x0547, "LOGICDATA d.o.o."); vendorModels.put(0x0548, "Knick Elektronische Messgeraete GmbH & Co. KG"); vendorModels.put(0x0549, "Smart Technologies and Investment Limited"); vendorModels.put(0x054A, "Linough Inc."); vendorModels.put(0x054B, "Advanced Electronic Designs, Inc."); vendorModels.put(0x054C, "Carefree Scott Fetzer Co Inc"); vendorModels.put(0x054D, "Sensome"); vendorModels.put(0x054E, "FORTRONIK storitve d.o.o."); vendorModels.put(0x054F, "Sinnoz"); vendorModels.put(0x0550, "Versa Networks, Inc."); vendorModels.put(0x0551, "Sylero"); vendorModels.put(0x0552, "Avempace SARL"); vendorModels.put(0x0553, "Nintendo Co.,Ltd."); vendorModels.put(0x0554, "National Instruments"); vendorModels.put(0x0555, "KROHNE Messtechnik GmbH"); vendorModels.put(0x0556, "Otodynamics Ltd"); vendorModels.put(0x0557, "Arwin Technology Limited"); vendorModels.put(0x0558, "benegear, Inc."); vendorModels.put(0x0559, "Newcon Optik"); vendorModels.put(0x055A, "CANDY HOUSE, Inc."); vendorModels.put(0x055B, "FRANKLIN TECHNOLOGY INC"); vendorModels.put(0x055C, "Lely"); vendorModels.put(0x055D, "Valve Corporation"); vendorModels.put(0x055E, "Hekatron Vertriebs GmbH"); vendorModels.put(0x055F, "PROTECH S.A.S. DI GIRARDI ANDREA & C."); vendorModels.put(0x0560, "Sarita CareTech IVS"); vendorModels.put(0x0561, "Finder S.p.A."); vendorModels.put(0x0562, "Thalmic Labs Inc."); vendorModels.put(0x0563, "Steinel Vertrieb GmbH"); vendorModels.put(0x0564, "Beghelli Spa"); vendorModels.put(0x0565, "Beijing Smartspace Technologies Inc."); vendorModels.put(0x0566, "CORE TRANSPORT TECHNOLOGIES NZ LIMITED"); vendorModels.put(0x0567, "Xiamen Everesports Goods Co.,Ltd"); vendorModels.put(0x0568, "Bodyport Inc."); vendorModels.put(0x0569, "Audionics System, Inc."); vendorModels.put(0x056A, "Flipnavi Co.);Ltd."); vendorModels.put(0x056B, "Rion Co.,Ltd."); vendorModels.put(0x056C, "Long AddressRange Systems,LLC"); vendorModels.put(0x056D, "Redmond Industrial Group LLC"); vendorModels.put(0x056E, "VIZPIN INC."); vendorModels.put(0x056F, "BikeFinder AS"); vendorModels.put(0x0570, "Consumer Sleep Solutions LLC"); vendorModels.put(0x0571, "PSIKICK, Inc."); vendorModels.put(0x0572, "AntTail.com"); vendorModels.put(0x0573, "Lighting Science Group Corp."); vendorModels.put(0x0574, "AFFORDABLE ELECTRONICS INC"); vendorModels.put(0x0575, "Integral Memroy Plc"); vendorModels.put(0x0576, "Globalstar, Inc."); vendorModels.put(0x0577, "True Wearables, Inc."); vendorModels.put(0x0578, "Wellington Drive Technologies Ltd"); vendorModels.put(0x0579, "Ensemble Tech Private Limited"); vendorModels.put(0x057A, "OMNI Remotes"); vendorModels.put(0x057B, "Duracell U.S. Operations Inc."); vendorModels.put(0x057C, "Toor Technologies LLC"); vendorModels.put(0x057D, "Instinct Performance"); vendorModels.put(0x057E, "Beco, Inc"); vendorModels.put(0x057F, "Scuf Gaming International,LLC"); vendorModels.put(0x0580, "ARANZ Medical Limited"); vendorModels.put(0x0581, "LYS TECHNOLOGIES LTD"); vendorModels.put(0x0582, "Breakwall Analytics,LLC"); vendorModels.put(0x0583, "Code Blue Communications"); vendorModels.put(0x0584, "Gira Giersiepen GmbH & Co. KG"); vendorModels.put(0x0585, "Hearing Lab Technology"); vendorModels.put(0x0586, "LEGRAND"); vendorModels.put(0x0587, "Derichs GmbH"); vendorModels.put(0x0588, "ALT-TEKNIK LLC"); vendorModels.put(0x0589, "Star Technologies"); vendorModels.put(0x058A, "START TODAY CO.);LTD."); vendorModels.put(0x058B, "Maxim Integrated Products"); vendorModels.put(0x058C, "MERCK Kommanditgesellschaft auf Aktien"); vendorModels.put(0x058D, "Jungheinrich Aktiengesellschaft"); vendorModels.put(0x058E, "Oculus VR,LLC"); vendorModels.put(0x058F, "HENDON SEMICONDUCTORS PTY LTD"); vendorModels.put(0x0590, "Pur3 Ltd"); vendorModels.put(0x0591, "Viasat Group S.p.A."); vendorModels.put(0x0592, "IZITHERM"); vendorModels.put(0x0593, "Spaulding Clinical Research"); vendorModels.put(0x0594, "Kohler Company"); vendorModels.put(0x0595, "Inor Process AB"); vendorModels.put(0x0596, "My Smart Blinds"); vendorModels.put(0x0597, "RadioPulse Inc"); vendorModels.put(0x0598, "rapitag GmbH"); vendorModels.put(0x0599, "Lazlo326,LLC."); vendorModels.put(0x059A, "Teledyne Lecroy, Inc."); vendorModels.put(0x059B, "Dataflow Systems Limited"); vendorModels.put(0x059C, "Macrogiga Electronics"); vendorModels.put(0x059D, "Tandem Diabetes Care"); vendorModels.put(0x059E, "Polycom, Inc."); vendorModels.put(0x059F, "Fisher & Paykel Healthcare"); vendorModels.put(0x05A0, "RCP Software Oy"); vendorModels.put(0x05A1, "Shanghai Xiaoyi Technology Co.);Ltd."); vendorModels.put(0x05A2, "ADHERIUM(NZ,LIMITED"); vendorModels.put(0x05A3, "Axiomware Systems Incorporated"); vendorModels.put(0x05A4, "O. E. M. Controls, Inc."); vendorModels.put(0x05A5, "Kiiroo BV"); vendorModels.put(0x05A6, "Telecon Mobile Limited"); vendorModels.put(0x05A7, "Sonos Inc"); vendorModels.put(0x05A8, "Tom Allebrandi Consulting"); vendorModels.put(0x05A9, "Monidor"); vendorModels.put(0x05AA, "Tramex Limited"); vendorModels.put(0x05AB, "Nofence AS"); vendorModels.put(0x05AC, "GoerTek Dynaudio Co.,Ltd."); vendorModels.put(0x05AD, "INIA"); vendorModels.put(0x05AE, "CARMATE MFG.CO.);LTD"); vendorModels.put(0x05AF, "ONvocal"); vendorModels.put(0x05B0, "NewTec GmbH"); vendorModels.put(0x05B1, "Medallion Instrumentation Systems"); vendorModels.put(0x05B2, "CAREL INDUSTRIES S.P.A."); vendorModels.put(0x05B3, "Parabit Systems, Inc."); vendorModels.put(0x05B4, "White Horse Scientific ltd"); vendorModels.put(0x05B5, "verisilicon"); vendorModels.put(0x05B6, "Elecs Industry Co.);Ltd."); vendorModels.put(0x05B7, "Beijing Pinecone Electronics Co.);Ltd."); vendorModels.put(0x05B8, "Ambystoma Labs Inc."); vendorModels.put(0x05B9, "Suzhou Pairlink Network Technology"); vendorModels.put(0x05BA, "igloohome"); vendorModels.put(0x05BB, "Oxford Metrics plc"); vendorModels.put(0x05BC, "Leviton Mfg. Co., Inc."); vendorModels.put(0x05BD, "ULC Robotics Inc."); vendorModels.put(0x05BE, "RFID Global by Softwork SrL"); vendorModels.put(0x05BF, "Real-World-Systems Corporation"); vendorModels.put(0x05C0, "Nalu Medical, Inc."); vendorModels.put(0x05C1, "P.I.Engineering"); vendorModels.put(0x05C2, "Grote Industries"); vendorModels.put(0x05C3, "Runtime, Inc."); vendorModels.put(0x05C4, "Codecoup sp. z o.o. sp. k."); vendorModels.put(0x05C5, "SELVE GmbH & Co. KG"); vendorModels.put(0x05C6, "Smart Animal Training Systems,LLC"); vendorModels.put(0x05C7, "Lippert Components, Inc"); vendorModels.put(0x05C8, "SOMFY SAS"); vendorModels.put(0x05C9, "TBS Electronics B.V."); vendorModels.put(0x05CA, "MHL Custom Inc"); vendorModels.put(0x05CB, "LucentWear LLC"); vendorModels.put(0x05CC, "WATTS ELECTRONICS"); vendorModels.put(0x05CD, "RJ Brands LLC"); vendorModels.put(0x05CE, "V-ZUG Ltd"); vendorModels.put(0x05CF, "Biowatch SA"); vendorModels.put(0x05D0, "Anova Applied Electronics"); vendorModels.put(0x05D1, "Lindab AB"); vendorModels.put(0x05D2, "frogblue TECHNOLOGY GmbH"); vendorModels.put(0x05D3, "Acurable Limited"); vendorModels.put(0x05D4, "LAMPLIGHT Co.,Ltd."); vendorModels.put(0x05D5, "TEGAM, Inc."); vendorModels.put(0x05D6, "Zhuhai Jieli technology Co.);Ltd"); vendorModels.put(0x05D7, "modum.io AG"); vendorModels.put(0x05D8, "Farm Jenny LLC"); vendorModels.put(0x05D9, "Toyo Electronics Corporation"); vendorModels.put(0x05DA, "Applied Neural Research Corp"); vendorModels.put(0x05DB, "Avid Identification Systems, Inc."); vendorModels.put(0x05DC, "Petronics Inc."); vendorModels.put(0x05DD, "essentim GmbH"); vendorModels.put(0x05DE, "QT Medical INC."); vendorModels.put(0x05DF, "VIRTUALCLINIC.DIRECT LIMITED"); vendorModels.put(0x05E0, "Viper Design LLC"); vendorModels.put(0x05E1, "Human, Incorporated"); vendorModels.put(0x05E2, "stAPPtronics GmbH"); vendorModels.put(0x05E3, "Elemental Machines, Inc."); vendorModels.put(0x05E4, "Taiyo Yuden Co.,Ltd"); vendorModels.put(0x05E5, "INEO ENERGY& SYSTEMS"); vendorModels.put(0x05E6, "Motion Instruments Inc."); vendorModels.put(0x05E7, "PressurePro"); vendorModels.put(0x05E8, "COWBOY"); vendorModels.put(0x05E9, "iconmobile GmbH"); vendorModels.put(0x05EA, "ACS-Control-System GmbH"); vendorModels.put(0x05EB, "Bayerische Motoren Werke AG"); vendorModels.put(0x05EC, "Gycom Svenska AB"); vendorModels.put(0x05ED, "Fuji Xerox Co.,Ltd"); vendorModels.put(0x05EE, "Glide Inc."); vendorModels.put(0x05EF, "SIKOM AS"); vendorModels.put(0x05F0, "beken"); vendorModels.put(0x05F1, "The Linux Foundation"); vendorModels.put(0x05F2, "Try and E CO.);LTD."); vendorModels.put(0x05F3, "SeeScan"); vendorModels.put(0x05F4, "Clearity,LLC"); vendorModels.put(0x05F5, "GS TAG"); vendorModels.put(0x05F6, "DPTechnics"); vendorModels.put(0x05F7, "TRACMO, Inc."); vendorModels.put(0x05F8, "Anki Inc."); vendorModels.put(0x05F9, "Hagleitner Hygiene International GmbH"); vendorModels.put(0x05FA, "Konami Sports Life Co.,Ltd."); vendorModels.put(0x05FB, "Arblet Inc."); vendorModels.put(0x05FC, "Masbando GmbH"); vendorModels.put(0x05FD, "Innoseis"); vendorModels.put(0x05FE, "Niko"); vendorModels.put(0x05FF, "Wellnomics Ltd"); vendorModels.put(0x0600, "iRobot Corporation"); vendorModels.put(0x0601, "Schrader Electronics"); vendorModels.put(0x0602, "Geberit International AG"); vendorModels.put(0x0603, "Fourth Evolution Inc"); vendorModels.put(0x0604, "Cell2Jack LLC"); vendorModels.put(0x0605, "FMW electronic Futterer u. Maier-Wolf OHG"); vendorModels.put(0x0606, "John Deere"); vendorModels.put(0x0607, "Rookery Technology Ltd"); vendorModels.put(0x0608, "KeySafe-Cloud"); vendorModels.put(0x0609, "Bchi Labortechnik AG"); vendorModels.put(0x060A, "IQAir AG"); vendorModels.put(0x060B, "Triax Technologies Inc"); vendorModels.put(0x060C, "Vuzix Corporation"); vendorModels.put(0x060D, "TDK Corporation"); vendorModels.put(0x060E, "Blueair AB"); vendorModels.put(0x060F, "Philips Lighting B.V."); vendorModels.put(0x0610, "ADH GUARDIAN USA LLC"); vendorModels.put(0x0611, "Beurer GmbH"); vendorModels.put(0x0612, "Playfinity AS"); vendorModels.put(0x0613, "Hans Dinslage GmbH"); vendorModels.put(0x0614, "OnAsset Intelligence, Inc."); vendorModels.put(0x0615, "INTER ACTION Corporation"); vendorModels.put(0x0616, "OS42 UG (haftungsbeschraenkt);"); vendorModels.put(0x0617, "WIZCONNECTED COMPANY LIMITED"); vendorModels.put(0x0618, "Audio-Technica Corporation"); vendorModels.put(0x0619, "Six Guys Labs, s.r.o."); vendorModels.put(0x061A, "R.W. Beckett Corporation"); vendorModels.put(0x061B, "silex technology, inc."); vendorModels.put(0x061C, "Univations Limited"); vendorModels.put(0x061D, "SENS Innovation ApS"); vendorModels.put(0x061E, "Diamond Kinetics, Inc."); vendorModels.put(0x061F, "Phrame Inc."); vendorModels.put(0x0620, "Forciot Oy"); vendorModels.put(0x0621, "Noordung d.o.o."); vendorModels.put(0x0622, "Beam Labs, LLC"); vendorModels.put(0x0623, "Philadelphia Scientific (U.K.) Limited"); vendorModels.put(0x0624, "Biovotion AG"); vendorModels.put(0x0625, "Square Panda, Inc."); vendorModels.put(0x0626, "Amplifico"); vendorModels.put(0x0627, "WEG S.A."); vendorModels.put(0x0628, "Ensto Oy"); vendorModels.put(0x0629, "PHONEPE PVT LTD"); vendorModels.put(0x062A, "Lunatico Astronomia SL"); vendorModels.put(0x062B, "MinebeaMitsumi Inc."); vendorModels.put(0x062C, "ASPion GmbH"); vendorModels.put(0x062D, "Vossloh-Schwabe Deutschland GmbH"); vendorModels.put(0x062E, "Procept"); vendorModels.put(0x062F, "ONKYO Corporation"); vendorModels.put(0x0630, "Asthrea D.O.O."); vendorModels.put(0x0631, "Fortiori Design LLC"); vendorModels.put(0x0632, "Hugo Muller GmbH & Co KG"); vendorModels.put(0x0633, "Wangi Lai PLT"); vendorModels.put(0x0634, "Fanstel Corp"); vendorModels.put(0x0635, "Crookwood"); vendorModels.put(0x0636, "ELECTRONICA INTEGRAL DE SONIDO S.A."); vendorModels.put(0x0637, "GiP Innovation Tools GmbH"); vendorModels.put(0x0638, "LX SOLUTIONS PTY LIMITED"); vendorModels.put(0x0639, "Shenzhen Minew Technologies Co., Ltd."); vendorModels.put(0x063A, "Prolojik Limited"); vendorModels.put(0x063B, "Kromek Group Plc"); vendorModels.put(0x063C, "Contec Medical Systems Co., Ltd."); vendorModels.put(0x063D, "Xradio Technology Co.,Ltd."); vendorModels.put(0x063E, "The Indoor Lab, LLC"); vendorModels.put(0x063F, "LDL TECHNOLOGY"); vendorModels.put(0x0640, "Parkifi"); vendorModels.put(0x0641, "Revenue Collection Systems FRANCE SAS"); vendorModels.put(0x0642, "Bluetrum Technology Co.,Ltd"); vendorModels.put(0x0643, "makita corporation"); vendorModels.put(0x0644, "Apogee Instruments"); vendorModels.put(0x0645, "BM3"); vendorModels.put(0x0646, "SGV Group Holding GmbH & Co. KG"); vendorModels.put(0x0647, "MED-EL"); vendorModels.put(0x0648, "Ultune Technologies"); vendorModels.put(0x0649, "Ryeex Technology Co.,Ltd."); vendorModels.put(0x064A, "Open Research Institute, Inc."); vendorModels.put(0x064B, "Scale-Tec, Ltd"); vendorModels.put(0x064C, "Zumtobel Group AG"); vendorModels.put(0x064D, "iLOQ Oy"); vendorModels.put(0x064E, "KRUXWorks Technologies Private Limited"); vendorModels.put(0x064F, "Digital Matter Pty Ltd"); vendorModels.put(0x0650, "Coravin, Inc."); vendorModels.put(0x0651, "Stasis Labs, Inc."); vendorModels.put(0x0652, "ITZ Innovations- und Technologiezentrum GmbH"); vendorModels.put(0x0653, "Meggitt SA"); vendorModels.put(0x0654, "Ledlenser GmbH & Co. KG"); vendorModels.put(0x0655, "Renishaw PLC"); vendorModels.put(0x0656, "ZhuHai AdvanPro Technology Company Limited"); vendorModels.put(0x0657, "Meshtronix Limited"); vendorModels.put(0x0658, "Payex Norge AS"); vendorModels.put(0x0659, "UnSeen Technologies Oy"); vendorModels.put(0x065A, "Zound Industries International AB"); vendorModels.put(0x065B, "Sesam Solutions BV"); vendorModels.put(0x065C, "PixArt Imaging Inc."); vendorModels.put(0x065D, "Panduit Corp."); vendorModels.put(0x065E, "Alo AB"); vendorModels.put(0x065F, "Ricoh Company Ltd"); vendorModels.put(0x0660, "RTC Industries, Inc."); vendorModels.put(0x0661, "Mode Lighting Limited"); vendorModels.put(0x0662, "Particle Industries, Inc."); vendorModels.put(0x0663, "Advanced Telemetry Systems, Inc."); vendorModels.put(0x0664, "RHA TECHNOLOGIES LTD"); vendorModels.put(0x0665, "Pure International Limited"); vendorModels.put(0x0666, "WTO Werkzeug-Einrichtungen GmbH"); vendorModels.put(0x0667, "Spark Technology Labs Inc."); vendorModels.put(0x0668, "Bleb Technology srl"); vendorModels.put(0x0669, "Livanova USA, Inc."); vendorModels.put(0x066A, "Brady Worldwide Inc."); vendorModels.put(0x066B, "DewertOkin GmbH"); vendorModels.put(0x066C, "Ztove ApS"); vendorModels.put(0x066D, "Venso EcoSolutions AB"); vendorModels.put(0x066E, "Eurotronik Kranj d.o.o."); vendorModels.put(0x066F, "Hug Technology Ltd"); vendorModels.put(0x0670, "Gema Switzerland GmbH"); vendorModels.put(0x0671, "Buzz Products Ltd."); vendorModels.put(0x0672, "Kopi"); vendorModels.put(0x0673, "Innova Ideas Limited"); vendorModels.put(0x0674, "BeSpoon"); vendorModels.put(0x0675, "Deco Enterprises, Inc."); vendorModels.put(0x0676, "Expai Solutions Private Limited"); vendorModels.put(0x0677, "Innovation First, Inc."); vendorModels.put(0x0678, "SABIK Offshore GmbH"); vendorModels.put(0x0679, "4iiii Innovations Inc."); vendorModels.put(0x067A, "The Energy Conservatory, Inc."); vendorModels.put(0x067B, "I.FARM, INC."); vendorModels.put(0x067C, "Tile, Inc."); vendorModels.put(0x067D, "Form Athletica Inc."); vendorModels.put(0x067E, "MbientLab Inc"); vendorModels.put(0x067F, "NETGRID S.N.C. DI BISSOLI MATTEO, CAMPOREALE SIMONE, TOGNETTI FEDERICO"); vendorModels.put(0x0680, "Mannkind Corporation"); vendorModels.put(0x0681, "Trade FIDES a.s."); vendorModels.put(0x0682, "Photron Limited"); vendorModels.put(0x0683, "Eltako GmbH"); vendorModels.put(0x0684, "Dermalapps, LLC"); vendorModels.put(0x0685, "Greenwald Industries"); vendorModels.put(0x0686, "inQs Co., Ltd."); vendorModels.put(0x0687, "Cherry GmbH"); vendorModels.put(0x0688, "Amsted Digital Solutions Inc."); vendorModels.put(0x0689, "Tacx b.v."); vendorModels.put(0x068A, "Raytac Corporation"); vendorModels.put(0x068B, "Jiangsu Teranovo Tech Co., Ltd."); vendorModels.put(0x068C, "Changzhou Sound Dragon Electronics and Acoustics Co., Ltd"); vendorModels.put(0x068D, "JetBeep Inc."); vendorModels.put(0x068E, "Razer Inc."); vendorModels.put(0x068F, "JRM Group Limited"); vendorModels.put(0x0690, "Eccrine Systems, Inc."); vendorModels.put(0x0691, "Curie Point AB"); vendorModels.put(0x0692, "Georg Fischer AG"); vendorModels.put(0x0693, "Hach - Danaher"); vendorModels.put(0x0694, "T&A Laboratories LLC"); vendorModels.put(0x0695, "Koki Holdings Co., Ltd."); vendorModels.put(0x0696, "Gunakar Private Limited"); vendorModels.put(0x0697, "Stemco Products Inc"); vendorModels.put(0x0698, "Wood IT Security, LLC"); vendorModels.put(0x0699, "RandomLab SAS"); vendorModels.put(0x069A, "Adero, Inc. (formerly as TrackR, Inc.)"); vendorModels.put(0x069B, "Dragonchip Limited"); vendorModels.put(0x069C, "Noomi AB"); vendorModels.put(0x069D, "Vakaros LLC"); vendorModels.put(0x069E, "Delta Electronics, Inc."); vendorModels.put(0x069F, "FlowMotion Technologies AS"); vendorModels.put(0x06A0, "OBIQ Location Technology Inc."); vendorModels.put(0x06A1, "Cardo Systems, Ltd"); vendorModels.put(0x06A2, "Globalworx GmbH"); vendorModels.put(0x06A3, "Nymbus, LLC"); vendorModels.put(0x06A4, "Sanyo Techno Solutions Tottori Co., Ltd."); vendorModels.put(0x06A5, "TEKZITEL PTY LTD"); vendorModels.put(0x06A6, "Roambee Corporation"); vendorModels.put(0x06A7, "Chipsea Technologies (ShenZhen) Corp."); vendorModels.put(0x06A8, "GD Midea Air-Conditioning Equipment Co., Ltd."); vendorModels.put(0x06A9, "Soundmax Electronics Limited"); vendorModels.put(0x06AA, "Produal Oy"); vendorModels.put(0x06AB, "HMS Industrial Networks AB"); vendorModels.put(0x06AC, "Ingchips Technology Co., Ltd."); vendorModels.put(0x06AD, "InnovaSea Systems Inc."); vendorModels.put(0x06AE, "SenseQ Inc."); vendorModels.put(0x06AF, "Shoof Technologies"); vendorModels.put(0x06B0, "BRK Brands, Inc."); vendorModels.put(0x06B1, "SimpliSafe, Inc."); vendorModels.put(0x06B2, "Tussock Innovation 2013 Limited"); vendorModels.put(0x06B3, "The Hablab ApS"); vendorModels.put(0x06B4, "Sencilion Oy"); vendorModels.put(0x06B5, "Wabilogic Ltd."); vendorModels.put(0x06B6, "Sociometric Solutions, Inc."); vendorModels.put(0x06B7, "iCOGNIZE GmbH"); vendorModels.put(0x06B8, "ShadeCraft, Inc"); vendorModels.put(0x06B9, "Beflex Inc."); vendorModels.put(0x06BA, "Beaconzone Ltd"); vendorModels.put(0x06BB, "Leaftronix Analogic Solutions Private Limited"); vendorModels.put(0x06BC, "TWS Srl"); vendorModels.put(0x06BD, "ABB Oy"); vendorModels.put(0x06BE, "HitSeed Oy"); vendorModels.put(0x06BF, "Delcom Products Inc."); vendorModels.put(0x06C0, "CAME S.p.A."); vendorModels.put(0x06C1, "Alarm.com Holdings, Inc"); vendorModels.put(0x06C2, "Measurlogic Inc."); vendorModels.put(0x06C3, "King I Electronics.Co.,Ltd"); vendorModels.put(0x06C4, "Dream Labs GmbH"); vendorModels.put(0x06C5, "Urban Compass, Inc"); vendorModels.put(0x06C6, "Simm Tronic Limited"); vendorModels.put(0x06C7, "Somatix Inc"); vendorModels.put(0x06C8, "Storz & Bickel GmbH & Co. KG"); vendorModels.put(0x06C9, "MYLAPS B.V."); vendorModels.put(0x06CA, "Shenzhen Zhongguang Infotech Technology Development Co., Ltd"); vendorModels.put(0x06CB, "Dyeware, LLC"); vendorModels.put(0x06CC, "Dongguan SmartAction Technology Co.,Ltd."); vendorModels.put(0x06CD, "DIG Corporation"); vendorModels.put(0x06CE, "FIOR & GENTZ"); vendorModels.put(0x06CF, "Belparts N.V."); vendorModels.put(0x06D0, "Etekcity Corporation"); vendorModels.put(0x06D1, "Meyer Sound Laboratories, Incorporated"); vendorModels.put(0x06D2, "CeoTronics AG"); vendorModels.put(0x06D3, "TriTeq Lock and Security, LLC"); vendorModels.put(0x06D4, "DYNAKODE TECHNOLOGY PRIVATE LIMITED"); vendorModels.put(0x06D5, "Sensirion AG"); vendorModels.put(0x06D6, "JCT Healthcare Pty Ltd"); vendorModels.put(0x06D7, "FUBA Automotive Electronics GmbH"); vendorModels.put(0x06D8, "AW Company"); vendorModels.put(0x06D9, "Shanghai Mountain View Silicon Co.,Ltd."); vendorModels.put(0x06DA, "Zliide Technologies ApS"); vendorModels.put(0x06DB, "Automatic Labs, Inc."); vendorModels.put(0x06DC, "Industrial Network Controls, LLC"); vendorModels.put(0x06DD, "Intellithings Ltd."); vendorModels.put(0x06DE, "Navcast, Inc."); vendorModels.put(0x06DF, "Hubbell Lighting, Inc."); vendorModels.put(0x06E0, "Avaya"); vendorModels.put(0x06E1, "Milestone AV Technologies LLC"); vendorModels.put(0x06E2, "Alango Technologies Ltd"); vendorModels.put(0x06E3, "Spinlock Ltd"); vendorModels.put(0x06E4, "Aluna"); vendorModels.put(0x06E5, "OPTEX CO.,LTD."); vendorModels.put(0x06E6, "NIHON DENGYO KOUSAKU"); vendorModels.put(0x06E7, "VELUX A/S"); vendorModels.put(0x06E8, "Almendo Technologies GmbH"); vendorModels.put(0x06E9, "Zmartfun Electronics, Inc."); vendorModels.put(0x06EA, "SafeLine Sweden AB"); vendorModels.put(0x06EB, "Houston Radar LLC"); vendorModels.put(0x06EC, "Sigur"); vendorModels.put(0x06ED, "J Neades Ltd"); vendorModels.put(0x06EE, "Avantis Systems Limited"); vendorModels.put(0x06EF, "ALCARE Co., Ltd."); vendorModels.put(0x06F0, "Chargy Technologies, SL"); vendorModels.put(0x06F1, "Shibutani Co., Ltd."); vendorModels.put(0x06F2, "Trapper Data AB"); vendorModels.put(0x06F3, "Alfred International Inc."); vendorModels.put(0x06F4, "Near Field Solutions Ltd"); vendorModels.put(0x06F5, "Vigil Technologies Inc."); vendorModels.put(0x06F6, "Vitulo Plus BV"); vendorModels.put(0x06F7, "WILKA Schliesstechnik GmbH"); vendorModels.put(0x06F8, "BodyPlus Technology Co.,Ltd"); vendorModels.put(0x06F9, "happybrush GmbH"); vendorModels.put(0x06FA, "Enequi AB"); vendorModels.put(0x06FB, "Sartorius AG"); vendorModels.put(0x06FC, "Tom Communication Industrial Co.,Ltd."); vendorModels.put(0x06FD, "ESS Embedded System Solutions Inc."); vendorModels.put(0x06FE, "Mahr GmbH"); vendorModels.put(0x06FF, "Redpine Signals Inc"); vendorModels.put(0x0700, "TraqFreq LLC"); vendorModels.put(0x0701, "PAFERS TECH"); vendorModels.put(0x0702, "Akciju sabiedriba \"SAF TEHNIKA\""); vendorModels.put(0x0703, "Beijing Jingdong Century Trading Co., Ltd."); vendorModels.put(0x0704, "JBX Designs Inc."); vendorModels.put(0x0705, "AB Electrolux"); vendorModels.put(0x0706, "Wernher von Braun Center for ASdvanced Research"); vendorModels.put(0x0707, "Essity Hygiene and Health Aktiebolag"); vendorModels.put(0x0708, "Be Interactive Co., Ltd"); vendorModels.put(0x0709, "Carewear Corp."); vendorModels.put(0x070A, "Huf Hlsbeck & Frst GmbH & Co. KG"); vendorModels.put(0x070B, "Element Products, Inc."); vendorModels.put(0x070C, "Beijing Winner Microelectronics Co.,Ltd"); vendorModels.put(0x070D, "SmartSnugg Pty Ltd"); vendorModels.put(0x070E, "FiveCo Sarl"); vendorModels.put(0x070F, "California Things Inc."); vendorModels.put(0x0710, "Audiodo AB"); vendorModels.put(0x0711, "ABAX AS"); vendorModels.put(0x0712, "Bull Group Company Limited"); vendorModels.put(0x0713, "Respiri Limited"); vendorModels.put(0x0714, "MindPeace Safety LLC"); vendorModels.put(0x0715, "Vgyan Solutions"); vendorModels.put(0x0716, "Altonics"); vendorModels.put(0x0717, "iQsquare BV"); vendorModels.put(0x0718, "IDIBAIX enginneering"); vendorModels.put(0x0719, "ECSG"); vendorModels.put(0x071A, "REVSMART WEARABLE HK CO LTD"); vendorModels.put(0x071B, "Precor"); vendorModels.put(0x071C, "F5 Sports, Inc"); vendorModels.put(0x071D, "exoTIC Systems"); vendorModels.put(0x071E, "DONGGUAN HELE ELECTRONICS CO., LTD"); vendorModels.put(0x071F, "Dongguan Liesheng Electronic Co.Ltd"); vendorModels.put(0x0720, "Oculeve, Inc."); vendorModels.put(0x0721, "Clover Network, Inc."); vendorModels.put(0x0722, "Xiamen Eholder Electronics Co.Ltd"); vendorModels.put(0x0723, "Ford Motor Company"); vendorModels.put(0x0724, "Guangzhou SuperSound Information Technology Co.,Ltd"); vendorModels.put(0x0725, "Tedee Sp. z o.o."); vendorModels.put(0x0726, "PHC Corporation"); vendorModels.put(0x0727, "STALKIT AS"); vendorModels.put(0x0728, "Eli Lilly and Company"); vendorModels.put(0x0729, "SwaraLink Technologies"); vendorModels.put(0x072A, "JMR embedded systems GmbH"); vendorModels.put(0x072B, "Bitkey Inc."); vendorModels.put(0x072C, "GWA Hygiene GmbH"); vendorModels.put(0x072D, "Safera Oy"); vendorModels.put(0x072E, "Open Platform Systems LLC"); vendorModels.put(0x072F, "OnePlus Electronics (Shenzhen) Co., Ltd."); vendorModels.put(0x0730, "Wildlife Acoustics, Inc."); vendorModels.put(0x0731, "ABLIC Inc."); vendorModels.put(0x0732, "Dairy Tech, Inc."); vendorModels.put(0x0733, "Iguanavation, Inc."); vendorModels.put(0x0734, "DiUS Computing Pty Ltd"); vendorModels.put(0x0735, "UpRight Technologies LTD"); vendorModels.put(0x0736, "FrancisFund, LLC"); vendorModels.put(0x0737, "LLC Navitek"); vendorModels.put(0x0738, "Glass Security Pte Ltd"); vendorModels.put(0x0739, "Jiangsu Qinheng Co., Ltd."); vendorModels.put(0x073A, "Chandler Systems Inc."); vendorModels.put(0x073B, "Fantini Cosmi s.p.a."); vendorModels.put(0x073C, "Acubit ApS"); vendorModels.put(0x073D, "Beijing Hao Heng Tian Tech Co., Ltd."); vendorModels.put(0x073E, "Bluepack S.R.L."); vendorModels.put(0x073F, "Beijing Unisoc Technologies Co., Ltd."); vendorModels.put(0x0740, "HITIQ LIMITED"); vendorModels.put(0x0741, "MAC SRL"); vendorModels.put(0x0742, "DML LLC"); vendorModels.put(0x0743, "Sanofi"); } /** * Returns the company name for the given company identifier * * @param companyIdentifier 16-bit company identifier * @return company name; */ public static String getCompanyName(final short companyIdentifier) { final String companyName = vendorModels.get(companyIdentifier); return companyName == null ? "Company ID unavailable" : companyName; } }
openremote/openremote
agent/src/main/java/org/openremote/agent/protocol/bluetooth/mesh/utils/CompanyIdentifiers.java
793
//jDownloader - Downloadmanager //Copyright (C) 2012 JD-Team [email protected] // //This program is free software: you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program. If not, see <http://www.gnu.org/licenses/>. package jd.plugins.hoster; import jd.PluginWrapper; import jd.http.Browser; import jd.http.URLConnectionAdapter; import jd.nutils.JDHash; import jd.nutils.encoding.Encoding; import jd.parser.Regex; import jd.plugins.DownloadLink; import jd.plugins.DownloadLink.AvailableStatus; import jd.plugins.HostPlugin; import jd.plugins.LinkStatus; import jd.plugins.PluginException; import jd.plugins.PluginForHost; @HostPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "uitzendinggemist.nl" }, urls = { "http://(www\\.)?uitzendinggemist\\.nl/afleveringen/\\d+" }) public class UitzendinggemistNl extends PluginForHost { private enum Quality { sb, bb, std; } private String clipData; private String finalURL = null; private boolean NEEDSSILVERLIGHT = false; public UitzendinggemistNl(final PluginWrapper wrapper) { super(wrapper); } @Override public String getAGBLink() { return "http://www.publiekeomroep.nl/disclaimer"; } private String getClipData(final String tag) { return new Regex(clipData, "<" + tag + ">(.*?)</" + tag + ">").getMatch(0); } private void getfinalLink(final String episodeID) throws Exception { /* Diverse urls besorgen. Link ist statisch, kommt aus dem Flashplayer */ final Browser br2 = br.cloneBrowser(); clipData = br2.getPage("http://embed.player.omroep.nl/fl/ug_config.xml"); String nextUrl = getClipData("sessionURL"); if (nextUrl == null) { return; } clipData = br2.getPage(nextUrl); final String[] params = Encoding.Base64Decode(getClipData("key")).split("\\|"); if (params == null || params.length != 4) { return; } nextUrl = "/info/stream/aflevering/" + episodeID + "/" + JDHash.getMD5(episodeID + "|" + params[1]).toUpperCase(); clipData = br2.getPage(nextUrl); if (getClipData("code") != null ? true : false) { return; } final String[] streamUrls = br2.getRegex("(http://[^<>]+)(\n|\r\n)").getColumn(0); if (streamUrls == null || streamUrls.length == 0) { return; } /* sb (low), bb (normal) or std (high) */ String[] Q = new String[2]; for (final String streamUrl : streamUrls) { if (streamUrl.contains("type=http")) { // !mms Q = new Regex(streamUrl, "/([0-9a-z]+_[a-z]+)/").getMatch(0).split("_"); Q[0] = Q[0] == null ? "fallback" : Q[0]; Q[1] = Q[1] == null ? "fallback" : Q[1]; switch (Quality.valueOf(Q[1])) { case sb: if (finalURL == null || !finalURL.contains("_bb/")) { finalURL = streamUrl; } break; case bb: finalURL = streamUrl; break; case std: finalURL = streamUrl; return; default: finalURL = streamUrl; break; } } } } @Override public int getMaxSimultanFreeDownloadNum() { return -1; } @Override public void handleFree(final DownloadLink downloadLink) throws Exception, PluginException { requestFileInformation(downloadLink); if (NEEDSSILVERLIGHT) { throw new PluginException(LinkStatus.ERROR_FATAL, "Can't download MS Silverlight videos!"); } dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, finalURL, true, 0); if (dl.getConnection().getContentType().contains("text")) { if (dl.getConnection().getContentType().contains("html")) { br.followConnection(); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } if (dl.getConnection().getContentType().contains("plain")) { final String error = br.toString(); if (error.length() < 100) { throw new PluginException(LinkStatus.ERROR_FATAL, error); } else { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } } } dl.startDownload(); } @Override public AvailableStatus requestFileInformation(final DownloadLink link) throws Exception { setBrowserExclusive(); br.setFollowRedirects(true); br.setCustomCharset("utf-8"); clipData = br.getPage(link.getDownloadURL()); if (br.containsHTML("(>Oeps\\.\\.\\.|Helaas, de opgevraagde pagina bestaat niet|<title>Home \\- Uitzending Gemist</title>)")) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } String filename = getClipData("title").replace("- Uitzending Gemist", ""); if (filename == null) { filename = br.getRegex("<meta content=\"(.*?)\" property=\"og:title\"").getMatch(0); } if (filename == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); filename = Encoding.htmlDecode(filename.trim().replaceAll("(:|,|\\s)", "_")); link.setFinalFileName(filename + ".mp4"); String episodeID = br.getRegex("episodeID=(\\d+)\\&").getMatch(0); if (episodeID == null) { episodeID = br.getRegex("data\\-episode\\-id=\"(\\d+)\"").getMatch(0); } if (episodeID == null) { link.getLinkStatus().setStatusText("Can't download MS Silverlight videos!"); NEEDSSILVERLIGHT = true; return AvailableStatus.TRUE; } /* * Es gibt mehrere Video urls in verschiedenen Qualitäten und Formaten. Methode ermittelt die höchst mögliche Qualität. mms:// Links * werden ignoriert. */ getfinalLink(episodeID); if (finalURL == null) { NEEDSSILVERLIGHT = true; return AvailableStatus.TRUE; } br.setFollowRedirects(true); URLConnectionAdapter con = null; try { con = br.openGetConnection(finalURL); if (!con.getContentType().contains("html")) { link.setDownloadSize(con.getLongContentLength()); } else { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } } finally { try { con.disconnect(); } catch (final Throwable e) { } } return AvailableStatus.TRUE; } @Override public void reset() { } @Override public void resetDownloadlink(final DownloadLink link) { } }
substanc3-dev/jdownloader2
src/jd/plugins/hoster/UitzendinggemistNl.java
794
package com.sixtyfour.basicshell; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Comparator; import java.util.Locale; import java.util.TreeSet; import com.sixtyfour.Loader; import com.sixtyfour.Logger; import com.sixtyfour.cbmnative.mos6502.util.Converter; import com.sixtyfour.parser.assembly.ControlCodes; import com.sixtyfour.parser.cbmnative.UnTokenizer; /** * The storage for the edited program. * * @author nietoperz809 */ public class ProgramStore { public static final String ERROR = "ERROR.\n"; public static final String OK = "READY.\n"; private final TreeSet<String> store = new TreeSet<>(new LineComparator()); private int getLineNumber(String in) throws NumberFormatException { StringBuilder buff = new StringBuilder(); for (int s = 0; s < in.length(); s++) { char c = in.charAt(s); if (!Character.isDigit(c)) break; buff.append(c); } return Integer.parseInt(buff.toString()); } @SuppressWarnings("unchecked") private void removeLine(int num) { TreeSet<String> clone = (TreeSet<String>) store.clone(); // avoid // java.util.ConcurrentModificationException for (String s : clone) { if (getLineNumber(s) == num) store.remove(s); } } @SuppressWarnings("unchecked") public String[] toArray() { TreeSet<String> clone = (TreeSet<String>) store.clone(); // avoid // java.util.ConcurrentModificationException String[] arr = new String[clone.size()]; int n = 0; for (String s : clone) { arr[n++] = s; } return arr; } @SuppressWarnings("unchecked") @Override public String toString() { TreeSet<String> clone = (TreeSet<String>) store.clone(); // avoid // java.util.ConcurrentModificationException StringBuilder sb = new StringBuilder(); for (String s : clone) { sb.append(s).append('\n'); } return sb.toString(); } @SuppressWarnings("unused") public boolean insert(String s) { if (s != null && s.trim().length() > 0) { try // Must begin with number { int num = getLineNumber(s); try { int num2 = Integer.parseInt(s); // Number only? removeLine(num); } catch (NumberFormatException ex) { addLine(s); } } catch (NumberFormatException ex) { return false; } } return true; } private void addLine(String s) { removeLine(getLineNumber(s)); store.add(s); } public void clear() { store.clear(); } public String load(String srcFile) { store.clear(); try { String[] lines = null; if (srcFile.toLowerCase(Locale.ENGLISH).endsWith(".prg")) { try { Logger.log("Looks like a PRG file, trying to convert it..."); byte[] data = Loader.loadBlob(srcFile); UnTokenizer unto = new UnTokenizer(); lines = unto.getText(data, true).toArray(new String[0]); for (int i=0;i<lines.length; i++) { lines[i]=ControlCodes.convert2Codes(Converter.convertCase(lines[i], false)); } Logger.log("PRG file converted into ASCII, proceeding!"); srcFile = srcFile.replace(".prg", ".bas"); } catch (Exception e) { Logger.log("Failed to convert PRG file: " + e.getMessage()); Logger.log("Proceeding as if it was ASCII instead!"); } } else { lines = Loader.loadProgram(srcFile); } for (String line : lines) { insert(line); } } catch (Exception e) { e.printStackTrace(); return ERROR; } return OK; } public String save(String path) { boolean ok = true; String txt = this.toString(); FileWriter outFile = null; try { outFile = new FileWriter(path); } catch (IOException e) { e.printStackTrace(); ok = false; } if (ok) { try { PrintWriter out1 = new PrintWriter(outFile); try { out1.append(txt); } finally { out1.close(); } } finally { try { outFile.close(); } catch (IOException e) { e.printStackTrace(); ok = false; } } } return ok ? OK : ERROR; } class LineComparator implements Comparator<String> { @Override public int compare(String s1, String s2) { return getLineNumber(s1) - getLineNumber(s2); } } }
EgonOlsen71/basicv2
src/main/java/com/sixtyfour/basicshell/ProgramStore.java
795
// -*- mode: java; c-basic-offset: 2; -*- // Copyright 2016 Massachusetts Institute of Technology. All rights reserved. /** * @fileoverview Dutch (Flanders (Belgium)/the Netherlands) strings. * @author [email protected] (volunteers from the Flemish Coderdojo Community) */ 'use strict'; goog.require('Blockly.Msg.nl'); goog.provide('AI.Blockly.Msg.nl'); /** * Due to the frequency of long strings, the 80-column wrap rule need not apply * to message files. */ Blockly.Msg.nl.switch_language_to_dutch = { // Switch language to Dutch. category: '', helpUrl: '', init: function() { Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT = 'Zoek op per paar sleutel %1 paren %2 nietGevonden %3'; Blockly.Msg.VARIABLE_CATEGORY = 'Variabelen'; Blockly.Msg.ADD_COMMENT = 'Commentaar toevoegen'; Blockly.Msg.EXPAND_BLOCK = 'Blok uitbreiden'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TITLE_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT = 'Verdeelt tekst in stukken met de tekst \'op\' als splitspunt en levert een lijst van de resultaten. \n"één,twee,drie,vier" splitsen op "," (komma) geeft de lijst "(één twee drie vier)" terug. \n"één-aardappel,twee-aardappel,drie-aardappel,vier" splitsen op "-aardappel," geeft ook de lijst "(één twee drie vier)" terug.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TOOLTIP = 'Geeft de waarde terug die was doorgegeven bij het openen van het scherm, meestal door een ander scherm in een app met meerdere schermen. Als er geen waarde was meegegeven, wordt er een lege tekst teruggegeven.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TITLE = 'item'; Blockly.Msg.DELETE_BLOCK = 'Verwijder blok'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TOOLTIP = 'Geeft het nummer terug in decimale notatie\nmet een bepaald aantal getallen achter de komma.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE = 'terwijl'; Blockly.Msg.LANG_COLOUR_PINK = 'roze'; Blockly.Msg.CONNECT_TO_DO_IT = 'U moet verbonden zijn met de AI Companion app of emulator om "Doe het" te gebruiken'; Blockly.Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT = 'krijg'; Blockly.Msg.LANG_MATH_TRIG_SIN = 'sin'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = 'ga verder met volgende iteratie'; Blockly.Msg.DISABLE_BLOCK = 'Schakel Blok uit'; Blockly.Msg.REPL_HELPER_Q = 'Helper?'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT = 'Vervang alle tekst %1 stukje tekst %2 vervangingstekst %3'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN = 'wanneer'; Blockly.Msg.LANG_COLOUR_CYAN = 'Lichtblauw'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_COLLAPSED_TEXT = 'sluit scherm met waarde'; Blockly.Msg.LANG_MATH_TRIG_ASIN = 'asin'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV = 'lijst naar .csv tabel'; Blockly.Msg.REPL_NOW_DOWNLOADING = 'We downloaden nu een update van de App Inventor server. Even geduld aub.'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TOOLTIP = 'specificeert een numerieke seed waarde\nvoor de willekeurige nummer maker'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT = 'zet om'; Blockly.Msg.LANG_MATH_SINGLE_OP_EXP = 'e^'; Blockly.Msg.LANG_TEXT_COMPARE_EQUAL = ' ='; Blockly.Msg.LANG_TEXT_COMPARE_NEQ = ' ≠'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ROOT = 'Geeft de vierkantswortel van een getal.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TOOLTIP = 'Voeg items toe aan het einde van een lijst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_TEXT_COMPARE_GT = ' >'; Blockly.Msg.REPL_USB_CONNECTED_WAIT = 'USB verbonden, effe wachten aub'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES = 'lokale namen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR = 'maak kleur'; Blockly.Msg.LANG_MATH_DIVIDE = '÷'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP = 'Voert alle blokken uit in \'do\' en geeft een statement terug. Handig wanneer je een procedure wil uitvoeren voor een waarde terug te geven aan een variabele.'; Blockly.Msg.COPY_ALLBLOCKS = 'Kopieer alle blokken naar de rugzak'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT_LIST = 'op (lijst)'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT = 'globaal'; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE = 'invoer:'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_NOT_FOUND = 'nietGevonden'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP = 'Laat je toe variabelen te maken die enkel toegankelijk zijn in het doe deel van dit blok.'; Blockly.Msg.REPL_PLUGGED_IN_Q = 'Aangesloten?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP = ''; Blockly.Msg.HORIZONTAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST = 'is een lijst?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE = 'invoer'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_FROM = 'van'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TITLE_APPEND = 'voeg toe aan lijst'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX = ' binnen bereik'; Blockly.Msg.NEW_VARIABLE_TITLE = 'Nieuwe variabelenaam:'; Blockly.Msg.VERTICAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TITLE_REPLACE = 'vervang element in de lijst'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_ANY = 'Verdeelt de gegeven tekst in een lijst, waarbij elk element in de lijst \'\'op\'\' als het\nverdeelpunt, en geeft een lijst terug van het resultaat. \nSplitsen van "sinaasappel,banaan,appel,hondenvoer" met als "op" een lijst van 2 elementen met als eerste \nelement een komma en als tweede element "pel" geeft een lijst van 4 elementen: \n"(sinaasap banaan ap hondenvoer)".'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN = 'in'; Blockly.Msg.DO_IT = 'Voer uit'; Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE = 'absoluut'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME = 'functie die niets teruggeeft'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_TOOLTIP = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.BACKPACK_DOCUMENTATION = 'De Rugzak is een knip/plak functie. Het laat toe om blokken te kopieren van een project of scherm en ze in een ander scherm of project te plakken. Om te kopieren sleep je de blokken in de rugzak. Om te plakken klik je op het Rugzak icoon en sleep je de blokken in de werkplaats.</p><p> De inhoud van de Rugzak blijft behouden tijdens de ganse App Inventor sessie. Als je de App Inventor dicht doet, of als je je browser herlaadt, wordt de Rugzak leeggemaakt.</p><p>Voor meer info en een video, bekijk:</p><p><a href="/reference/other/backpack.html" target="_blank">http://ai2.appinventor.mit.edu/reference/other/backpack.html</a>'; Blockly.Msg.LANG_MATH_TRIG_ATAN2 = 'atan2'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX = 'aanroep '; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSEIF = 'of als'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN = 'resultaat'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_CALL = 'roep aan'; Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE = 'splits bij spaties'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV = 'lijst van .csv rij'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE = 'x'; Blockly.Msg.REPL_CONNECTION_FAILURE1 = 'Verbindingsfout'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST_OF_ANY = 'Splitst een gegeven tekst in een lijst met twee elementen. De eerste plaats van eender welk item in de lijst "aan" is het \'\'splitsingspunt\'\'. \n\nBijvoorbeeld als je "Ik hou van appels, bananen en ananas" splitst volgens de lijst "(ba,ap)", dan geeft dit \neen lijst van 2 elementen terug. Het eerste item is "Ik hou van" en het tweede item is \n"pels, bananen en ananas."'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE = 'open een ander scherm'; Blockly.Msg.LANG_LISTS_IS_LIST_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties om dit lijst blok opnieuw te configureren. '; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GTE = 'Geef waar terug als het eerste getal groter is\ndan of gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_FOR_TOOLTIP = 'Tel van een start- tot een eindnummer.\nZet het huidige nummer, voor iedere tel, op\nvariabele "%1", en doe erna een aantal dingen.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TOOLTIP = 'Geef een willekeurig getal tussen 0 en 1 terug.'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_VARIABLE = ' variabele'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.WARNING_DELETE_X_BLOCKS = 'Weet u zeker dat u alle %1 van deze blokken wilt verwijderen?'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TOOLTIP = ''; Blockly.Msg.LANG_LISTS_INSERT_INPUT_ITEM = 'item'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE = 'sluit scherm'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_EQUAL = 'Test of stukken tekst identiek zijn, of ze dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale=\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn=\nmaar niet tekst =.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_NEQ = 'Test of stukken tekst verschillend zijn, of ze niet dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale≠\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn tekst ≠\nmaar wiskundig =.'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_ROUND = 'Rond een nummer af naar boven of beneden.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_END = 'tot'; Blockly.Msg.LANG_COLOUR_ORANGE = 'oranje'; Blockly.Msg.REPL_STARTING_COMPANION_IN_EMULATOR = 'AI Companion App wordt opgestart in de emulator.'; Blockly.Msg.LANG_MATH_COMPARE_LT = '<'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ABS = 'Geef de absolute waarde van een getal terug.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM = 'item'; Blockly.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN = 'Selecteer een geldig item uit de drop down.'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD = 'graden naar radialen'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TOOLTIP = 'Geeft de platte tekst terug die doorgegeven werd toen dit scherm werd gestart door een andere app. Als er geen waarde werd doorgegeven, geeft deze functie een lege tekst terug. Voor multischerm apps, gebruik dan neem start waarde in plaats van neem platte start tekst.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM = 'voor elk'; Blockly.Msg.BACKPACK_DOC_TITLE = 'Rugzak informatie'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN = 'samenvoegen'; Blockly.Msg.LANG_TEXT_LENGTH_TOOLTIP = 'Geeft het aantal letters (inclusief spaties)\nterug in de meegegeven tekst.'; Blockly.Msg.LANG_CONTROLS_IF_IF_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties\nom dit blok opnieuw te configureren.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1 = 'De AI Companion die je op je smartphone gebruikt, is verouderd.<br/><br/>Deze versie van de App Inventor moet gebruikt worden met Companion versie'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE = 'hoofdletters'; Blockly.Msg.LANG_MATH_ARITHMETIC_ADD = '+'; Blockly.Msg.REPL_COMPANION_VERSION_CHECK = 'Versie controle van de AI Companion'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP = 'Een procedure die een resultaat teruggeeft.'; Blockly.Msg.LANG_MATH_TRIG_ATAN2_X = 'x'; Blockly.Msg.EXPAND_ALL = 'Blok uitbreiden'; Blockly.Msg.CHANGE_VALUE_TITLE = 'Wijzig waarde:'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TOOLTIP = 'Opent een nieuw scherm in een app met meerdere schermen.'; Blockly.Msg.LANG_TEXT_ISEMPTY_TOOLTIP = 'Geeft waar terug als de lengte van de\ntekst gelijk is aan 0, anders wordt niet waar teruggegeven.'; Blockly.Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT = 'ingesteld'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM = 'willekeurig deel'; Blockly.Msg.LANG_COLOUR_BLUE = 'blauw'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = 'tot'; Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET = 'krijg'; Blockly.Msg.REPL_APPROVE_UPDATE = ' scherm omdat je gevraagd gaat worden om een update goed te keuren.'; Blockly.Msg.LANG_TEXT_TRIM_TOOLTIP = 'Geeft een kopie terug van de tekst argumenten met elke\nspatie vooraan en achteraan verwijderd.'; Blockly.Msg.REPL_EMULATORS = 'emulators'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM = 'is een getal?'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX = 'to '; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE = 'vergelijk teksten'; Blockly.Msg.LANG_MATH_NUMBER_TOOLTIP = 'Rapporteer het getoonde getal.'; Blockly.Msg.LANG_TEXT_COMPARE_LT = ' <'; Blockly.Msg.LANG_LISTS_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TOOLTIP = 'Verwijdert het element op de gegeven positie uit de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_TITLE_IS_IN = 'staat in een lijst?'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_CEILING = 'Rond de input af tot het kleinste\ngetal dat niet kleiner is dan de input'; Blockly.Msg.LANG_COLOUR_YELLOW = 'geel'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_FLOOR = 'Rond de input af tot het grootste\ngetal dat niet groter is dan de input'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_MODULO = 'Geeft de gehele deling terug.'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TITLE_ITEM = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_STARTS_AT_TOOLTIP = 'Geeft de beginpositie terug van het stukje in de tekst\nwaar index 1 het begin van de tekst aangeeft. Geeft 0 terug wanneer\nhet stuk tekst niet voorkomt.'; Blockly.Msg.SORT_W = 'Sorteer blokken op breedte'; Blockly.Msg.ENABLE_BLOCK = 'Schakel blok aan'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_COLLAPSED_TEXT = 'evalueer maar negeer'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_ADD = 'Geeft de som van twee getallen terug.'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT = 'index in lijst item %1 lijst %2'; Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING = ' seconden om er zeker van te zijn dat alles draait.'; Blockly.Msg.REPL_NO_ERROR_FIVE_SECONDS = '<br/><i>Merk op:</i>&nbsp,Je zal geen andere foutmeldingen zien gedurende de volgende 5 seconden.'; Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT = 'niet'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CATEGORY_CONTROLS = 'Bediening'; Blockly.Msg.LANG_COLOUR_MAGENTA = 'magenta'; Blockly.Msg.LANG_LISTS_IS_IN_TOOLTIP = 'Geeft waar terug als het ding een item is dat in de lijst zit, anders wordt onwaar teruggegeven.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT = 'vervang lijst item lijst %1 index %2 vervanging %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Neemt een positief geheel decimaal getal en geeft de tekst weer die dat getal voorstelt in binair'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex naar dec'; Blockly.Msg.LANG_LOGIC_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME = 'naam'; Blockly.Msg.NEW_VARIABLE = 'Nieuwe variabele ...'; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_OR = 'Geef waar terug als de invoer waar is.'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP = ''; Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS = 'bevat'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT = 'verwijder lijstitem lijst %1 index %2'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT = 'segment tekst %1 start %2 lengte %3'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT = 'lengte van de lijst lijst %1'; Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP = 'Test of het stukje voorkomt in de tekst.'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_RAD_TO_DEG = 'Geeft de graden terug tussen\n(0,360) die overeenkomt met het argument in radialen.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_COLLAPSED_TEXT = 'Neem platte start tekst'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_SEGMENT = 'segment'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_LIST = ' lijst'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_TAN = 'tan'; Blockly.Msg.LANG_MATH_TRIG_ATAN = 'atan'; Blockly.Msg.LANG_MATH_RANDOM_SEED_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = 'Terwijl een waarde onwaar is, doe enkele andere stappen.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_INPUT_RESULT = 'resultaat'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG = 'radialen naar graden'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_SELECT = 'kies een item uit de lijst'; Blockly.Msg.LANG_CATEGORY_TEXT = 'Tekst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT = 'voeg toe aan lijst lijst1 %1 lijst2 %2'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR = 'splits kleur'; Blockly.Msg.LANG_CONTROLS_IF_MSG_IF = 'als'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP = 'Roep een procedure op die iets teruggeeft.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND = 'rond af'; Blockly.Msg.REPL_DISMISS = 'Negeer'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TOOLTIP = 'Vervangt het n\'de item in een lijst.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_GT = 'Geeft aan of tekst1 lexicologisch groter is dan tekst2.\nAls een tekst het eerste deel is van de andere, dan wordt de kortere tekst aanzien als kleiner.\nHoofdletters hebben voorrang op kleine letters.'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR = 'item'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO = 'tot'; Blockly.Msg.LANG_COLOUR_RED = 'rood'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_TO = 'tot'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.REPL_KEEP_TRYING = 'Blijf Proberen'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST = 'maak een lijst'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING = 'afrondenNaarBoven'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_SET = 'zet'; Blockly.Msg.EXTERNAL_INPUTS = 'Externe ingangen'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_PAIRS = 'paren'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE = 'open ander scherm met startwaarde'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Neemt een tekst die een hexadecimaal getal voorstelt en geeft een tekst terug die dat nummer voorstelt als decimaal getal.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_SIN = 'Geeft de sinus van de gegeven hoek (in graden).'; Blockly.Msg.REPL_GIVE_UP = 'Opgeven'; Blockly.Msg.LANG_CATEGORY_LOGIC = 'Logica'; Blockly.Msg.LANG_LISTS_COPY_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_INSERT_INPUT = 'voeg lijstitem toe lijst %1 index %2 item %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Neemt een positief decimaal getal en geeft een tekst terug die dat getal voorstelt in hexadecimale notatie.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_START = 'van'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = 'breek uit'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. door komma\'s gescheiden waarde) opgemaakte rij om een ​​lijst met velden te produceren. Als de rij tekst meerdere onbeschermde nieuwe regels (meerdere lijnen) bevat in de velden, krijg je een foutmelding. Je moet de rij tekst laten eindigen in een nieuwe regel of CRLF.'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_POWER = 'Geeft het eerste getal verheven tot\nde macht van het tweede getal.'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET = 'zet'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_DO = 'doe'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_COLOUR_GRAY = 'grijs'; Blockly.Msg.REPL_NETWORK_ERROR_RESTART = 'Netwerk Communicatie Fout met de AI Companion. <br />Probeer eens de smartphone te herstarten en opnieuw te connecteren.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM = 'kies een willekeurig item'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_LT = 'Controleert of tekst1 lexicografisch kleiner is dan text2. \ NAls een stuk tekst het voorvoegsel is van de andere, dan wordt de kortere tekst \ nals kleiner beschouwd. Kleine letters worden voorafgegaan door hoofdletters.'; Blockly.Msg.LANG_TEXT_APPEND_APPENDTEXT = 'voeg tekst toe'; Blockly.Msg.REPL_CANCEL = 'Annuleren'; Blockly.Msg.LANG_CATEGORY_MATH = 'Wiskunde'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE_TOOLTIP = 'Produceert tekst, zoals een tekstblok. Het verschil is dat de \ntekst niet gemakkelijk te detecteren is door de APK van de app te onderzoeken. Gebruik deze functie daarom bij het maken van apps \n die vertrouwelijke informatie bevatten, zoals API sleutels. \nWaarschuwing: tegen complexe security-aanvallen biedt deze functie slechts een zeer lage bescherming.'; Blockly.Msg.SORT_C = 'Sorteer blokken op categorie'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TOOLTIP = 'Geeft het item op positie index in de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH = 'lengte van de lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME = 'naam'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TITLE = 'maak op als decimaal'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = 'Zolang een waarde waar is, do dan enkele regels code.'; Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE = 'maak lege lijst'; Blockly.Msg.LANG_MATH_ARITHMETIC_POWER = '^'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TOOLTIP = 'Voert het aangesloten blok code uit en negeert de return waarde (indien aanwezig). Deze functie is handig wanneer je een procedure wil aanroepen die een return waarde heeft, zonder dat je die waarde zelf nodig hebt.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TOOLTIP = 'Maak een lijst met een bepaald aantal items.'; Blockly.Msg.ERROR_DUPLICATE_EVENT_HANDLER = 'Dit een een copy van een signaalafhandelaar voor deze component.'; Blockly.Msg.LANG_MATH_TRIG_COS = 'cos'; Blockly.Msg.BACKPACK_CONFIRM_EMPTY = 'Weet u zeker dat u de rugzak wil ledigen?'; Blockly.Msg.LANG_LISTS_IS_EMPTY_TOOLTIP = 'Geeft \'waar\' terug als de lijst leeg is.'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME = 'oproep weergave'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_LN = 'Teruggave van het natuurlijke logaritme van een getal, d.w.z. het logaritme met het grondtal e (2,71828 ...)'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_UPPERCASE = 'Geeft een kopie van de meegegeven tekst omgezet in hoofdletters.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TOOLTIP = 'Toevoegen, verwijderen of herschikken van secties om dit lijstblok te herconfigureren.'; Blockly.Msg.LANG_COLOUR_DARK_GRAY = 'donkergrijs'; Blockly.Msg.ARRANGE_H = 'Rangschik blokken horizontaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF = 'anders als'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TOOLTIP = 'Sluit het huidig scherm en geeft een resultaat terug aan het scherm dat deze opende.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_4 = 'Als de eerste waarde \'waar\' is, voer dan het eerste blok met opdrachten uit.\nAnders, als de tweede waarde \'waar\' is, voer dan het tweede blok met opdrachten uit.\nAls geen van de waarden \'waar\' is, voer dan het laatste blok met opdrachten uit.'; Blockly.Msg.REPL_NETWORK_CONNECTION_ERROR = 'Fout netwerkverbinding'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX = ' in lijst'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT = 'is in lijst? item %1 lijst %2'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_VAR = 'x'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM = 'is decimaal?'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_TOOLTIP = 'Een lijst van vier elementen, elk op een schaal van 0 tot 255, die de rode, groene, blauwe en alfa componenten voorstellen.'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE = 'evalueer maar negeer het resultaat'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_INPUT_LIST = 'lijst'; Blockly.Msg.CAN_NOT_DO_IT = 'Kan dit niet doen'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME = 'initialiseer lokale variable in doe'; Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE = '“'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = 'Sla de rest van deze loop over en \n begin met de volgende iteratie.'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_FROM = 'van'; Blockly.Msg.COPY_TO_BACKPACK = 'Voeg toe aan rugzak'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY = 'is leeg'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY = 'splits bij elk'; Blockly.Msg.EXPORT_IMAGE = 'Download blokken als afbeelding'; Blockly.Msg.REPL_GOT_IT = 'Begrepen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP = 'Een kleur met de gegeven rood, groen, blauw en optionele alfa componenten.'; Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY = 'is de lijst leeg?'; Blockly.Msg.LANG_MATH_SINGLE_OP_NEG = 'negatief'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET = 'stel in'; Blockly.Msg.INLINE_INPUTS = 'Inlijn invulveld'; Blockly.Msg.LANG_LISTS_INSERT_TOOLTIP = 'Voeg een element toe op een specifieke plaats in een lijst.'; Blockly.Msg.REPL_CONNECTING = 'Verbinden ...'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TOOLTIP = 'Geeft de waarde terug die hoort bij de sleutel in een lijst van paren'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_NEG = 'Geeft het negatief van een getal.'; Blockly.Msg.REPL_UNABLE_TO_LOAD = 'Opladen naar de App Inventor server mislukt'; Blockly.Msg.LANG_LISTS_COPY_TOOLTIP = 'Maakt een kopie van een lijst. Sublijsten worden ook gekopieerd'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_TRUE = 'Geeft de booleaanse waar terug.'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE = 'Onleesbaar gemaakte Tekst'; Blockly.Msg.LANG_TEXT_TEXT_TOOLTIP = 'Een tekst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT = 'Selecteer een element uit lijst %1 index %2'; Blockly.Msg.REPL_DO_YOU_REALLY_Q = 'Wil Je Dit Echt? Echt echt?'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP = 'Laat je toe om variabelen te maken die je alleen kan gebruiken in het deel van dit blok dat iets teruggeeft.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT = 'Initializeer globaal'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM = 'is hexadecimaal?'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_QUOTIENT = 'Berekent het quotient.'; Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM = 'is binair?'; Blockly.Msg.LANG_CONTROLS_FOREACH_TOOLTIP = 'Voert de blokken in het \'doe\' deel uit voor elk element van de lijst. Gebruik de opgegeven naam van de variabele om te verwijzen naar het huidige element.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE = '”'; Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN = 'dan'; Blockly.Msg.LANG_CONTROLS_WHILE_TITLE = 'terwijl'; Blockly.Msg.LANG_MATH_COMPARE_GT = '>'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_TOOLTIP = 'Test of iets een string is die een positief integraal grondgetal 10 voorstelt.'; Blockly.Msg.LANG_MATH_MUTATOR_ITEM_INPUT_NUMBER = 'getal'; Blockly.Msg.LANG_LISTS_ADD_ITEM_TOOLTIP = 'Voeg een item toe aan de lijst.'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO = 'in'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LT = 'Geeft Waar terug als het eerste nummer\nkleiner is dan het tweede nummer.'; Blockly.Msg.LANG_COLOUR_BLACK = 'zwart'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TOOLTIP = 'Sluit het huidige scherm af en geeft de tekst terug aan de app die dit scherm geopend heeft. Deze functie is bedoeld om tekst te retourneren aan activiteiten die niet gerelateerd zijn aan App Inventor en niet om naar App Inventor schermen terug te keren. Voor App Inventor apps met meerdere schermen, gebruik de functie Sluit Scherm met Waarde, niet Sluit Scherm met Gewone Tekst.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE = 'Jouw Companion App is te oud. Klik "OK" om bijwerken te starten. Bekijk jouw '; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_AND = 'Geef Waar terug als alle invoer Waar is.'; Blockly.Msg.REPL_NO_START_EMULATOR = 'Het is niet gelukt de MIT AI Companion te starten in de Emulator'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = 'Breek uit de omliggende lus.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_EQ = 'Geef Waar terug als beide getallen gelijk zijn aan elkaar.'; Blockly.Msg.LANG_LOGIC_OPERATION_AND = 'en'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST = 'Verdeelt de opgegeven tekst in twee delen en gebruikt hiervoor de plaats het eerste voorkomen \nvan de tekst \'aan\' als splitser, en geeft een lijst met twee elementen terug. Deze lijst bestaat \nuit het deel voor de splitser en het deel achter de splitser. \nHet splitsen van "appel,banaan,kers,hondeneten" met als een komma als splitser geeft een lijst \nterug met twee elementen: het eerste is de tekst "appel" en het tweede is de tekst \n"banaan,kers,hondeneten". \nMerk op de de komma achter "appel\' niet in het resultaat voorkomt, omdat dit de splitser is.'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binair naar decimaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TOOLTIP = 'Voeg een finaal, vang-alles-op conditie toe aan het als blok.'; Blockly.Msg.GENERATE_YAIL = 'Genereer Yail'; Blockly.Msg.LANG_LOGIC_COMPARE_TRANSLATED_NAME = 'logische is gelijk'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_DOWNCASE = 'Geeft een kopie terug van de tekst in kleine letters.'; Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT = 'quotiënt van'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_NEQ = 'Geef Waar terug als beide getallen niet gelijk zijn aan elkaar.'; Blockly.Msg.DELETE_X_BLOCKS = 'Verwijder %1 blokken'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'rest van'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT = 'start op tekst %1 stuk %2'; Blockly.Msg.BACKPACK_EMPTY = 'Maak de Rugzak leeg'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST = 'in lijst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP = 'Voert de blokken in \'\'doe\'\' uit en geeft een statement terug. Handig als je een procedure wil uitvoeren alvorens een waarde terug te geven aan een variabele.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP = 'Voert de blokken in de \'doe\' sectie uit voor elke numerieke waarde van begin tot eind, telkens verdergaand met de volgende waarde. Gebruik de gegeven naam van de variabele om te verwijzen naar de actuele waarde.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TITLE_REMOVE = 'verwijder lijst item'; Blockly.Msg.REPL_STARTING_COMPANION_ON_PHONE = 'Bezig het opstarten van de Companion App op de aangesloten telefoon.'; Blockly.Msg.ARRANGE_S = 'Rangschik blokken diagonaal'; Blockly.Msg.ERROR_COMPONENT_DOES_NOT_EXIST = 'Component bestaat niet'; Blockly.Msg.LANG_MATH_COMPARE_LTE = '≤'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT = '%1 tekst %2 %3 %4'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN = 'min'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT = 'Formatteer als decimaal getal %1 plaatsen %2'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_TEST = ''; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP = ''; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_TAN = 'Geeft de tangens van de gegeven hoek in graden.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO = 'tot'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.HELP = 'Hulp'; Blockly.Msg.LANG_LISTS_POSITION_IN_TITLE_POSITION = 'positie in lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE = 'toepassing sluiten'; Blockly.Msg.LANG_COLOUR_GREEN = 'groen'; Blockly.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF = 'Markeer Procedure'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE = 'krijg startwaarde'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP = 'van lus'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX = 'roep op '; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE = 'Verkrijg gewone starttekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP = 'Roep een procedure op die geen waarde teruggeeft.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV = 'lijst van een csv tabel'; Blockly.Msg.LANG_LISTS_INSERT_TITLE_INSERT_LIST = 'voeg een lijst element toe'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST1 = 'lijst1'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST2 = 'lijst2'; Blockly.Msg.REPL_UPDATE_INFO = 'De update wordt nu geïnstalleerd op je toestel. Hou je scherm (of emulator) in het oog en keur de installatie goed wanneer je dat gevraagd wordt.<br /><br />BELANGRIJK: Wanneer de update afloopt, kies "VOLTOOID" (klik niet op "open"). Ga dan naar App Inventor in je web browser, klik op het "Connecteer" menu en kies "Herstart Verbinding". Verbind dan het toestel.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LTE = 'Geeft waar terug als het eerste getal kleiner is\nof gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_COLLAPSED_TEXT = 'sluit scherm met platte tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_COLLAPSED_TEXT = 'herhaal tot'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_KEY = 'sleutel'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_CREATEWITH = 'maak tekst met'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TOOLTIP = 'Interpreteert de lijst als een rij van een tabel en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de rij representeert. Elk item in de rij lijst wordt beschouwd als een veld, er wordt naar verwezen met dubbele aanhalingstekens in de CSV tekst. Items worden gescheiden door een komma. De geretourneerde rij tekst heeft geen lijn separator aan het einde.'; Blockly.Msg.LANG_TEXT_JOIN_TOOLTIP = 'Voegt alle inputs samen tot 1 enkele tekst.\nAls er geen inputs zijn, wordt een lege tekst gemaakt.'; Blockly.Msg.LANG_COLOUR_WHITE = 'Wit'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE = 'Geeft het quotiënt van twee getallen.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT = 'voeg items to lijst lijst %1 item %2'; Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE = 'onwaar'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_INDEX = 'index'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. een door komma\'s gescheiden waarde) opgemaakte tabel om een ​​lijst van rijen te produceren, elke rij is een lijst van velden. Rijen kunnen worden gescheiden door nieuwe lijnen (n) of CRLF (rn).'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN = 'anders'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TOOLTIP = 'Opent een nieuw scherm in een meer-schermen app en geeft de startwaarde mee aan dat scherm.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ASIN = 'Geeft een hoek tussen [-90,+90]\ngraden met de gegeven sinus waarde.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_GETTER_TITLE_OF_COMPONENT = 'van component'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM = 'stel willekeurige seed in'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO = 'doe'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TITLE_LOOKUP_IN_PAIRS = 'zoek op in paren'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_STARTS_AT = 'begint bij'; Blockly.Msg.REPL_NOT_NOW = 'Niet Nu. Later, misschien ...'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT = 'voor component'; Blockly.Msg.HIDE_WARNINGS = 'Waarschuwingen Verbergen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'decimaal naar hexadecimaal'; Blockly.Msg.REPL_CONNECT_TO_COMPANION = 'Connecteer met de Companion'; Blockly.Msg.LANG_COLOUR_PICKER_TOOLTIP = 'Klik op de rechthoek om een kleur te kiezen.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_TO = ' tot'; Blockly.Msg.REPL_SOFTWARE_UPDATE = 'Software bijwerken'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TOOLTIP = 'Als de voorwaarde die wordt getest waar is,retourneer dan het resultaat verbonden aan het \'dan-teruggave\' veld, indien niet, geef dan het resultaat terug van het \'zoneen-teruggave\' veld, op zijn minst een van de resultaten verbonden aan beide teruggave velden wordt weergegeven.'; Blockly.Msg.RENAME_VARIABLE_TITLE = 'Hernoem alle "%1" variabelen naar:'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_FALSE = 'Geeft booleaanse niet waar terug.'; Blockly.Msg.REPL_TRY_AGAIN1 = 'Connecteren met de AI2 Companion is mislukt, probeer het eens opnieuw.'; Blockly.Msg.REPL_VERIFYING_COMPANION = 'Kijken of de Companion gestart is...'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_LISTS_POSITION_IN_TOOLTIP = 'Zoek de positie van het ding op in de lijst. Als het ding niet in de lijst zit, geef 0 terug.'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Waarschuwing:\nDit blok mag alleen\ngebruikt worden in een lus.'; Blockly.Msg.REPL_AI_NO_SEE_DEVICE = 'AI2 ziet je toestel niet, zorg ervoor dat de kabel is aangesloten en dat de besturingsprogramma\'s juist zijn.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_DEG_TO_RAD = 'Geeft de waarde in radialen terug volgens een schaal van\n[-π, +π) overeenkomstig met de graden.'; Blockly.Msg.REPL_STARTING_EMULATOR = 'Bezig met opstarten van de Android Emulator<br/>Even geduld: Dit kan een minuutje of twee duren (of koop snellere computer, grapke Pol! :p).'; Blockly.Msg.REPL_RUNTIME_ERROR = 'Uitvoeringsfout'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_COLLAPSED_TEXT = 'open scherm'; Blockly.Msg.REPL_FACTORY_RESET = 'Deze probeert jouw Emulator te herstellen in zijn initiële staat. Als je eerder je AI Companion had geupdate in de emulator, ga je dit waarschijnlijk op nieuw moeten doen. '; Blockly.Msg.LANG_LISTS_ADD_ITEM_TITLE = 'item'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE = 'als'; Blockly.Msg.LANG_CATEGORY_LISTS = 'Lijsten'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GT = 'Geeft waar terug als het eerste getal groter is\ndan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_COLLAPSED_TEXT = 'sluit toepassing'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_COLLAPSED_TEXT = 'Krijg start waarde'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_COLLAPSED_TEXT = 'sluit scherm'; Blockly.Msg.REMOVE_COMMENT = 'Commentaar Verwijderen'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.REPL_OK_LOWER = 'OK'; Blockly.Msg.LANG_MATH_SINGLE_OP_LN = 'log'; Blockly.Msg.LANG_MATH_IS_A_BINARY_TOOLTIP = 'Test of iets een tekst is die een binair getal voorstelt.'; Blockly.Msg.REPL_UNABLE_TO_UPDATE = 'Het is niet gelukt een update naar het toestel/emulator te sturen.'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO = 'tot'; Blockly.Msg.LANG_MATH_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP = 'bij'; Blockly.Msg.LANG_MATH_COMPARE_GTE = '≥'; Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_ACOS = 'acos'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN = 'Geeft een hoek tussen [-90, +90]\ngraden met de gegeven tangens.'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS = '-'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_1 = 'Als een waarde waar is, voer dan enkele stappen uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_3 = 'Als de eerste waarde waar is, voer dan het eerste codeblok uit.\nAnders, als de tweede waarde waar is, voer het tweede codeblok uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_2 = 'Als de waarde waar is, voer dan het eerste codeblok uit.\nAnders, voer het tweede codeblok uit.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR = 'naar beneden afgerond'; Blockly.Msg.LANG_TEXT_APPEND_TO = 'naar'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TOOLTIP = 'Voeg een test toe aan het als blok.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT = 'herhaal'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_WITH = 'tel met'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP = 'Maakt een globale variabele en geeft die de waarde van de geconnecteerde blokken'; Blockly.Msg.CLEAR_DO_IT_ERROR = 'Wis Fout'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV = 'lijst to csv rij'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_EXP = 'Geef e (2.71828...) tot de macht terug'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME = 'naam'; Blockly.Msg.LANG_MATH_ARITHMETIC_MULTIPLY = '*'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TOOLTIP = 'Sluit al de schermen af in deze app en stopt de app.'; Blockly.Msg.MISSING_SOCKETS_WARNINGS = 'Je moet alle connecties opvullen met blokken'; Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE = '/'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TOOLTIP = 'Sluit het huidige scherm'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TOOLTIP = 'Interpreteert de lijst als een tabel in rij-eerst formaat en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de tabel voorstelt. Elk element in de lijst zou op zijn beurt zelf een lijst moeten zijn die een rij van de CSV tabel voorstelt. Elk element in de rij lijst wordt beschouwd als een veld, waarvan de uiteindelijke CSV tekst zich binnen dubbele aanhalingstekens bevindt. In de teruggegeven tekst worden de elementen in de rijen gescheiden door komma\'s en worden de rijen zelf gescheiden door CRLF (\\r\\n).'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE = 'sluit venster met waarde'; Blockly.Msg.LANG_TEXT_SPLIT_AT_TOOLTIP = 'Splitst de tekst in stukjes bij elke spatie.'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_TOOLTIP = 'Test of iets een getal is.'; Blockly.Msg.LANG_LISTS_IS_LIST_TOOLTIP = 'Test of iets in een lijst zit.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ACOS = 'Geeft een hoek tussen [0, 180]\ngraden met de gegeven cosinus waarde.'; Blockly.Msg.LANG_MATH_RANDOM_INT_TITLE_RANDOM = 'willekeurig getal'; Blockly.Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINTION = 'Dit blok kan niet in een definitie'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_REMAINDER = 'Geef de rest terug.'; Blockly.Msg.REPL_CONNECTING_USB_CABLE = 'Aan het connecteren via USB kabel'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_PLACES = 'plaatsen'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_COLLAPSED_TEXT = 'open scherm met waarde'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TOOLTIP = 'Voeg alle elementen van list2 achteraan toe bij lijst1. Na deze toevoegoperatie zal lijst1 de toegevoegde elementen bevatten, lijst2 zal niet gewijzigd zijn.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE_IMMEDIATE = 'Je gebrukt een oude Companion. Je zou zo snel mogelijk moeten upgraden naar MIT AI2 Companion. Als je automatisch updaten hebt ingesteld in de store, gebeurt de update binnenkort vanzelf.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_COS = 'Geeft de cosinus van een gegeven hoek in graden.'; Blockly.Msg.LANG_TEXT_SEGMENT_TITLE_SEGMENT = 'segment'; Blockly.Msg.BACKPACK_GET = 'Plak Alle Blokken van Rugzak'; Blockly.Msg.PROCEDURE_CATEGORY = 'Procedures'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_TO = ' tot'; Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY = 'copieer lijst'; Blockly.Msg.LANG_LISTS_LENGTH_TOOLTIP = 'Telt het aantal elementen van een lijst'; Blockly.Msg.LANG_VARIABLES_GET_TOOLTIP = 'Geeft de waarde van deze variabele terug.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_INPUT_DO = 'doe'; Blockly.Msg.LANG_TEXT_APPEND_VARIABLE = 'item'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY = 'Geeft het product van twee getallen terug.'; Blockly.Msg.REPL_OK = 'OK'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_ATAN2_Y = 'j'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DO = 'doe'; Blockly.Msg.REPL_HELPER_NOT_RUNNING = 'De aiStarter helper lijkt niet opgestart<br /><a href="http://appinventor.mit.edu" target="_blank">hulp nodig?</a>'; Blockly.Msg.LANG_TEXT_SEGMENT_AT_TOOLTIP = 'Haalt een deel van gegeven lengte uit de gegeven tekst\nstartend van de gegeven tekst op de gegeven positie. Positie \n1 betekent het begin van de tekst.'; Blockly.Msg.LANG_LOGIC_OPERATION_OR = 'of'; Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS = 'Dit blok moet worden geconnecteerd met een gebeurtenisblok of de definitie van een procedure'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS = 'Geeft het verschil tussen twee getallen terug.'; Blockly.Msg.LANG_TEXT_APPEND_TOOLTIP = 'Voeg wat tekst toe aan variabele "%1".'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TITLE_REPLACE_ALL = 'vervang allemaal'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_TEST = 'test'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX = 'tot '; Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM = 'trim'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR = 'getal'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_NUM = 'getal'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN2 = 'Geeft een hoek in tussen [-180, +180]\ngraden met de gegeven rechthoekcoordinaten.'; Blockly.Msg.REPL_YOUR_CODE_IS = 'Jouw code is'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT = 'splits'; Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF = 'als'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_DO = 'doe'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME = 'initializeer lokaal in return'; Blockly.Msg.REPL_EMULATOR_STARTED = 'Emulator gestart, wachten '; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST = 'splits aan de eerste'; Blockly.Msg.LANG_COLOUR_LIGHT_GRAY = 'lichtgrijs'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_1 = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.DUPLICATE_BLOCK = 'Dupliceer'; Blockly.Msg.SORT_H = 'Soorteer Blokken op Hoogte'; Blockly.Msg.ARRANGE_V = 'Organizeer Blokken Vertikaal'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT = 'willekeurig getal tussen %1 en %2'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_EQ = 'Test of twee dingen gelijk zijn. \nDe dingen die worden vergeleken kunnen vanalles zijn, niet enkel getallen. \nGetallen worden als gelijk beschouwd aan hun tekstvorm, \nbijvoorbeeld, het getal 0 is gelijk aan de tekst "0". Ook two tekstvelden \ndie getallen voorstellen zijn gelijk aan elkaar als de getallen gelijk zijn aan mekaar. \n"1" is gelijk aan "01".'; Blockly.Msg.LANG_LOGIC_COMPARE_EQ = '='; Blockly.Msg.RENAME_VARIABLE = 'Geef variabele een andere naam...'; Blockly.Msg.LANG_MATH_RANDOM_INT_TOOLTIP = 'Geeft een willekeurige geheel getal tussen de boven en de\nondergrens. De grenzen worden afgerond tot getallen kleiner\ndan 2**30.'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE = 'waar'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM = 'voor elk'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TOOLTIP = 'Neem een willekeurig element van de lijst.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE = 'Sluit het venster met gewone tekst'; Blockly.Msg.REPL_UNABLE_TO_LOAD_NO_RESPOND = 'Kan geen update laden van de App Inventor server (de server antwoordt niet)'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_START = 'start'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE = 'doe resultaat'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP = 'Een procedure die geen waarde teruggeeft.'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_TOOLTIP = 'Tests of iets een tekst is die een hexadecimaal getal voorstelt.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TOOLTIP = 'Geeft een nieuwe tekst terug door alle stukjes tekst zoals het segment\nte vervangen door de vervangtekst.'; Blockly.Msg.LANG_VARIABLES_SET_TOOLTIP = 'Zet deze variabele gelijk aan de input.'; Blockly.Msg.REPL_ERROR_FROM_COMPANION = 'Fout van de Companion'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_NEQ = 'Geef waar terug als beide inputs niet gelijk zijn aan elkaar.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT = 'van de component'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP = 'Voeg een element toe aan de lijst.'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE = 'naar kleine letters'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT = 'voor element in lijst'; Blockly.Msg.COLLAPSE_ALL = 'Klap blokken dicht'; Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Waarschuwing:\nDeze procedure heeft\ndubbele inputs.'; Blockly.Msg.LANG_CONTROLS_CHOOSE_COLLAPSED_TEXT = 'als'; Blockly.Msg.REPL_NETWORK_ERROR = 'Netwerkfout'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'zet getal om'; Blockly.Msg.COLLAPSE_BLOCK = 'Klap blok dicht'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD = 'voeg dingen toe aan lijst'; Blockly.Msg.REPL_COMPANION_STARTED_WAITING = 'Companion start op, effe wachten ...'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Neemt een tekst die een binair getal voorstelt en geeft de tekst terug die dat getal decimaal voorstelt'; Blockly.Msg.LANG_LOGIC_NEGATE_TOOLTIP = 'Geeft waar terug wanneer de input niet waar is.\nGeeft niet waar terug waneer de input waar is.'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER = 'de rest van'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY = 'splits bij de eerste van'; Blockly.Msg.SHOW_WARNINGS = 'Toon Waarschuwingen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'decimaal naar binair'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT = 'initializeer lokaal'; Blockly.Msg.REPL_DEVICES = 'apparaten'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN = 'dan'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT = 'op'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT = 'voor getal in een zeker bereik'; Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT = 'vierkantswortel'; Blockly.Msg.LANG_MATH_COMPARE_EQ = '='; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Geeft het kleinste van zijn argumenten terug..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Geeft het grootste van zijn argumenten terug..'; Blockly.Msg.TIME_YEARS = "Jaren"; Blockly.Msg.TIME_MONTHS = "Maanden"; Blockly.Msg.TIME_WEEKS = "Weken"; Blockly.Msg.TIME_DAYS = "Dagen"; Blockly.Msg.TIME_HOURS = "Uren"; Blockly.Msg.TIME_MINUTES = "Minuten"; Blockly.Msg.TIME_SECONDS = "Seconden"; Blockly.Msg.TIME_DURATION = "Duurtijd"; Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION = "Toon Rugzak informatie"; Blockly.Msg.ENABLE_GRID = 'Toon Werkruimte raster'; Blockly.Msg.DISABLE_GRID = 'Werkruimte raster verbergen'; Blockly.Msg.ENABLE_SNAPPING = 'Uitlijnen op raster aanzetten'; Blockly.Msg.DISABLE_SNAPPING = 'Uitlijnen op raster uitzetten'; } }; // Initalize language definition to Dutch Blockly.Msg.nl.switch_blockly_language_to_nl.init(); Blockly.Msg.nl.switch_language_to_dutch.init();
kometapp/appinventor-sources
appinventor/blocklyeditor/src/msg/nl/_messages.js
796
// -*- mode: java; c-basic-offset: 2; -*- // Copyright 2016 Massachusetts Institute of Technology. All rights reserved. /** * @fileoverview Dutch (Flanders (Belgium)/the Netherlands) strings. * @author [email protected] (volunteers from the Flemish Coderdojo Community) */ 'use strict'; goog.require('Blockly.Msg.nl'); goog.provide('AI.Blockly.Msg.nl'); /** * Due to the frequency of long strings, the 80-column wrap rule need not apply * to message files. */ Blockly.Msg.nl.switch_language_to_dutch = { // Switch language to Dutch. category: '', helpUrl: '', init: function() { Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT = 'Zoek op per paar sleutel %1 paren %2 nietGevonden %3'; Blockly.Msg.VARIABLE_CATEGORY = 'Variabelen'; Blockly.Msg.ADD_COMMENT = 'Commentaar toevoegen'; Blockly.Msg.EXPAND_BLOCK = 'Blok uitbreiden'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TITLE_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT = 'Verdeelt tekst in stukken met de tekst \'op\' als splitspunt en levert een lijst van de resultaten. \n"één,twee,drie,vier" splitsen op "," (komma) geeft de lijst "(één twee drie vier)" terug. \n"één-aardappel,twee-aardappel,drie-aardappel,vier" splitsen op "-aardappel," geeft ook de lijst "(één twee drie vier)" terug.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TOOLTIP = 'Geeft de waarde terug die was doorgegeven bij het openen van het scherm, meestal door een ander scherm in een app met meerdere schermen. Als er geen waarde was meegegeven, wordt er een lege tekst teruggegeven.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TITLE = 'item'; Blockly.Msg.DELETE_BLOCK = 'Verwijder blok'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TOOLTIP = 'Geeft het nummer terug in decimale notatie\nmet een bepaald aantal getallen achter de komma.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE = 'terwijl'; Blockly.Msg.LANG_COLOUR_PINK = 'roze'; Blockly.Msg.CONNECT_TO_DO_IT = 'U moet verbonden zijn met de AI Companion app of emulator om "Doe het" te gebruiken'; Blockly.Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT = 'krijg'; Blockly.Msg.LANG_MATH_TRIG_SIN = 'sin'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = 'ga verder met volgende iteratie'; Blockly.Msg.DISABLE_BLOCK = 'Schakel Blok uit'; Blockly.Msg.REPL_HELPER_Q = 'Helper?'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT = 'Vervang alle tekst %1 stukje tekst %2 vervangingstekst %3'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN = 'wanneer'; Blockly.Msg.LANG_COLOUR_CYAN = 'Lichtblauw'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_COLLAPSED_TEXT = 'sluit scherm met waarde'; Blockly.Msg.LANG_MATH_TRIG_ASIN = 'asin'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV = 'lijst naar .csv tabel'; Blockly.Msg.REPL_NOW_DOWNLOADING = 'We downloaden nu een update van de App Inventor server. Even geduld aub.'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TOOLTIP = 'specificeert een numerieke seed waarde\nvoor de willekeurige nummer maker'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT = 'zet om'; Blockly.Msg.LANG_MATH_SINGLE_OP_EXP = 'e^'; Blockly.Msg.LANG_TEXT_COMPARE_EQUAL = ' ='; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ROOT = 'Geeft de vierkantswortel van een getal.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TOOLTIP = 'Voeg items toe aan het einde van een lijst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_TEXT_COMPARE_GT = ' >'; Blockly.Msg.REPL_USB_CONNECTED_WAIT = 'USB verbonden, effe wachten aub'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES = 'lokale namen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR = 'maak kleur'; Blockly.Msg.LANG_MATH_DIVIDE = '÷'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP = 'Voert alle blokken uit in \'do\' en geeft een statement terug. Handig wanneer je een procedure wil uitvoeren voor een waarde terug te geven aan een variabele.'; Blockly.Msg.COPY_ALLBLOCKS = 'Kopieer alle blokken naar de rugzak'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT_LIST = 'op (lijst)'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT = 'globaal'; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE = 'invoer:'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_NOT_FOUND = 'nietGevonden'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP = 'Laat je toe variabelen te maken die enkel toegankelijk zijn in het doe deel van dit blok.'; Blockly.Msg.REPL_PLUGGED_IN_Q = 'Aangesloten?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP = ''; Blockly.Msg.HORIZONTAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST = 'is een lijst?'; Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE = 'invoer'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_FROM = 'van'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TITLE_APPEND = 'voeg toe aan lijst'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX = ' binnen bereik'; Blockly.Msg.NEW_VARIABLE_TITLE = 'Nieuwe variabelenaam:'; Blockly.Msg.VERTICAL_PARAMETERS = 'Rangschik eigenschappen horizontaal'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TITLE_REPLACE = 'vervang element in de lijst'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_ANY = 'Verdeelt de gegeven tekst in een lijst, waarbij elk element in de lijst \'\'op\'\' als het\nverdeelpunt, en geeft een lijst terug van het resultaat. \nSplitsen van "sinaasappel,banaan,appel,hondenvoer" met als "op" een lijst van 2 elementen met als eerste \nelement een komma en als tweede element "pel" geeft een lijst van 4 elementen: \n"(sinaasap banaan ap hondenvoer)".'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN = 'in'; Blockly.Msg.DO_IT = 'Voer uit'; Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE = 'absoluut'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME = 'functie die niets teruggeeft'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_TOOLTIP = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.BACKPACK_DOCUMENTATION = 'De Rugzak is een knip/plak functie. Het laat toe om blokken te kopieren van een project of scherm en ze in een ander scherm of project te plakken. Om te kopieren sleep je de blokken in de rugzak. Om te plakken klik je op het Rugzak icoon en sleep je de blokken in de werkplaats.</p><p> De inhoud van de Rugzak blijft behouden tijdens de ganse App Inventor sessie. Als je de App Inventor dicht doet, of als je je browser herlaadt, wordt de Rugzak leeggemaakt.</p><p>Voor meer info en een video, bekijk:</p><p><a href="/reference/other/backpack.html" target="_blank">http://ai2.appinventor.mit.edu/reference/other/backpack.html</a>'; Blockly.Msg.LANG_MATH_TRIG_ATAN2 = 'atan2'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX = 'aanroep '; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSEIF = 'of als'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN = 'resultaat'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_CALL = 'roep aan'; Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE = 'splits bij spaties'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV = 'lijst van .csv rij'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE = 'x'; Blockly.Msg.REPL_CONNECTION_FAILURE1 = 'Verbindingsfout'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST_OF_ANY = 'Splitst een gegeven tekst in een lijst met twee elementen. De eerste plaats van eender welk item in de lijst "aan" is het \'\'splitsingspunt\'\'. \n\nBijvoorbeeld als je "Ik hou van appels, bananen en ananas" splitst volgens de lijst "(ba,ap)", dan geeft dit \neen lijst van 2 elementen terug. Het eerste item is "Ik hou van" en het tweede item is \n"pels, bananen en ananas."'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE = 'open een ander scherm'; Blockly.Msg.LANG_LISTS_IS_LIST_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties om dit lijst blok opnieuw te configureren. '; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GTE = 'Geef waar terug als het eerste getal groter is\ndan of gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_FOR_TOOLTIP = 'Tel van een start- tot een eindnummer.\nZet het huidige nummer, voor iedere tel, op\nvariabele "%1", en doe erna een aantal dingen.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TOOLTIP = 'Geef een willekeurig getal tussen 0 en 1 terug.'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_VARIABLE = ' variabele'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.WARNING_DELETE_X_BLOCKS = 'Weet u zeker dat u alle %1 van deze blokken wilt verwijderen?'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TOOLTIP = ''; Blockly.Msg.LANG_LISTS_INSERT_INPUT_ITEM = 'item'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE = 'sluit scherm'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_EQUAL = 'Test of stukken tekst identiek zijn, of ze dezelfde karakters hebben\n in dezelfde volgorde. Dit verschilt van de normale=\nin het geval waarin de stukken tekst getallen zijn: 123 en 0123 zijn=\nmaar niet tekst =.'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_ROUND = 'Rond een nummer af naar boven of beneden.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_END = 'tot'; Blockly.Msg.LANG_COLOUR_ORANGE = 'oranje'; Blockly.Msg.REPL_STARTING_COMPANION_IN_EMULATOR = 'AI Companion App wordt opgestart in de emulator.'; Blockly.Msg.LANG_MATH_COMPARE_LT = '<'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ABS = 'Geef de absolute waarde van een getal terug.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM = 'item'; Blockly.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN = 'Selecteer een geldig item uit de drop down.'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD = 'graden naar radialen'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TOOLTIP = 'Geeft de platte tekst terug die doorgegeven werd toen dit scherm werd gestart door een andere app. Als er geen waarde werd doorgegeven, geeft deze functie een lege tekst terug. Voor multischerm apps, gebruik dan neem start waarde in plaats van neem platte start tekst.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM = 'voor elk'; Blockly.Msg.BACKPACK_DOC_TITLE = 'Rugzak informatie'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN = 'samenvoegen'; Blockly.Msg.LANG_TEXT_LENGTH_TOOLTIP = 'Geeft het aantal letters (inclusief spaties)\nterug in de meegegeven tekst.'; Blockly.Msg.LANG_CONTROLS_IF_IF_TOOLTIP = 'Voeg toe, verwijder of verander de volgorde van de secties\nom dit blok opnieuw te configureren.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1 = 'De AI Companion die je op je smartphone gebruikt, is verouderd.<br/><br/>Deze versie van de App Inventor moet gebruikt worden met Companion versie'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE = 'hoofdletters'; Blockly.Msg.LANG_MATH_ARITHMETIC_ADD = '+'; Blockly.Msg.REPL_COMPANION_VERSION_CHECK = 'Versie controle van de AI Companion'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP = 'Een procedure die een resultaat teruggeeft.'; Blockly.Msg.LANG_MATH_TRIG_ATAN2_X = 'x'; Blockly.Msg.EXPAND_ALL = 'Blok uitbreiden'; Blockly.Msg.CHANGE_VALUE_TITLE = 'Wijzig waarde:'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TOOLTIP = 'Opent een nieuw scherm in een app met meerdere schermen.'; Blockly.Msg.LANG_TEXT_ISEMPTY_TOOLTIP = 'Geeft waar terug als de lengte van de\ntekst gelijk is aan 0, anders wordt niet waar teruggegeven.'; Blockly.Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT = 'ingesteld'; Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM = 'willekeurig deel'; Blockly.Msg.LANG_COLOUR_BLUE = 'blauw'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = 'tot'; Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET = 'krijg'; Blockly.Msg.REPL_APPROVE_UPDATE = ' scherm omdat je gevraagd gaat worden om een update goed te keuren.'; Blockly.Msg.LANG_TEXT_TRIM_TOOLTIP = 'Geeft een kopie terug van de tekst argumenten met elke\nspatie vooraan en achteraan verwijderd.'; Blockly.Msg.REPL_EMULATORS = 'emulators'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM = 'is een getal?'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX = 'to '; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE = 'vergelijk teksten'; Blockly.Msg.LANG_MATH_NUMBER_TOOLTIP = 'Rapporteer het getoonde getal.'; Blockly.Msg.LANG_TEXT_COMPARE_LT = ' <'; Blockly.Msg.LANG_LISTS_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TOOLTIP = 'Verwijdert het element op de gegeven positie uit de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_TITLE_IS_IN = 'staat in een lijst?'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_CEILING = 'Rond de input af tot het kleinste\ngetal dat niet kleiner is dan de input'; Blockly.Msg.LANG_COLOUR_YELLOW = 'geel'; Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_FLOOR = 'Rond de input af tot het grootste\ngetal dat niet groter is dan de input'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_MODULO = 'Geeft de gehele deling terug.'; Blockly.Msg.LANG_TEXT_JOIN_ITEM_TITLE_ITEM = 'tekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSE = 'anders'; Blockly.Msg.LANG_TEXT_STARTS_AT_TOOLTIP = 'Geeft de beginpositie terug van het stukje in de tekst\nwaar index 1 het begin van de tekst aangeeft. Geeft 0 terug wanneer\nhet stuk tekst niet voorkomt.'; Blockly.Msg.SORT_W = 'Sorteer blokken op breedte'; Blockly.Msg.ENABLE_BLOCK = 'Schakel blok aan'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_COLLAPSED_TEXT = 'evalueer maar negeer'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_ADD = 'Geeft de som van twee getallen terug.'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT = 'index in lijst item %1 lijst %2'; Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING = ' seconden om er zeker van te zijn dat alles draait.'; Blockly.Msg.REPL_NO_ERROR_FIVE_SECONDS = '<br/><i>Merk op:</i>&nbsp,Je zal geen andere foutmeldingen zien gedurende de volgende 5 seconden.'; Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT = 'niet'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_CATEGORY_CONTROLS = 'Bediening'; Blockly.Msg.LANG_COLOUR_MAGENTA = 'magenta'; Blockly.Msg.LANG_LISTS_IS_IN_TOOLTIP = 'Geeft waar terug als het ding een item is dat in de lijst zit, anders wordt onwaar teruggegeven.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT = 'vervang lijst item lijst %1 index %2 vervanging %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Neemt een positief geheel decimaal getal en geeft de tekst weer die dat getal voorstelt in binair'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex naar dec'; Blockly.Msg.LANG_LOGIC_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME = 'naam'; Blockly.Msg.NEW_VARIABLE = 'Nieuwe variabele ...'; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_OR = 'Geef waar terug als de invoer waar is.'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP = ''; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_CONTAINS = 'bevat'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT = 'verwijder lijstitem lijst %1 index %2'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT = 'segment tekst %1 start %2 lengte %3'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT = 'lengte van de lijst lijst %1'; Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP = 'Test of het stukje voorkomt in de tekst.'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_RAD_TO_DEG = 'Geeft de graden terug tussen\n(0,360) die overeenkomt met het argument in radialen.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_COLLAPSED_TEXT = 'Neem platte start tekst'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_SEGMENT = 'segment'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_LIST = ' lijst'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_TAN = 'tan'; Blockly.Msg.LANG_MATH_TRIG_ATAN = 'atan'; Blockly.Msg.LANG_MATH_RANDOM_SEED_INPUT_TO = 'tot'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = 'Terwijl een waarde onwaar is, doe enkele andere stappen.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_INPUT_RESULT = 'resultaat'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG = 'radialen naar graden'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_SELECT = 'kies een item uit de lijst'; Blockly.Msg.LANG_CATEGORY_TEXT = 'Tekst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT = 'voeg toe aan lijst lijst1 %1 lijst2 %2'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR = 'splits kleur'; Blockly.Msg.LANG_CONTROLS_IF_MSG_IF = 'als'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP = 'Roep een procedure op die iets teruggeeft.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND = 'rond af'; Blockly.Msg.REPL_DISMISS = 'Negeer'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TOOLTIP = 'Vervangt het n\'de item in een lijst.'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_GT = 'Geeft aan of tekst1 lexicologisch groter is dan tekst2.\nAls een tekst het eerste deel is van de andere, dan wordt de kortere tekst aanzien als kleiner.\nHoofdletters hebben voorrang op kleine letters.'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR = 'item'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO = 'tot'; Blockly.Msg.LANG_COLOUR_RED = 'rood'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_TO = 'tot'; Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = 'lijst'; Blockly.Msg.REPL_KEEP_TRYING = 'Blijf Proberen'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST = 'maak een lijst'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING = 'afrondenNaarBoven'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_SET = 'zet'; Blockly.Msg.EXTERNAL_INPUTS = 'Externe ingangen'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_PAIRS = 'paren'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE = 'open ander scherm met startwaarde'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Neemt een tekst die een hexadecimaal getal voorstelt en geeft een tekst terug die dat nummer voorstelt als decimaal getal.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_SIN = 'Geeft de sinus van de gegeven hoek (in graden).'; Blockly.Msg.REPL_GIVE_UP = 'Opgeven'; Blockly.Msg.LANG_CATEGORY_LOGIC = 'Logica'; Blockly.Msg.LANG_LISTS_COPY_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_INSERT_INPUT = 'voeg lijstitem toe lijst %1 index %2 item %3'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Neemt een positief decimaal getal en geeft een tekst terug die dat getal voorstelt in hexadecimale notatie.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_START = 'van'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = 'breek uit'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. door komma\'s gescheiden waarde) opgemaakte rij om een ​​lijst met velden te produceren. Als de rij tekst meerdere onbeschermde nieuwe regels (meerdere lijnen) bevat in de velden, krijg je een foutmelding. Je moet de rij tekst laten eindigen in een nieuwe regel of CRLF.'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_POWER = 'Geeft het eerste getal verheven tot\nde macht van het tweede getal.'; Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET = 'zet'; Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_DO = 'doe'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_COLOUR_GRAY = 'grijs'; Blockly.Msg.REPL_NETWORK_ERROR_RESTART = 'Netwerk Communicatie Fout met de AI Companion. <br />Probeer eens de smartphone te herstarten en opnieuw te connecteren.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM = 'kies een willekeurig item'; Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_LT = 'Controleert of tekst1 lexicografisch kleiner is dan text2. \ NAls een stuk tekst het voorvoegsel is van de andere, dan wordt de kortere tekst \ nals kleiner beschouwd. Kleine letters worden voorafgegaan door hoofdletters.'; Blockly.Msg.LANG_TEXT_APPEND_APPENDTEXT = 'voeg tekst toe'; Blockly.Msg.REPL_CANCEL = 'Annuleren'; Blockly.Msg.LANG_CATEGORY_MATH = 'Wiskunde'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE_TOOLTIP = 'Produceert tekst, zoals een tekstblok. Het verschil is dat de \ntekst niet gemakkelijk te detecteren is door de APK van de app te onderzoeken. Gebruik deze functie daarom bij het maken van apps \n die vertrouwelijke informatie bevatten, zoals API sleutels. \nWaarschuwing: tegen complexe security-aanvallen biedt deze functie slechts een zeer lage bescherming.'; Blockly.Msg.SORT_C = 'Sorteer blokken op categorie'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_DO = 'doe'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_TOOLTIP = 'Geeft het item op positie index in de lijst.'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH = 'lengte van de lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME = 'naam'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TITLE = 'maak op als decimaal'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = 'Zolang een waarde waar is, do dan enkele regels code.'; Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE = 'maak lege lijst'; Blockly.Msg.LANG_MATH_ARITHMETIC_POWER = '^'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TOOLTIP = 'Voert het aangesloten blok code uit en negeert de return waarde (indien aanwezig). Deze functie is handig wanneer je een procedure wil aanroepen die een return waarde heeft, zonder dat je die waarde zelf nodig hebt.'; Blockly.Msg.LANG_LISTS_CREATE_WITH_TOOLTIP = 'Maak een lijst met een bepaald aantal items.'; Blockly.Msg.ERROR_DUPLICATE_EVENT_HANDLER = 'Dit een een copy van een signaalafhandelaar voor deze component.'; Blockly.Msg.LANG_MATH_TRIG_COS = 'cos'; Blockly.Msg.BACKPACK_CONFIRM_EMPTY = 'Weet u zeker dat u de rugzak wil ledigen?'; Blockly.Msg.LANG_LISTS_IS_EMPTY_TOOLTIP = 'Geeft \'waar\' terug als de lijst leeg is.'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME = 'oproep weergave'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_LN = 'Teruggave van het natuurlijke logaritme van een getal, d.w.z. het logaritme met het grondtal e (2,71828 ...)'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_UPPERCASE = 'Geeft een kopie van de meegegeven tekst omgezet in hoofdletters.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TOOLTIP = 'Toevoegen, verwijderen of herschikken van secties om dit lijstblok te herconfigureren.'; Blockly.Msg.LANG_COLOUR_DARK_GRAY = 'donkergrijs'; Blockly.Msg.ARRANGE_H = 'Rangschik blokken horizontaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF = 'anders als'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TOOLTIP = 'Sluit het huidig scherm en geeft een resultaat terug aan het scherm dat deze opende.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_4 = 'Als de eerste waarde \'waar\' is, voer dan het eerste blok met opdrachten uit.\nAnders, als de tweede waarde \'waar\' is, voer dan het tweede blok met opdrachten uit.\nAls geen van de waarden \'waar\' is, voer dan het laatste blok met opdrachten uit.'; Blockly.Msg.REPL_NETWORK_CONNECTION_ERROR = 'Fout netwerkverbinding'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX = ' in lijst'; Blockly.Msg.LANG_LISTS_IS_IN_INPUT = 'is in lijst? item %1 lijst %2'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_VAR = 'x'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM = 'is decimaal?'; Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_TOOLTIP = 'Een lijst van vier elementen, elk op een schaal van 0 tot 255, die de rode, groene, blauwe en alfa componenten voorstellen.'; Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE = 'evalueer maar negeer het resultaat'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_INPUT_LIST = 'lijst'; Blockly.Msg.CAN_NOT_DO_IT = 'Kan dit niet doen'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME = 'initialiseer lokale variable in doe'; Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE = '“'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = 'Sla de rest van deze loop over en \n begin met de volgende iteratie.'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_FROM = 'van'; Blockly.Msg.COPY_TO_BACKPACK = 'Voeg toe aan rugzak'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY = 'is leeg'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY = 'splits bij elk'; Blockly.Msg.EXPORT_IMAGE = 'Download blokken als afbeelding'; Blockly.Msg.REPL_GOT_IT = 'Begrepen'; Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP = 'Een kleur met de gegeven rood, groen, blauw en optionele alfa componenten.'; Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY = 'is de lijst leeg?'; Blockly.Msg.LANG_MATH_SINGLE_OP_NEG = 'negatief'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET = 'stel in'; Blockly.Msg.INLINE_INPUTS = 'Inlijn invulveld'; Blockly.Msg.LANG_LISTS_INSERT_TOOLTIP = 'Voeg een element toe op een specifieke plaats in een lijst.'; Blockly.Msg.REPL_CONNECTING = 'Verbinden ...'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TOOLTIP = 'Geeft de waarde terug die hoort bij de sleutel in een lijst van paren'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_NEG = 'Geeft het negatief van een getal.'; Blockly.Msg.REPL_UNABLE_TO_LOAD = 'Opladen naar de App Inventor server mislukt'; Blockly.Msg.LANG_LISTS_COPY_TOOLTIP = 'Maakt een kopie van een lijst. Sublijsten worden ook gekopieerd'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_TRUE = 'Geeft de booleaanse waar terug.'; Blockly.Msg.LANG_TEXT_TEXT_OBSFUCATE = 'Onleesbaar gemaakte Tekst'; Blockly.Msg.LANG_TEXT_TEXT_TOOLTIP = 'Een tekst.'; Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT = 'Selecteer een element uit lijst %1 index %2'; Blockly.Msg.REPL_DO_YOU_REALLY_Q = 'Wil Je Dit Echt? Echt echt?'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP = 'Laat je toe om variabelen te maken die je alleen kan gebruiken in het deel van dit blok dat iets teruggeeft.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT = 'Initializeer globaal'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM = 'is hexadecimaal?'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_QUOTIENT = 'Berekent het quotient.'; Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM = 'is binair?'; Blockly.Msg.LANG_CONTROLS_FOREACH_TOOLTIP = 'Voert de blokken in het \'doe\' deel uit voor elk element van de lijst. Gebruik de opgegeven naam van de variabele om te verwijzen naar het huidige element.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE = '”'; Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN = 'dan'; Blockly.Msg.LANG_CONTROLS_WHILE_TITLE = 'terwijl'; Blockly.Msg.LANG_MATH_COMPARE_GT = '>'; Blockly.Msg.LANG_MATH_IS_A_DECIMAL_TOOLTIP = 'Test of iets een string is die een positief integraal grondgetal 10 voorstelt.'; Blockly.Msg.LANG_MATH_MUTATOR_ITEM_INPUT_NUMBER = 'getal'; Blockly.Msg.LANG_LISTS_ADD_ITEM_TOOLTIP = 'Voeg een item toe aan de lijst.'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO = 'in'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LT = 'Geeft Waar terug als het eerste nummer\nkleiner is dan het tweede nummer.'; Blockly.Msg.LANG_COLOUR_BLACK = 'zwart'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TOOLTIP = 'Sluit het huidige scherm af en geeft de tekst terug aan de app die dit scherm geopend heeft. Deze functie is bedoeld om tekst te retourneren aan activiteiten die niet gerelateerd zijn aan App Inventor en niet om naar App Inventor schermen terug te keren. Voor App Inventor apps met meerdere schermen, gebruik de functie Sluit Scherm met Waarde, niet Sluit Scherm met Gewone Tekst.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE = 'Jouw Companion App is te oud. Klik "OK" om bijwerken te starten. Bekijk jouw '; Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_AND = 'Geef Waar terug als alle invoer Waar is.'; Blockly.Msg.REPL_NO_START_EMULATOR = 'Het is niet gelukt de MIT AI Companion te starten in de Emulator'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = 'Breek uit de omliggende lus.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_EQ = 'Geef Waar terug als beide getallen gelijk zijn aan elkaar.'; Blockly.Msg.LANG_LOGIC_OPERATION_AND = 'en'; Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST = 'Verdeelt de opgegeven tekst in twee delen en gebruikt hiervoor de plaats het eerste voorkomen \nvan de tekst \'aan\' als splitser, en geeft een lijst met twee elementen terug. Deze lijst bestaat \nuit het deel voor de splitser en het deel achter de splitser. \nHet splitsen van "appel,banaan,kers,hondeneten" met als een komma als splitser geeft een lijst \nterug met twee elementen: het eerste is de tekst "appel" en het tweede is de tekst \n"banaan,kers,hondeneten". \nMerk op de de komma achter "appel\' niet in het resultaat voorkomt, omdat dit de splitser is.'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binair naar decimaal'; Blockly.Msg.LANG_CONTROLS_IF_ELSE_TOOLTIP = 'Voeg een finaal, vang-alles-op conditie toe aan het als blok.'; Blockly.Msg.GENERATE_YAIL = 'Genereer Yail'; Blockly.Msg.LANG_LOGIC_COMPARE_TRANSLATED_NAME = 'logische is gelijk'; Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_DOWNCASE = 'Geeft een kopie terug van de tekst in kleine letters.'; Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT_THING = 'ding'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT = 'quotiënt van'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_NEQ = 'Geef Waar terug als beide getallen niet gelijk zijn aan elkaar.'; Blockly.Msg.DELETE_X_BLOCKS = 'Verwijder %1 blokken'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'rest van'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT = 'start op tekst %1 stuk %2'; Blockly.Msg.BACKPACK_EMPTY = 'Maak de Rugzak leeg'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST = 'in lijst'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP = 'Voert de blokken in \'\'doe\'\' uit en geeft een statement terug. Handig als je een procedure wil uitvoeren alvorens een waarde terug te geven aan een variabele.'; Blockly.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP = 'Voert de blokken in de \'doe\' sectie uit voor elke numerieke waarde van begin tot eind, telkens verdergaand met de volgende waarde. Gebruik de gegeven naam van de variabele om te verwijzen naar de actuele waarde.'; Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TITLE_REMOVE = 'verwijder lijst item'; Blockly.Msg.REPL_STARTING_COMPANION_ON_PHONE = 'Bezig het opstarten van de Companion App op de aangesloten telefoon.'; Blockly.Msg.ARRANGE_S = 'Rangschik blokken diagonaal'; Blockly.Msg.ERROR_COMPONENT_DOES_NOT_EXIST = 'Component bestaat niet'; Blockly.Msg.LANG_MATH_COMPARE_LTE = '≤'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT = 'bevat tekst %1 stuk %2'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN = 'min'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT = 'Formatteer als decimaal getal %1 plaatsen %2'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_TEST = ''; Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP = ''; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_TAN = 'Geeft de tangens van de gegeven hoek in graden.'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO = 'tot'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_INPUT_SCREENNAME = 'schermNaam'; Blockly.Msg.HELP = 'Hulp'; Blockly.Msg.LANG_LISTS_POSITION_IN_TITLE_POSITION = 'positie in lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE = 'toepassing sluiten'; Blockly.Msg.LANG_COLOUR_GREEN = 'groen'; Blockly.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF = 'Markeer Procedure'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE = 'krijg startwaarde'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP = 'van lus'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX = 'roep op '; Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE = 'Verkrijg gewone starttekst'; Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP = 'Roep een procedure op die geen waarde teruggeeft.'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV = 'lijst van een csv tabel'; Blockly.Msg.LANG_LISTS_INSERT_TITLE_INSERT_LIST = 'voeg een lijst element toe'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST1 = 'lijst1'; Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT_LIST2 = 'lijst2'; Blockly.Msg.REPL_UPDATE_INFO = 'De update wordt nu geïnstalleerd op je toestel. Hou je scherm (of emulator) in het oog en keur de installatie goed wanneer je dat gevraagd wordt.<br /><br />BELANGRIJK: Wanneer de update afloopt, kies "VOLTOOID" (klik niet op "open"). Ga dan naar App Inventor in je web browser, klik op het "Connecteer" menu en kies "Herstart Verbinding". Verbind dan het toestel.'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LTE = 'Geeft waar terug als het eerste getal kleiner is\nof gelijk aan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_COLLAPSED_TEXT = 'sluit scherm met platte tekst'; Blockly.Msg.LANG_CONTROLS_WHILE_COLLAPSED_TEXT = 'herhaal tot'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT_KEY = 'sleutel'; Blockly.Msg.LANG_TEXT_JOIN_TITLE_CREATEWITH = 'maak tekst met'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TOOLTIP = 'Interpreteert de lijst als een rij van een tabel en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de rij representeert. Elk item in de rij lijst wordt beschouwd als een veld, er wordt naar verwezen met dubbele aanhalingstekens in de CSV tekst. Items worden gescheiden door een komma. De geretourneerde rij tekst heeft geen lijn separator aan het einde.'; Blockly.Msg.LANG_TEXT_JOIN_TOOLTIP = 'Voegt alle inputs samen tot 1 enkele tekst.\nAls er geen inputs zijn, wordt een lege tekst gemaakt.'; Blockly.Msg.LANG_COLOUR_WHITE = 'Wit'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE = 'Geeft het quotiënt van twee getallen.'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT = 'voeg items to lijst lijst %1 item %2'; Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE = 'onwaar'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_INDEX = 'index'; Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TOOLTIP = 'Ontleedt een tekst als een CSV (d.i. een door komma\'s gescheiden waarde) opgemaakte tabel om een ​​lijst van rijen te produceren, elke rij is een lijst van velden. Rijen kunnen worden gescheiden door nieuwe lijnen (n) of CRLF (rn).'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN = 'anders'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TOOLTIP = 'Opent een nieuw scherm in een meer-schermen app en geeft de startwaarde mee aan dat scherm.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ASIN = 'Geeft een hoek tussen [-90,+90]\ngraden met de gegeven sinus waarde.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_GETTER_TITLE_OF_COMPONENT = 'van component'; Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM = 'stel willekeurige seed in'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO = 'doe'; Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TITLE_LOOKUP_IN_PAIRS = 'zoek op in paren'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT = 'lokaal'; Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_STARTS_AT = 'begint bij'; Blockly.Msg.REPL_NOT_NOW = 'Niet Nu. Later, misschien ...'; Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_PIECE = 'stukje'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT = 'voor component'; Blockly.Msg.HIDE_WARNINGS = 'Waarschuwingen Verbergen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'decimaal naar hexadecimaal'; Blockly.Msg.REPL_CONNECT_TO_COMPANION = 'Connecteer met de Companion'; Blockly.Msg.LANG_COLOUR_PICKER_TOOLTIP = 'Klik op de rechthoek om een kleur te kiezen.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_TO = ' tot'; Blockly.Msg.REPL_SOFTWARE_UPDATE = 'Software bijwerken'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TOOLTIP = 'Als de voorwaarde die wordt getest waar is,retourneer dan het resultaat verbonden aan het \'dan-teruggave\' veld, indien niet, geef dan het resultaat terug van het \'zoneen-teruggave\' veld, op zijn minst een van de resultaten verbonden aan beide teruggave velden wordt weergegeven.'; Blockly.Msg.RENAME_VARIABLE_TITLE = 'Hernoem alle "%1" variabelen naar:'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_FALSE = 'Geeft booleaanse niet waar terug.'; Blockly.Msg.REPL_TRY_AGAIN1 = 'Connecteren met de AI2 Companion is mislukt, probeer het eens opnieuw.'; Blockly.Msg.REPL_VERIFYING_COMPANION = 'Kijken of de Companion gestart is...'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_LISTS_POSITION_IN_TOOLTIP = 'Zoek de positie van het ding op in de lijst. Als het ding niet in de lijst zit, geef 0 terug.'; Blockly.Msg.LANG_LISTS_INSERT_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_INPUT_TEXT = 'tekst'; Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Waarschuwing:\nDit blok mag alleen\ngebruikt worden in een lus.'; Blockly.Msg.REPL_AI_NO_SEE_DEVICE = 'AI2 ziet je toestel niet, zorg ervoor dat de kabel is aangesloten en dat de besturingsprogramma\'s juist zijn.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_INDEX = 'index'; Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_DEG_TO_RAD = 'Geeft de waarde in radialen terug volgens een schaal van\n[-π, +π) overeenkomstig met de graden.'; Blockly.Msg.REPL_STARTING_EMULATOR = 'Bezig met opstarten van de Android Emulator<br/>Even geduld: Dit kan een minuutje of twee duren (of koop snellere computer, grapke Pol! :p).'; Blockly.Msg.REPL_RUNTIME_ERROR = 'Uitvoeringsfout'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_COLLAPSED_TEXT = 'open scherm'; Blockly.Msg.REPL_FACTORY_RESET = 'Deze probeert jouw Emulator te herstellen in zijn initiële staat. Als je eerder je AI Companion had geupdate in de emulator, ga je dit waarschijnlijk op nieuw moeten doen. '; Blockly.Msg.LANG_LISTS_ADD_ITEM_TITLE = 'item'; Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE = 'als'; Blockly.Msg.LANG_CATEGORY_LISTS = 'Lijsten'; Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GT = 'Geeft waar terug als het eerste getal groter is\ndan het tweede getal.'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_COLLAPSED_TEXT = 'sluit toepassing'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_COLLAPSED_TEXT = 'Krijg start waarde'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_COLLAPSED_TEXT = 'sluit scherm'; Blockly.Msg.REMOVE_COMMENT = 'Commentaar Verwijderen'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE = 'procedure'; Blockly.Msg.REPL_OK_LOWER = 'OK'; Blockly.Msg.LANG_MATH_SINGLE_OP_LN = 'log'; Blockly.Msg.LANG_MATH_IS_A_BINARY_TOOLTIP = 'Test of iets een tekst is die een binair getal voorstelt.'; Blockly.Msg.REPL_UNABLE_TO_UPDATE = 'Het is niet gelukt een update naar het toestel/emulator te sturen.'; Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LIST = 'lijst'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO = 'tot'; Blockly.Msg.LANG_MATH_COMPARE_NEQ = '≠'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP = 'bij'; Blockly.Msg.LANG_MATH_COMPARE_GTE = '≥'; Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL = 'aanroep '; Blockly.Msg.LANG_MATH_TRIG_ACOS = 'acos'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN = 'Geeft een hoek tussen [-90, +90]\ngraden met de gegeven tangens.'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS = '-'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_1 = 'Als een waarde waar is, voer dan enkele stappen uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_3 = 'Als de eerste waarde waar is, voer dan het eerste codeblok uit.\nAnders, als de tweede waarde waar is, voer het tweede codeblok uit.'; Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_2 = 'Als de waarde waar is, voer dan het eerste codeblok uit.\nAnders, voer het tweede codeblok uit.'; Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR = 'naar beneden afgerond'; Blockly.Msg.LANG_TEXT_APPEND_TO = 'naar'; Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TOOLTIP = 'Voeg een test toe aan het als blok.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT = 'herhaal'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_WITH = 'tel met'; Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP = 'Maakt een globale variabele en geeft die de waarde van de geconnecteerde blokken'; Blockly.Msg.CLEAR_DO_IT_ERROR = 'Wis Fout'; Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV = 'lijst to csv rij'; Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_EXP = 'Geef e (2.71828...) tot de macht terug'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME = 'naam'; Blockly.Msg.LANG_MATH_ARITHMETIC_MULTIPLY = '*'; Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TOOLTIP = 'Sluit al de schermen af in deze app en stopt de app.'; Blockly.Msg.MISSING_SOCKETS_WARNINGS = 'Je moet alle connecties opvullen met blokken'; Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE = '/'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TOOLTIP = 'Sluit het huidige scherm'; Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TOOLTIP = 'Interpreteert de lijst als een tabel in rij-eerst formaat en geeft een CSV (door komma\'s gescheiden waarden) tekst terug die de tabel voorstelt. Elk element in de lijst zou op zijn beurt zelf een lijst moeten zijn die een rij van de CSV tabel voorstelt. Elk element in de rij lijst wordt beschouwd als een veld, waarvan de uiteindelijke CSV tekst zich binnen dubbele aanhalingstekens bevindt. In de teruggegeven tekst worden de elementen in de rijen gescheiden door komma\'s en worden de rijen zelf gescheiden door CRLF (\\r\\n).'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE = 'sluit venster met waarde'; Blockly.Msg.LANG_TEXT_SPLIT_AT_TOOLTIP = 'Splitst de tekst in stukjes bij elke spatie.'; Blockly.Msg.LANG_MATH_IS_A_NUMBER_TOOLTIP = 'Test of iets een getal is.'; Blockly.Msg.LANG_LISTS_IS_LIST_TOOLTIP = 'Test of iets in een lijst zit.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ACOS = 'Geeft een hoek tussen [0, 180]\ngraden met de gegeven cosinus waarde.'; Blockly.Msg.LANG_MATH_RANDOM_INT_TITLE_RANDOM = 'willekeurig getal'; Blockly.Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINTION = 'Dit blok kan niet in een definitie'; Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_REMAINDER = 'Geef de rest terug.'; Blockly.Msg.REPL_CONNECTING_USB_CABLE = 'Aan het connecteren via USB kabel'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_PLACES = 'plaatsen'; Blockly.Msg.LANG_CONTROLS_FOR_INPUT_DO = 'doe'; Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_COLLAPSED_TEXT = 'open scherm met waarde'; Blockly.Msg.LANG_LISTS_APPEND_LIST_TOOLTIP = 'Voeg alle elementen van list2 achteraan toe bij lijst1. Na deze toevoegoperatie zal lijst1 de toegevoegde elementen bevatten, lijst2 zal niet gewijzigd zijn.'; Blockly.Msg.REPL_COMPANION_OUT_OF_DATE_IMMEDIATE = 'Je gebrukt een oude Companion. Je zou zo snel mogelijk moeten upgraden naar MIT AI2 Companion. Als je automatisch updaten hebt ingesteld in de store, gebeurt de update binnenkort vanzelf.'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_COS = 'Geeft de cosinus van een gegeven hoek in graden.'; Blockly.Msg.LANG_TEXT_SEGMENT_TITLE_SEGMENT = 'segment'; Blockly.Msg.BACKPACK_GET = 'Plak Alle Blokken van Rugzak'; Blockly.Msg.PROCEDURE_CATEGORY = 'Procedures'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_LENGTH = 'lengte'; Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_TO = ' tot'; Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY = 'copieer lijst'; Blockly.Msg.LANG_LISTS_LENGTH_TOOLTIP = 'Telt het aantal elementen van een lijst'; Blockly.Msg.LANG_VARIABLES_GET_TOOLTIP = 'Geeft de waarde van deze variabele terug.'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_INPUT_DO = 'doe'; Blockly.Msg.LANG_TEXT_APPEND_VARIABLE = 'item'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY = 'Geeft het product van twee getallen terug.'; Blockly.Msg.REPL_OK = 'OK'; Blockly.Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN = 'resultaat'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX = 'voor '; Blockly.Msg.LANG_MATH_TRIG_ATAN2_Y = 'j'; Blockly.Msg.LANG_PROCEDURES_CALLRETURN_PROCEDURE = 'procedure'; Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DO = 'doe'; Blockly.Msg.REPL_HELPER_NOT_RUNNING = 'De aiStarter helper lijkt niet opgestart<br /><a href="http://appinventor.mit.edu" target="_blank">hulp nodig?</a>'; Blockly.Msg.LANG_TEXT_SEGMENT_AT_TOOLTIP = 'Haalt een deel van gegeven lengte uit de gegeven tekst\nstartend van de gegeven tekst op de gegeven positie. Positie \n1 betekent het begin van de tekst.'; Blockly.Msg.LANG_LOGIC_OPERATION_OR = 'of'; Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS = 'Dit blok moet worden geconnecteerd met een gebeurtenisblok of de definitie van een procedure'; Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS = 'Geeft het verschil tussen twee getallen terug.'; Blockly.Msg.LANG_TEXT_APPEND_TOOLTIP = 'Voeg wat tekst toe aan variabele "%1".'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TITLE_REPLACE_ALL = 'vervang allemaal'; Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_TEST = 'test'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX = 'tot '; Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM = 'trim'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR = 'getal'; Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_INPUT_STARTVALUE = 'startWaarde'; Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT_NUM = 'getal'; Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN2 = 'Geeft een hoek in tussen [-180, +180]\ngraden met de gegeven rechthoekcoordinaten.'; Blockly.Msg.REPL_YOUR_CODE_IS = 'Jouw code is'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT = 'splits'; Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF = 'als'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_DO = 'doe'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME = 'initializeer lokaal in return'; Blockly.Msg.REPL_EMULATOR_STARTED = 'Emulator gestart, wachten '; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST = 'splits aan de eerste'; Blockly.Msg.LANG_COLOUR_LIGHT_GRAY = 'lichtgrijs'; Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_1 = 'Voert de blokken in het \'doe\'-gedeelte uit zolang de test waar is.'; Blockly.Msg.DUPLICATE_BLOCK = 'Dupliceer'; Blockly.Msg.SORT_H = 'Soorteer Blokken op Hoogte'; Blockly.Msg.ARRANGE_V = 'Organizeer Blokken Vertikaal'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE = 'tot'; Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT = 'willekeurig getal tussen %1 en %2'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_EQ = 'Test of twee dingen gelijk zijn. \nDe dingen die worden vergeleken kunnen vanalles zijn, niet enkel getallen. \nGetallen worden als gelijk beschouwd aan hun tekstvorm, \nbijvoorbeeld, het getal 0 is gelijk aan de tekst "0". Ook two tekstvelden \ndie getallen voorstellen zijn gelijk aan elkaar als de getallen gelijk zijn aan mekaar. \n"1" is gelijk aan "01".'; Blockly.Msg.LANG_LOGIC_COMPARE_EQ = '='; Blockly.Msg.RENAME_VARIABLE = 'Geef variabele een andere naam...'; Blockly.Msg.LANG_MATH_RANDOM_INT_TOOLTIP = 'Geeft een willekeurige geheel getal tussen de boven en de\nondergrens. De grenzen worden afgerond tot getallen kleiner\ndan 2**30.'; Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE = 'waar'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM = 'voor elk'; Blockly.Msg.LANG_LISTS_PICK_RANDOM_TOOLTIP = 'Neem een willekeurig element van de lijst.'; Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT_REPLACEMENT = 'vervanging'; Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE = 'Sluit het venster met gewone tekst'; Blockly.Msg.REPL_UNABLE_TO_LOAD_NO_RESPOND = 'Kan geen update laden van de App Inventor server (de server antwoordt niet)'; Blockly.Msg.LANG_TEXT_SEGMENT_INPUT_START = 'start'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE = 'doe resultaat'; Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP = 'Een procedure die geen waarde teruggeeft.'; Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_TOOLTIP = 'Tests of iets een tekst is die een hexadecimaal getal voorstelt.'; Blockly.Msg.LANG_TEXT_REPLACE_ALL_TOOLTIP = 'Geeft een nieuwe tekst terug door alle stukjes tekst zoals het segment\nte vervangen door de vervangtekst.'; Blockly.Msg.LANG_VARIABLES_SET_TOOLTIP = 'Zet deze variabele gelijk aan de input.'; Blockly.Msg.REPL_ERROR_FROM_COMPANION = 'Fout van de Companion'; Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_NEQ = 'Geef waar terug als beide inputs niet gelijk zijn aan elkaar.'; Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT = 'van de component'; Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT = 'doe/resultaat'; Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP = 'Voeg een element toe aan de lijst.'; Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE = 'naar kleine letters'; Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT = 'voor element in lijst'; Blockly.Msg.COLLAPSE_ALL = 'Klap blokken dicht'; Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Waarschuwing:\nDeze procedure heeft\ndubbele inputs.'; Blockly.Msg.LANG_CONTROLS_CHOOSE_COLLAPSED_TEXT = 'als'; Blockly.Msg.REPL_NETWORK_ERROR = 'Netwerkfout'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'zet getal om'; Blockly.Msg.COLLAPSE_BLOCK = 'Klap blok dicht'; Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD = 'voeg dingen toe aan lijst'; Blockly.Msg.REPL_COMPANION_STARTED_WAITING = 'Companion start op, effe wachten ...'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Neemt een tekst die een binair getal voorstelt en geeft de tekst terug die dat getal decimaal voorstelt'; Blockly.Msg.LANG_LOGIC_NEGATE_TOOLTIP = 'Geeft waar terug wanneer de input niet waar is.\nGeeft niet waar terug waneer de input waar is.'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER = 'de rest van'; Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY = 'splits bij de eerste van'; Blockly.Msg.SHOW_WARNINGS = 'Toon Waarschuwingen'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'decimaal naar binair'; Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT = 'initializeer lokaal'; Blockly.Msg.REPL_DEVICES = 'apparaten'; Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN = 'dan'; Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT = 'op'; Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT = 'voor getal in een zeker bereik'; Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT = 'vierkantswortel'; Blockly.Msg.LANG_MATH_COMPARE_EQ = '='; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Geeft het kleinste van zijn argumenten terug..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Geeft het grootste van zijn argumenten terug..'; Blockly.Msg.TIME_YEARS = "Jaren"; Blockly.Msg.TIME_MONTHS = "Maanden"; Blockly.Msg.TIME_WEEKS = "Weken"; Blockly.Msg.TIME_DAYS = "Dagen"; Blockly.Msg.TIME_HOURS = "Uren"; Blockly.Msg.TIME_MINUTES = "Minuten"; Blockly.Msg.TIME_SECONDS = "Seconden"; Blockly.Msg.TIME_DURATION = "Duurtijd"; Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION = "Toon Rugzak informatie"; Blockly.Msg.ENABLE_GRID = 'Toon Werkruimte raster'; Blockly.Msg.DISABLE_GRID = 'Werkruimte raster verbergen'; Blockly.Msg.ENABLE_SNAPPING = 'Uitlijnen op raster aanzetten'; Blockly.Msg.DISABLE_SNAPPING = 'Uitlijnen op raster uitzetten'; } }; // Initalize language definition to Dutch Blockly.Msg.nl.switch_blockly_language_to_nl.init(); Blockly.Msg.nl.switch_language_to_dutch.init();
sbis04/appinventor-sources
appinventor/blocklyeditor/src/msg/nl/_messages.js
797
import java.util.ArrayList; import java.util.PriorityQueue; import java.util.LinkedList; import java.util.Arrays; public class l001 { public static class Edge { int v, w; Edge(int v, int w) { this.v = v; this.w = w; } } public static void addEdge(ArrayList<Edge>[] graph, int u, int v, int w) { graph[u].add(new Edge(v, w)); graph[v].add(new Edge(u, w)); } public static void display(ArrayList<Edge>[] graph) { for (int i = 0; i < graph.length; i++) { System.out.print(i + " -> "); for (Edge e : graph[i]) { System.out.print("(" + e.v + ", " + e.w + ") "); } System.out.println(); } } public static int findVtx(ArrayList<Edge>[] graph, int u, int v) { int idx = -1; ArrayList<Edge> al = graph[u]; for (int i = 0; i < al.size(); i++) { Edge e = al.get(i); if (e.v == v) { idx = i; break; } } return idx; } public static void removeEdge(ArrayList<Edge>[] graph, int u, int v) { int idx1 = findVtx(graph, u, v); int idx2 = findVtx(graph, v, u); graph[u].remove(idx1); graph[v].remove(idx2); } public static void removeVtx(ArrayList<Edge>[] graph, int u) { ArrayList<Edge> al = graph[u]; while (al.size() != 0) { int v = al.get(al.size() - 1).v; removeEdge(graph, u, v); } } public static boolean hasPath(ArrayList<Edge>[] graph, int src, int dest, boolean[] vis) { if (src == dest) return true; vis[src] = true; boolean res = false; for (Edge e : graph[src]) { if (!vis[e.v]) res = res || hasPath(graph, e.v, dest, vis); } return res; } public static int printAllPath(ArrayList<Edge>[] graph, int src, int dest, boolean[] vis, String ans) { if (src == dest) { System.out.println(ans + dest); return 1; } int count = 0; vis[src] = true; for (Edge e : graph[src]) { if (!vis[e.v]) { count += printAllPath(graph, e.v, dest, vis, ans + src); } } vis[src] = false; return count; } public static void printpreOrder(ArrayList<Edge>[] graph, int src, int wsf, boolean[] vis, String ans) { System.out.println(src + " -> " + ans + src + "@" + wsf); vis[src] = true; for (Edge e : graph[src]) { if (!vis[e.v]) printpreOrder(graph, e.v, wsf + e.w, vis, ans + src); } vis[src] = false; } public static class pair { String psf = ""; int wsf = 0; pair(String psf, int wsf) { this.wsf = wsf; this.psf = psf; } pair() { } } public static pair heavyWeightPath(ArrayList<Edge>[] graph, int src, int dest, boolean[] vis) { if (src == dest) { return new pair(src + "", 0); } vis[src] = true; pair myAns = new pair("", -(int) 1e9); for (Edge e : graph[src]) { if (!vis[e.v]) { pair recAns = heavyWeightPath(graph, e.v, dest, vis); if (recAns.wsf != -(int) 1e9 && recAns.wsf + e.w > myAns.wsf) { myAns.wsf = recAns.wsf + e.w; myAns.psf = src + recAns.psf; } } } vis[src] = false; return myAns; } public static pair lightWeightPath(ArrayList<Edge>[] graph, int src, int dest, boolean[] vis) { if (src == dest) { return new pair(src + "", 0); } vis[src] = true; pair myAns = new pair("", (int) 1e9); for (Edge e : graph[src]) { if (!vis[e.v]) { pair recAns = lightWeightPath(graph, e.v, dest, vis); if (recAns.wsf != -(int) 1e9 && recAns.wsf + e.w < myAns.wsf) { myAns.wsf = recAns.wsf + e.w; myAns.psf = src + recAns.psf; } } } vis[src] = false; return myAns; } // static class Pair implements Comparable<Pair> { // int wsf; // String psf; // Pair(int wsf, String psf) { // this.wsf = wsf; // this.psf = psf; // } // public int compareTo(Pair o) { // return this.wsf - o.wsf; // } // } // static String spath; // static Integer spathwt = Integer.MAX_VALUE; // static String lpath; // static Integer lpathwt = Integer.MIN_VALUE; // static String cpath; // static Integer cpathwt = Integer.MAX_VALUE; // static String fpath; // static Integer fpathwt = Integer.MIN_VALUE; // static PriorityQueue<Pair> pq = new PriorityQueue<>(); // public static void multisolver(ArrayList<Edge>[] graph, int src, int dest, // boolean[] vis, int criteria, int k, // String psf, int wsf) { // if (src == dest) { // if (wsf < spathwt) { // spathwt = wsf; // spath = psf; // } // if (lpathwt < wsf) { // lpathwt = wsf; // lpath = psf; // } // if (wsf < criteria && wsf > fpathwt) { // fpathwt = wsf; // fpath = psf; // } // if (wsf > criteria && wsf < cpathwt) { // cpathwt = wsf; // cpath = psf; // } // pq.add(new Pair(wsf, psf)); // if (pq.size() > k) // pq.remove(); // return; // } // vis[src] = true; // for (Edge e : graph[src]) { // if (!vis[e.v]) // multisolver(graph, e.v, dest, vis, criteria, k, psf + e.v, wsf + e.w); // } // vis[src] = false; // } // Get Connected Components public static void dfs(ArrayList<Edge>[] graph, int src, boolean[] vis) { vis[src] = true; for (Edge e : graph[src]) { if (!vis[e.v]) dfs(graph, e.v, vis); } } public static int GCC(ArrayList<Edge>[] graph) { int N = graph.length; boolean[] vis = new boolean[N]; int components = 0; for (int i = 0; i < N; i++) { if (!vis[i]) { components++; dfs(graph, i, vis); } } return components; } public static int dfs_hamintonianPath(ArrayList<Edge>[] graph, boolean[] vis, int src, int osrc, int count, String psf) { if (count == graph.length - 1) { int idx = findVtx(graph, src, osrc); if (idx != -1) System.out.println(psf + "*"); else System.out.println(psf + "."); return 1; } int totalPaths = 0; vis[src] = true; for (Edge e : graph[src]) { if (!vis[e.v]) { totalPaths += dfs_hamintonianPath(graph, vis, e.v, osrc, count + 1, psf + e.v); } } vis[src] = false; return totalPaths; } // Hamintonian Path public static void hamintonianPath(int src, ArrayList<Edge>[] graph, int N) { boolean[] vis = new boolean[N]; dfs_hamintonianPath(graph, vis, src, src, 0, src + ""); } // BFS.=========================================================== public static void BFS(ArrayList<Edge>[] graph, int src, boolean[] vis) { LinkedList<Integer> que = new LinkedList<>(); // que -> addLast, removeFirst que.addLast(src); int level = 0; boolean isCycle = false; while (que.size() != 0) { int size = que.size(); System.out.print(level + " No Of Edges Required for: "); while (size-- > 0) { Integer rvtx = que.removeFirst(); if (vis[rvtx]) { isCycle = true; continue; } System.out.print(rvtx + " "); vis[rvtx] = true; for (Edge e : graph[rvtx]) { if (!vis[e.v]) que.addLast(e.v); } } level++; System.out.println(); } } public static void BFS_forNoCycle(ArrayList<Edge>[] graph, int src, boolean[] vis) { LinkedList<Integer> que = new LinkedList<>(); // que -> addLast, removeFirst que.addLast(src); vis[src] = true; int level = 0; while (que.size() != 0) { int size = que.size(); System.out.print(level + " No Of Edges Required for: "); while (size-- > 0) { Integer rvtx = que.removeFirst(); System.out.print(rvtx + " "); for (Edge e : graph[rvtx]) { if (!vis[e.v]) { vis[e.v] = true; que.addLast(e.v); } } } level++; System.out.println(); } } public static boolean isBipartite(ArrayList<Edge>[] graph, int src, int[] vis) { LinkedList<Integer> que = new LinkedList<>(); // que -> addLast, removeFirst que.addLast(src); int color = 0; // 0 -> red, 1 -> green boolean isBipartite = true; while (que.size() != 0) { int size = que.size(); while (size != 0) { int rvtx = que.removeFirst(); if (vis[rvtx] != -1) { if (vis[rvtx] != color) isBipartite = false; continue; } vis[rvtx] = color; for (Edge e : graph[rvtx]) { if (vis[e.v] == -1) que.addLast(e.v); } } color = (color + 1) % 2; } return isBipartite; } public static boolean isBipartit(ArrayList<Edge>[] graph) { int[] vis = new int[graph.length]; Arrays.fill(vis, -1); for (int i = 0; i < graph.length; i++) { if (vis[i] == -1) { if (!isBipartite(graph, i, vis)) return false; } } return true; } public static class diji_pair implements Comparable<diji_pair> { int vtx, par, wt, wsf; String psf; diji_pair(int vtx, int par, int wt, int wsf, String psf) { this.vtx = vtx; this.par = par; this.wt = wt; this.wsf = wsf; this.psf = psf; } @Override public int compareTo(diji_pair o) { return this.wsf - o.wsf; } } public static void dijikstrAlgo_01(ArrayList<Edge>[] graph, int src) { int N = 7; ArrayList<Edge>[] myGraph = new ArrayList[N]; for (int i = 0; i < N; i++) myGraph[i] = new ArrayList<>(); boolean[] vis = new boolean[N]; PriorityQueue<diji_pair> pq = new PriorityQueue<>(); pq.add(new diji_pair(src, -1, 0, 0, src + "")); int[] dis = new int[N]; while (pq.size() != 0) { diji_pair rp = pq.remove(); if (vis[rp.vtx]) continue; if (rp.par != -1) addEdge(myGraph, rp.vtx, rp.par, rp.wt); System.out.println(rp.vtx + " via " + rp.psf + " @ " + rp.wsf); dis[rp.vtx] = rp.wsf; vis[rp.vtx] = true; for (Edge e : graph[rp.vtx]) { if (!vis[e.v]) pq.add(new diji_pair(e.v, rp.vtx, e.w, rp.wsf + e.w, rp.psf + e.v)); } } display(myGraph); for (int ele : dis) System.out.print(ele + " "); } public static int[] dijikstrAlgo_forQuestionSolving(ArrayList<Edge>[] graph, int src) { int N = graph.length; boolean[] vis = new boolean[N]; PriorityQueue<diji_pair> pq = new PriorityQueue<>(); pq.add(new diji_pair(src, -1, 0, 0, src + "")); int[] dis = new int[N]; while (pq.size() != 0) { diji_pair rp = pq.remove(); if (vis[rp.vtx]) continue; dis[rp.vtx] = rp.wsf; vis[rp.vtx] = true; for (Edge e : graph[rp.vtx]) { if (!vis[e.v]) pq.add(new diji_pair(e.v, rp.vtx, e.w, rp.wsf + e.w, rp.psf + e.v)); } } return dis; } public static class diji_pair2 implements Comparable<diji_pair2> { int vtx, wsf; diji_pair2(int vtx, int wsf) { this.vtx = vtx; this.wsf = wsf; } @Override public int compareTo(diji_pair2 o) { return this.wsf - o.wsf; } } public static int[] dijikstrAlgo_bestMethod(ArrayList<Edge>[] graph, int src) { int N = graph.length; PriorityQueue<diji_pair2> pq = new PriorityQueue<>(); int[] dis = new int[N]; int[] par = new int[N]; boolean[] vis = new boolean[N]; Arrays.fill(dis, (int) 1e9); Arrays.fill(par, -1); pq.add(new diji_pair2(src, 0)); dis[src] = 0; while (pq.size() != 0) { diji_pair2 rp = pq.remove(); if (vis[rp.vtx]) continue; vis[rp.vtx] = true; for (Edge e : graph[rp.vtx]) { if (!vis[e.v] && e.w + rp.wsf < dis[e.v]) { dis[e.v] = e.w + rp.wsf; par[e.v] = rp.vtx; pq.add(new diji_pair2(e.v, rp.wsf + e.w)); } } } return dis; } private static class primsPair { int vtx, wt; primsPair(int vtx, int wt) { this.vtx = vtx; this.wt = wt; } } private static void prims(ArrayList<Edge>[] graph, int src, ArrayList<Edge>[] primsGraph, boolean[] vis) { int N = graph.length; PriorityQueue<primsPair> pq = new PriorityQueue<>((a, b) -> { return a.wt - b.wt; }); int[] dis = new int[N]; int[] par = new int[N]; Arrays.fill(dis, (int) 1e9); Arrays.fill(par, -1); pq.add(new primsPair(src, 0)); dis[src] = 0; while (pq.size() != 0) { primsPair p = pq.remove(); if (vis[p.vtx]) continue; vis[p.vtx] = true; for (Edge e : graph[p.vtx]) { if (!vis[e.v] && e.w < dis[e.v]) { dis[e.v] = e.w; par[e.v] = p.vtx; pq.add(new primsPair(e.v, e.w)); } } } } public static void prims(ArrayList<Edge>[] graph) { int N = 7; ArrayList<Edge>[] primsg = new ArrayList[N]; for (int i = 0; i < N; i++) primsg[i] = new ArrayList<>(); boolean[] vis = new boolean[N]; for (int i = 0; i < N; i++) { if (!vis[i]) { prims(graph, i, primsg, vis); } } display(primsg); } public static void graphConstruct() { int N = 7; ArrayList<Edge>[] graph = new ArrayList[N]; for (int i = 0; i < N; i++) graph[i] = new ArrayList<>(); addEdge(graph, 0, 1, 10); addEdge(graph, 0, 3, 40); addEdge(graph, 1, 2, 10); addEdge(graph, 2, 3, 10); addEdge(graph, 3, 4, 2); addEdge(graph, 4, 5, 3); addEdge(graph, 5, 6, 3); addEdge(graph, 4, 6, 8); addEdge(graph, 2, 5, 5); display(graph); // boolean[] vis = new boolean[N]; // System.out.println(printAllPath(graph, 0, 6, vis, "")); // printpreOrder(graph, 0, 0, vis, ""); // pair ans = heavyWeightPath(graph, 0, 6, vis); // pair ans = lightWeightPath(graph, 0, 6, vis); // if (ans.wsf != -(int) 1e9) // System.out.println(ans.psf + "@" + ans.wsf); // hamintonianPath(0, graph, N); // BFS(graph, 0, vis); System.out.println(); dijikstrAlgo_01(graph, 0); } public static void main(String[] args) { graphConstruct(); } }
pankajmahato/pepcoding-Batches
2020/NIET/graph/l001.java
798
package GUI; import Database.Database; import Logica.*; import Logica.Vestiging; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; public class ToevoegenWinkel3 extends javax.swing.JFrame { public JFrame myCaller; public Database d = new Database(); public Winkel actief = InlogScherm.getInstance().getActief(); public DefaultTableModel t = d.naarTabel("select artikelnr, artikelnaam, prijs, ptnwinst, minimumaantal, ptnkost, minimumbedrag from artikel where winkelnaam = '" + actief.getWinkelnaam() + "'"); public ToevoegenWinkel3() { initComponents(); } public ToevoegenWinkel3(JFrame caller) { initComponents(); myCaller = caller; } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel12 = new javax.swing.JLabel(); knopTerug = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); txtArtikelnr = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); txtNaam = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); tabelArtikelen = new javax.swing.JTable(t); knopToevoegen = new javax.swing.JButton(); knopVoegToe = new javax.swing.JButton(); jLabel5 = new javax.swing.JLabel(); txtPrijs = new javax.swing.JTextField(); txtPuntenplus = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); txtPuntenmin = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); checkMinimumartikelen = new javax.swing.JCheckBox(); checkMinimumaankoopbedrag = new javax.swing.JCheckBox(); txtMinimumartikelen = new javax.swing.JTextField(); jLabel10 = new javax.swing.JLabel(); txtMinimumbedrag = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel(); checkGeeftpunten = new javax.swing.JCheckBox(); checkKostpunten = new javax.swing.JCheckBox(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel12.setForeground(new java.awt.Color(255, 0, 0)); jLabel12.setText("Er moet minstens 1 artikel zijn dat punten oplevert"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Artikel toevoegen"); knopTerug.setText("Terug"); knopTerug.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { knopTerugActionPerformed(evt); } }); jLabel1.setText("Voeg minstens 1 artikel toe."); jLabel2.setText("Artikelnummer"); jLabel3.setForeground(new java.awt.Color(153, 0, 0)); jLabel3.setText("Opgepast! Elk artikel moet een verschillend nummer hebben."); jLabel4.setText("Artikelnaam"); txtNaam.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtNaamActionPerformed(evt); } }); tabelArtikelen.getTableHeader().setReorderingAllowed(false); jScrollPane1.setViewportView(tabelArtikelen); knopToevoegen.setText("Toevoegen"); knopToevoegen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { knopToevoegenActionPerformed(evt); } }); knopVoegToe.setText("Voeg deze winkel toe!"); knopVoegToe.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { knopVoegToeActionPerformed(evt); } }); jLabel5.setText("Prijs"); jLabel8.setText("bonuspunten"); jLabel9.setText("bonuspunten"); checkMinimumartikelen.setText("Bij aankoop van"); checkMinimumaankoopbedrag.setText("Bij een minimum aankoopbedrag van"); jLabel10.setText("artikelen"); jLabel11.setText("euro"); checkGeeftpunten.setText("Geeft"); checkKostpunten.setText("Kost"); jLabel6.setForeground(new java.awt.Color(153, 0, 0)); jLabel6.setText("Opgepast! Er moet minstens 1 artikel zijn dat punten oplevert en 1 artikel dat punten kost."); jLabel7.setForeground(new java.awt.Color(153, 0, 0)); jLabel7.setText("Gebruik '.' voor decimale getallen."); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup() .addComponent(knopTerug) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(knopVoegToe)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(txtNaam, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtPrijs, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(txtArtikelnr, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 543, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(checkGeeftpunten) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(txtPuntenplus, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel8)) .addComponent(knopToevoegen, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(checkKostpunten) .addGap(12, 12, 12) .addComponent(txtPuntenmin, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel9))) .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(checkMinimumaankoopbedrag) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMinimumbedrag, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(checkMinimumartikelen) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMinimumartikelen, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGap(0, 59, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(txtArtikelnr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(txtNaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addComponent(txtPrijs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(checkGeeftpunten) .addComponent(txtPuntenplus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8) .addComponent(checkMinimumartikelen) .addComponent(txtMinimumartikelen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(checkKostpunten) .addComponent(txtPuntenmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9) .addComponent(checkMinimumaankoopbedrag) .addComponent(txtMinimumbedrag, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel11)) .addGap(24, 24, 24) .addComponent(jLabel6) .addGap(18, 18, 18) .addComponent(knopToevoegen) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(knopTerug) .addComponent(knopVoegToe)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void txtNaamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNaamActionPerformed ToevoegenWinkel2 s = new ToevoegenWinkel2(this); s.setLocationRelativeTo(null); s.setVisible(true); setVisible(false); }//GEN-LAST:event_txtNaamActionPerformed private void knopVoegToeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knopVoegToeActionPerformed boolean toevoegen = true; if(d.aantalVestigingen(actief.getWinkelnaam()) == 0) { JOptionPane.showMessageDialog(null, "Er moet minstens 1 vestiging zijn."); toevoegen = false; } if(!Artikel.minstensArtikelPlus(actief.getWinkelnaam()) || !Artikel.minstensArtikelMin(actief.getWinkelnaam()) || d.aantalArtikelen(actief.getWinkelnaam()) == 0) { JOptionPane.showMessageDialog(null, "Er moet minstens 1 artikel zijn dat punten geeft en 1 artikel dat punten kost."); toevoegen = false; } if(toevoegen) { JOptionPane.showMessageDialog(null, "Winkel toegevoegd, u kan nu inloggen."); InlogScherm s = new InlogScherm(); s.setLocationRelativeTo(null); s.setVisible(true); setVisible(false); } }//GEN-LAST:event_knopVoegToeActionPerformed private void knopTerugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knopTerugActionPerformed myCaller.setVisible(true); myCaller.setLocationRelativeTo(null); setVisible(false); }//GEN-LAST:event_knopTerugActionPerformed private void knopToevoegenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_knopToevoegenActionPerformed String winkelnaam = actief.getWinkelnaam(); int puntenplus = 0; Integer puntenmin = null; int minimumartikelen = 1; int minimumbedrag = 0; int artikelnr = Integer.parseInt(txtArtikelnr.getText()); double prijs = 0; int pr = (int) Math.round(prijs * 100); double prijsAfgerond = pr / 100.00 ; String artikelnaam = txtNaam.getText(); boolean toevoegen = true; if(txtPrijs.getText().equals("") || Double.parseDouble(txtPrijs.getText())<0) { toevoegen = false; JOptionPane.showMessageDialog(null, "De prijs moet groter dan of gelijk aan nul zijn."); } else { prijs = Double.parseDouble(txtPrijs.getText()); pr = (int) Math.round(prijs * 100); prijsAfgerond = pr / 100.00 ; } if(checkGeeftpunten.isSelected()) { if(txtPuntenplus.getText().equals("")) { toevoegen = false; JOptionPane.showMessageDialog(null, "Puntenkost niet ingevuld"); } else if(!Artikel.checkPuntenplusWaarde(Integer.parseInt(txtPuntenplus.getText()), prijs)){ toevoegen = false; JOptionPane.showMessageDialog(null, "De punten per eenheid van de prijs moeten tussen de 0,25 en 2 punten."); } else { puntenplus = Integer.parseInt(txtPuntenplus.getText()); if(checkMinimumartikelen.isSelected()) { if(txtMinimumartikelen.getText().equals("")) { toevoegen = false; JOptionPane.showMessageDialog(null, "Aantal minimumartikelen niet ingevuld"); } else { minimumartikelen = Integer.parseInt(txtMinimumartikelen.getText()); } } } } if(checkKostpunten.isSelected()){ if(txtPuntenmin.getText().equals("")) { toevoegen = false; JOptionPane.showMessageDialog(null, "Puntenkost niet ingevuld"); } else if(!Artikel.checkPuntenminWaarde(Integer.parseInt(txtPuntenmin.getText()), prijs)){ toevoegen = false; JOptionPane.showMessageDialog(null, "De punten per eenheid van de prijs moeten tussen de 0,25 en 2 punten."); } else { puntenmin = Integer.parseInt(txtPuntenmin.getText()); if(checkMinimumaankoopbedrag.isSelected()) { if(txtMinimumbedrag.getText().equals("")) { toevoegen = false; JOptionPane.showMessageDialog(null, "Minimumbedrag niet ingevuld"); } else { minimumbedrag = Integer.parseInt(txtMinimumbedrag.getText()); } } } } if(d.checkArtikel(artikelnr, winkelnaam)){ toevoegen = false; JOptionPane.showMessageDialog(null, "Dit productnummer bestaat al voor deze winkel."); } Artikel q = new Artikel(artikelnr, winkelnaam, artikelnaam, prijsAfgerond, puntenplus, minimumartikelen, puntenmin, minimumbedrag); if(toevoegen) { d.addArtikel(q); t = d.naarTabel("select artikelnr, artikelnaam, prijs, ptnwinst, minimumaantal, ptnkost, minimumbedrag from artikel where winkelnaam = '" + actief.getWinkelnaam() + "'"); tabelArtikelen.setModel(t); txtArtikelnr.setText(""); txtPrijs.setText(""); txtPuntenplus.setText(""); txtPuntenmin.setText(""); txtMinimumartikelen.setText(""); txtMinimumbedrag.setText(""); txtNaam.setText(""); checkKostpunten.setSelected(false); checkMinimumartikelen.setSelected(false); checkGeeftpunten.setSelected(false); checkMinimumaankoopbedrag.setSelected(false); } }//GEN-LAST:event_knopToevoegenActionPerformed public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ToevoegenWinkel3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ToevoegenWinkel3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ToevoegenWinkel3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ToevoegenWinkel3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ToevoegenWinkel3().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox checkGeeftpunten; private javax.swing.JCheckBox checkKostpunten; private javax.swing.JCheckBox checkMinimumaankoopbedrag; private javax.swing.JCheckBox checkMinimumartikelen; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton knopTerug; private javax.swing.JButton knopToevoegen; private javax.swing.JButton knopVoegToe; private javax.swing.JTable tabelArtikelen; private javax.swing.JTextField txtArtikelnr; private javax.swing.JTextField txtMinimumartikelen; private javax.swing.JTextField txtMinimumbedrag; private javax.swing.JTextField txtNaam; private javax.swing.JTextField txtPrijs; private javax.swing.JTextField txtPuntenmin; private javax.swing.JTextField txtPuntenplus; // End of variables declaration//GEN-END:variables }
dietervdm/Bingo
src/GUI/ToevoegenWinkel3.java
799
// Near Infinity - An Infinity Engine Browser and Editor // Copyright (C) 2001 Jon Olav Hauglid // See LICENSE.txt for license information package org.infinity.resource.bcs; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Set; import java.util.SortedSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.filechooser.FileFilter; import javax.swing.text.BadLocationException; import org.infinity.gui.ButtonPanel; import org.infinity.gui.ButtonPopupMenu; import org.infinity.gui.DataMenuItem; import org.infinity.gui.InfinityScrollPane; import org.infinity.gui.InfinityTextArea; import org.infinity.gui.ScriptTextArea; import org.infinity.gui.ViewFrame; import org.infinity.gui.menu.BrowserMenuBar; import org.infinity.icon.Icons; import org.infinity.resource.Closeable; import org.infinity.resource.Profile; import org.infinity.resource.Referenceable; import org.infinity.resource.ResourceFactory; import org.infinity.resource.TextResource; import org.infinity.resource.ViewableContainer; import org.infinity.resource.Writeable; import org.infinity.resource.key.ResourceEntry; import org.infinity.search.ScriptReferenceSearcher; import org.infinity.search.TextResourceSearcher; import org.infinity.util.IdsMap; import org.infinity.util.Misc; import org.infinity.util.StaticSimpleXorDecryptor; import org.infinity.util.io.StreamUtils; /** * This resource represent scripted actions. {@code .bcs} files are scripts attached to anything other than the player * characters. {@code .bs} files are scripts which drive a characters actions automatically (AI scripts) based on * criteria in the environment. * <p> * Just as the files from which they are compiled, these script files make use of the concept of "triggers" and * "responses". A trigger is a condition which causes a response with a certain probability. A response is one or more * calls to functions they have exposed to the script. It seems that this to be the difference between {@code .bcs} and * {@code .bs} files. (They are assigned different resource types in the resource management code, too.) * <p> * The format will be given in a top-down sense: i.e. first will describe the formatting of top-level blocks, and then * will describe the contents of the blocks. The process will proceed recursively until the whole format is described. * <p> * The top-level block is the script file. * * <h3>Parameters</h3> First, a brief word on "function parameters". Both {@link BcsTrigger triggers} and * {@link BcsAction actions} are essentially calls to functions inside the Infinity Engine. Triggers can take up to 7 * arguments, and actions can take up to 10 arguments. There are three allowable forms of arguments: strings, integers, * and objects. The different function calls are defined in {@code TRIGGER.IDS} and {@code ACTION.IDS}. * <p> * There are also functions defined in {@code SVTRIOBJ.IDS}, which are a {sub|super} set of of the function calls * defined in {@code TRIGGER.IDS}. They are probably used for {insert spiel here}. * <p> * String arguments are simply quoted strings (i.e. ASCII strings delimited by the double quote character {@code '"'}). * The format of these descriptions is given below, by way of an example (from BG's {@code TRIGGER.IDS}): * * <code><pre> * 0x401D Specifics(O:Object*,I:Specifics*Specific) * </pre></code> * * The first thing on the line is the ID (in hex. IDs in scripts are typically in decimal). Next is the name of the * function. Inside the parentheses, similarly to C/C++, is a comma-delimited list of argument type and argument name. * <p> * The argument types are: * <ul> * <li>S: string</li> * <li>O: object</li> * <li>I: integer</li> * <li>P: point</li> * <li>A: action</li> * </ul> * There is always a tag after the {@code ':'} and before the {@code '*'}. It seems that the tag is used only for * expository function -- i.e. simply an argument name to help discern the purpose. There is, however, one minor * complication. Actions only have space for 2 string parameters. There are actions taking anywhere from 0 to 4 strings. * Some of the actions which take strings (usually either 2 or 4 strings) actually concatenate the strings. In this * case, it is always an {@code "Area"} and a {@code "Name"} parameter, (though the parameter names vary somewhat). * <p> * The only surefire way to tell which is which is to hardcode the values of the actions which concatenate strings. When * the strings are concatenated, the {@code "Area"} is always the first part of the resulting string, and always takes * exactly 6 characters. It works, in most respects, just like a namespace qualifier in, for instance, C++. An aside: * The functions which actually concatenate the strings are typically the ones which access "global variables", i.e. * {@code Global}, {@code SetGlobal}, {@code IncrementGlobal}, et cetera. * <p> * At present there is no confidence how "action" type parameters are stored. This will require some investigation. * <p> * The final detail in the above example is the bit following the {@code '*'}. This occurs (it seems) only in integer * arguments; the string following the asterisk is the name of an {@link IdsMap IDS} file. The values in the IDS file * are the only allowed values for that parameter; moreover, it is extremely probable that the parameter can be accessed * using the symbolic names given in the IDS file, though this is merely speculation. Each trigger can use up to 2 (3?) * integer arguments, up to 2 string arguments, and one object argument. These seven arguments are always specified in * each trigger, even if they are not all used. If an argument is not used, it is assigned a dummy value. Finally, the * arguments are used in order when they are listed in the scripts. For instance, two integer parameters always occupy * the first two "integer parameter" slots in the trigger or action. A trigger has an additional "flags" field, in * which, for instance, a bit is either set or cleared to indicate whether the trigger is to be negated or not. (i.e. * whether the success of the trigger should return {@code true} or {@code false}). * * <h3>Script file</h3> <code><pre> * SC (newline) * Condition-response block * Condition-response block * ... * Condition-response block * SC (newline) * </pre></code> * * <h3>Condition-response block</h3> This can be interpreted as "if condition, then response set". A response set is a * set of actions, each of which is performed with a certain probability: <code><pre> * CR (newline) * Condition * Response set * CR (newline) * </pre></code> * * <h3>Condition</h3> This should be interpreted as the AND of all the "trigger" conditions. The condition is * {@code true} iff all triggers inside are {@code true}: <code><pre> * CO (newline) * Trigger * Trigger * ... * Trigger * CO (newline) * </pre></code> * * <h3>Trigger</h3> This format is slightly hairier. First, it has a "trigger ID", which is an ID in the * {@code TRIGGER.IDS} file. Essentially, each trigger corresponds to a call to one of the functions listed in there. * See the section on parameters for details: <code><pre> * TR (newline) * trigger ID from TRIGGER.IDS (no newline) * 1 integer parameter (no newline) * 1 flags dword (no newline): * bit 0: negate condition flag (if true, this trigger is negated -- i.e. success=>false, failure=>true) * 1 integer parameter (no newline) * 1 integer. Unknown purpose. * 2 string parameters (no newline) * 1 object parameter (newline) * TR (newline) * </pre></code> * * <h3>Response set</h3> Each response in a reponse set has a certain weight associated with it. Usually, this is 100%, * but if not, then the response is only played with a certain probability. To find the chance of a particular response * being chosen, sum the probabilities of all the responses in the response set. Each response Rnhas a probability * {@code Pn/Sum(P)} of being chosen, if the response set is to be played: <code><pre> * RS (newline) * Response * Response * ... * Response * </pre></code> * * <h3>Response</h3> A response is simply the concatenation of a probability and an ACTION: <code><pre> * RE (newline) * weight. i.e. how likely this response is to occur, given that the response * set is to be run (no newline -- often no whitespace, though that may * not be important). * action (newline) * RE (newline) * </pre></code> * * <h3>Action</h3> This format is slightly hairier. First, it has a "action ID", which is an ID in the * {@code action.IDS} file. Essentially, each action corresponds to a call to one of the functions listed in there. See * the section on parameters for details: <code><pre> * AC (newline) * action ID from ACTION.IDS (no newline) * 3 object parameters (newlines after each) * 1 integer parameters (no newline) * 1 point parameter (formatted as two integers x y) (no newline) * 2 integer parameters (no newline) * 2 string parameters (no newline) * AC (newline) * </pre></code> * * <h3>Object</h3> Objects represent things (i.e. characters) in the game. An object has several parameters. These * parameters have enumerated values which can be looked up in {@code .IDS} files. Planescape: Torment has more * parameters than BG did: * <ul> * <li>{@code TEAM} (Planescape: Torment only). * <p> * Every object in Torment can have a TEAM. Most objects do not have a team specified</li> * <li>{@code FACTION} (Planescape: Torment only). * <p> * Every object in Torment can belong to a FACTION. Most creatures do, in fact, belong to a faction</li> * <li>{@code EA} (Enemy-Ally). * <p> * Whether the character is friendly to your party. Values include {@code "INANIMATE" (=1)}, for inanimate objects, * {@code "PC" (=2)} for characters belonging to the player, {@code "CHARMED" (=6)} for characters who have been * charmed, and hence are under friendly control, or {@code "ENEMY" (=255)} for characters who are hostile towards the * character. Two special values of EA exist: {@code "GOODCUTOFF" (=30)} and {@code "EVILCUTOFF" (=200)}. Characters who * are below the good cutoff are always hostile towards characters over the evil cutoff, and vice versa. To this end, * you can use {@code GOODCUTOFF} and {@code EVILCUTOFF} as sort of "wildcards". {@code EVILCUTOFF} specifies all * characters who are "evil", and {@code GOODCUTOFF} specifies all characters who are "good". Note that this has little * to do with the alignment</li> * <li>{@code GENERAL} * <p> * The general type of an object. This includes {@code "HUMANOID"}, {@code "UNDEAD"}, {@code "ANIMAL"} et cetera, but * also {@code "HELMET"}, {@code "KEY"}, {@code "POTION"}, {@code "GLOVES"}, et cetera</li> * <li>{@code RACE} * <p> * The race of an object. Creatures obviously have a race, but items also have "race", which can include a slightly more * specific description of the type of item than was given in the {@code GENERAL} field. For instance, for armor items, * this includes the "type" of the armor -- leather, chain, plate, etc.</li> * <li>{@code CLASS} * <p> * The class of a creature or item. Again, the class notion makes more sense for creatures, but gives some information * about the specific type of an item. For a "sword" or "bow", for instance, the class can be {@code "LONG_SWORD"} or * {@code * "LONG_BOW"}. As another example, the different types of spiders (phase, wraith, etc) are differentiated by the class * field</li> * <li>{@code SPECIFIC} * <p> * The specific type of an item. BG only defines three specific types: {@code NORMAL}, {@code MAGIC}, and * {@code NO_MAGIC}. Dunno. Torment uses this field much more extensively to differentiate precise individuals matching * a description from everyone else</li> * <li>{@code GENDER} * <p> * Gender field. There are, mind-boggling as it may seem, five possible values for this in BG, including the expected * {@code MALE} and {@code FEMALE}. There's also {@code "NIETHER"} (sic), which seems presume was meant as * {@code NEITHER}. Finally, there are {@code OTHER} and {@code BOTH}</li> * <li>{@code ALIGNMENT} * <p> * This field is fairly obvious. The high nybble is the Chaotic-Lawful axis, and the low nybble is the Good-Evil axis. * The values for this are specified in {@code ALIGNMEN.IDS}. The only nuance to this is that there are several values * {@code MASK_CHAOTIC}, {@code MASK_LCNEUTRAL}, {@code MASK_LAWFUL}, {@code MASK_EVIL}, {@code MASK_GENEUTRAL}, * {@code MASK_GOOD} which are wildcards, meaning, respectively, all chaotic objects, all neutral (on the lawful-chaotic * axis) objects, all lawful objects, all evil objects, all neutral (good-evil axis) objects, and all good objects</li> * <li>{@code IDENTIFIERS} * <p> * The 5 identifiers for an object allow functional specification of an object ({@code LastAttackedBy(Myself)}, etc.). * These values are looked up in {@code OBJECT.IDS}. Any unused bytes are set to 0. * <li>{@code NAME} * <p> * This is a string parameter, and is only used for characters who have specific names. Objects can be looked up by * name, or referenced by name in scripts. That is the purpose of this field. * </ul> * The specific format of an object is as follows: <code><pre> * OB (newline) * integer: enemy-ally field (EA.IDS) * integer: (torment only) faction (FACTION.IDS) * integer: (torment only) team (TEAM.IDS) * integer: general (GENERAL.IDS) * integer: race (RACE.IDS) * integer: class (CLASS.IDS) * integer: specific (SPECIFIC.IDS) * integer: gender (GENDER.IDS) * integer: alignment (ALIGNMEN.IDS) * integer: identifiers (OBJECT.IDS) * (Not in BG1) object coordinates * string: name * OB (newline) * </pre></code> Object coordinates must be specified as a point. Coordinate values which are -1 indicate that the * specified part of the coordinate is not used. A point is represented as: <code><pre> * [x.y] * </pre></code> * * @see <a href="https://gibberlings3.github.io/iesdp/file_formats/ie_formats/bcs.htm"> * https://gibberlings3.github.io/iesdp/file_formats/ie_formats/bcs.htm</a> */ public final class BcsResource implements TextResource, Writeable, Closeable, Referenceable, ActionListener, ItemListener, DocumentListener { // for decompile panel private static final ButtonPanel.Control CTRL_COMPILE = ButtonPanel.Control.CUSTOM_1; private static final ButtonPanel.Control CTRL_ERRORS = ButtonPanel.Control.CUSTOM_2; private static final ButtonPanel.Control CTRL_WARNINGS = ButtonPanel.Control.CUSTOM_3; // for compiled panel private static final ButtonPanel.Control CTRL_DECOMPILE = ButtonPanel.Control.CUSTOM_1; // for button panel private static final ButtonPanel.Control CTRL_USES = ButtonPanel.Control.CUSTOM_1; private static JFileChooser chooser; private final ResourceEntry entry; private final ButtonPanel buttonPanel = new ButtonPanel(); private final ButtonPanel bpDecompile = new ButtonPanel(); private final ButtonPanel bpCompiled = new ButtonPanel(); private JMenuItem iFindAll; private JMenuItem iFindThis; private JMenuItem iFindUsage; private JMenuItem iExportSource; private JMenuItem iExportScript; private JPanel panel; private JTabbedPane tabbedPane; private InfinityTextArea codeText; private ScriptTextArea sourceText; private String text; private boolean sourceChanged = false; private boolean codeChanged = false; public BcsResource(ResourceEntry entry) throws Exception { this.entry = entry; ByteBuffer buffer = entry.getResourceBuffer(); if (buffer.limit() > 1 && buffer.getShort(0) == -1) { buffer = StaticSimpleXorDecryptor.decrypt(buffer, 2); } text = StreamUtils.readString(buffer, buffer.limit(), Misc.getCharsetFrom(BrowserMenuBar.getInstance().getOptions().getSelectedCharset())); } // --------------------- Begin Interface ActionListener --------------------- @Override public void actionPerformed(ActionEvent event) { if (bpDecompile.getControlByType(CTRL_COMPILE) == event.getSource()) { compile(); } else if (bpCompiled.getControlByType(CTRL_DECOMPILE) == event.getSource()) { decompile(); } else if (buttonPanel.getControlByType(ButtonPanel.Control.SAVE) == event.getSource()) { save(false); } else if (buttonPanel.getControlByType(ButtonPanel.Control.SAVE_AS) == event.getSource()) { save(true); } } // --------------------- End Interface ActionListener --------------------- // --------------------- Begin Interface Closeable --------------------- @Override public void close() throws Exception { if (sourceChanged) { String options[] = { "Compile & save", "Discard changes", "Cancel" }; int result = JOptionPane.showOptionDialog(panel, "Script contains uncompiled changes", "Uncompiled changes", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (result == JOptionPane.YES_OPTION) { ((JButton) bpDecompile.getControlByType(CTRL_COMPILE)).doClick(); if (bpDecompile.getControlByType(CTRL_ERRORS).isEnabled()) { throw new Exception("Save aborted"); } ResourceFactory.saveResource(this, panel.getTopLevelAncestor()); } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { throw new Exception("Save aborted"); } } else if (codeChanged) { ResourceFactory.closeResource(this, entry, panel); } } // --------------------- End Interface Closeable --------------------- // --------------------- Begin Interface Referenceable --------------------- @Override public boolean isReferenceable() { return true; } @Override public void searchReferences(Component parent) { new ScriptReferenceSearcher(entry, parent); } // --------------------- End Interface Referenceable --------------------- // --------------------- Begin Interface DocumentListener --------------------- @Override public void insertUpdate(DocumentEvent event) { if (event.getDocument() == codeText.getDocument()) { buttonPanel.getControlByType(ButtonPanel.Control.SAVE).setEnabled(true); buttonPanel.getControlByType(ButtonPanel.Control.SAVE_AS).setEnabled(true); bpCompiled.getControlByType(CTRL_DECOMPILE).setEnabled(true); sourceChanged = false; codeChanged = true; } else if (event.getDocument() == sourceText.getDocument()) { bpDecompile.getControlByType(CTRL_COMPILE).setEnabled(true); sourceChanged = true; } } @Override public void removeUpdate(DocumentEvent event) { if (event.getDocument() == codeText.getDocument()) { buttonPanel.getControlByType(ButtonPanel.Control.SAVE).setEnabled(true); buttonPanel.getControlByType(ButtonPanel.Control.SAVE_AS).setEnabled(true); bpCompiled.getControlByType(CTRL_DECOMPILE).setEnabled(true); sourceChanged = false; codeChanged = true; } else if (event.getDocument() == sourceText.getDocument()) { bpDecompile.getControlByType(CTRL_COMPILE).setEnabled(true); sourceChanged = true; } } @Override public void changedUpdate(DocumentEvent event) { if (event.getDocument() == codeText.getDocument()) { buttonPanel.getControlByType(ButtonPanel.Control.SAVE).setEnabled(true); buttonPanel.getControlByType(ButtonPanel.Control.SAVE_AS).setEnabled(true); bpCompiled.getControlByType(CTRL_DECOMPILE).setEnabled(true); sourceChanged = false; codeChanged = true; } else if (event.getDocument() == sourceText.getDocument()) { bpDecompile.getControlByType(CTRL_COMPILE).setEnabled(true); sourceChanged = true; } } // --------------------- End Interface DocumentListener --------------------- // --------------------- Begin Interface ItemListener --------------------- @Override public void itemStateChanged(ItemEvent event) { if (buttonPanel.getControlByType(ButtonPanel.Control.FIND_MENU) == event.getSource()) { ButtonPopupMenu bpmFind = (ButtonPopupMenu) event.getSource(); if (bpmFind.getSelectedItem() == iFindAll) { List<ResourceEntry> files = ResourceFactory.getResources("BCS"); files.addAll(ResourceFactory.getResources("BS")); new TextResourceSearcher(files, panel.getTopLevelAncestor()); } else if (bpmFind.getSelectedItem() == iFindThis) { List<ResourceEntry> files = new ArrayList<>(1); files.add(entry); new TextResourceSearcher(files, panel.getTopLevelAncestor()); } else if (bpmFind.getSelectedItem() == iFindUsage) { searchReferences(panel.getTopLevelAncestor()); } } else if (buttonPanel.getControlByType(CTRL_USES) == event.getSource()) { ButtonPopupMenu bpmUses = (ButtonPopupMenu) event.getSource(); JMenuItem item = bpmUses.getSelectedItem(); String name = item.getText(); int index = name.indexOf(" ("); if (index != -1) { name = name.substring(0, index); } ResourceEntry resEntry = ResourceFactory.getResourceEntry(name); new ViewFrame(panel.getTopLevelAncestor(), ResourceFactory.getResource(resEntry)); } else if (buttonPanel.getControlByType(ButtonPanel.Control.EXPORT_MENU) == event.getSource()) { ButtonPopupMenu bpmExport = (ButtonPopupMenu) event.getSource(); if (bpmExport.getSelectedItem() == iExportSource) { if (chooser == null) { chooser = new JFileChooser(Profile.getGameRoot().toFile()); chooser.setDialogTitle("Export source"); chooser.setFileFilter(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory() || pathname.getName().toLowerCase(Locale.ENGLISH).endsWith(".baf"); } @Override public String getDescription() { return "Infinity script (.BAF)"; } }); } chooser.setSelectedFile(new File(StreamUtils.replaceFileExtension(entry.getResourceName(), "BAF"))); int returnval = chooser.showSaveDialog(panel.getTopLevelAncestor()); if (returnval == JFileChooser.APPROVE_OPTION) { try (BufferedWriter bw = Files.newBufferedWriter(chooser.getSelectedFile().toPath(), Misc.getCharsetFrom(BrowserMenuBar.getInstance().getOptions().getSelectedCharset()))) { bw.write(sourceText.getText().replaceAll("\r?\n", Misc.LINE_SEPARATOR)); JOptionPane.showMessageDialog(panel, "File saved to \"" + chooser.getSelectedFile().toString() + '\"', "Export complete", JOptionPane.INFORMATION_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(panel, "Error exporting " + chooser.getSelectedFile().toString(), "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } } else if (bpmExport.getSelectedItem() == iExportScript) { ResourceFactory.exportResource(entry, panel.getTopLevelAncestor()); } } else if (bpDecompile.getControlByType(CTRL_ERRORS) == event.getSource()) { ButtonPopupMenu bpmErrors = (ButtonPopupMenu) event.getSource(); String selected = bpmErrors.getSelectedItem().getText(); int linenr = Integer.parseInt(selected.substring(0, selected.indexOf(": "))); highlightText(linenr, null); } else if (bpDecompile.getControlByType(CTRL_WARNINGS) == event.getSource()) { ButtonPopupMenu bpmWarnings = (ButtonPopupMenu) event.getSource(); String selected = bpmWarnings.getSelectedItem().getText(); int linenr = Integer.parseInt(selected.substring(0, selected.indexOf(": "))); highlightText(linenr, null); } } // --------------------- End Interface ItemListener --------------------- // --------------------- Begin Interface Resource --------------------- @Override public ResourceEntry getResourceEntry() { return entry; } // --------------------- End Interface Resource --------------------- // --------------------- Begin Interface TextResource --------------------- @Override public String getText() { if (sourceText != null) { return sourceText.getText(); } Decompiler decompiler = new Decompiler(text, false); decompiler.setGenerateComments(BrowserMenuBar.getInstance().getOptions().autogenBCSComments()); try { return decompiler.getSource(); } catch (Exception e) { e.printStackTrace(); return "// Error: " + e.getMessage(); } } @Override public void highlightText(int linenr, String highlightText) { try { int startOfs = sourceText.getLineStartOffset(linenr - 1); int endOfs = sourceText.getLineEndOffset(linenr - 1); if (highlightText != null) { String text = sourceText.getText(startOfs, endOfs - startOfs); Pattern p = Pattern.compile(highlightText, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(text); if (m.find()) { startOfs += m.start(); endOfs = startOfs + m.end() - m.start() + 1; } } highlightText(startOfs, endOfs); } catch (BadLocationException ble) { } } @Override public void highlightText(int startOfs, int endOfs) { try { sourceText.setCaretPosition(startOfs); sourceText.moveCaretPosition(endOfs - 1); sourceText.getCaret().setSelectionVisible(true); } catch (IllegalArgumentException e) { } } // --------------------- End Interface TextResource --------------------- // --------------------- Begin Interface Viewable --------------------- @Override public JComponent makeViewer(ViewableContainer container) { sourceText = new ScriptTextArea(); sourceText.setAutoIndentEnabled(BrowserMenuBar.getInstance().getOptions().getBcsAutoIndentEnabled()); sourceText.addCaretListener(container.getStatusBar()); sourceText.setMargin(new Insets(3, 3, 3, 3)); sourceText.setLineWrap(false); sourceText.getDocument().addDocumentListener(this); InfinityScrollPane scrollDecompiled = new InfinityScrollPane(sourceText, true); scrollDecompiled.setBorder(BorderFactory.createLineBorder(UIManager.getColor("controlDkShadow"))); JButton bCompile = new JButton("Compile", Icons.ICON_REDO_16.getIcon()); bCompile.setMnemonic('c'); bCompile.addActionListener(this); ButtonPopupMenu bpmErrors = new ButtonPopupMenu("Errors (0)...", new JMenuItem[0], 20); bpmErrors.setIcon(Icons.ICON_UP_16.getIcon()); bpmErrors.addItemListener(this); bpmErrors.setEnabled(false); ButtonPopupMenu bpmWarnings = new ButtonPopupMenu("Warnings (0)...", new JMenuItem[0], 20); bpmWarnings.setIcon(Icons.ICON_UP_16.getIcon()); bpmWarnings.addItemListener(this); bpmWarnings.setEnabled(false); bpDecompile.addControl(bCompile, CTRL_COMPILE); bpDecompile.addControl(bpmErrors, CTRL_ERRORS); bpDecompile.addControl(bpmWarnings, CTRL_WARNINGS); JPanel decompiledPanel = new JPanel(new BorderLayout()); decompiledPanel.add(scrollDecompiled, BorderLayout.CENTER); decompiledPanel.add(bpDecompile, BorderLayout.SOUTH); codeText = new InfinityTextArea(text, true); codeText.setMargin(new Insets(3, 3, 3, 3)); codeText.setCaretPosition(0); codeText.setLineWrap(false); codeText.getDocument().addDocumentListener(this); InfinityScrollPane scrollCompiled = new InfinityScrollPane(codeText, true); scrollCompiled.setBorder(BorderFactory.createLineBorder(UIManager.getColor("controlDkShadow"))); JButton bDecompile = new JButton("Decompile", Icons.ICON_UNDO_16.getIcon()); bDecompile.setMnemonic('d'); bDecompile.addActionListener(this); bDecompile.setEnabled(false); bpCompiled.addControl(bDecompile, CTRL_DECOMPILE); JPanel compiledPanel = new JPanel(new BorderLayout()); compiledPanel.add(scrollCompiled, BorderLayout.CENTER); compiledPanel.add(bpCompiled, BorderLayout.SOUTH); iFindAll = new JMenuItem("in all scripts"); iFindThis = new JMenuItem("in this script only"); iFindUsage = new JMenuItem("references to this script"); ButtonPopupMenu bpmFind = (ButtonPopupMenu) buttonPanel.addControl(ButtonPanel.Control.FIND_MENU); bpmFind.setMenuItems(new JMenuItem[] { iFindAll, iFindThis, iFindUsage }); bpmFind.addItemListener(this); ButtonPopupMenu bpmUses = new ButtonPopupMenu("Uses...", new JMenuItem[] {}); bpmUses.setIcon(Icons.ICON_FIND_16.getIcon()); bpmUses.addItemListener(this); buttonPanel.addControl(bpmUses, CTRL_USES); iExportScript = new JMenuItem("script code"); iExportSource = new JMenuItem("script source"); iExportScript.setToolTipText("NB! Will export last *saved* version"); ButtonPopupMenu bpmExport = (ButtonPopupMenu) buttonPanel.addControl(ButtonPanel.Control.EXPORT_MENU); bpmExport.setMenuItems(new JMenuItem[] { iExportScript, iExportSource }); bpmExport.addItemListener(this); JButton bSave = (JButton) buttonPanel.addControl(ButtonPanel.Control.SAVE); bSave.addActionListener(this); JButton bSaveAs = (JButton) buttonPanel.addControl(ButtonPanel.Control.SAVE_AS); bSaveAs.addActionListener(this); tabbedPane = new JTabbedPane(); tabbedPane.addTab("Script source (decompiled)", decompiledPanel); tabbedPane.addTab("Script code", compiledPanel); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(tabbedPane, BorderLayout.CENTER); panel.add(buttonPanel, BorderLayout.SOUTH); decompile(); if (BrowserMenuBar.getInstance().getOptions().autocheckBCS()) { compile(); codeChanged = false; } else { bCompile.setEnabled(true); bpmErrors.setEnabled(false); bpmWarnings.setEnabled(false); } bDecompile.setEnabled(false); bSave.setEnabled(false); bSaveAs.setEnabled(false); return panel; } // --------------------- End Interface Viewable --------------------- // --------------------- Begin Interface Writeable --------------------- @Override public void write(OutputStream os) throws IOException { if (codeText == null) { StreamUtils.writeString(os, text, text.length()); } else { StreamUtils.writeString(os, codeText.getText(), codeText.getText().length()); } } // --------------------- End Interface Writeable --------------------- public String getCode() { return text; } public void insertString(String s) { int pos = sourceText.getCaret().getDot(); sourceText.insert(s, pos); } private void compile() { JButton bCompile = (JButton) bpDecompile.getControlByType(CTRL_COMPILE); JButton bDecompile = (JButton) bpCompiled.getControlByType(CTRL_DECOMPILE); ButtonPopupMenu bpmErrors = (ButtonPopupMenu) bpDecompile.getControlByType(CTRL_ERRORS); ButtonPopupMenu bpmWarnings = (ButtonPopupMenu) bpDecompile.getControlByType(CTRL_WARNINGS); Compiler compiler = new Compiler(sourceText.getText()); codeText.setText(compiler.getCode()); codeText.setCaretPosition(0); bCompile.setEnabled(false); bDecompile.setEnabled(false); sourceChanged = false; codeChanged = true; iExportScript.setEnabled(compiler.getErrors().size() == 0); SortedSet<ScriptMessage> errorMap = compiler.getErrors(); SortedSet<ScriptMessage> warningMap = compiler.getWarnings(); sourceText.clearGutterIcons(); bpmErrors.setText("Errors (" + errorMap.size() + ")..."); bpmWarnings.setText("Warnings (" + warningMap.size() + ")..."); if (errorMap.size() == 0) { bpmErrors.setEnabled(false); } else { JMenuItem errorItems[] = new JMenuItem[errorMap.size()]; int counter = 0; for (final ScriptMessage sm : errorMap) { sourceText.setLineError(sm.getLine(), sm.getMessage(), false); errorItems[counter++] = new DataMenuItem(sm.getLine() + ": " + sm.getMessage(), null, sm); } bpmErrors.setMenuItems(errorItems, false); bpmErrors.setEnabled(true); } if (warningMap.size() == 0) { bpmWarnings.setEnabled(false); } else { JMenuItem warningItems[] = new JMenuItem[warningMap.size()]; int counter = 0; for (final ScriptMessage sm : warningMap) { sourceText.setLineWarning(sm.getLine(), sm.getMessage(), false); warningItems[counter++] = new DataMenuItem(sm.getLine() + ": " + sm.getMessage(), null, sm); } bpmWarnings.setMenuItems(warningItems, false); bpmWarnings.setEnabled(true); } } private void decompile() { JButton bDecompile = (JButton) bpDecompile.getControlByType(CTRL_DECOMPILE); JButton bCompile = (JButton) bpDecompile.getControlByType(CTRL_COMPILE); ButtonPopupMenu bpmUses = (ButtonPopupMenu) buttonPanel.getControlByType(CTRL_USES); Decompiler decompiler = new Decompiler(codeText.getText(), true); decompiler.setGenerateComments(BrowserMenuBar.getInstance().getOptions().autogenBCSComments()); try { sourceText.setText(decompiler.getSource()); } catch (Exception e) { e.printStackTrace(); sourceText.setText("/*\nError: " + e.getMessage() + "\n*/"); } sourceText.setCaretPosition(0); Set<ResourceEntry> uses = decompiler.getResourcesUsed(); JMenuItem usesItems[] = new JMenuItem[uses.size()]; int usesIndex = 0; for (final ResourceEntry usesEntry : uses) { if (usesEntry.getSearchString() != null) { usesItems[usesIndex++] = new JMenuItem(usesEntry.getResourceName() + " (" + usesEntry.getSearchString() + ')'); } else { usesItems[usesIndex++] = new JMenuItem(usesEntry.toString()); } } bpmUses.setMenuItems(usesItems); bpmUses.setEnabled(usesItems.length > 0); bCompile.setEnabled(false); bDecompile.setEnabled(false); sourceChanged = false; tabbedPane.setSelectedIndex(0); } private void save(boolean interactive) { final JButton bSave = (JButton) buttonPanel.getControlByType(ButtonPanel.Control.SAVE); final JButton bSaveAs = (JButton) buttonPanel.getControlByType(ButtonPanel.Control.SAVE_AS); final ButtonPopupMenu bpmErrors = (ButtonPopupMenu) bpDecompile.getControlByType(CTRL_ERRORS); if (bpmErrors.isEnabled()) { String options[] = { "Save", "Cancel" }; int result = JOptionPane.showOptionDialog(panel, "Script contains errors. Save anyway?", "Errors found", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (result != 0) { return; } } final boolean result; if (interactive) { result = ResourceFactory.saveResourceAs(this, panel.getTopLevelAncestor()); } else { result = ResourceFactory.saveResource(this, panel.getTopLevelAncestor()); } if (result) { bSave.setEnabled(false); bSaveAs.setEnabled(false); sourceChanged = false; codeChanged = false; } } }
Argent77/NearInfinity
src/org/infinity/resource/bcs/BcsResource.java
800
// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. package org.uma.jmetal.algorithm.multiobjective.smpso; import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.impl.AbstractParticleSwarmOptimization; import org.uma.jmetal.operator.mutation.MutationOperator; import org.uma.jmetal.problem.doubleproblem.DoubleProblem; import org.uma.jmetal.solution.doublesolution.DoubleSolution; import org.uma.jmetal.util.archive.BoundedArchive; import org.uma.jmetal.util.archivewithreferencepoint.ArchiveWithReferencePoint; import org.uma.jmetal.util.bounds.Bounds; import org.uma.jmetal.util.comparator.dominanceComparator.DominanceComparator; import org.uma.jmetal.util.evaluator.SolutionListEvaluator; import org.uma.jmetal.util.measure.Measurable; import org.uma.jmetal.util.measure.MeasureManager; import org.uma.jmetal.util.measure.impl.BasicMeasure; import org.uma.jmetal.util.measure.impl.CountingMeasure; import org.uma.jmetal.util.measure.impl.SimpleMeasureManager; import org.uma.jmetal.util.pseudorandom.JMetalRandom; import org.uma.jmetal.util.solutionattribute.impl.GenericSolutionAttribute; /** * This class implements the SMPSORP algorithm described in: "Extending the Speed-constrained * Multi-Objective PSO (SMPSO) With Reference Point Based Preference Articulation. Antonio J. Nebro, * Juan J. Durillo, José García-Nieto, Cristóbal Barba-González, Javier Del Ser, Carlos A. Coello * Coello, Antonio Benítez-Hidalgo, José F. Aldana-Montes. Parallel Problem Solving from Nature -- * PPSN XV. Lecture Notes In Computer Science, Vol. 11101, pp. 298-310. 2018". * * @author Antonio J. Nebro <[email protected]> */ @SuppressWarnings("serial") public class SMPSORP extends AbstractParticleSwarmOptimization<DoubleSolution, List<DoubleSolution>> implements Measurable { private DoubleProblem problem; private double c1Max; private double c1Min; private double c2Max; private double c2Min; private double r1Max; private double r1Min; private double r2Max; private double r2Min; private double weightMax; private double weightMin; private double changeVelocity1; private double changeVelocity2; protected int swarmSize; protected int maxIterations; protected int iterations; private GenericSolutionAttribute<DoubleSolution, DoubleSolution> localBest; private double[][] speed; private JMetalRandom randomGenerator; public List<ArchiveWithReferencePoint<DoubleSolution>> leaders; private DominanceComparator<DoubleSolution> dominanceComparator; private MutationOperator<DoubleSolution> mutation; protected double deltaMax[]; protected double deltaMin[]; protected SolutionListEvaluator<DoubleSolution> evaluator; protected List<List<Double>> referencePoints; protected CountingMeasure currentIteration; protected SimpleMeasureManager measureManager; protected BasicMeasure<List<DoubleSolution>> solutionListMeasure; private List<DoubleSolution> referencePointSolutions; /** * Constructor */ public SMPSORP(DoubleProblem problem, int swarmSize, List<ArchiveWithReferencePoint<DoubleSolution>> leaders, List<List<Double>> referencePoints, MutationOperator<DoubleSolution> mutationOperator, int maxIterations, double r1Min, double r1Max, double r2Min, double r2Max, double c1Min, double c1Max, double c2Min, double c2Max, double weightMin, double weightMax, double changeVelocity1, double changeVelocity2, DominanceComparator<DoubleSolution> dominanceComparator, SolutionListEvaluator<DoubleSolution> evaluator) { this.problem = problem; this.swarmSize = swarmSize; this.leaders = leaders; this.mutation = mutationOperator; this.maxIterations = maxIterations; this.referencePoints = referencePoints; this.r1Max = r1Max; this.r1Min = r1Min; this.r2Max = r2Max; this.r2Min = r2Min; this.c1Max = c1Max; this.c1Min = c1Min; this.c2Max = c2Max; this.c2Min = c2Min; this.weightMax = weightMax; this.weightMin = weightMin; this.changeVelocity1 = changeVelocity1; this.changeVelocity2 = changeVelocity2; randomGenerator = JMetalRandom.getInstance(); this.evaluator = evaluator; this.dominanceComparator = dominanceComparator; localBest = new GenericSolutionAttribute<>(); speed = new double[swarmSize][problem.numberOfVariables()]; deltaMax = new double[problem.numberOfVariables()]; deltaMin = new double[problem.numberOfVariables()]; for (int i = 0; i < problem.numberOfVariables(); i++) { Bounds<Double> bounds = problem.variableBounds().get(i); deltaMax[i] = (bounds.getUpperBound() - bounds.getLowerBound()) / 2.0; deltaMin[i] = -deltaMax[i]; } currentIteration = new CountingMeasure(0); solutionListMeasure = new BasicMeasure<>(); measureManager = new SimpleMeasureManager(); measureManager.setPushMeasure("currentPopulation", solutionListMeasure); measureManager.setPushMeasure("currentIteration", currentIteration); referencePointSolutions = new ArrayList<>(); for (int i = 0; i < referencePoints.size(); i++) { DoubleSolution refPoint = problem.createSolution(); for (int j = 0; j < referencePoints.get(0).size(); j++) { refPoint.objectives()[j] = referencePoints.get(i).get(j); } referencePointSolutions.add(refPoint); } } protected void updateLeadersDensityEstimator() { for (BoundedArchive<DoubleSolution> leader : leaders) { leader.computeDensityEstimator(); } } @Override protected void initProgress() { iterations = 1; currentIteration.reset(1); updateLeadersDensityEstimator(); } @Override protected void updateProgress() { iterations += 1; currentIteration.increment(1); updateLeadersDensityEstimator(); solutionListMeasure.push(result()); } @Override protected boolean isStoppingConditionReached() { return iterations >= maxIterations; } @Override protected List<DoubleSolution> createInitialSwarm() { List<DoubleSolution> swarm = new ArrayList<>(swarmSize); DoubleSolution newSolution; for (int i = 0; i < swarmSize; i++) { newSolution = problem.createSolution(); swarm.add(newSolution); } return swarm; } @Override protected List<DoubleSolution> evaluateSwarm(List<DoubleSolution> swarm) { swarm = evaluator.evaluate(swarm, problem); return swarm; } @Override protected void initializeLeader(List<DoubleSolution> swarm) { for (DoubleSolution particle : swarm) { for (BoundedArchive<DoubleSolution> leader : leaders) { leader.add((DoubleSolution) particle.copy()); } } } @Override protected void initializeVelocity(List<DoubleSolution> swarm) { for (int i = 0; i < swarm.size(); i++) { for (int j = 0; j < problem.numberOfVariables(); j++) { speed[i][j] = 0.0; } } } @Override protected void initializeParticlesMemory(List<DoubleSolution> swarm) { for (DoubleSolution particle : swarm) { localBest.setAttribute(particle, (DoubleSolution) particle.copy()); } } @Override protected void updateVelocity(List<DoubleSolution> swarm) { double r1, r2, c1, c2; double wmax, wmin; DoubleSolution bestGlobal; for (int i = 0; i < swarm.size(); i++) { DoubleSolution particle = (DoubleSolution) swarm.get(i).copy(); DoubleSolution bestParticle = (DoubleSolution) localBest.getAttribute(swarm.get(i)).copy(); bestGlobal = selectGlobalBest(); r1 = randomGenerator.nextDouble(r1Min, r1Max); r2 = randomGenerator.nextDouble(r2Min, r2Max); c1 = randomGenerator.nextDouble(c1Min, c1Max); c2 = randomGenerator.nextDouble(c2Min, c2Max); wmax = weightMax; wmin = weightMin; for (int var = 0; var < particle.variables().size(); var++) { speed[i][var] = velocityConstriction(constrictionCoefficient(c1, c2) * ( inertiaWeight(iterations, maxIterations, wmax, wmin) * speed[i][var] + c1 * r1 * (bestParticle.variables().get(var) - particle.variables().get(var)) + c2 * r2 * (bestGlobal.variables().get(var) - particle.variables().get(var))), deltaMax, deltaMin, var); } } } @Override protected void updatePosition(List<DoubleSolution> swarm) { for (int i = 0; i < swarmSize; i++) { DoubleSolution particle = swarm.get(i); for (int j = 0; j < particle.variables().size(); j++) { particle.variables().set(j, particle.variables().get(j) + speed[i][j]); Bounds<Double> bounds = problem.variableBounds().get(j); Double lowerBound = bounds.getLowerBound(); Double upperBound = bounds.getUpperBound(); if (particle.variables().get(j) < lowerBound) { particle.variables().set(j, lowerBound); speed[i][j] = speed[i][j] * changeVelocity1; } if (particle.variables().get(j) > upperBound) { particle.variables().set(j, upperBound); speed[i][j] = speed[i][j] * changeVelocity2; } } } } @Override protected void perturbation(List<DoubleSolution> swarm) { for (int i = 0; i < swarm.size(); i++) { if ((i % 6) == 0) { mutation.execute(swarm.get(i)); } } } @Override protected void updateLeaders(List<DoubleSolution> swarm) { for (DoubleSolution particle : swarm) { for (BoundedArchive<DoubleSolution> leader : leaders) { leader.add((DoubleSolution) particle.copy()); } } } @Override protected void updateParticlesMemory(List<DoubleSolution> swarm) { for (int i = 0; i < swarm.size(); i++) { int flag = dominanceComparator.compare(swarm.get(i), localBest.getAttribute(swarm.get(i))); if (flag != 1) { DoubleSolution particle = (DoubleSolution) swarm.get(i).copy(); localBest.setAttribute(swarm.get(i), particle); } } } @Override public List<DoubleSolution> result() { List<DoubleSolution> resultList = new ArrayList<>(); for (BoundedArchive<DoubleSolution> leader : leaders) { for (DoubleSolution solution : leader.solutions()) { resultList.add(solution); } } return resultList; } protected DoubleSolution selectGlobalBest() { int selectedSwarmIndex; selectedSwarmIndex = randomGenerator.nextInt(0, leaders.size() - 1); BoundedArchive<DoubleSolution> selectedSwarm = leaders.get(selectedSwarmIndex); DoubleSolution one, two; DoubleSolution bestGlobal; int pos1 = randomGenerator.nextInt(0, selectedSwarm.solutions().size() - 1); int pos2 = randomGenerator.nextInt(0, selectedSwarm.solutions().size() - 1); one = selectedSwarm.solutions().get(pos1); two = selectedSwarm.solutions().get(pos2); if (selectedSwarm.comparator().compare(one, two) < 1) { bestGlobal = (DoubleSolution) one.copy(); } else { bestGlobal = (DoubleSolution) two.copy(); } return bestGlobal; } private double velocityConstriction(double v, double[] deltaMax, double[] deltaMin, int variableIndex) { double result; double dmax = deltaMax[variableIndex]; double dmin = deltaMin[variableIndex]; result = v; if (v > dmax) { result = dmax; } if (v < dmin) { result = dmin; } return result; } private double constrictionCoefficient(double c1, double c2) { double rho = c1 + c2; if (rho <= 4) { return 1.0; } else { return 2 / (2 - rho - Math.sqrt(Math.pow(rho, 2.0) - 4.0 * rho)); } } private double inertiaWeight(int iter, int miter, double wma, double wmin) { return wma; } @Override public String name() { return "SMPSO/RP"; } @Override public String description() { return "Speed contrained Multiobjective PSO"; } @Override public MeasureManager getMeasureManager() { return measureManager; } public void removeDominatedSolutionsInArchives() { for (ArchiveWithReferencePoint<DoubleSolution> archive : leaders) { int i = 0; while (i < archive.solutions().size()) { boolean dominated = false; for (DoubleSolution referencePoint : referencePointSolutions) { if (dominanceComparator.compare(archive.solutions().get(i), referencePoint) == 0) { dominated = true; } } if (dominated) { archive.solutions().remove(i); } else { i++; } } } } public synchronized void changeReferencePoints(List<List<Double>> referencePoints) { for (int i = 0; i < leaders.size(); i++) { leaders.get(i).changeReferencePoint(referencePoints.get(i)); } } public List<DoubleSolution> getReferencePointSolutions() { return referencePointSolutions; } public void setReferencePointSolutions(List<DoubleSolution> referencePointSolutions) { this.referencePointSolutions = referencePointSolutions; } }
jMetal/jMetal
jmetal-algorithm/src/main/java/org/uma/jmetal/algorithm/multiobjective/smpso/SMPSORP.java
802
/* * Copyright (C) 2011 The Guava Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package com.google.common.base; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import java.io.Serializable; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; import javax.annotation.CheckForNull; /** * Utility methods for working with {@link Enum} instances. * * @author Steve McKay * @since 9.0 */ @GwtIncompatible @J2ktIncompatible @ElementTypesAreNonnullByDefault public final class Enums { private Enums() {} /** * Returns the {@link Field} in which {@code enumValue} is defined. For example, to get the {@code * Description} annotation on the {@code GOLF} constant of enum {@code Sport}, use {@code * Enums.getField(Sport.GOLF).getAnnotation(Description.class)}. * * @since 12.0 */ @GwtIncompatible // reflection public static Field getField(Enum<?> enumValue) { Class<?> clazz = enumValue.getDeclaringClass(); try { return clazz.getDeclaredField(enumValue.name()); } catch (NoSuchFieldException impossible) { throw new AssertionError(impossible); } } /** * Returns an optional enum constant for the given type, using {@link Enum#valueOf}. If the * constant does not exist, {@link Optional#absent} is returned. A common use case is for parsing * user input or falling back to a default enum constant. For example, {@code * Enums.getIfPresent(Country.class, countryInput).or(Country.DEFAULT);} * * @since 12.0 */ public static <T extends Enum<T>> Optional<T> getIfPresent(Class<T> enumClass, String value) { checkNotNull(enumClass); checkNotNull(value); return Platform.getEnumIfPresent(enumClass, value); } @GwtIncompatible // java.lang.ref.WeakReference private static final Map<Class<? extends Enum<?>>, Map<String, WeakReference<? extends Enum<?>>>> enumConstantCache = new WeakHashMap<>(); @GwtIncompatible // java.lang.ref.WeakReference private static <T extends Enum<T>> Map<String, WeakReference<? extends Enum<?>>> populateCache( Class<T> enumClass) { Map<String, WeakReference<? extends Enum<?>>> result = new HashMap<>(); for (T enumInstance : EnumSet.allOf(enumClass)) { result.put(enumInstance.name(), new WeakReference<Enum<?>>(enumInstance)); } enumConstantCache.put(enumClass, result); return result; } @GwtIncompatible // java.lang.ref.WeakReference static <T extends Enum<T>> Map<String, WeakReference<? extends Enum<?>>> getEnumConstants( Class<T> enumClass) { synchronized (enumConstantCache) { Map<String, WeakReference<? extends Enum<?>>> constants = enumConstantCache.get(enumClass); if (constants == null) { constants = populateCache(enumClass); } return constants; } } /** * Returns a serializable converter that converts between strings and {@code enum} values of type * {@code enumClass} using {@link Enum#valueOf(Class, String)} and {@link Enum#name()}. The * converter will throw an {@code IllegalArgumentException} if the argument is not the name of any * enum constant in the specified enum. * * @since 16.0 */ @GwtIncompatible public static <T extends Enum<T>> Converter<String, T> stringConverter(Class<T> enumClass) { return new StringConverter<>(enumClass); } @GwtIncompatible private static final class StringConverter<T extends Enum<T>> extends Converter<String, T> implements Serializable { private final Class<T> enumClass; StringConverter(Class<T> enumClass) { this.enumClass = checkNotNull(enumClass); } @Override protected T doForward(String value) { return Enum.valueOf(enumClass, value); } @Override protected String doBackward(T enumValue) { return enumValue.name(); } @Override public boolean equals(@CheckForNull Object object) { if (object instanceof StringConverter) { StringConverter<?> that = (StringConverter<?>) object; return this.enumClass.equals(that.enumClass); } return false; } @Override public int hashCode() { return enumClass.hashCode(); } @Override public String toString() { return "Enums.stringConverter(" + enumClass.getName() + ".class)"; } private static final long serialVersionUID = 0L; } }
google/guava
android/guava/src/com/google/common/base/Enums.java
805
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.script; import org.elasticsearch.common.util.set.Sets; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.AbstractSet; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; /** * A scripting ctx map with metadata for write ingest contexts. Delegates all metadata updates to metadata and * all other updates to source. Implements the {@link Map} interface for backwards compatibility while performing * validation via {@link Metadata}. */ public class CtxMap<T extends Metadata> extends AbstractMap<String, Object> { protected static final String SOURCE = "_source"; protected Map<String, Object> source; protected final T metadata; /** * Create CtxMap from a source and metadata * * @param source the source document map * @param metadata the metadata map */ public CtxMap(Map<String, Object> source, T metadata) { this.source = source; this.metadata = metadata; Set<String> badKeys = Sets.intersection(this.metadata.keySet(), this.source.keySet()); if (badKeys.size() > 0) { throw new IllegalArgumentException( "unexpected metadata [" + badKeys.stream().sorted().map(k -> k + ":" + this.source.get(k)).collect(Collectors.joining(", ")) + "] in source" ); } } /** * Does this access to the internal {@link #source} map occur directly via ctx? ie {@code ctx['myField']}. * Or does it occur via the {@link #SOURCE} key? ie {@code ctx['_source']['myField']}. * * Defaults to indirect, {@code ctx['_source']} */ protected boolean directSourceAccess() { return false; } /** * get the source map, if externally modified then the guarantees of this class are not enforced */ public final Map<String, Object> getSource() { return source; } /** * get the metadata map, if externally modified then the guarantees of this class are not enforced */ public T getMetadata() { return metadata; } /** * Returns an entrySet that respects the validators of the map. */ @Override public Set<Map.Entry<String, Object>> entrySet() { // Make a copy of the Metadata.keySet() to avoid a ConcurrentModificationException when removing a value from the iterator Set<Map.Entry<String, Object>> sourceEntries = directSourceAccess() ? source.entrySet() : Set.of(new IndirectSourceEntry()); return new EntrySet(sourceEntries, new HashSet<>(metadata.keySet())); } /** * Associate a key with a value. If the key has a validator, it is applied before association. * @throws IllegalArgumentException if value does not pass validation for the given key */ @Override public Object put(String key, Object value) { if (metadata.isAvailable(key)) { return metadata.put(key, value); } if (directSourceAccess()) { return source.put(key, value); } else if (SOURCE.equals(key)) { return replaceSource(value); } throw new IllegalArgumentException("Cannot put key [" + key + "] with value [" + value + "] into ctx"); } private Object replaceSource(Object value) { if (value instanceof Map == false) { throw new IllegalArgumentException( "Expected [" + SOURCE + "] to be a Map, not [" + value + "]" + (value != null ? " with type [" + value.getClass().getName() + "]" : "") ); } var oldSource = source; source = castSourceMap(value); return oldSource; } @SuppressWarnings({ "unchecked", "raw" }) private static Map<String, Object> castSourceMap(Object value) { return (Map<String, Object>) value; } /** * Remove the mapping of key. If the key has a validator, it is checked before key removal. * @throws IllegalArgumentException if the validator does not allow the key to be removed */ @Override public Object remove(Object key) { // uses map directly to avoid AbstractMaps linear time implementation using entrySet() if (key instanceof String str) { if (metadata.isAvailable(str)) { return metadata.remove(str); } } if (directSourceAccess()) { return source.remove(key); } else { throw new UnsupportedOperationException("Cannot remove key " + key + " from ctx"); } } /** * Clear entire map. For each key in the map with a validator, that validator is checked as in {@link #remove(Object)}. * @throws IllegalArgumentException if any validator does not allow the key to be removed, in this case the map is unmodified */ @Override public void clear() { // AbstractMap uses entrySet().clear(), it should be quicker to run through the validators, then call the wrapped maps clear for (String key : metadata.keySet()) { metadata.remove(key); } // TODO: this is just bogus, there isn't any case where metadata won't trip a failure above? source.clear(); } @Override public int size() { // uses map directly to avoid creating an EntrySet via AbstractMaps implementation, which returns entrySet().size() final int sourceSize = directSourceAccess() ? source.size() : 1; return sourceSize + metadata.size(); } @Override public boolean containsValue(Object value) { // uses map directly to avoid AbstractMaps linear time implementation using entrySet() return metadata.containsValue(value) || (directSourceAccess() ? source.containsValue(value) : source.equals(value)); } @Override public boolean containsKey(Object key) { // uses map directly to avoid AbstractMaps linear time implementation using entrySet() if (key instanceof String str) { if (metadata.isAvailable(str)) { return metadata.containsKey(str); } return directSourceAccess() ? source.containsKey(key) : SOURCE.equals(key); } return false; } @Override public Object get(Object key) { // uses map directly to avoid AbstractMaps linear time implementation using entrySet() if (key instanceof String str) { if (metadata.isAvailable(str)) { return metadata.get(str); } } return directSourceAccess() ? source.get(key) : (SOURCE.equals(key) ? source : null); } /** * Set of entries of the wrapped map that calls the appropriate validator before changing an entries value or removing an entry. * * Inherits {@link AbstractSet#removeAll(Collection)}, which calls the overridden {@link #remove(Object)} which performs validation. * * Inherits {@link AbstractCollection#retainAll(Collection)} and {@link AbstractCollection#clear()}, which both use * {@link EntrySetIterator#remove()} for removal. */ class EntrySet extends AbstractSet<Map.Entry<String, Object>> { Set<Map.Entry<String, Object>> sourceSet; Set<String> metadataKeys; EntrySet(Set<Map.Entry<String, Object>> sourceSet, Set<String> metadataKeys) { this.sourceSet = sourceSet; this.metadataKeys = metadataKeys; } @Override public Iterator<Map.Entry<String, Object>> iterator() { return new EntrySetIterator(sourceSet.iterator(), metadataKeys.iterator()); } @Override public int size() { return sourceSet.size() + metadataKeys.size(); } @Override public boolean remove(Object o) { if (o instanceof Map.Entry<?, ?> entry) { if (entry.getKey() instanceof String key) { if (metadata.containsKey(key)) { if (Objects.equals(entry.getValue(), metadata.get(key))) { metadata.remove(key); return true; } } } } return sourceSet.remove(o); } } /** * Iterator over the wrapped map that returns a validating {@link Entry} on {@link #next()} and validates on {@link #remove()}. * * {@link #remove()} is called by remove in {@link AbstractMap#values()}, {@link AbstractMap#keySet()}, {@link AbstractMap#clear()} via * {@link AbstractSet#clear()} */ class EntrySetIterator implements Iterator<Map.Entry<String, Object>> { final Iterator<Map.Entry<String, Object>> sourceIter; final Iterator<String> metadataKeyIter; boolean sourceCur = true; Map.Entry<String, Object> cur; EntrySetIterator(Iterator<Map.Entry<String, Object>> sourceIter, Iterator<String> metadataKeyIter) { this.sourceIter = sourceIter; this.metadataKeyIter = metadataKeyIter; } @Override public boolean hasNext() { return sourceIter.hasNext() || metadataKeyIter.hasNext(); } @Override public Map.Entry<String, Object> next() { sourceCur = sourceIter.hasNext(); return cur = sourceCur ? sourceIter.next() : new Entry(metadataKeyIter.next()); } /** * Remove current entry from the backing Map. Checks the Entry's key's validator, if one exists, before removal. * @throws IllegalArgumentException if the validator does not allow the Entry to be removed * @throws IllegalStateException if remove is called before {@link #next()} */ @Override public void remove() { if (cur == null) { throw new IllegalStateException(); } if (sourceCur) { try { sourceIter.remove(); } catch (UnsupportedOperationException e) { // UnsupportedOperationException's message is "remove", rethrowing with more helpful message throw new UnsupportedOperationException("Cannot remove key [" + cur.getKey() + "] from ctx"); } } else { metadata.remove(cur.getKey()); } } } private class IndirectSourceEntry implements Map.Entry<String, Object> { @Override public String getKey() { return SOURCE; } @Override public Object getValue() { return source; } @Override public Object setValue(Object value) { return replaceSource(value); } } /** * Map.Entry that stores metadata key and calls into {@link #metadata} for {@link #setValue} */ class Entry implements Map.Entry<String, Object> { final String key; Entry(String key) { this.key = key; } @Override public String getKey() { return key; } @Override public Object getValue() { return metadata.get(key); } @Override public Object setValue(Object value) { return metadata.put(key, value); } } @Override public boolean equals(Object o) { if (this == o) return true; if ((o instanceof CtxMap) == false) return false; if (super.equals(o) == false) return false; CtxMap<?> ctxMap = (CtxMap<?>) o; return source.equals(ctxMap.source) && metadata.equals(ctxMap.metadata); } @Override public int hashCode() { return Objects.hash(source, metadata); } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/script/CtxMap.java
809
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ package org.tensorflow.lite; import java.io.File; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Map; import org.checkerframework.checker.nullness.qual.NonNull; /** * Driver class to drive model inference with TensorFlow Lite. * * <p>Note: If you don't need access to any of the "experimental" API features below, prefer to use * InterpreterApi and InterpreterFactory rather than using Interpreter directly. * * <p>A {@code Interpreter} encapsulates a pre-trained TensorFlow Lite model, in which operations * are executed for model inference. * * <p>For example, if a model takes only one input and returns only one output: * * <pre>{@code * try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) { * interpreter.run(input, output); * } * }</pre> * * <p>If a model takes multiple inputs or outputs: * * <pre>{@code * Object[] inputs = {input0, input1, ...}; * Map<Integer, Object> map_of_indices_to_outputs = new HashMap<>(); * FloatBuffer ith_output = FloatBuffer.allocateDirect(3 * 2 * 4); // Float tensor, shape 3x2x4. * ith_output.order(ByteOrder.nativeOrder()); * map_of_indices_to_outputs.put(i, ith_output); * try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) { * interpreter.runForMultipleInputsOutputs(inputs, map_of_indices_to_outputs); * } * }</pre> * * <p>If a model takes or produces string tensors: * * <pre>{@code * String[] input = {"foo", "bar"}; // Input tensor shape is [2]. * String[][] output = new String[3][2]; // Output tensor shape is [3, 2]. * try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) { * interpreter.runForMultipleInputsOutputs(input, output); * } * }</pre> * * <p>Note that there's a distinction between shape [] and shape[1]. For scalar string tensor * outputs: * * <pre>{@code * String[] input = {"foo"}; // Input tensor shape is [1]. * ByteBuffer outputBuffer = ByteBuffer.allocate(OUTPUT_BYTES_SIZE); // Output tensor shape is []. * try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) { * interpreter.runForMultipleInputsOutputs(input, outputBuffer); * } * byte[] outputBytes = new byte[outputBuffer.remaining()]; * outputBuffer.get(outputBytes); * // Below, the `charset` can be StandardCharsets.UTF_8. * String output = new String(outputBytes, charset); * }</pre> * * <p>Orders of inputs and outputs are determined when converting TensorFlow model to TensorFlowLite * model with Toco, as are the default shapes of the inputs. * * <p>When inputs are provided as (multi-dimensional) arrays, the corresponding input tensor(s) will * be implicitly resized according to that array's shape. When inputs are provided as {@code Buffer} * types, no implicit resizing is done; the caller must ensure that the {@code Buffer} byte size * either matches that of the corresponding tensor, or that they first resize the tensor via {@link * #resizeInput(int, int[])}. Tensor shape and type information can be obtained via the {@link * Tensor} class, available via {@link #getInputTensor(int)} and {@link #getOutputTensor(int)}. * * <p><b>WARNING:</b>{@code Interpreter} instances are <b>not</b> thread-safe. A {@code Interpreter} * owns resources that <b>must</b> be explicitly freed by invoking {@link #close()} * * <p>The TFLite library is built against NDK API 19. It may work for Android API levels below 19, * but is not guaranteed. */ public final class Interpreter extends InterpreterImpl implements InterpreterApi { /** An options class for controlling runtime interpreter behavior. */ public static class Options extends InterpreterImpl.Options { public Options() {} public Options(InterpreterApi.Options options) { super(options); } Options(InterpreterImpl.Options options) { super(options); } @Override public Options setUseXNNPACK(boolean useXNNPACK) { super.setUseXNNPACK(useXNNPACK); return this; } @Override public Options setNumThreads(int numThreads) { super.setNumThreads(numThreads); return this; } @Override public Options setUseNNAPI(boolean useNNAPI) { super.setUseNNAPI(useNNAPI); return this; } /** * Sets whether to allow float16 precision for FP32 calculation when possible. Defaults to false * (disallow). * * @deprecated Prefer using <a * href="https://github.com/tensorflow/tensorflow/blob/5dc7f6981fdaf74c8c5be41f393df705841fb7c5/tensorflow/lite/delegates/nnapi/java/src/main/java/org/tensorflow/lite/nnapi/NnApiDelegate.java#L127">NnApiDelegate.Options#setAllowFp16(boolean * enable)</a>. */ @Deprecated public Options setAllowFp16PrecisionForFp32(boolean allow) { this.allowFp16PrecisionForFp32 = allow; return this; } @Override public Options addDelegate(Delegate delegate) { super.addDelegate(delegate); return this; } @Override public Options addDelegateFactory(DelegateFactory delegateFactory) { super.addDelegateFactory(delegateFactory); return this; } /** * Advanced: Set if buffer handle output is allowed. * * <p>When a {@link Delegate} supports hardware acceleration, the interpreter will make the data * of output tensors available in the CPU-allocated tensor buffers by default. If the client can * consume the buffer handle directly (e.g. reading output from OpenGL texture), it can set this * flag to false, avoiding the copy of data to the CPU buffer. The delegate documentation should * indicate whether this is supported and how it can be used. * * <p>WARNING: This is an experimental interface that is subject to change. */ public Options setAllowBufferHandleOutput(boolean allow) { this.allowBufferHandleOutput = allow; return this; } @Override public Options setCancellable(boolean allow) { super.setCancellable(allow); return this; } @Override public Options setRuntime(InterpreterApi.Options.TfLiteRuntime runtime) { super.setRuntime(runtime); return this; } } /** * Initializes an {@code Interpreter}. * * @param modelFile a File of a pre-trained TF Lite model. * @throws IllegalArgumentException if {@code modelFile} does not encode a valid TensorFlow Lite * model. */ public Interpreter(@NonNull File modelFile) { this(modelFile, /*options = */ null); } /** * Initializes an {@code Interpreter} and specifies options for customizing interpreter behavior. * * @param modelFile a file of a pre-trained TF Lite model * @param options a set of options for customizing interpreter behavior * @throws IllegalArgumentException if {@code modelFile} does not encode a valid TensorFlow Lite * model. */ public Interpreter(@NonNull File modelFile, Options options) { this(new NativeInterpreterWrapperExperimental(modelFile.getAbsolutePath(), options)); } /** * Initializes an {@code Interpreter} with a {@code ByteBuffer} of a model file. * * <p>The ByteBuffer should not be modified after the construction of a {@code Interpreter}. The * {@code ByteBuffer} can be either a {@code MappedByteBuffer} that memory-maps a model file, or a * direct {@code ByteBuffer} of nativeOrder() that contains the bytes content of a model. * * @throws IllegalArgumentException if {@code byteBuffer} is not a {@code MappedByteBuffer} nor a * direct {@code ByteBuffer} of nativeOrder. */ public Interpreter(@NonNull ByteBuffer byteBuffer) { this(byteBuffer, /* options= */ null); } /** * Initializes an {@code Interpreter} with a {@code ByteBuffer} of a model file and a set of * custom {@link Interpreter.Options}. * * <p>The {@code ByteBuffer} should not be modified after the construction of an {@code * Interpreter}. The {@code ByteBuffer} can be either a {@code MappedByteBuffer} that memory-maps * a model file, or a direct {@code ByteBuffer} of nativeOrder() that contains the bytes content * of a model. * * @throws IllegalArgumentException if {@code byteBuffer} is not a {@code MappedByteBuffer} nor a * direct {@code ByteBuffer} of nativeOrder. */ public Interpreter(@NonNull ByteBuffer byteBuffer, Options options) { this(new NativeInterpreterWrapperExperimental(byteBuffer, options)); } private Interpreter(NativeInterpreterWrapperExperimental wrapper) { super(wrapper); wrapperExperimental = wrapper; signatureKeyList = getSignatureKeys(); } /** * Runs model inference based on SignatureDef provided through {@code signatureKey}. * * <p>See {@link Interpreter#run(Object, Object)} for more details on the allowed input and output * data types. * * <p>WARNING: This is an experimental API and subject to change. * * @param inputs A map from input name in the SignatureDef to an input object. * @param outputs A map from output name in SignatureDef to output data. This may be empty if the * caller wishes to query the {@link Tensor} data directly after inference (e.g., if the * output shape is dynamic, or output buffer handles are used). * @param signatureKey Signature key identifying the SignatureDef. * @throws IllegalArgumentException if {@code inputs} is null or empty, if {@code outputs} or * {@code signatureKey} is null, or if an error occurs when running inference. */ public void runSignature( @NonNull Map<String, Object> inputs, @NonNull Map<String, Object> outputs, String signatureKey) { checkNotClosed(); if (signatureKey == null && signatureKeyList.length == 1) { signatureKey = signatureKeyList[0]; } if (signatureKey == null) { throw new IllegalArgumentException( "Input error: SignatureDef signatureKey should not be null. null is only allowed if the" + " model has a single Signature. Available Signatures: " + Arrays.toString(signatureKeyList)); } wrapper.runSignature(inputs, outputs, signatureKey); } /** * Same as {@link #runSignature(Map, Map, String)} but doesn't require passing a signatureKey, * assuming the model has one SignatureDef. If the model has more than one SignatureDef it will * throw an exception. * * <p>WARNING: This is an experimental API and subject to change. */ public void runSignature( @NonNull Map<String, Object> inputs, @NonNull Map<String, Object> outputs) { checkNotClosed(); runSignature(inputs, outputs, null); } /** * Gets the Tensor associated with the provided input name and signature method name. * * <p>WARNING: This is an experimental API and subject to change. * * @param inputName Input name in the signature. * @param signatureKey Signature key identifying the SignatureDef, can be null if the model has * one signature. * @throws IllegalArgumentException if {@code inputName} or {@code signatureKey} is null or empty, * or invalid name provided. */ public Tensor getInputTensorFromSignature(String inputName, String signatureKey) { checkNotClosed(); if (signatureKey == null && signatureKeyList.length == 1) { signatureKey = signatureKeyList[0]; } if (signatureKey == null) { throw new IllegalArgumentException( "Input error: SignatureDef signatureKey should not be null. null is only allowed if the" + " model has a single Signature. Available Signatures: " + Arrays.toString(signatureKeyList)); } return wrapper.getInputTensor(inputName, signatureKey); } /** * Gets the list of SignatureDef exported method names available in the model. * * <p>WARNING: This is an experimental API and subject to change. */ public String[] getSignatureKeys() { checkNotClosed(); return wrapper.getSignatureKeys(); } /** * Gets the list of SignatureDefs inputs for method {@code signatureKey}. * * <p>WARNING: This is an experimental API and subject to change. */ public String[] getSignatureInputs(String signatureKey) { checkNotClosed(); return wrapper.getSignatureInputs(signatureKey); } /** * Gets the list of SignatureDefs outputs for method {@code signatureKey}. * * <p>WARNING: This is an experimental API and subject to change. */ public String[] getSignatureOutputs(String signatureKey) { checkNotClosed(); return wrapper.getSignatureOutputs(signatureKey); } /** * Gets the Tensor associated with the provided output name in specific signature method. * * <p>Note: Output tensor details (e.g., shape) may not be fully populated until after inference * is executed. If you need updated details *before* running inference (e.g., after resizing an * input tensor, which may invalidate output tensor shapes), use {@link #allocateTensors()} to * explicitly trigger allocation and shape propagation. Note that, for graphs with output shapes * that are dependent on input *values*, the output shape may not be fully determined until * running inference. * * <p>WARNING: This is an experimental API and subject to change. * * @param outputName Output name in the signature. * @param signatureKey Signature key identifying the SignatureDef, can be null if the model has * one signature. * @throws IllegalArgumentException if {@code outputName} or {@code signatureKey} is null or * empty, or invalid name provided. */ public Tensor getOutputTensorFromSignature(String outputName, String signatureKey) { checkNotClosed(); if (signatureKey == null && signatureKeyList.length == 1) { signatureKey = signatureKeyList[0]; } if (signatureKey == null) { throw new IllegalArgumentException( "Input error: SignatureDef signatureKey should not be null. null is only allowed if the" + " model has a single Signature. Available Signatures: " + Arrays.toString(signatureKeyList)); } return wrapper.getOutputTensor(outputName, signatureKey); } /** * Advanced: Resets all variable tensors to the default value. * * <p>If a variable tensor doesn't have an associated buffer, it will be reset to zero. * * <p>WARNING: This is an experimental API and subject to change. */ public void resetVariableTensors() { checkNotClosed(); wrapperExperimental.resetVariableTensors(); } /** * Advanced: Interrupts inference in the middle of a call to {@link Interpreter#run}. * * <p>A cancellation flag will be set to true when this function gets called. The interpreter will * check the flag between Op invocations, and if it's {@code true}, the interpreter will stop * execution. The interpreter will remain a cancelled state until explicitly "uncancelled" by * {@code setCancelled(false)}. * * <p>WARNING: This is an experimental API and subject to change. * * @param cancelled {@code true} to cancel inference in a best-effort way; {@code false} to * resume. * @throws IllegalStateException if the interpreter is not initialized with the cancellable * option, which is by default off. * @see Interpreter.Options#setCancellable(boolean). */ public void setCancelled(boolean cancelled) { wrapper.setCancelled(cancelled); } private final NativeInterpreterWrapperExperimental wrapperExperimental; private final String[] signatureKeyList; }
tensorflow/tensorflow
tensorflow/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java
815
// Implement a trie with insert, search, and startsWith methods. // Note: // You may assume that all inputs are consist of lowercase letters a-z. // Your Trie object will be instantiated and called as such: // Trie trie = new Trie(); // trie.insert("somestring"); // trie.search("key"); class TrieNode { HashMap<Character, TrieNode> map; char character; boolean last; // Initialize your data structure here. public TrieNode(char character) { this.map = new HashMap<Character, TrieNode>(); this.character = character; this.last = false; } } public class Trie { private TrieNode root; public Trie() { root = new TrieNode(' '); } // Inserts a word into the trie. public void insert(String word) { TrieNode current = root; for(char c : word.toCharArray()) { if(!current.map.containsKey(c)) { current.map.put(c, new TrieNode(c)); } current = current.map.get(c); } current.last = true; } // Returns if the word is in the trie. public boolean search(String word) { TrieNode current = root; for(char c : word.toCharArray()) { if(!current.map.containsKey(c)) { return false; } current = current.map.get(c); } if(current.last == true) { return true; } else { return false; } } // Returns if there is any word in the trie // that starts with the given prefix. public boolean startsWith(String prefix) { TrieNode current = root; for(char c : prefix.toCharArray()) { if(!current.map.containsKey(c)) { return false; } current = current.map.get(c); } return true; } }
kdn251/interviews
company/twitter/ImplementTrie.java
817
import java.io.*; import java.util.*; /************************************************************************************************************************************** * Class Example *****/ class Example implements Debuggable { int domain_id; double current_boosting_weight; // loss = @TemperedLoss => tempered weight // loss = @LogLoss => unnormalized boosting weight Vector typed_features; // features with type, excluding class double initial_class; double unnormalized_class; double normalized_class; double noisy_normalized_class; // class, only for training and in the context of LS model public void affiche() { System.out.println(this); } public String toString() { String v = ""; int i; v += domain_id + " typed features : "; for (i = 0; i < typed_features.size(); i++) v += typed_features.elementAt(i) + " "; v += " -> " + normalized_class + "(" + noisy_normalized_class + "), w = " + current_boosting_weight; return v; } static Vector TO_TYPED_FEATURES(Vector ev, int index_class, Vector fv) { Vector vv = new Vector(); int i; Feature f; for (i = 0; i < fv.size(); i++) { if (i != index_class) { f = (Feature) fv.elementAt(i); if (f.type.equals(Feature.CONTINUOUS)) vv.addElement(new Double(Double.parseDouble((String) ev.elementAt(i)))); else if (f.type.equals(Feature.NOMINAL)) vv.addElement(new String((String) ev.elementAt(i))); } } return vv; } static double VAL_CLASS(Vector ev, int index_class) { return Double.parseDouble(((String) ev.elementAt(index_class))); } Example(int id, Vector v, int index_class, Vector fv) { domain_id = id; typed_features = Example.TO_TYPED_FEATURES(v, index_class, fv); initial_class = Example.VAL_CLASS(v, index_class); unnormalized_class = initial_class; current_boosting_weight = -1.0; } public int checkFeatures(Vector fv, int index_class) { // check that the example has features in the domain, otherwise errs int i, index = 0, vret = 0; Feature f; String fn; double fd; for (i = 0; i < fv.size(); i++) { if (i != index_class) { f = (Feature) fv.elementAt(i); if (f.type.equals(Feature.NOMINAL)) { fn = (String) typed_features.elementAt(index); if (!f.has_in_range(fn)) { Dataset.warning( "Example.class :: nominal attribute value " + fn + " not in range " + f.range() + " for feature " + f.name); vret++; } } index++; } } return vret; } public void complete_normalized_class( double translate_v, double min_v, double max_v, double eta) { // TO Expand for more choices if (max_v != min_v) { if ((Dataset.DEFAULT_INDEX_FIT_CLASS != 0) && (Dataset.DEFAULT_INDEX_FIT_CLASS != 3) && (Dataset.DEFAULT_INDEX_FIT_CLASS != 4)) Dataset.perror( "Example.class :: Choice " + Dataset.DEFAULT_INDEX_FIT_CLASS + " not implemented to fit the class"); normalized_class = Dataset.TRANSLATE_SHRINK( unnormalized_class, translate_v, min_v, max_v, Feature.MAX_CLASS_MAGNITUDE); if (Dataset.DEFAULT_INDEX_FIT_CLASS == 4) normalized_class = Math.signum(normalized_class); unnormalized_class = 0.0; } else normalized_class = max_v; noisy_normalized_class = normalized_class; if (Utils.R.nextDouble() < eta) noisy_normalized_class = -noisy_normalized_class; } public boolean is_positive_noisy() { if (noisy_normalized_class == 0.0) Dataset.perror("Example.class :: normalized class is zero"); if (noisy_normalized_class < 0.0) return false; return true; } }
google-research/google-research
tempered_boosting/Example.java
821
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.rest; import org.apache.lucene.util.SetOnce; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.core.Booleans; import org.elasticsearch.core.CheckedConsumer; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.Tuple; import org.elasticsearch.http.HttpChannel; import org.elasticsearch.http.HttpRequest; import org.elasticsearch.telemetry.tracing.Traceable; import org.elasticsearch.xcontent.ParsedMediaType; import org.elasticsearch.xcontent.ToXContent; import org.elasticsearch.xcontent.XContentParser; import org.elasticsearch.xcontent.XContentParserConfiguration; import org.elasticsearch.xcontent.XContentType; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import java.util.regex.Pattern; import static org.elasticsearch.common.unit.ByteSizeValue.parseBytesSizeValue; import static org.elasticsearch.core.TimeValue.parseTimeValue; public class RestRequest implements ToXContent.Params, Traceable { public static final String PATH_RESTRICTED = "pathRestricted"; // tchar pattern as defined by RFC7230 section 3.2.6 private static final Pattern TCHAR_PATTERN = Pattern.compile("[a-zA-Z0-9!#$%&'*+\\-.\\^_`|~]+"); private static final AtomicLong requestIdGenerator = new AtomicLong(); private final XContentParserConfiguration parserConfig; private final Map<String, String> params; private final Map<String, List<String>> headers; private final String rawPath; private final Set<String> consumedParams = new HashSet<>(); private final SetOnce<XContentType> xContentType = new SetOnce<>(); private final HttpChannel httpChannel; private final ParsedMediaType parsedAccept; private final ParsedMediaType parsedContentType; private final Optional<RestApiVersion> restApiVersion; private HttpRequest httpRequest; private boolean contentConsumed = false; private final long requestId; public boolean isContentConsumed() { return contentConsumed; } @SuppressWarnings("this-escape") protected RestRequest( XContentParserConfiguration parserConfig, Map<String, String> params, String path, Map<String, List<String>> headers, HttpRequest httpRequest, HttpChannel httpChannel ) { this(parserConfig, params, path, headers, httpRequest, httpChannel, requestIdGenerator.incrementAndGet()); } @SuppressWarnings("this-escape") private RestRequest( XContentParserConfiguration parserConfig, Map<String, String> params, String path, Map<String, List<String>> headers, HttpRequest httpRequest, HttpChannel httpChannel, long requestId ) { try { this.parsedAccept = parseHeaderWithMediaType(httpRequest.getHeaders(), "Accept"); } catch (IllegalArgumentException e) { throw new MediaTypeHeaderException(e, "Accept"); } try { this.parsedContentType = parseHeaderWithMediaType(httpRequest.getHeaders(), "Content-Type"); if (parsedContentType != null) { this.xContentType.set(parsedContentType.toMediaType(XContentType.MEDIA_TYPE_REGISTRY)); } } catch (IllegalArgumentException e) { throw new MediaTypeHeaderException(e, "Content-Type"); } this.httpRequest = httpRequest; try { this.restApiVersion = RestCompatibleVersionHelper.getCompatibleVersion(parsedAccept, parsedContentType, hasContent()); } catch (ElasticsearchStatusException e) { throw new MediaTypeHeaderException(e, "Accept", "Content-Type"); } var effectiveApiVersion = this.getRestApiVersion(); this.parserConfig = parserConfig.restApiVersion().equals(effectiveApiVersion) ? parserConfig : parserConfig.withRestApiVersion(effectiveApiVersion); this.httpChannel = httpChannel; this.params = params; this.rawPath = path; this.headers = Collections.unmodifiableMap(headers); this.requestId = requestId; } protected RestRequest(RestRequest other) { assert other.parserConfig.restApiVersion().equals(other.getRestApiVersion()); this.parsedAccept = other.parsedAccept; this.parsedContentType = other.parsedContentType; if (other.xContentType.get() != null) { this.xContentType.set(other.xContentType.get()); } this.restApiVersion = other.restApiVersion; this.parserConfig = other.parserConfig; this.httpRequest = other.httpRequest; this.httpChannel = other.httpChannel; this.params = other.params; this.rawPath = other.rawPath; this.headers = other.headers; this.requestId = other.requestId; } private static @Nullable ParsedMediaType parseHeaderWithMediaType(Map<String, List<String>> headers, String headerName) { // TODO: make all usages of headers case-insensitive List<String> header = headers.get(headerName); if (header == null || header.isEmpty()) { return null; } else if (header.size() > 1) { throw new IllegalArgumentException("Incorrect header [" + headerName + "]. Only one value should be provided"); } String rawContentType = header.get(0); if (Strings.hasText(rawContentType)) { return ParsedMediaType.parseMediaType(rawContentType); } else { throw new IllegalArgumentException("Header [" + headerName + "] cannot be empty."); } } /** * Invoke {@link HttpRequest#releaseAndCopy()} on the http request in this instance and replace a pooled http request * with an unpooled copy. This is supposed to be used before passing requests to {@link RestHandler} instances that can not safely * handle http requests that use pooled buffers as determined by {@link RestHandler#allowsUnsafeBuffers()}. */ void ensureSafeBuffers() { httpRequest = httpRequest.releaseAndCopy(); } /** * Creates a new REST request. * * @throws BadParameterException if the parameters can not be decoded * @throws MediaTypeHeaderException if the Content-Type or Accept header can not be parsed */ public static RestRequest request(XContentParserConfiguration parserConfig, HttpRequest httpRequest, HttpChannel httpChannel) { Map<String, String> params = params(httpRequest.uri()); String path = path(httpRequest.uri()); return new RestRequest( parserConfig, params, path, httpRequest.getHeaders(), httpRequest, httpChannel, requestIdGenerator.incrementAndGet() ); } private static Map<String, String> params(final String uri) { final Map<String, String> params = new HashMap<>(); int index = uri.indexOf('?'); if (index >= 0) { try { RestUtils.decodeQueryString(uri, index + 1, params); } catch (final IllegalArgumentException e) { throw new BadParameterException(e); } } return params; } private static String path(final String uri) { final int index = uri.indexOf('?'); if (index >= 0) { return uri.substring(0, index); } else { return uri; } } /** * Creates a new REST request. The path is not decoded so this constructor will not throw a * {@link BadParameterException}. * * @throws MediaTypeHeaderException if the Content-Type or Accept header can not be parsed */ public static RestRequest requestWithoutParameters( XContentParserConfiguration parserConfig, HttpRequest httpRequest, HttpChannel httpChannel ) { Map<String, String> params = Collections.emptyMap(); return new RestRequest( parserConfig, params, httpRequest.uri(), httpRequest.getHeaders(), httpRequest, httpChannel, requestIdGenerator.incrementAndGet() ); } public enum Method { GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH, TRACE, CONNECT } /** * Returns the HTTP method used in the REST request. * * @return the {@link Method} used in the REST request * @throws IllegalArgumentException if the HTTP method is invalid */ public Method method() { return httpRequest.method(); } /** * The uri of the rest request, with the query string. */ public String uri() { return httpRequest.uri(); } /** * The non decoded, raw path provided. */ public String rawPath() { return rawPath; } /** * The path part of the URI (without the query string), decoded. */ public final String path() { return RestUtils.decodeComponent(rawPath()); } public boolean hasContent() { return contentLength() > 0; } public int contentLength() { return httpRequest.content().length(); } public BytesReference content() { this.contentConsumed = true; return httpRequest.content(); } /** * @return content of the request body or throw an exception if the body or content type is missing */ public final BytesReference requiredContent() { if (hasContent() == false) { throw new ElasticsearchParseException("request body is required"); } else if (xContentType.get() == null) { throw new IllegalStateException("unknown content type"); } return content(); } /** * Get the value of the header or {@code null} if not found. This method only retrieves the first header value if multiple values are * sent. Use of {@link #getAllHeaderValues(String)} should be preferred */ public final String header(String name) { List<String> values = headers.get(name); if (values != null && values.isEmpty() == false) { return values.get(0); } return null; } /** * Get all values for the header or {@code null} if the header was not found */ public final List<String> getAllHeaderValues(String name) { List<String> values = headers.get(name); if (values != null) { return Collections.unmodifiableList(values); } return null; } /** * Get all of the headers and values associated with the headers. Modifications of this map are not supported. */ public final Map<String, List<String>> getHeaders() { return headers; } public final long getRequestId() { return requestId; } /** * The {@link XContentType} that was parsed from the {@code Content-Type} header. This value will be {@code null} in the case of * a request without a valid {@code Content-Type} header, a request without content ({@link #hasContent()}, or a plain text request */ @Nullable public final XContentType getXContentType() { return xContentType.get(); } public HttpChannel getHttpChannel() { return httpChannel; } public HttpRequest getHttpRequest() { return httpRequest; } public final boolean hasParam(String key) { return params.containsKey(key); } @Override public final String param(String key) { consumedParams.add(key); return params.get(key); } @Override public final String param(String key, String defaultValue) { consumedParams.add(key); String value = params.get(key); if (value == null) { return defaultValue; } return value; } public Map<String, String> params() { return params; } /** * Returns a list of parameters that have been consumed. This method returns a copy, callers * are free to modify the returned list. * * @return the list of currently consumed parameters. */ List<String> consumedParams() { return new ArrayList<>(consumedParams); } /** * Returns a list of parameters that have not yet been consumed. This method returns a copy, * callers are free to modify the returned list. * * @return the list of currently unconsumed parameters. */ List<String> unconsumedParams() { return params.keySet().stream().filter(p -> consumedParams.contains(p) == false).toList(); } public float paramAsFloat(String key, float defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; } try { return Float.parseFloat(sValue); } catch (NumberFormatException e) { throw new IllegalArgumentException("Failed to parse float parameter [" + key + "] with value [" + sValue + "]", e); } } public double paramAsDouble(String key, double defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; } try { return Double.parseDouble(sValue); } catch (NumberFormatException e) { throw new IllegalArgumentException("Failed to parse double parameter [" + key + "] with value [" + sValue + "]", e); } } public int paramAsInt(String key, int defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; } try { return Integer.parseInt(sValue); } catch (NumberFormatException e) { throw new IllegalArgumentException("Failed to parse int parameter [" + key + "] with value [" + sValue + "]", e); } } public long paramAsLong(String key, long defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; } try { return Long.parseLong(sValue); } catch (NumberFormatException e) { throw new IllegalArgumentException("Failed to parse long parameter [" + key + "] with value [" + sValue + "]", e); } } @Override public boolean paramAsBoolean(String key, boolean defaultValue) { String rawParam = param(key); // Treat empty string as true because that allows the presence of the url parameter to mean "turn this on" if (rawParam != null && rawParam.length() == 0) { return true; } else { return Booleans.parseBoolean(rawParam, defaultValue); } } @Override public Boolean paramAsBoolean(String key, Boolean defaultValue) { return Booleans.parseBoolean(param(key), defaultValue); } public TimeValue paramAsTime(String key, TimeValue defaultValue) { return parseTimeValue(param(key), defaultValue, key); } public ByteSizeValue paramAsSize(String key, ByteSizeValue defaultValue) { return parseBytesSizeValue(param(key), defaultValue, key); } public String[] paramAsStringArray(String key, String[] defaultValue) { String value = param(key); if (value == null) { return defaultValue; } return Strings.splitStringByCommaToArray(value); } public String[] paramAsStringArrayOrEmptyIfAll(String key) { String[] params = paramAsStringArray(key, Strings.EMPTY_ARRAY); if (Strings.isAllOrWildcard(params)) { return Strings.EMPTY_ARRAY; } return params; } /** * Get the configuration that should be used to create {@link XContentParser} from this request. */ public XContentParserConfiguration contentParserConfig() { return parserConfig; } /** * A parser for the contents of this request if there is a body, otherwise throws an {@link ElasticsearchParseException}. Use * {@link #applyContentParser(CheckedConsumer)} if you want to gracefully handle when the request doesn't have any contents. Use * {@link #contentOrSourceParamParser()} for requests that support specifying the request body in the {@code source} param. */ public final XContentParser contentParser() throws IOException { BytesReference content = requiredContent(); // will throw exception if body or content type missing return XContentHelper.createParserNotCompressed(parserConfig, content, xContentType.get()); } /** * If there is any content then call {@code applyParser} with the parser, otherwise do nothing. */ public final void applyContentParser(CheckedConsumer<XContentParser, IOException> applyParser) throws IOException { if (hasContent()) { try (XContentParser parser = contentParser()) { applyParser.accept(parser); } } } /** * Does this request have content or a {@code source} parameter? Use this instead of {@link #hasContent()} if this * {@linkplain RestHandler} treats the {@code source} parameter like the body content. */ public final boolean hasContentOrSourceParam() { return hasContent() || hasParam("source"); } /** * A parser for the contents of this request if it has contents, otherwise a parser for the {@code source} parameter if there is one, * otherwise throws an {@link ElasticsearchParseException}. Use {@link #withContentOrSourceParamParserOrNull(CheckedConsumer)} instead * if you need to handle the absence request content gracefully. */ public final XContentParser contentOrSourceParamParser() throws IOException { Tuple<XContentType, BytesReference> tuple = contentOrSourceParam(); return XContentHelper.createParserNotCompressed(parserConfig, tuple.v2(), tuple.v1().xContent().type()); } /** * Call a consumer with the parser for the contents of this request if it has contents, otherwise with a parser for the {@code source} * parameter if there is one, otherwise with {@code null}. Use {@link #contentOrSourceParamParser()} if you should throw an exception * back to the user when there isn't request content. */ public final void withContentOrSourceParamParserOrNull(CheckedConsumer<XContentParser, IOException> withParser) throws IOException { if (hasContentOrSourceParam()) { Tuple<XContentType, BytesReference> tuple = contentOrSourceParam(); try (XContentParser parser = XContentHelper.createParserNotCompressed(parserConfig, tuple.v2(), tuple.v1())) { withParser.accept(parser); } } else { withParser.accept(null); } } /** * Get the content of the request or the contents of the {@code source} param or throw an exception if both are missing. * Prefer {@link #contentOrSourceParamParser()} or {@link #withContentOrSourceParamParserOrNull(CheckedConsumer)} if you need a parser. */ public final Tuple<XContentType, BytesReference> contentOrSourceParam() { if (hasContentOrSourceParam() == false) { throw new ElasticsearchParseException("request body or source parameter is required"); } else if (hasContent()) { return new Tuple<>(xContentType.get(), requiredContent()); } String source = param("source"); String typeParam = param("source_content_type"); if (source == null || typeParam == null) { throw new IllegalStateException("source and source_content_type parameters are required"); } BytesArray bytes = new BytesArray(source); final XContentType xContentType = parseContentType(Collections.singletonList(typeParam)); if (xContentType == null) { throw new IllegalStateException("Unknown value for source_content_type [" + typeParam + "]"); } return new Tuple<>(xContentType, bytes); } public ParsedMediaType getParsedAccept() { return parsedAccept; } public ParsedMediaType getParsedContentType() { return parsedContentType; } /** * Parses the given content type string for the media type. This method currently ignores parameters. */ // TODO stop ignoring parameters such as charset... public static XContentType parseContentType(List<String> header) { if (header == null || header.isEmpty()) { return null; } else if (header.size() > 1) { throw new IllegalArgumentException("only one Content-Type header should be provided"); } String rawContentType = header.get(0); final String[] elements = rawContentType.split("[ \t]*;"); if (elements.length > 0) { final String[] splitMediaType = elements[0].split("/"); if (splitMediaType.length == 2 && TCHAR_PATTERN.matcher(splitMediaType[0]).matches() && TCHAR_PATTERN.matcher(splitMediaType[1].trim()).matches()) { return XContentType.fromMediaType(elements[0]); } else { throw new IllegalArgumentException("invalid Content-Type header [" + rawContentType + "]"); } } throw new IllegalArgumentException("empty Content-Type header"); } /** * The requested version of the REST API. */ public RestApiVersion getRestApiVersion() { return restApiVersion.orElse(RestApiVersion.current()); } public boolean hasExplicitRestApiVersion() { return restApiVersion.isPresent(); } public void markPathRestricted(String restriction) { if (params.containsKey(PATH_RESTRICTED)) { throw new IllegalArgumentException("The parameter [" + PATH_RESTRICTED + "] is already defined."); } params.put(PATH_RESTRICTED, restriction); // this parameter is intended be consumed via ToXContent.Params.param(..), not this.params(..) so don't require it is consumed here consumedParams.add(PATH_RESTRICTED); } @Override public String getSpanId() { return "rest-" + getRequestId(); } public static class MediaTypeHeaderException extends RuntimeException { private final String message; private final Set<String> failedHeaderNames; MediaTypeHeaderException(final RuntimeException cause, String... failedHeaderNames) { super(cause); this.failedHeaderNames = Set.of(failedHeaderNames); this.message = "Invalid media-type value on headers " + this.failedHeaderNames; } public Set<String> getFailedHeaderNames() { return failedHeaderNames; } @Override public String getMessage() { return message; } } public static class BadParameterException extends RuntimeException { BadParameterException(final IllegalArgumentException cause) { super(cause); } } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/rest/RestRequest.java
822
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.http; import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ChunkedToXContent; import org.elasticsearch.xcontent.ToXContent; import org.elasticsearch.xcontent.ToXContentFragment; import org.elasticsearch.xcontent.XContentBuilder; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; import static org.elasticsearch.TransportVersions.V_8_12_0; public record HttpStats(long serverOpen, long totalOpen, List<ClientStats> clientStats, Map<String, HttpRouteStats> httpRouteStats) implements Writeable, ChunkedToXContent { public static final HttpStats IDENTITY = new HttpStats(0, 0, List.of(), Map.of()); public HttpStats(long serverOpen, long totalOpened) { this(serverOpen, totalOpened, List.of(), Map.of()); } public HttpStats(StreamInput in) throws IOException { this( in.readVLong(), in.readVLong(), in.readCollectionAsList(ClientStats::new), in.getTransportVersion().onOrAfter(V_8_12_0) ? in.readMap(HttpRouteStats::new) : Map.of() ); } @Override public void writeTo(StreamOutput out) throws IOException { out.writeVLong(serverOpen); out.writeVLong(totalOpen); out.writeCollection(clientStats); if (out.getTransportVersion().onOrAfter(V_8_12_0)) { out.writeMap(httpRouteStats, StreamOutput::writeWriteable); } } public long getServerOpen() { return this.serverOpen; } public long getTotalOpen() { return this.totalOpen; } public List<ClientStats> getClientStats() { return this.clientStats; } public static HttpStats merge(HttpStats first, HttpStats second) { return new HttpStats( first.serverOpen + second.serverOpen, first.totalOpen + second.totalOpen, Stream.concat(first.clientStats.stream(), second.clientStats.stream()).toList(), Stream.concat(first.httpRouteStats.entrySet().stream(), second.httpRouteStats.entrySet().stream()) .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue, HttpRouteStats::merge)) ); } static final class Fields { static final String HTTP = "http"; static final String CURRENT_OPEN = "current_open"; static final String TOTAL_OPENED = "total_opened"; static final String CLIENTS = "clients"; static final String CLIENT_ID = "id"; static final String CLIENT_AGENT = "agent"; static final String CLIENT_LOCAL_ADDRESS = "local_address"; static final String CLIENT_REMOTE_ADDRESS = "remote_address"; static final String CLIENT_LAST_URI = "last_uri"; static final String CLIENT_OPENED_TIME_MILLIS = "opened_time_millis"; static final String CLIENT_CLOSED_TIME_MILLIS = "closed_time_millis"; static final String CLIENT_LAST_REQUEST_TIME_MILLIS = "last_request_time_millis"; static final String CLIENT_REQUEST_COUNT = "request_count"; static final String CLIENT_REQUEST_SIZE_BYTES = "request_size_bytes"; static final String CLIENT_FORWARDED_FOR = "x_forwarded_for"; static final String CLIENT_OPAQUE_ID = "x_opaque_id"; static final String ROUTES = "routes"; } @Override public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params outerParams) { return Iterators.<ToXContent>concat( Iterators.single( (builder, params) -> builder.startObject(Fields.HTTP) .field(Fields.CURRENT_OPEN, serverOpen) .field(Fields.TOTAL_OPENED, totalOpen) .startArray(Fields.CLIENTS) ), clientStats.iterator(), Iterators.single((builder, params) -> { builder.endArray(); builder.startObject(Fields.ROUTES); return builder; }), Iterators.map(httpRouteStats.entrySet().iterator(), entry -> (builder, params) -> { builder.field(entry.getKey()); entry.getValue().toXContent(builder, params); return builder; }), Iterators.single((builder, params) -> builder.endObject().endObject()) ); } public record ClientStats( int id, String agent, String localAddress, String remoteAddress, String lastUri, String forwardedFor, String opaqueId, long openedTimeMillis, long closedTimeMillis, long lastRequestTimeMillis, long requestCount, long requestSizeBytes ) implements Writeable, ToXContentFragment { public static final long NOT_CLOSED = -1L; ClientStats(StreamInput in) throws IOException { this( in.readInt(), in.readOptionalString(), in.readOptionalString(), in.readOptionalString(), in.readOptionalString(), in.readOptionalString(), in.readOptionalString(), in.readLong(), in.readLong(), in.readLong(), in.readLong(), in.readLong() ); } @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(Fields.CLIENT_ID, id); if (agent != null) { builder.field(Fields.CLIENT_AGENT, agent); } if (localAddress != null) { builder.field(Fields.CLIENT_LOCAL_ADDRESS, localAddress); } if (remoteAddress != null) { builder.field(Fields.CLIENT_REMOTE_ADDRESS, remoteAddress); } if (lastUri != null) { builder.field(Fields.CLIENT_LAST_URI, lastUri); } if (forwardedFor != null) { builder.field(Fields.CLIENT_FORWARDED_FOR, forwardedFor); } if (opaqueId != null) { builder.field(Fields.CLIENT_OPAQUE_ID, opaqueId); } builder.field(Fields.CLIENT_OPENED_TIME_MILLIS, openedTimeMillis); if (closedTimeMillis != NOT_CLOSED) { builder.field(Fields.CLIENT_CLOSED_TIME_MILLIS, closedTimeMillis); } builder.field(Fields.CLIENT_LAST_REQUEST_TIME_MILLIS, lastRequestTimeMillis); builder.field(Fields.CLIENT_REQUEST_COUNT, requestCount); builder.field(Fields.CLIENT_REQUEST_SIZE_BYTES, requestSizeBytes); builder.endObject(); return builder; } @Override public void writeTo(StreamOutput out) throws IOException { out.writeInt(id); out.writeOptionalString(agent); out.writeOptionalString(localAddress); out.writeOptionalString(remoteAddress); out.writeOptionalString(lastUri); out.writeOptionalString(forwardedFor); out.writeOptionalString(opaqueId); out.writeLong(openedTimeMillis); out.writeLong(closedTimeMillis); out.writeLong(lastRequestTimeMillis); out.writeLong(requestCount); out.writeLong(requestSizeBytes); } } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/http/HttpStats.java
823
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.bridge; /** * Enchantment. */ public interface Enchantment { void onActivate(); void apply(); void onDeactivate(); }
smedals/java-design-patterns
bridge/src/main/java/com/iluwatar/bridge/Enchantment.java
824
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.core.Booleans; import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.IndexVersions; import org.elasticsearch.internal.BuildExtension; import org.elasticsearch.plugins.ExtensionLoader; import java.io.IOException; import java.net.URL; import java.security.CodeSource; import java.util.Locale; import java.util.ServiceLoader; import java.util.jar.JarInputStream; import java.util.jar.Manifest; import java.util.regex.Pattern; /** * Information about a build of Elasticsearch. */ public record Build( String flavor, Type type, String hash, String date, String version, String qualifier, boolean isSnapshot, String minWireCompatVersion, String minIndexCompatVersion, String displayString ) { private static class CurrentHolder { private static final Build CURRENT = findCurrent(); // finds the pluggable current build, or uses the local build as a fallback private static Build findCurrent() { return ExtensionLoader.loadSingleton(ServiceLoader.load(BuildExtension.class)) .map(BuildExtension::getCurrentBuild) .orElseGet(Build::findLocalBuild); } } private static final Pattern qualfiedVersionRegex = Pattern.compile("([^-]+)(?:-((:?alpha|beta|rc)[0-9]+))?(?:-SNAPSHOT)?"); /** * Finds build info scanned from the server jar. */ private static Build findLocalBuild() { final Type type; final String hash; final String date; final boolean isSnapshot; final String qualifier; final String version; // these are parsed at startup, and we require that we are able to recognize the values passed in by the startup scripts type = Type.fromDisplayName(System.getProperty("es.distribution.type", "unknown"), true); final String esPrefix = "elasticsearch-" + Version.CURRENT; final URL url = getElasticsearchCodeSourceLocation(); final String urlStr = url == null ? "" : url.toString(); if (urlStr.startsWith("file:/") && (urlStr.endsWith(esPrefix + ".jar") || urlStr.matches("(.*)" + esPrefix + "(-)?((alpha|beta|rc)[0-9]+)?(-SNAPSHOT)?.jar"))) { try (JarInputStream jar = new JarInputStream(FileSystemUtils.openFileURLStream(url))) { Manifest manifest = jar.getManifest(); hash = manifest.getMainAttributes().getValue("Change"); date = manifest.getMainAttributes().getValue("Build-Date"); isSnapshot = "true".equals(manifest.getMainAttributes().getValue("X-Compile-Elasticsearch-Snapshot")); String rawVersion = manifest.getMainAttributes().getValue("X-Compile-Elasticsearch-Version"); var versionMatcher = qualfiedVersionRegex.matcher(rawVersion); if (versionMatcher.matches() == false) { throw new IllegalStateException(String.format(Locale.ROOT, "Malformed elasticsearch compile version: %s", rawVersion)); } version = versionMatcher.group(1); qualifier = versionMatcher.group(2); } catch (IOException e) { throw new RuntimeException(e); } } else { // not running from the official elasticsearch jar file (unit tests, IDE, uber client jar, shadiness) hash = "unknown"; date = "unknown"; version = Version.CURRENT.toString(); final String buildSnapshot = System.getProperty("build.snapshot"); if (buildSnapshot != null) { try { Class.forName("com.carrotsearch.randomizedtesting.RandomizedContext"); } catch (final ClassNotFoundException e) { // we are not in tests but build.snapshot is set, bail hard throw new IllegalStateException("build.snapshot set to [" + buildSnapshot + "] but not running tests"); } isSnapshot = Booleans.parseBoolean(buildSnapshot); } else { isSnapshot = true; } qualifier = System.getProperty("build.version_qualifier"); } if (hash == null) { throw new IllegalStateException( "Error finding the build hash. " + "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug." ); } if (date == null) { throw new IllegalStateException( "Error finding the build date. " + "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug." ); } if (version == null) { throw new IllegalStateException( "Error finding the build version. " + "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug." ); } final String flavor = "default"; String minWireCompat = Version.CURRENT.minimumCompatibilityVersion().toString(); String minIndexCompat = minimumCompatString(IndexVersions.MINIMUM_COMPATIBLE); String displayString = defaultDisplayString(type, hash, date, qualifiedVersionString(version, qualifier, isSnapshot)); return new Build(flavor, type, hash, date, version, qualifier, isSnapshot, minWireCompat, minIndexCompat, displayString); } public static String minimumCompatString(IndexVersion minimumCompatible) { if (minimumCompatible.before(IndexVersions.FIRST_DETACHED_INDEX_VERSION)) { // use Version for compatibility return Version.fromId(minimumCompatible.id()).toString(); } else { // use the IndexVersion string return minimumCompatible.toString(); } } public static Build current() { return CurrentHolder.CURRENT; } public enum Type { DEB("deb"), DOCKER("docker"), RPM("rpm"), TAR("tar"), ZIP("zip"), UNKNOWN("unknown"); final String displayName; public String displayName() { return displayName; } Type(final String displayName) { this.displayName = displayName; } public static Type fromDisplayName(final String displayName, final boolean strict) { switch (displayName) { case "deb": return Type.DEB; case "docker": return Type.DOCKER; case "rpm": return Type.RPM; case "tar": return Type.TAR; case "zip": return Type.ZIP; case "unknown": return Type.UNKNOWN; default: if (strict) { throw new IllegalStateException("unexpected distribution type [" + displayName + "]; your distribution is broken"); } else { return Type.UNKNOWN; } } } } /** * The location of the code source for Elasticsearch * * @return the location of the code source for Elasticsearch which may be null */ static URL getElasticsearchCodeSourceLocation() { final CodeSource codeSource = Build.class.getProtectionDomain().getCodeSource(); return codeSource == null ? null : codeSource.getLocation(); } public static Build readBuild(StreamInput in) throws IOException { final String flavor; if (in.getTransportVersion().before(TransportVersions.V_8_3_0) || in.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) { flavor = in.readString(); } else { flavor = "default"; } // be lenient when reading on the wire, the enumeration values from other versions might be different than what we know final Type type = Type.fromDisplayName(in.readString(), false); String hash = in.readString(); String date = in.readString(); final String version; final String qualifier; final boolean snapshot; final String minWireVersion; final String minIndexVersion; final String displayString; if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) { version = in.readString(); qualifier = in.readOptionalString(); snapshot = in.readBoolean(); } else { snapshot = in.readBoolean(); String rawVersion = in.readString(); // need to separate out qualifiers from older nodes var versionMatcher = qualfiedVersionRegex.matcher(rawVersion); if (versionMatcher.matches() == false) { throw new IllegalStateException(String.format(Locale.ROOT, "Malformed elasticsearch compile version: %s", rawVersion)); } version = versionMatcher.group(1); qualifier = versionMatcher.group(2); } if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) { minWireVersion = in.readString(); minIndexVersion = in.readString(); displayString = in.readString(); } else { // the version is qualified, so we may need to strip off -SNAPSHOT or -alpha, etc. Here we simply find the first dash int dashNdx = version.indexOf('-'); var versionConstant = Version.fromString(dashNdx == -1 ? version : version.substring(0, dashNdx)); minWireVersion = versionConstant.minimumCompatibilityVersion().toString(); minIndexVersion = minimumCompatString(IndexVersion.getMinimumCompatibleIndexVersion(versionConstant.id())); displayString = defaultDisplayString(type, hash, date, qualifiedVersionString(version, qualifier, snapshot)); } return new Build(flavor, type, hash, date, version, qualifier, snapshot, minWireVersion, minIndexVersion, displayString); } public static void writeBuild(Build build, StreamOutput out) throws IOException { if (out.getTransportVersion().before(TransportVersions.V_8_3_0) || out.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) { out.writeString(build.flavor()); } out.writeString(build.type().displayName()); out.writeString(build.hash()); out.writeString(build.date()); if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) { out.writeString(build.version()); out.writeOptionalString(build.qualifier()); out.writeBoolean(build.isSnapshot()); } else { out.writeBoolean(build.isSnapshot()); out.writeString(build.qualifiedVersion()); } if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) { out.writeString(build.minWireCompatVersion()); out.writeString(build.minIndexCompatVersion()); out.writeString(build.displayString()); } } /** * Get the version as considered at build time * <p> * Offers a way to get the fully qualified version as configured by the build. * This will be the same as {@link Version} for production releases, but may include on of the qualifier ( e.x alpha1 ) * or -SNAPSHOT for others. * * @return the fully qualified build */ public String qualifiedVersion() { return qualifiedVersionString(version, qualifier, isSnapshot); } private static String qualifiedVersionString(String version, String qualifier, boolean isSnapshot) { String versionString = version; if (qualifier != null) { versionString += "-" + qualifier; } if (isSnapshot) { versionString += "-SNAPSHOT"; } return versionString; } public boolean isProductionRelease() { return isSnapshot == false && qualifier == null; } public static String defaultDisplayString(Type type, String hash, String date, String version) { return "[" + type.displayName + "][" + hash + "][" + date + "][" + version + "]"; } @Override public String toString() { return displayString(); } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/Build.java
825
class Solution1 { public int searchInsert(int[] nums, int target) { int i=0; for(;i<nums.length;i++){ if (nums[i]>=target){ break; } } return i; } }
MisterBooo/LeetCodeAnimation
0035-search-insert-position/Code/1.java
827
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.tasks; import org.elasticsearch.TransportVersions; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ObjectParserHelper; import org.elasticsearch.core.TimeValue; import org.elasticsearch.xcontent.ConstructingObjectParser; import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.ToXContentFragment; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentParser; import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.concurrent.TimeUnit; import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg; import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg; /** * Information about a currently running task. * <p> * Tasks are used for communication with transport actions. As a result, they can contain callback * references as well as mutable state. That makes it impractical to send tasks over transport channels * and use in APIs. Instead, immutable and writeable TaskInfo objects are used to represent * snapshot information about currently running tasks. */ public record TaskInfo( TaskId taskId, String type, String node, String action, String description, Task.Status status, long startTime, long runningTimeNanos, boolean cancellable, boolean cancelled, TaskId parentTaskId, Map<String, String> headers ) implements Writeable, ToXContentFragment { static final String INCLUDE_CANCELLED_PARAM = "include_cancelled"; public TaskInfo { assert cancellable || cancelled == false : "uncancellable task cannot be cancelled"; } /** * Read from a stream. */ public static TaskInfo from(StreamInput in) throws IOException { TaskId taskId = TaskId.readFromStream(in); return new TaskInfo( taskId, in.readString(), in.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X) ? in.readString() : taskId.getNodeId(), in.readString(), in.readOptionalString(), in.readOptionalNamedWriteable(Task.Status.class), in.readLong(), in.readLong(), in.readBoolean(), in.readBoolean(), TaskId.readFromStream(in), in.readMap(StreamInput::readString) ); } @Override public void writeTo(StreamOutput out) throws IOException { taskId.writeTo(out); out.writeString(type); if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) { out.writeString(node); } out.writeString(action); out.writeOptionalString(description); out.writeOptionalNamedWriteable(status); out.writeLong(startTime); out.writeLong(runningTimeNanos); out.writeBoolean(cancellable); out.writeBoolean(cancelled); parentTaskId.writeTo(out); out.writeMap(headers, StreamOutput::writeString); } public long id() { return taskId.getId(); } @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field("node", node); builder.field("id", taskId.getId()); builder.field("type", type); builder.field("action", action); if (status != null) { builder.field("status", status, params); } if (description != null) { builder.field("description", description); } builder.timeField("start_time_in_millis", "start_time", startTime); if (builder.humanReadable()) { builder.field("running_time", new TimeValue(runningTimeNanos, TimeUnit.NANOSECONDS).toString()); } builder.field("running_time_in_nanos", runningTimeNanos); builder.field("cancellable", cancellable); if (params.paramAsBoolean(INCLUDE_CANCELLED_PARAM, true) && cancellable) { // don't record this on entries in the tasks index, since we can't add this field to the mapping dynamically and it's not // important for completed tasks anyway builder.field("cancelled", cancelled); } if (parentTaskId.isSet()) { builder.field("parent_task_id", parentTaskId.toString()); } builder.startObject("headers"); for (Map.Entry<String, String> attribute : headers.entrySet()) { builder.field(attribute.getKey(), attribute.getValue()); } builder.endObject(); return builder; } public static TaskInfo fromXContent(XContentParser parser) { return PARSER.apply(parser, null); } public static final ConstructingObjectParser<TaskInfo, Void> PARSER = new ConstructingObjectParser<>("task_info", true, a -> { int i = 0; String node = (String) a[i++]; TaskId id = new TaskId(node, (Long) a[i++]); String type = (String) a[i++]; String action = (String) a[i++]; String description = (String) a[i++]; BytesReference statusBytes = (BytesReference) a[i++]; long startTime = (Long) a[i++]; long runningTimeNanos = (Long) a[i++]; boolean cancellable = (Boolean) a[i++]; boolean cancelled = a[i++] == Boolean.TRUE; String parentTaskIdString = (String) a[i++]; @SuppressWarnings("unchecked") Map<String, String> headers = (Map<String, String>) a[i++]; if (headers == null) { // This might happen if we are reading an old version of task info headers = Collections.emptyMap(); } RawTaskStatus status = statusBytes == null ? null : new RawTaskStatus(statusBytes); TaskId parentTaskId = parentTaskIdString == null ? TaskId.EMPTY_TASK_ID : new TaskId(parentTaskIdString); return new TaskInfo( id, type, node, action, description, status, startTime, runningTimeNanos, cancellable, cancelled, parentTaskId, headers ); }); static { // Note for the future: this has to be backwards and forwards compatible with all changes to the task storage format PARSER.declareString(constructorArg(), new ParseField("node")); PARSER.declareLong(constructorArg(), new ParseField("id")); PARSER.declareString(constructorArg(), new ParseField("type")); PARSER.declareString(constructorArg(), new ParseField("action")); PARSER.declareString(optionalConstructorArg(), new ParseField("description")); ObjectParserHelper.declareRawObject(PARSER, optionalConstructorArg(), new ParseField("status")); PARSER.declareLong(constructorArg(), new ParseField("start_time_in_millis")); PARSER.declareLong(constructorArg(), new ParseField("running_time_in_nanos")); PARSER.declareBoolean(constructorArg(), new ParseField("cancellable")); PARSER.declareBoolean(optionalConstructorArg(), new ParseField("cancelled")); PARSER.declareString(optionalConstructorArg(), new ParseField("parent_task_id")); PARSER.declareObject(optionalConstructorArg(), (p, c) -> p.mapStrings(), new ParseField("headers")); } @Override public String toString() { return Strings.toString(this, true, true); } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/tasks/TaskInfo.java
830
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.index; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.xcontent.ObjectParser; import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.ToXContentObject; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentParser; import java.io.IOException; import java.util.Comparator; import java.util.Objects; /** * A value class representing the basic required properties of an Elasticsearch index. */ public class Index implements Writeable, ToXContentObject { public static final Index[] EMPTY_ARRAY = new Index[0]; public static Comparator<Index> COMPARE_BY_NAME = Comparator.comparing(Index::getName); private static final String INDEX_UUID_KEY = "index_uuid"; private static final String INDEX_NAME_KEY = "index_name"; private static final ObjectParser<Builder, Void> INDEX_PARSER = new ObjectParser<>("index", Builder::new); static { INDEX_PARSER.declareString(Builder::name, new ParseField(INDEX_NAME_KEY)); INDEX_PARSER.declareString(Builder::uuid, new ParseField(INDEX_UUID_KEY)); } private final String name; private final String uuid; public Index(String name, String uuid) { this.name = Objects.requireNonNull(name); this.uuid = Objects.requireNonNull(uuid); } /** * Read from a stream. */ public Index(StreamInput in) throws IOException { this.name = in.readString(); this.uuid = in.readString(); } public String getName() { return this.name; } public String getUUID() { return uuid; } @Override public String toString() { /* * If we have a uuid we put it in the toString so it'll show up in logs which is useful as more and more things use the uuid rather * than the name as the lookup key for the index. */ if (ClusterState.UNKNOWN_UUID.equals(uuid)) { return "[" + name + "]"; } return "[" + name + "/" + uuid + "]"; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Index index1 = (Index) o; return uuid.equals(index1.uuid) && name.equals(index1.name); // allow for _na_ uuid } @Override public int hashCode() { int result = name.hashCode(); result = 31 * result + uuid.hashCode(); return result; } @Override public void writeTo(final StreamOutput out) throws IOException { out.writeString(name); out.writeString(uuid); } @Override public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException { builder.startObject(); toXContentFragment(builder); return builder.endObject(); } public XContentBuilder toXContentFragment(final XContentBuilder builder) throws IOException { builder.field(INDEX_NAME_KEY, name); builder.field(INDEX_UUID_KEY, uuid); return builder; } public static Index fromXContent(final XContentParser parser) throws IOException { return INDEX_PARSER.parse(parser, null).build(); } /** * Builder for Index objects. Used by ObjectParser instances only. */ private static final class Builder { private String name; private String uuid; public void name(final String name) { this.name = name; } public void uuid(final String uuid) { this.uuid = uuid; } public Index build() { return new Index(name, uuid); } } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/index/Index.java
831
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * This project is based on a modification of https://github.com/uber/h3 which is licensed under the Apache 2.0 License. * * Copyright 2016-2021 Uber Technologies, Inc. */ package org.elasticsearch.h3; import java.util.Arrays; import static java.lang.Math.toRadians; /** * Defines the public API of the H3 library. */ public final class H3 { public static int MAX_H3_RES = Constants.MAX_H3_RES; private static final long[] NORTH = new long[MAX_H3_RES + 1]; private static final long[] SOUTH = new long[MAX_H3_RES + 1]; static { for (int res = 0; res <= H3.MAX_H3_RES; res++) { NORTH[res] = H3.geoToH3(90, 0, res); SOUTH[res] = H3.geoToH3(-90, 0, res); } } /** * Converts from <code>long</code> representation of an index to <code>String</code> representation. */ public static String h3ToString(long h3) { return Long.toHexString(h3); } /** * Converts from <code>String</code> representation of an index to <code>long</code> representation. */ public static long stringToH3(String h3Address) { return Long.parseUnsignedLong(h3Address, 16); } /** returns the resolution of the provided H3 cell */ public static int getResolution(long h3) { return H3Index.H3_get_resolution(h3); } /** returns the resolution of the provided H3 cell in string format */ public static int getResolution(String h3Address) { return getResolution(stringToH3(h3Address)); } /** determines if an H3 cell is a pentagon */ public static boolean isPentagon(long h3) { return H3Index.H3_is_pentagon(h3); } /** determines if an H3 cell in string format is a pentagon */ public static boolean isPentagon(String h3Address) { return isPentagon(stringToH3(h3Address)); } /** Returns true if this is a valid H3 index */ public static boolean h3IsValid(long h3) { if (H3Index.H3_get_high_bit(h3) != 0) { return false; } if (H3Index.H3_get_mode(h3) != Constants.H3_CELL_MODE) { return false; } if (H3Index.H3_get_reserved_bits(h3) != 0) { return false; } int baseCell = H3Index.H3_get_base_cell(h3); if (baseCell < 0 || baseCell >= Constants.NUM_BASE_CELLS) { // LCOV_EXCL_BR_LINE // Base cells less than zero can not be represented in an index return false; } int res = H3Index.H3_get_resolution(h3); if (res < 0 || res > Constants.MAX_H3_RES) { // LCOV_EXCL_BR_LINE // Resolutions less than zero can not be represented in an index return false; } boolean foundFirstNonZeroDigit = false; for (int r = 1; r <= res; r++) { int digit = H3Index.H3_get_index_digit(h3, r); if (foundFirstNonZeroDigit == false && digit != CoordIJK.Direction.CENTER_DIGIT.digit()) { foundFirstNonZeroDigit = true; if (BaseCells.isBaseCellPentagon(baseCell) && digit == CoordIJK.Direction.K_AXES_DIGIT.digit()) { return false; } } if (digit < CoordIJK.Direction.CENTER_DIGIT.digit() || digit >= CoordIJK.Direction.NUM_DIGITS.digit()) { return false; } } for (int r = res + 1; r <= Constants.MAX_H3_RES; r++) { int digit = H3Index.H3_get_index_digit(h3, r); if (digit != CoordIJK.Direction.INVALID_DIGIT.digit()) { return false; } } return true; } /** Returns true if this is a valid H3 index */ public static boolean h3IsValid(String h3Address) { return h3IsValid(stringToH3(h3Address)); } /** * Return all base cells */ public static long[] getLongRes0Cells() { long[] cells = new long[Constants.NUM_BASE_CELLS]; for (int bc = 0; bc < Constants.NUM_BASE_CELLS; bc++) { long baseCell = H3Index.H3_INIT; baseCell = H3Index.H3_set_mode(baseCell, Constants.H3_CELL_MODE); baseCell = H3Index.H3_set_base_cell(baseCell, bc); cells[bc] = baseCell; } return cells; } /** * Return all base cells */ public static String[] getStringRes0Cells() { return h3ToStringList(getLongRes0Cells()); } /** * Find the {@link LatLng} center point of the cell. */ public static LatLng h3ToLatLng(long h3) { final FaceIJK fijk = H3Index.h3ToFaceIjk(h3); return fijk.faceIjkToGeo(H3Index.H3_get_resolution(h3)); } /** * Find the {@link LatLng} center point of the cell. */ public static LatLng h3ToLatLng(String h3Address) { return h3ToLatLng(stringToH3(h3Address)); } /** * Find the cell {@link CellBoundary} coordinates for the cell */ public static CellBoundary h3ToGeoBoundary(long h3) { FaceIJK fijk = H3Index.h3ToFaceIjk(h3); if (H3Index.H3_is_pentagon(h3)) { return fijk.faceIjkPentToCellBoundary(H3Index.H3_get_resolution(h3), 0, Constants.NUM_PENT_VERTS); } else { return fijk.faceIjkToCellBoundary(H3Index.H3_get_resolution(h3), 0, Constants.NUM_HEX_VERTS); } } /** * Find the cell {@link CellBoundary} coordinates for the cell */ public static CellBoundary h3ToGeoBoundary(String h3Address) { return h3ToGeoBoundary(stringToH3(h3Address)); } /** * Find the H3 index of the resolution <code>res</code> cell containing the lat/lon (in degrees) * * @param lat Latitude in degrees. * @param lng Longitude in degrees. * @param res Resolution, 0 &lt;= res &lt;= 15 * @return The H3 index. * @throws IllegalArgumentException latitude, longitude, or resolution are out of range. */ public static long geoToH3(double lat, double lng, int res) { checkResolution(res); return Vec3d.geoToH3(res, toRadians(lat), toRadians(lng)); } /** * Find the H3 index of the resolution <code>res</code> cell containing the lat/lon (in degrees) * * @param lat Latitude in degrees. * @param lng Longitude in degrees. * @param res Resolution, 0 &lt;= res &lt;= 15 * @return The H3 index. * @throws IllegalArgumentException Latitude, longitude, or resolution is out of range. */ public static String geoToH3Address(double lat, double lng, int res) { return h3ToString(geoToH3(lat, lng, res)); } /** * Returns the parent of the given index. */ public static long h3ToParent(long h3) { int childRes = H3Index.H3_get_resolution(h3); if (childRes == 0) { throw new IllegalArgumentException("Input is a base cell"); } long parentH = H3Index.H3_set_resolution(h3, childRes - 1); return H3Index.H3_set_index_digit(parentH, childRes, H3Index.H3_DIGIT_MASK); } /** * Returns the parent of the given index. */ public static String h3ToParent(String h3Address) { long parent = h3ToParent(stringToH3(h3Address)); return h3ToString(parent); } /** * Returns the children of the given index. */ public static long[] h3ToChildren(long h3) { final long[] children = new long[h3ToChildrenSize(h3)]; for (int i = 0; i < children.length; i++) { children[i] = childPosToH3(h3, i); } return children; } /** * Transforms a list of H3 indexes in long form to a list of H3 * indexes in string form. */ public static String[] h3ToChildren(String h3Address) { return h3ToStringList(h3ToChildren(stringToH3(h3Address))); } /** * Returns the child cell at the given position */ public static long childPosToH3(long h3, int childPos) { final int childrenRes = H3Index.H3_get_resolution(h3) + 1; if (childrenRes > MAX_H3_RES) { throw new IllegalArgumentException("Resolution overflow"); } final long childH = H3Index.H3_set_resolution(h3, childrenRes); if (childPos == 0) { return H3Index.H3_set_index_digit(childH, childrenRes, CoordIJK.Direction.CENTER_DIGIT.digit()); } final boolean isPentagon = isPentagon(h3); final int maxPos = isPentagon ? 5 : 6; if (childPos < 0 || childPos > maxPos) { throw new IllegalArgumentException("invalid child position"); } if (isPentagon) { // Pentagon skip digit (position) is the number 1, therefore we add one // to the current position. return H3Index.H3_set_index_digit(childH, childrenRes, childPos + 1); } else { return H3Index.H3_set_index_digit(childH, childrenRes, childPos); } } /** * Returns the child address at the given position */ public static String childPosToH3(String h3Address, int childPos) { return h3ToString(childPosToH3(stringToH3(h3Address), childPos)); } private static final int[] PEN_INTERSECTING_CHILDREN_DIRECTIONS = new int[] { 3, 1, 6, 4, 2 }; private static final int[] HEX_INTERSECTING_CHILDREN_DIRECTIONS = new int[] { 3, 6, 2, 5, 1, 4 }; /** * Returns the h3 bins on the level below which are not children of the given H3 index but * intersects with it. */ public static long[] h3ToNoChildrenIntersecting(long h3) { final boolean isPentagon = isPentagon(h3); final long[] noChildren = new long[isPentagon ? 5 : 6]; for (int i = 0; i < noChildren.length; i++) { noChildren[i] = noChildIntersectingPosToH3(h3, i); } return noChildren; } /** * Returns the h3 addresses on the level below which are not children of the given H3 address but * intersects with it. */ public static String[] h3ToNoChildrenIntersecting(String h3Address) { return h3ToStringList(h3ToNoChildrenIntersecting(stringToH3(h3Address))); } /** * Returns the no child intersecting cell at the given position */ public static long noChildIntersectingPosToH3(long h3, int childPos) { final int childrenRes = H3Index.H3_get_resolution(h3) + 1; if (childrenRes > MAX_H3_RES) { throw new IllegalArgumentException("Resolution overflow"); } final boolean isPentagon = isPentagon(h3); final int maxPos = isPentagon ? 4 : 5; if (childPos < 0 || childPos > maxPos) { throw new IllegalArgumentException("invalid child position"); } final long childH = H3Index.H3_set_resolution(h3, childrenRes); if (isPentagon) { // Pentagon skip digit (position) is the number 1, therefore we add one // for the skip digit and one for the 0 (center) digit. final long child = H3Index.H3_set_index_digit(childH, childrenRes, childPos + 2); return HexRing.h3NeighborInDirection(child, PEN_INTERSECTING_CHILDREN_DIRECTIONS[childPos]); } else { // we add one for the 0 (center) digit. final long child = H3Index.H3_set_index_digit(childH, childrenRes, childPos + 1); return HexRing.h3NeighborInDirection(child, HEX_INTERSECTING_CHILDREN_DIRECTIONS[childPos]); } } /** * Returns the no child intersecting cell at the given position */ public static String noChildIntersectingPosToH3(String h3Address, int childPos) { return h3ToString(noChildIntersectingPosToH3(stringToH3(h3Address), childPos)); } /** * Returns the neighbor indexes. * * @param h3Address Origin index * @return All neighbor indexes from the origin */ public static String[] hexRing(String h3Address) { return h3ToStringList(hexRing(stringToH3(h3Address))); } /** * Returns the neighbor indexes. * * @param h3 Origin index * @return All neighbor indexes from the origin */ public static long[] hexRing(long h3) { final long[] ring = new long[hexRingSize(h3)]; for (int i = 0; i < ring.length; i++) { ring[i] = hexRingPosToH3(h3, i); assert ring[i] >= 0; } return ring; } /** * Returns the number of neighbor indexes. * * @param h3 Origin index * @return the number of neighbor indexes from the origin */ public static int hexRingSize(long h3) { return H3Index.H3_is_pentagon(h3) ? 5 : 6; } /** * Returns the number of neighbor indexes. * * @param h3Address Origin index * @return the number of neighbor indexes from the origin */ public static int hexRingSize(String h3Address) { return hexRingSize(stringToH3(h3Address)); } /** * Returns the neighbor index at the given position. * * @param h3 Origin index * @param ringPos position of the neighbour index * @return the actual neighbour at the given position */ public static long hexRingPosToH3(long h3, int ringPos) { // for pentagons, we skip direction at position 2 final int pos = H3Index.H3_is_pentagon(h3) && ringPos >= 2 ? ringPos + 1 : ringPos; if (pos < 0 || pos > 5) { throw new IllegalArgumentException("invalid ring position"); } return HexRing.h3NeighborInDirection(h3, HexRing.DIRECTIONS[pos].digit()); } /** * Returns the neighbor index at the given position. * * @param h3Address Origin index * @param ringPos position of the neighbour index * @return the actual neighbour at the given position */ public static String hexRingPosToH3(String h3Address, int ringPos) { return h3ToString(hexRingPosToH3(stringToH3(h3Address), ringPos)); } /** * returns whether or not the provided hexagons border * * @param origin the first index * @param destination the second index * @return whether or not the provided hexagons border */ public static boolean areNeighborCells(String origin, String destination) { return areNeighborCells(stringToH3(origin), stringToH3(destination)); } /** * returns whether or not the provided hexagons border * * @param origin the first index * @param destination the second index * @return whether or not the provided hexagons border */ public static boolean areNeighborCells(long origin, long destination) { return HexRing.areNeighbours(origin, destination); } /** * h3ToChildrenSize returns the exact number of children for a cell at a * given child resolution. * * @param h3 H3Index to find the number of children of * @param childRes The child resolution you're interested in * * @return long Exact number of children (handles hexagons and pentagons * correctly) */ public static long h3ToChildrenSize(long h3, int childRes) { final int parentRes = H3Index.H3_get_resolution(h3); if (childRes <= parentRes || childRes > MAX_H3_RES) { throw new IllegalArgumentException("Invalid child resolution [" + childRes + "]"); } final int n = childRes - parentRes; if (H3Index.H3_is_pentagon(h3)) { return (1L + 5L * (_ipow(7, n) - 1L) / 6L); } else { return _ipow(7, n); } } /** * h3ToChildrenSize returns the exact number of children for a h3 affress at a * given child resolution. * * @param h3Address H3 address to find the number of children of * @param childRes The child resolution you're interested in * * @return int Exact number of children (handles hexagons and pentagons * correctly) */ public static long h3ToChildrenSize(String h3Address, int childRes) { return h3ToChildrenSize(stringToH3(h3Address), childRes); } /** * h3ToChildrenSize returns the exact number of children * * @param h3 H3Index to find the number of children. * * @return int Exact number of children, 6 for Pentagons and 7 for hexagons, */ public static int h3ToChildrenSize(long h3) { if (H3Index.H3_get_resolution(h3) == MAX_H3_RES) { throw new IllegalArgumentException("Invalid child resolution [" + MAX_H3_RES + "]"); } return isPentagon(h3) ? 6 : 7; } /** * h3ToChildrenSize returns the exact number of children * * @param h3Address H3 address to find the number of children. * * @return int Exact number of children, 6 for Pentagons and 7 for hexagons, */ public static int h3ToChildrenSize(String h3Address) { return h3ToChildrenSize(stringToH3(h3Address)); } /** * h3ToNotIntersectingChildrenSize returns the exact number of children intersecting * the given parent but not part of the children set. * * @param h3 H3Index to find the number of children. * * @return int Exact number of children, 5 for Pentagons and 6 for hexagons, */ public static int h3ToNotIntersectingChildrenSize(long h3) { if (H3Index.H3_get_resolution(h3) == MAX_H3_RES) { throw new IllegalArgumentException("Invalid child resolution [" + MAX_H3_RES + "]"); } return isPentagon(h3) ? 5 : 6; } /** * h3ToNotIntersectingChildrenSize returns the exact number of children intersecting * the given parent but not part of the children set. * * @param h3Address H3 address to find the number of children. * * @return int Exact number of children, 5 for Pentagons and 6 for hexagons, */ public static int h3ToNotIntersectingChildrenSize(String h3Address) { return h3ToNotIntersectingChildrenSize(stringToH3(h3Address)); } /** * Find the h3 index containing the North Pole at the given resolution. * * @param res the provided resolution. * * @return the h3 index containing the North Pole. */ public static long northPolarH3(int res) { checkResolution(res); return NORTH[res]; } /** * Find the h3 address containing the North Pole at the given resolution. * * @param res the provided resolution. * * @return the h3 address containing the North Pole. */ public static String northPolarH3Address(int res) { return h3ToString(northPolarH3(res)); } /** * Find the h3 index containing the South Pole at the given resolution. * * @param res the provided resolution. * * @return the h3 index containing the South Pole. */ public static long southPolarH3(int res) { checkResolution(res); return SOUTH[res]; } /** * Find the h3 address containing the South Pole at the given resolution. * * @param res the provided resolution. * * @return the h3 address containing the South Pole. */ public static String southPolarH3Address(int res) { return h3ToString(southPolarH3(res)); } /** * _ipow does integer exponentiation efficiently. Taken from StackOverflow. * * @param base the integer base (can be positive or negative) * @param exp the integer exponent (should be nonnegative) * * @return the exponentiated value */ private static long _ipow(int base, int exp) { long result = 1; while (exp != 0) { if ((exp & 1) != 0) { result *= base; } exp >>= 1; base *= base; } return result; } private static String[] h3ToStringList(long[] h3s) { return Arrays.stream(h3s).mapToObj(H3::h3ToString).toArray(String[]::new); } /** * @throws IllegalArgumentException <code>res</code> is not a valid H3 resolution. */ private static void checkResolution(int res) { if (res < 0 || res > Constants.MAX_H3_RES) { throw new IllegalArgumentException("resolution [" + res + "] is out of range (must be 0 <= res <= 15)"); } } }
elastic/elasticsearch
libs/h3/src/main/java/org/elasticsearch/h3/H3.java
832
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.http; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestUtils; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; import java.io.OutputStream; import java.util.List; import static org.elasticsearch.core.Strings.format; /** * Http request trace logger. See {@link #maybeLogRequest(RestRequest, Exception)} for details. */ class HttpTracer { private static final Logger logger = LogManager.getLogger(HttpTracer.class); private volatile String[] tracerLogInclude; private volatile String[] tracerLogExclude; // for testing HttpTracer() { tracerLogInclude = tracerLogExclude = new String[0]; } HttpTracer(Settings settings, ClusterSettings clusterSettings) { setTracerLogInclude(HttpTransportSettings.SETTING_HTTP_TRACE_LOG_INCLUDE.get(settings)); setTracerLogExclude(HttpTransportSettings.SETTING_HTTP_TRACE_LOG_EXCLUDE.get(settings)); clusterSettings.addSettingsUpdateConsumer(HttpTransportSettings.SETTING_HTTP_TRACE_LOG_INCLUDE, this::setTracerLogInclude); clusterSettings.addSettingsUpdateConsumer(HttpTransportSettings.SETTING_HTTP_TRACE_LOG_EXCLUDE, this::setTracerLogExclude); } /** * Logs the given request if request tracing is enabled and the request uri matches the current include and exclude patterns defined * in {@link HttpTransportSettings#SETTING_HTTP_TRACE_LOG_INCLUDE} and {@link HttpTransportSettings#SETTING_HTTP_TRACE_LOG_EXCLUDE}. * If the request was logged returns a logger to log sending the response with or {@code null} otherwise. * * @param restRequest Rest request to trace * @param e Exception when handling the request or {@code null} if none * @return This instance to use for logging the response via {@link #logResponse} to this request if it was logged or * {@code null} if the request wasn't logged */ @Nullable HttpTracer maybeLogRequest(RestRequest restRequest, @Nullable Exception e) { if (logger.isTraceEnabled() && TransportService.shouldTraceAction(restRequest.uri(), tracerLogInclude, tracerLogExclude)) { // trace.id in the response log is included from threadcontext, which isn't set at request log time // so include it here as part of the message logger.trace( () -> format( "[%s][%s][%s][%s] received request from [%s]%s", restRequest.getRequestId(), restRequest.header(Task.X_OPAQUE_ID_HTTP_HEADER), restRequest.method(), restRequest.uri(), restRequest.getHttpChannel(), RestUtils.extractTraceId(restRequest.header(Task.TRACE_PARENT_HTTP_HEADER)).map(t -> " trace.id: " + t).orElse("") ), e ); if (isBodyTracerEnabled()) { try (var stream = HttpBodyTracer.getBodyOutputStream(restRequest.getRequestId(), HttpBodyTracer.Type.REQUEST)) { restRequest.content().writeTo(stream); } catch (Exception e2) { assert false : e2; // no real IO here } } return this; } return null; } boolean isBodyTracerEnabled() { return HttpBodyTracer.isEnabled(); } /** * Logs the response to a request that was logged by {@link #maybeLogRequest(RestRequest, Exception)}. * * @param restResponse RestResponse * @param httpChannel HttpChannel the response was sent on * @param contentLength Value of the response content length header * @param opaqueHeader Value of HTTP header {@link Task#X_OPAQUE_ID_HTTP_HEADER} * @param requestId Request id as returned by {@link RestRequest#getRequestId()} * @param success Whether the response was successfully sent */ void logResponse( RestResponse restResponse, HttpChannel httpChannel, String contentLength, String opaqueHeader, long requestId, boolean success ) { // trace id is included in the ThreadContext for the response logger.trace( () -> format( "[%s][%s][%s][%s][%s] sent response to [%s] success [%s]", requestId, opaqueHeader, restResponse.status(), restResponse.contentType(), contentLength, httpChannel, success ) ); } private void setTracerLogInclude(List<String> tracerLogInclude) { this.tracerLogInclude = tracerLogInclude.toArray(Strings.EMPTY_ARRAY); } private void setTracerLogExclude(List<String> tracerLogExclude) { this.tracerLogExclude = tracerLogExclude.toArray(Strings.EMPTY_ARRAY); } OutputStream openResponseBodyLoggingStream(long requestId) { return HttpBodyTracer.getBodyOutputStream(requestId, HttpBodyTracer.Type.RESPONSE); } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/http/HttpTracer.java
837
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.visitor; import java.util.Arrays; /** * Interface for the nodes in hierarchy. */ public abstract class Unit { private final Unit[] children; public Unit(Unit... children) { this.children = children; } /** * Accept visitor. */ public void accept(UnitVisitor visitor) { Arrays.stream(children).forEach(child -> child.accept(visitor)); } }
smedals/java-design-patterns
visitor/src/main/java/com/iluwatar/visitor/Unit.java
839
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.updatemethod; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; import java.util.Random; import lombok.extern.slf4j.Slf4j; /** * The game world class. Maintain all the objects existed in the game frames. */ @Slf4j public class World { protected List<Entity> entities; protected volatile boolean isRunning; public World() { entities = new ArrayList<>(); isRunning = false; } /** * Main game loop. This loop will always run until the game is over. For * each loop it will process user input, update internal status, and render * the next frames. For more detail please refer to the game-loop pattern. */ private void gameLoop() { while (isRunning) { processInput(); update(); render(); } } /** * Handle any user input that has happened since the last call. In order to * simulate the situation in real-life game, here we add a random time lag. * The time lag ranges from 50 ms to 250 ms. */ private void processInput() { try { int lag = new SecureRandom().nextInt(200) + 50; Thread.sleep(lag); } catch (InterruptedException e) { LOGGER.error(e.getMessage()); Thread.currentThread().interrupt(); } } /** * Update internal status. The update method pattern invoke update method for * each entity in the game. */ private void update() { for (var entity : entities) { entity.update(); } } /** * Render the next frame. Here we do nothing since it is not related to the * pattern. */ private void render() { // Does Nothing } /** * Run game loop. */ public void run() { LOGGER.info("Start game."); isRunning = true; var thread = new Thread(this::gameLoop); thread.start(); } /** * Stop game loop. */ public void stop() { LOGGER.info("Stop game."); isRunning = false; } public void addEntity(Entity entity) { entities.add(entity); } }
rajprins/java-design-patterns
update-method/src/main/java/com/iluwatar/updatemethod/World.java
841
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch; import org.elasticsearch.common.Strings; import org.elasticsearch.common.VersionId; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.core.Assertions; import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.xcontent.ToXContentFragment; import org.elasticsearch.xcontent.XContentBuilder; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; public class Version implements VersionId<Version>, ToXContentFragment { /* * The logic for ID is: XXYYZZAA, where XX is major version, YY is minor version, ZZ is revision, and AA is alpha/beta/rc indicator AA * values below 25 are for alpha builder (since 5.0), and above 25 and below 50 are beta builds, and below 99 are RC builds, with 99 * indicating a release the (internal) format of the id is there so we can easily do after/before checks on the id * * IMPORTANT: Unreleased vs. Released Versions * * All listed versions MUST be released versions, except the last major, the last minor and the last revison. ONLY those are required * as unreleased versions. * * Example: assume the last release is 7.3.0 * The unreleased last major is the next major release, e.g. _8_.0.0 * The unreleased last minor is the current major with a upped minor: 7._4_.0 * The unreleased revision is the very release with a upped revision 7.3._1_ */ public static final int V_EMPTY_ID = 0; public static final Version V_EMPTY = new Version(V_EMPTY_ID); public static final Version V_7_0_0 = new Version(7_00_00_99); public static final Version V_7_0_1 = new Version(7_00_01_99); public static final Version V_7_1_0 = new Version(7_01_00_99); public static final Version V_7_1_1 = new Version(7_01_01_99); public static final Version V_7_2_0 = new Version(7_02_00_99); public static final Version V_7_2_1 = new Version(7_02_01_99); public static final Version V_7_3_0 = new Version(7_03_00_99); public static final Version V_7_3_1 = new Version(7_03_01_99); public static final Version V_7_3_2 = new Version(7_03_02_99); public static final Version V_7_4_0 = new Version(7_04_00_99); public static final Version V_7_4_1 = new Version(7_04_01_99); public static final Version V_7_4_2 = new Version(7_04_02_99); public static final Version V_7_5_0 = new Version(7_05_00_99); public static final Version V_7_5_1 = new Version(7_05_01_99); public static final Version V_7_5_2 = new Version(7_05_02_99); public static final Version V_7_6_0 = new Version(7_06_00_99); public static final Version V_7_6_1 = new Version(7_06_01_99); public static final Version V_7_6_2 = new Version(7_06_02_99); public static final Version V_7_7_0 = new Version(7_07_00_99); public static final Version V_7_7_1 = new Version(7_07_01_99); public static final Version V_7_8_0 = new Version(7_08_00_99); public static final Version V_7_8_1 = new Version(7_08_01_99); public static final Version V_7_9_0 = new Version(7_09_00_99); public static final Version V_7_9_1 = new Version(7_09_01_99); public static final Version V_7_9_2 = new Version(7_09_02_99); public static final Version V_7_9_3 = new Version(7_09_03_99); public static final Version V_7_10_0 = new Version(7_10_00_99); public static final Version V_7_10_1 = new Version(7_10_01_99); public static final Version V_7_10_2 = new Version(7_10_02_99); public static final Version V_7_11_0 = new Version(7_11_00_99); public static final Version V_7_11_1 = new Version(7_11_01_99); public static final Version V_7_11_2 = new Version(7_11_02_99); public static final Version V_7_12_0 = new Version(7_12_00_99); public static final Version V_7_12_1 = new Version(7_12_01_99); public static final Version V_7_13_0 = new Version(7_13_00_99); public static final Version V_7_13_1 = new Version(7_13_01_99); public static final Version V_7_13_2 = new Version(7_13_02_99); public static final Version V_7_13_3 = new Version(7_13_03_99); public static final Version V_7_13_4 = new Version(7_13_04_99); public static final Version V_7_14_0 = new Version(7_14_00_99); public static final Version V_7_14_1 = new Version(7_14_01_99); public static final Version V_7_14_2 = new Version(7_14_02_99); public static final Version V_7_15_0 = new Version(7_15_00_99); public static final Version V_7_15_1 = new Version(7_15_01_99); public static final Version V_7_15_2 = new Version(7_15_02_99); public static final Version V_7_16_0 = new Version(7_16_00_99); public static final Version V_7_16_1 = new Version(7_16_01_99); public static final Version V_7_16_2 = new Version(7_16_02_99); public static final Version V_7_16_3 = new Version(7_16_03_99); public static final Version V_7_17_0 = new Version(7_17_00_99); public static final Version V_7_17_1 = new Version(7_17_01_99); public static final Version V_7_17_2 = new Version(7_17_02_99); public static final Version V_7_17_3 = new Version(7_17_03_99); public static final Version V_7_17_4 = new Version(7_17_04_99); public static final Version V_7_17_5 = new Version(7_17_05_99); public static final Version V_7_17_6 = new Version(7_17_06_99); public static final Version V_7_17_7 = new Version(7_17_07_99); public static final Version V_7_17_8 = new Version(7_17_08_99); public static final Version V_7_17_9 = new Version(7_17_09_99); public static final Version V_7_17_10 = new Version(7_17_10_99); public static final Version V_7_17_11 = new Version(7_17_11_99); public static final Version V_7_17_12 = new Version(7_17_12_99); public static final Version V_7_17_13 = new Version(7_17_13_99); public static final Version V_7_17_14 = new Version(7_17_14_99); public static final Version V_7_17_15 = new Version(7_17_15_99); public static final Version V_7_17_16 = new Version(7_17_16_99); public static final Version V_7_17_17 = new Version(7_17_17_99); public static final Version V_7_17_18 = new Version(7_17_18_99); public static final Version V_7_17_19 = new Version(7_17_19_99); public static final Version V_7_17_20 = new Version(7_17_20_99); public static final Version V_7_17_21 = new Version(7_17_21_99); public static final Version V_7_17_22 = new Version(7_17_22_99); public static final Version V_8_0_0 = new Version(8_00_00_99); public static final Version V_8_0_1 = new Version(8_00_01_99); public static final Version V_8_1_0 = new Version(8_01_00_99); public static final Version V_8_1_1 = new Version(8_01_01_99); public static final Version V_8_1_2 = new Version(8_01_02_99); public static final Version V_8_1_3 = new Version(8_01_03_99); public static final Version V_8_2_0 = new Version(8_02_00_99); public static final Version V_8_2_1 = new Version(8_02_01_99); public static final Version V_8_2_2 = new Version(8_02_02_99); public static final Version V_8_2_3 = new Version(8_02_03_99); public static final Version V_8_3_0 = new Version(8_03_00_99); public static final Version V_8_3_1 = new Version(8_03_01_99); public static final Version V_8_3_2 = new Version(8_03_02_99); public static final Version V_8_3_3 = new Version(8_03_03_99); public static final Version V_8_4_0 = new Version(8_04_00_99); public static final Version V_8_4_1 = new Version(8_04_01_99); public static final Version V_8_4_2 = new Version(8_04_02_99); public static final Version V_8_4_3 = new Version(8_04_03_99); public static final Version V_8_5_0 = new Version(8_05_00_99); public static final Version V_8_5_1 = new Version(8_05_01_99); public static final Version V_8_5_2 = new Version(8_05_02_99); public static final Version V_8_5_3 = new Version(8_05_03_99); public static final Version V_8_6_0 = new Version(8_06_00_99); public static final Version V_8_6_1 = new Version(8_06_01_99); public static final Version V_8_6_2 = new Version(8_06_02_99); public static final Version V_8_7_0 = new Version(8_07_00_99); public static final Version V_8_7_1 = new Version(8_07_01_99); public static final Version V_8_8_0 = new Version(8_08_00_99); public static final Version V_8_8_1 = new Version(8_08_01_99); public static final Version V_8_8_2 = new Version(8_08_02_99); public static final Version V_8_9_0 = new Version(8_09_00_99); public static final Version V_8_9_1 = new Version(8_09_01_99); public static final Version V_8_9_2 = new Version(8_09_02_99); public static final Version V_8_10_0 = new Version(8_10_00_99); public static final Version V_8_10_1 = new Version(8_10_01_99); public static final Version V_8_10_2 = new Version(8_10_02_99); public static final Version V_8_10_3 = new Version(8_10_03_99); public static final Version V_8_10_4 = new Version(8_10_04_99); public static final Version V_8_11_0 = new Version(8_11_00_99); public static final Version V_8_11_1 = new Version(8_11_01_99); public static final Version V_8_11_2 = new Version(8_11_02_99); public static final Version V_8_11_3 = new Version(8_11_03_99); public static final Version V_8_11_4 = new Version(8_11_04_99); public static final Version V_8_12_0 = new Version(8_12_00_99); public static final Version V_8_12_1 = new Version(8_12_01_99); public static final Version V_8_12_2 = new Version(8_12_02_99); public static final Version V_8_13_0 = new Version(8_13_00_99); public static final Version V_8_13_1 = new Version(8_13_01_99); public static final Version V_8_13_2 = new Version(8_13_02_99); public static final Version V_8_13_3 = new Version(8_13_03_99); public static final Version V_8_13_4 = new Version(8_13_04_99); public static final Version V_8_13_5 = new Version(8_13_05_99); public static final Version V_8_14_0 = new Version(8_14_00_99); public static final Version V_8_15_0 = new Version(8_15_00_99); public static final Version CURRENT = V_8_15_0; private static final NavigableMap<Integer, Version> VERSION_IDS; private static final Map<String, Version> VERSION_STRINGS; static { final NavigableMap<Integer, Version> builder = new TreeMap<>(); final Map<String, Version> builderByString = new HashMap<>(); for (final Field declaredField : Version.class.getFields()) { if (declaredField.getType().equals(Version.class)) { final String fieldName = declaredField.getName(); if (fieldName.equals("CURRENT") || fieldName.equals("V_EMPTY")) { continue; } assert fieldName.matches("V_\\d+_\\d+_\\d+") : "expected Version field [" + fieldName + "] to match V_\\d+_\\d+_\\d+"; try { final Version version = (Version) declaredField.get(null); if (Assertions.ENABLED) { final String[] fields = fieldName.split("_"); final int major = Integer.valueOf(fields[1]) * 1000000; final int minor = Integer.valueOf(fields[2]) * 10000; final int revision = Integer.valueOf(fields[3]) * 100; final int expectedId = major + minor + revision + 99; assert version.id == expectedId : "expected version [" + fieldName + "] to have id [" + expectedId + "] but was [" + version.id + "]"; } final Version maybePrevious = builder.put(version.id, version); builderByString.put(version.toString(), version); assert maybePrevious == null : "expected [" + version.id + "] to be uniquely mapped but saw [" + maybePrevious + "] and [" + version + "]"; } catch (final IllegalAccessException e) { assert false : "Version field [" + fieldName + "] should be public"; } } } assert RestApiVersion.current().major == CURRENT.major && RestApiVersion.previous().major == CURRENT.major - 1 : "RestApiVersion must be upgraded " + "to reflect major from Version.CURRENT [" + CURRENT.major + "]" + " but is still set to [" + RestApiVersion.current().major + "]"; builder.put(V_EMPTY_ID, V_EMPTY); builderByString.put(V_EMPTY.toString(), V_EMPTY); VERSION_IDS = Collections.unmodifiableNavigableMap(builder); VERSION_STRINGS = Map.copyOf(builderByString); } public static Version readVersion(StreamInput in) throws IOException { return fromId(in.readVInt()); } public static Version fromId(int id) { final Version known = VERSION_IDS.get(id); if (known != null) { return known; } return fromIdSlow(id); } private static Version fromIdSlow(int id) { return new Version(id); } public static void writeVersion(Version version, StreamOutput out) throws IOException { out.writeVInt(version.id); } /** * Returns the minimum version of {@code version1} and {@code version2} */ public static Version min(Version version1, Version version2) { return version1.id < version2.id ? version1 : version2; } /** * Returns the maximum version of {@code version1} and {@code version2} */ public static Version max(Version version1, Version version2) { return version1.id > version2.id ? version1 : version2; } /** * Returns the version given its string representation, current version if the argument is null or empty */ public static Version fromString(String version) { if (Strings.hasLength(version) == false) { return Version.CURRENT; } final Version cached = VERSION_STRINGS.get(version); if (cached != null) { return cached; } return fromStringSlow(version); } private static Version fromStringSlow(String version) { final boolean snapshot; // this is some BWC for 2.x and before indices if (snapshot = version.endsWith("-SNAPSHOT")) { version = version.substring(0, version.length() - 9); } String[] parts = version.split("[.-]"); if (parts.length != 3) { throw new IllegalArgumentException( "the version needs to contain major, minor, and revision, and optionally the build: " + version ); } try { final int rawMajor = Integer.parseInt(parts[0]); if (rawMajor >= 5 && snapshot) { // we don't support snapshot as part of the version here anymore throw new IllegalArgumentException("illegal version format - snapshots are only supported until version 2.x"); } if (rawMajor >= 7 && parts.length == 4) { // we don't support qualifier as part of the version anymore throw new IllegalArgumentException("illegal version format - qualifiers are only supported until version 6.x"); } if (parts[1].length() > 2) { throw new IllegalArgumentException( "illegal minor version format - only one or two digit numbers are supported but found " + parts[1] ); } if (parts[2].length() > 2) { throw new IllegalArgumentException( "illegal revision version format - only one or two digit numbers are supported but found " + parts[2] ); } // we reverse the version id calculation based on some assumption as we can't reliably reverse the modulo final int major = rawMajor * 1000000; final int minor = Integer.parseInt(parts[1]) * 10000; final int revision = Integer.parseInt(parts[2]) * 100; // TODO: 99 is leftover from alpha/beta/rc, it should be removed return fromId(major + minor + revision + 99); } catch (NumberFormatException e) { throw new IllegalArgumentException("unable to parse version " + version, e); } } public final int id; public final byte major; public final byte minor; public final byte revision; public final byte build; private final String toString; private final int previousMajorId; Version(int id) { this.id = id; this.major = (byte) ((id / 1000000) % 100); this.minor = (byte) ((id / 10000) % 100); this.revision = (byte) ((id / 100) % 100); this.build = (byte) (id % 100); this.toString = major + "." + minor + "." + revision; this.previousMajorId = major > 0 ? (major - 1) * 1000000 + 99 : major; } @Override public int id() { return id; } @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return builder.value(toString()); } /* * We need the declared versions when computing the minimum compatibility version. As computing the declared versions uses reflection it * is not cheap. Since computing the minimum compatibility version can occur often, we use this holder to compute the declared versions * lazily once. */ private static class DeclaredVersionsHolder { static final List<Version> DECLARED_VERSIONS = List.copyOf(getDeclaredVersions(Version.class)); } // lazy initialized because we don't yet have the declared versions ready when instantiating the cached Version // instances private Version minCompatVersion; /** * Returns the minimum compatible version based on the current * version. Ie a node needs to have at least the return version in order * to communicate with a node running the current version. The returned version * is in most of the cases the smallest major version release unless the current version * is a beta or RC release then the version itself is returned. */ public Version minimumCompatibilityVersion() { Version res = minCompatVersion; if (res == null) { res = computeMinCompatVersion(); minCompatVersion = res; } return res; } private Version computeMinCompatVersion() { if (major == 6) { // force the minimum compatibility for version 6 to 5.6 since we don't reference version 5 anymore return Version.fromId(5060099); } else if (major == 7) { // force the minimum compatibility for version 7 to 6.8 since we don't reference version 6 anymore return Version.fromId(6080099); } else if (major >= 8) { // all major versions from 8 onwards are compatible with last minor series of the previous major Version bwcVersion = null; for (int i = DeclaredVersionsHolder.DECLARED_VERSIONS.size() - 1; i >= 0; i--) { final Version candidateVersion = DeclaredVersionsHolder.DECLARED_VERSIONS.get(i); if (candidateVersion.major == major - 1 && after(candidateVersion)) { if (bwcVersion != null && candidateVersion.minor < bwcVersion.minor) { break; } bwcVersion = candidateVersion; } } return bwcVersion == null ? this : bwcVersion; } return Version.min(this, fromId(major * 1000000 + 0 * 10000 + 99)); } /** * Returns <code>true</code> iff both version are compatible. Otherwise <code>false</code> */ public boolean isCompatible(Version version) { boolean compatible = onOrAfter(version.minimumCompatibilityVersion()) && version.onOrAfter(minimumCompatibilityVersion()); assert compatible == false || Math.max(major, version.major) - Math.min(major, version.major) <= 1; return compatible; } /** * Returns a first major version previous to the version stored in this object. * I.e 8.1.0 will return 7.0.0 */ public Version previousMajor() { return Version.fromId(previousMajorId); } @SuppressForbidden(reason = "System.out.*") public static void main(String[] args) { final String versionOutput = String.format( Locale.ROOT, "Version: %s, Build: %s/%s/%s, JVM: %s", Build.current().qualifiedVersion(), Build.current().type().displayName(), Build.current().hash(), Build.current().date(), JvmInfo.jvmInfo().version() ); System.out.println(versionOutput); } @Override public String toString() { return toString; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Version version = (Version) o; if (id != version.id) { return false; } return true; } @Override public int hashCode() { return id; } /** * Extracts a sorted list of declared version constants from a class. * The argument would normally be Version.class but is exposed for * testing with other classes-containing-version-constants. */ public static List<Version> getDeclaredVersions(final Class<?> versionClass) { final Field[] fields = versionClass.getFields(); final List<Version> versions = new ArrayList<>(fields.length); for (final Field field : fields) { final int mod = field.getModifiers(); if (false == Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) { continue; } if (field.getType() != Version.class) { continue; } switch (field.getName()) { case "CURRENT": case "V_EMPTY": continue; } assert field.getName().matches("V(_\\d+){3}?") : field.getName(); try { versions.add(((Version) field.get(null))); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } } Collections.sort(versions); return versions; } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/Version.java
844
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * This project is based on a modification of https://github.com/uber/h3 which is licensed under the Apache 2.0 License. * * Copyright 2016-2021 Uber Technologies, Inc. */ package org.elasticsearch.h3; /** * Mutable face number and ijk coordinates on that face-centered coordinate system. * * References the Vec2d cartesian coordinate systems hex2d: local face-centered * coordinate system scaled a specific H3 grid resolution unit length and * with x-axes aligned with the local i-axes */ final class FaceIJK { /** enum representing overage type */ enum Overage { /** * Digit representing overage type */ NO_OVERAGE, /** * On face edge (only occurs on substrate grids) */ FACE_EDGE, /** * Overage on new face interior */ NEW_FACE } // indexes for faceNeighbors table /** * IJ quadrant faceNeighbors table direction */ private static final int IJ = 1; /** * KI quadrant faceNeighbors table direction */ private static final int KI = 2; /** * JK quadrant faceNeighbors table direction */ private static final int JK = 3; /** * overage distance table */ private static final int[] maxDimByCIIres = { 2, // res 0 -1, // res 1 14, // res 2 -1, // res 3 98, // res 4 -1, // res 5 686, // res 6 -1, // res 7 4802, // res 8 -1, // res 9 33614, // res 10 -1, // res 11 235298, // res 12 -1, // res 13 1647086, // res 14 -1, // res 15 11529602 // res 16 }; private static final Vec2d[][] maxDimByCIIVec2d = new Vec2d[maxDimByCIIres.length][3]; static { for (int i = 0; i < maxDimByCIIres.length; i++) { maxDimByCIIVec2d[i][0] = new Vec2d(3.0 * maxDimByCIIres[i], 0.0); maxDimByCIIVec2d[i][1] = new Vec2d(-1.5 * maxDimByCIIres[i], 3.0 * Constants.M_SQRT3_2 * maxDimByCIIres[i]); maxDimByCIIVec2d[i][2] = new Vec2d(-1.5 * maxDimByCIIres[i], -3.0 * Constants.M_SQRT3_2 * maxDimByCIIres[i]); } } /** * unit scale distance table */ private static final int[] unitScaleByCIIres = { 1, // res 0 -1, // res 1 7, // res 2 -1, // res 3 49, // res 4 -1, // res 5 343, // res 6 -1, // res 7 2401, // res 8 -1, // res 9 16807, // res 10 -1, // res 11 117649, // res 12 -1, // res 13 823543, // res 14 -1, // res 15 5764801 // res 16 }; /** * direction from the origin face to the destination face, relative to * the origin face's coordinate system, or -1 if not adjacent. */ private static final int[][] adjacentFaceDir = new int[][] { { 0, KI, -1, -1, IJ, JK, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // face 0 { IJ, 0, KI, -1, -1, -1, JK, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // face 1 { -1, IJ, 0, KI, -1, -1, -1, JK, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // face 2 { -1, -1, IJ, 0, KI, -1, -1, -1, JK, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // face 3 { KI, -1, -1, IJ, 0, -1, -1, -1, -1, JK, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // face 4 { JK, -1, -1, -1, -1, 0, -1, -1, -1, -1, IJ, -1, -1, -1, KI, -1, -1, -1, -1, -1 }, // face 5 { -1, JK, -1, -1, -1, -1, 0, -1, -1, -1, KI, IJ, -1, -1, -1, -1, -1, -1, -1, -1 }, // face 6 { -1, -1, JK, -1, -1, -1, -1, 0, -1, -1, -1, KI, IJ, -1, -1, -1, -1, -1, -1, -1 }, // face 7 { -1, -1, -1, JK, -1, -1, -1, -1, 0, -1, -1, -1, KI, IJ, -1, -1, -1, -1, -1, -1 }, // face 8 { -1, -1, -1, -1, JK, -1, -1, -1, -1, 0, -1, -1, -1, KI, IJ, -1, -1, -1, -1, -1 }, // face 9 { -1, -1, -1, -1, -1, IJ, KI, -1, -1, -1, 0, -1, -1, -1, -1, JK, -1, -1, -1, -1 }, // face 10 { -1, -1, -1, -1, -1, -1, IJ, KI, -1, -1, -1, 0, -1, -1, -1, -1, JK, -1, -1, -1 }, // face 11 { -1, -1, -1, -1, -1, -1, -1, IJ, KI, -1, -1, -1, 0, -1, -1, -1, -1, JK, -1, -1 }, // face 12 { -1, -1, -1, -1, -1, -1, -1, -1, IJ, KI, -1, -1, -1, 0, -1, -1, -1, -1, JK, -1 }, // face 13 { -1, -1, -1, -1, -1, KI, -1, -1, -1, IJ, -1, -1, -1, -1, 0, -1, -1, -1, -1, JK }, // face 14 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, JK, -1, -1, -1, -1, 0, IJ, -1, -1, KI }, // face 15 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, JK, -1, -1, -1, KI, 0, IJ, -1, -1 }, // face 16 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, JK, -1, -1, -1, KI, 0, IJ, -1 }, // face 17 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, JK, -1, -1, -1, KI, 0, IJ }, // face 18 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, JK, IJ, -1, -1, KI, 0 } // face 19 }; /** Maximum input for any component to face-to-base-cell lookup functions */ private static final int MAX_FACE_COORD = 2; /** * Information to transform into an adjacent face IJK system */ private static class FaceOrientIJK { // face number final int face; // res 0 translation relative to primary face final int translateI; final int translateJ; final int translateK; // number of 60 degree ccw rotations relative to primary final int ccwRot60; // face FaceOrientIJK(int face, int translateI, int translateJ, int translateK, int ccwRot60) { this.face = face; this.translateI = translateI; this.translateJ = translateJ; this.translateK = translateK; this.ccwRot60 = ccwRot60; } } /** * Definition of which faces neighbor each other. */ private static final FaceOrientIJK[][] faceNeighbors = new FaceOrientIJK[][] { { // face 0 new FaceOrientIJK(0, 0, 0, 0, 0), // central face new FaceOrientIJK(4, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(1, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(5, 0, 2, 2, 3) // jk quadrant }, { // face 1 new FaceOrientIJK(1, 0, 0, 0, 0), // central face new FaceOrientIJK(0, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(2, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(6, 0, 2, 2, 3) // jk quadrant }, { // face 2 new FaceOrientIJK(2, 0, 0, 0, 0), // central face new FaceOrientIJK(1, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(3, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(7, 0, 2, 2, 3) // jk quadrant }, { // face 3 new FaceOrientIJK(3, 0, 0, 0, 0), // central face new FaceOrientIJK(2, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(4, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(8, 0, 2, 2, 3) // jk quadrant }, { // face 4 new FaceOrientIJK(4, 0, 0, 0, 0), // central face new FaceOrientIJK(3, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(0, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(9, 0, 2, 2, 3) // jk quadrant }, { // face 5 new FaceOrientIJK(5, 0, 0, 0, 0), // central face new FaceOrientIJK(10, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(14, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(0, 0, 2, 2, 3) // jk quadrant }, { // face 6 new FaceOrientIJK(6, 0, 0, 0, 0), // central face new FaceOrientIJK(11, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(10, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(1, 0, 2, 2, 3) // jk quadrant }, { // face 7 new FaceOrientIJK(7, 0, 0, 0, 0), // central face new FaceOrientIJK(12, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(11, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(2, 0, 2, 2, 3) // jk quadrant }, { // face 8 new FaceOrientIJK(8, 0, 0, 0, 0), // central face new FaceOrientIJK(13, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(12, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(3, 0, 2, 2, 3) // jk quadrant }, { // face 9 new FaceOrientIJK(9, 0, 0, 0, 0), // central face new FaceOrientIJK(14, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(13, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(4, 0, 2, 2, 3) // jk quadrant }, { // face 10 new FaceOrientIJK(10, 0, 0, 0, 0), // central face new FaceOrientIJK(5, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(6, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(15, 0, 2, 2, 3) // jk quadrant }, { // face 11 new FaceOrientIJK(11, 0, 0, 0, 0), // central face new FaceOrientIJK(6, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(7, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(16, 0, 2, 2, 3) // jk quadrant }, { // face 12 new FaceOrientIJK(12, 0, 0, 0, 0), // central face new FaceOrientIJK(7, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(8, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(17, 0, 2, 2, 3) // jk quadrant }, { // face 13 new FaceOrientIJK(13, 0, 0, 0, 0), // central face new FaceOrientIJK(8, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(9, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(18, 0, 2, 2, 3) // jk quadrant }, { // face 14 new FaceOrientIJK(14, 0, 0, 0, 0), // central face new FaceOrientIJK(9, 2, 2, 0, 3), // ij quadrant new FaceOrientIJK(5, 2, 0, 2, 3), // ki quadrant new FaceOrientIJK(19, 0, 2, 2, 3) // jk quadrant }, { // face 15 new FaceOrientIJK(15, 0, 0, 0, 0), // central face new FaceOrientIJK(16, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(19, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(10, 0, 2, 2, 3) // jk quadrant }, { // face 16 new FaceOrientIJK(16, 0, 0, 0, 0), // central face new FaceOrientIJK(17, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(15, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(11, 0, 2, 2, 3) // jk quadrant }, { // face 17 new FaceOrientIJK(17, 0, 0, 0, 0), // central face new FaceOrientIJK(18, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(16, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(12, 0, 2, 2, 3) // jk quadrant }, { // face 18 new FaceOrientIJK(18, 0, 0, 0, 0), // central face new FaceOrientIJK(19, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(17, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(13, 0, 2, 2, 3) // jk quadrant }, { // face 19 new FaceOrientIJK(19, 0, 0, 0, 0), // central face new FaceOrientIJK(15, 2, 0, 2, 1), // ij quadrant new FaceOrientIJK(18, 2, 2, 0, 5), // ki quadrant new FaceOrientIJK(14, 0, 2, 2, 3) // jk quadrant } }; // the vertexes of an origin-centered cell in a Class III resolution on a // substrate grid with aperture sequence 33r7r. The aperture 3 gets us the // vertices, and the 3r7r gets us to Class II. // vertices listed ccw from the i-axes private static final int[][] VERTEX_CLASSIII = new int[][] { { 5, 4, 0 }, // 0 { 1, 5, 0 }, // 1 { 0, 5, 4 }, // 2 { 0, 1, 5 }, // 3 { 4, 0, 5 }, // 4 { 5, 0, 1 } // 5 }; // the vertexes of an origin-centered cell in a Class II resolution on a // substrate grid with aperture sequence 33r. The aperture 3 gets us the // vertices, and the 3r gets us back to Class II. // vertices listed ccw from the i-axes private static final int[][] VERTEX_CLASSII = new int[][] { { 2, 1, 0 }, // 0 { 1, 2, 0 }, // 1 { 0, 2, 1 }, // 2 { 0, 1, 2 }, // 3 { 1, 0, 2 }, // 4 { 2, 0, 1 } // 5 }; int face; // face number CoordIJK coord; // ijk coordinates on that face FaceIJK(int face, CoordIJK coord) { this.face = face; this.coord = coord; } /** * Adjusts this FaceIJK address so that the resulting cell address is * relative to the correct icosahedral face. * * @param res The H3 resolution of the cell. * @param pentLeading4 Whether or not the cell is a pentagon with a leading * digit 4. * @param substrate Whether or not the cell is in a substrate grid. * @return 0 if on original face (no overage); 1 if on face edge (only occurs * on substrate grids); 2 if overage on new face interior */ public Overage adjustOverageClassII(int res, boolean pentLeading4, boolean substrate) { Overage overage = Overage.NO_OVERAGE; // get the maximum dimension value; scale if a substrate grid int maxDim = maxDimByCIIres[res]; if (substrate) { maxDim *= 3; } // check for overage if (substrate && this.coord.i + this.coord.j + this.coord.k == maxDim) { // on edge overage = Overage.FACE_EDGE; } else if (this.coord.i + this.coord.j + this.coord.k > maxDim) { // overage overage = Overage.NEW_FACE; final FaceOrientIJK fijkOrient; if (this.coord.k > 0) { if (this.coord.j > 0) { // jk "quadrant" fijkOrient = faceNeighbors[this.face][JK]; } else { // ik "quadrant" fijkOrient = faceNeighbors[this.face][KI]; // adjust for the pentagonal missing sequence if (pentLeading4) { // translate origin to center of pentagon this.coord.ijkSub(maxDim, 0, 0); // rotate to adjust for the missing sequence this.coord.ijkRotate60cw(); // translate the origin back to the center of the triangle this.coord.ijkAdd(maxDim, 0, 0); } } } else { // ij "quadrant" fijkOrient = faceNeighbors[this.face][IJ]; } this.face = fijkOrient.face; // rotate and translate for adjacent face for (int i = 0; i < fijkOrient.ccwRot60; i++) { this.coord.ijkRotate60ccw(); } int unitScale = unitScaleByCIIres[res]; if (substrate) { unitScale *= 3; } this.coord.ijkAdd(fijkOrient.translateI * unitScale, fijkOrient.translateJ * unitScale, fijkOrient.translateK * unitScale); this.coord.ijkNormalize(); // overage points on pentagon boundaries can end up on edges if (substrate && this.coord.i + this.coord.j + this.coord.k == maxDim) { // on edge overage = Overage.FACE_EDGE; } } return overage; } /** * Computes the center point in spherical coordinates of a cell given by * a FaceIJK address at a specified resolution. * * @param res The H3 resolution of the cell. */ public LatLng faceIjkToGeo(int res) { return coord.ijkToGeo(face, res, false); } /** * Computes the cell boundary in spherical coordinates for a pentagonal cell * for this FaceIJK address at a specified resolution. * * @param res The H3 resolution of the cell. * @param start The first topological vertex to return. * @param length The number of topological vertexes to return. */ public CellBoundary faceIjkPentToCellBoundary(int res, int start, int length) { // adjust the center point to be in an aperture 33r substrate grid // these should be composed for speed this.coord.downAp3(); this.coord.downAp3r(); // if res is Class III we need to add a cw aperture 7 to get to // icosahedral Class II int adjRes = res; if (H3Index.isResolutionClassIII(res)) { this.coord.downAp7r(); adjRes += 1; } // If we're returning the entire loop, we need one more iteration in case // of a distortion vertex on the last edge final int additionalIteration = length == Constants.NUM_PENT_VERTS ? 1 : 0; final boolean isResolutionClassIII = H3Index.isResolutionClassIII(res); // convert each vertex to lat/lng // adjust the face of each vertex as appropriate and introduce // edge-crossing vertices as needed final CellBoundary boundary = new CellBoundary(); final CoordIJK scratch = new CoordIJK(0, 0, 0); final FaceIJK fijk = new FaceIJK(this.face, scratch); final int[][] coord = isResolutionClassIII ? VERTEX_CLASSIII : VERTEX_CLASSII; final CoordIJK lastCoord = new CoordIJK(0, 0, 0); int lastFace = this.face; for (int vert = start; vert < start + length + additionalIteration; vert++) { final int v = vert % Constants.NUM_PENT_VERTS; // The center point is now in the same substrate grid as the origin // cell vertices. Add the center point substate coordinates // to each vertex to translate the vertices to that cell. scratch.reset(coord[v][0], coord[v][1], coord[v][2]); scratch.ijkAdd(this.coord.i, this.coord.j, this.coord.k); scratch.ijkNormalize(); fijk.face = this.face; fijk.adjustPentVertOverage(adjRes); // all Class III pentagon edges cross icosa edges // note that Class II pentagons have vertices on the edge, // not edge intersections if (isResolutionClassIII && vert > start) { // find hex2d of the two vertexes on the last face final Vec2d orig2d0 = lastCoord.ijkToHex2d(); final int currentToLastDir = adjacentFaceDir[fijk.face][lastFace]; final FaceOrientIJK fijkOrient = faceNeighbors[fijk.face][currentToLastDir]; lastCoord.reset(fijk.coord.i, fijk.coord.j, fijk.coord.k); // rotate and translate for adjacent face for (int i = 0; i < fijkOrient.ccwRot60; i++) { lastCoord.ijkRotate60ccw(); } final int unitScale = unitScaleByCIIres[adjRes] * 3; lastCoord.ijkAdd( Math.multiplyExact(fijkOrient.translateI, unitScale), Math.multiplyExact(fijkOrient.translateJ, unitScale), Math.multiplyExact(fijkOrient.translateK, unitScale) ); lastCoord.ijkNormalize(); final Vec2d orig2d1 = lastCoord.ijkToHex2d(); // find the appropriate icosa face edge vertexes final Vec2d edge0; final Vec2d edge1; switch (adjacentFaceDir[fijkOrient.face][fijk.face]) { case IJ -> { edge0 = maxDimByCIIVec2d[adjRes][0]; edge1 = maxDimByCIIVec2d[adjRes][1]; } case JK -> { edge0 = maxDimByCIIVec2d[adjRes][1]; edge1 = maxDimByCIIVec2d[adjRes][2]; } // case KI: default -> { assert (adjacentFaceDir[fijkOrient.face][fijk.face] == KI); edge0 = maxDimByCIIVec2d[adjRes][2]; edge1 = maxDimByCIIVec2d[adjRes][0]; } } // find the intersection and add the lat/lng point to the result final Vec2d inter = Vec2d.v2dIntersect(orig2d0, orig2d1, edge0, edge1); final LatLng point = inter.hex2dToGeo(fijkOrient.face, adjRes, true); boundary.add(point); } // convert vertex to lat/lng and add to the result // vert == start + NUM_PENT_VERTS is only used to test for possible // intersection on last edge if (vert < start + Constants.NUM_PENT_VERTS) { final LatLng point = fijk.coord.ijkToGeo(fijk.face, adjRes, true); boundary.add(point); } lastFace = fijk.face; lastCoord.reset(fijk.coord.i, fijk.coord.j, fijk.coord.k); } return boundary; } /** * Generates the cell boundary in spherical coordinates for a cell given by this * FaceIJK address at a specified resolution. * * @param res The H3 resolution of the cell. * @param start The first topological vertex to return. * @param length The number of topological vertexes to return. */ public CellBoundary faceIjkToCellBoundary(final int res, final int start, final int length) { // adjust the center point to be in an aperture 33r substrate grid // these should be composed for speed this.coord.downAp3(); this.coord.downAp3r(); // if res is Class III we need to add a cw aperture 7 to get to // icosahedral Class II int adjRes = res; if (H3Index.isResolutionClassIII(res)) { this.coord.downAp7r(); adjRes += 1; } // If we're returning the entire loop, we need one more iteration in case // of a distortion vertex on the last edge final int additionalIteration = length == Constants.NUM_HEX_VERTS ? 1 : 0; final boolean isResolutionClassIII = H3Index.isResolutionClassIII(res); // convert each vertex to lat/lng // adjust the face of each vertex as appropriate and introduce // edge-crossing vertices as needed final CellBoundary boundary = new CellBoundary(); final CoordIJK scratch1 = new CoordIJK(0, 0, 0); final FaceIJK fijk = new FaceIJK(this.face, scratch1); final CoordIJK scratch2 = isResolutionClassIII ? new CoordIJK(0, 0, 0) : null; final int[][] verts = isResolutionClassIII ? VERTEX_CLASSIII : VERTEX_CLASSII; int lastFace = -1; Overage lastOverage = Overage.NO_OVERAGE; for (int vert = start; vert < start + length + additionalIteration; vert++) { int v = vert % Constants.NUM_HEX_VERTS; scratch1.reset(verts[v][0], verts[v][1], verts[v][2]); scratch1.ijkAdd(this.coord.i, this.coord.j, this.coord.k); scratch1.ijkNormalize(); fijk.face = this.face; final Overage overage = fijk.adjustOverageClassII(adjRes, false, true); /* Check for edge-crossing. Each face of the underlying icosahedron is a different projection plane. So if an edge of the hexagon crosses an icosahedron edge, an additional vertex must be introduced at that intersection point. Then each half of the cell edge can be projected to geographic coordinates using the appropriate icosahedron face projection. Note that Class II cell edges have vertices on the face edge, with no edge line intersections. */ if (isResolutionClassIII && vert > start && fijk.face != lastFace && lastOverage != Overage.FACE_EDGE) { // find hex2d of the two vertexes on original face final int lastV = (v + 5) % Constants.NUM_HEX_VERTS; // The center point is now in the same substrate grid as the origin // cell vertices. Add the center point substate coordinates // to each vertex to translate the vertices to that cell. final int[] vertexLast = verts[lastV]; final int[] vertexV = verts[v]; scratch2.reset( Math.addExact(vertexLast[0], this.coord.i), Math.addExact(vertexLast[1], this.coord.j), Math.addExact(vertexLast[2], this.coord.k) ); scratch2.ijkNormalize(); final Vec2d orig2d0 = scratch2.ijkToHex2d(); scratch2.reset( Math.addExact(vertexV[0], this.coord.i), Math.addExact(vertexV[1], this.coord.j), Math.addExact(vertexV[2], this.coord.k) ); scratch2.ijkNormalize(); final Vec2d orig2d1 = scratch2.ijkToHex2d(); // find the appropriate icosa face edge vertexes final int face2 = ((lastFace == this.face) ? fijk.face : lastFace); final Vec2d edge0; final Vec2d edge1; switch (adjacentFaceDir[this.face][face2]) { case IJ -> { edge0 = maxDimByCIIVec2d[adjRes][0]; edge1 = maxDimByCIIVec2d[adjRes][1]; } case JK -> { edge0 = maxDimByCIIVec2d[adjRes][1]; edge1 = maxDimByCIIVec2d[adjRes][2]; } // case KI: default -> { assert (adjacentFaceDir[this.face][face2] == KI); edge0 = maxDimByCIIVec2d[adjRes][2]; edge1 = maxDimByCIIVec2d[adjRes][0]; } } // find the intersection and add the lat/lng point to the result final Vec2d inter = Vec2d.v2dIntersect(orig2d0, orig2d1, edge0, edge1); /* If a point of intersection occurs at a hexagon vertex, then each adjacent hexagon edge will lie completely on a single icosahedron face, and no additional vertex is required. */ final boolean isIntersectionAtVertex = orig2d0.numericallyIdentical(inter) || orig2d1.numericallyIdentical(inter); if (isIntersectionAtVertex == false) { final LatLng point = inter.hex2dToGeo(this.face, adjRes, true); boundary.add(point); } } // convert vertex to lat/lng and add to the result // vert == start + NUM_HEX_VERTS is only used to test for possible // intersection on last edge if (vert < start + Constants.NUM_HEX_VERTS) { final LatLng point = fijk.coord.ijkToGeo(fijk.face, adjRes, true); boundary.add(point); } lastFace = fijk.face; lastOverage = overage; } return boundary; } /** * compute the corresponding H3Index. * @param res The cell resolution. * @param face The face. * @param coord The CoordIJK. * @return The encoded H3Index */ static long faceIjkToH3(int res, int face, CoordIJK coord) { // initialize the index long h = H3Index.H3_INIT; h = H3Index.H3_set_mode(h, Constants.H3_CELL_MODE); h = H3Index.H3_set_resolution(h, res); // check for res 0/base cell if (res == 0) { if (coord.i > MAX_FACE_COORD || coord.j > MAX_FACE_COORD || coord.k > MAX_FACE_COORD) { // out of range input throw new IllegalArgumentException(" out of range input"); } return H3Index.H3_set_base_cell(h, BaseCells.getBaseCell(face, coord)); } // we need to find the correct base cell CoordIJK for this H3 index; // start with the passed in face and resolution res ijk coordinates // in that face's coordinate system // build the H3Index from finest res up // adjust r for the fact that the res 0 base cell offsets the indexing // digits final CoordIJK scratch = new CoordIJK(0, 0, 0); for (int r = res; r > 0; r--) { final int lastI = coord.i; final int lastJ = coord.j; final int lastK = coord.k; if (H3Index.isResolutionClassIII(r)) { // rotate ccw coord.upAp7(); scratch.reset(coord.i, coord.j, coord.k); scratch.downAp7(); } else { // rotate cw coord.upAp7r(); scratch.reset(coord.i, coord.j, coord.k); scratch.downAp7r(); } scratch.reset(Math.subtractExact(lastI, scratch.i), Math.subtractExact(lastJ, scratch.j), Math.subtractExact(lastK, scratch.k)); scratch.ijkNormalize(); h = H3Index.H3_set_index_digit(h, r, scratch.unitIjkToDigit()); } // we should now hold the IJK of the base cell in the // coordinate system of the given face if (coord.i > MAX_FACE_COORD || coord.j > MAX_FACE_COORD || coord.k > MAX_FACE_COORD) { // out of range input throw new IllegalArgumentException(" out of range input"); } // lookup the correct base cell final int baseCell = BaseCells.getBaseCell(face, coord); h = H3Index.H3_set_base_cell(h, baseCell); // rotate if necessary to get canonical base cell orientation // for this base cell final int numRots = BaseCells.getBaseCellCCWrot60(face, coord); if (BaseCells.isBaseCellPentagon(baseCell)) { // force rotation out of missing k-axes sub-sequence if (H3Index.h3LeadingNonZeroDigit(h) == CoordIJK.Direction.K_AXES_DIGIT.digit()) { // check for a cw/ccw offset face; default is ccw if (BaseCells.baseCellIsCwOffset(baseCell, face)) { h = H3Index.h3Rotate60cw(h); } else { h = H3Index.h3Rotate60ccw(h); } } for (int i = 0; i < numRots; i++) { h = H3Index.h3RotatePent60ccw(h); } } else { for (int i = 0; i < numRots; i++) { h = H3Index.h3Rotate60ccw(h); } } return h; } /** * Adjusts a FaceIJK address for a pentagon vertex in a substrate grid in * place so that the resulting cell address is relative to the correct * icosahedral face. * * @param res The H3 resolution of the cell. */ private void adjustPentVertOverage(int res) { Overage overage; do { overage = adjustOverageClassII(res, false, true); } while (overage == Overage.NEW_FACE); } }
elastic/elasticsearch
libs/h3/src/main/java/org/elasticsearch/h3/FaceIJK.java
849
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.env; import org.elasticsearch.index.shard.ShardId; import java.io.Closeable; import java.util.concurrent.atomic.AtomicBoolean; /** * A shard lock guarantees exclusive access to a shards data * directory. Internal processes should acquire a lock on a shard * before executing any write operations on the shards data directory. * * @see NodeEnvironment */ public abstract class ShardLock implements Closeable { private final ShardId shardId; private final AtomicBoolean closed = new AtomicBoolean(false); public ShardLock(ShardId id) { this.shardId = id; } /** * Returns the locks shards Id. */ public final ShardId getShardId() { return shardId; } @Override public final void close() { if (this.closed.compareAndSet(false, true)) { closeInternal(); } } protected abstract void closeInternal(); /** * Update the details of the holder of this lock. These details are displayed alongside a {@link ShardLockObtainFailedException}. Must * only be called by the holder of this lock. */ public void setDetails(String details) {} @Override public String toString() { return "ShardLock{shardId=" + shardId + '}'; } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/env/ShardLock.java
850
package com.thealgorithms.sorts; // BeadSort Algorithm(wikipedia) : https://en.wikipedia.org/wiki/Bead_sort // BeadSort can't sort negative number, Character, String. It can sort positive number only public class BeadSort { public int[] sort(int[] unsorted) { int[] sorted = new int[unsorted.length]; int max = 0; for (int i = 0; i < unsorted.length; i++) { max = Math.max(max, unsorted[i]); } char[][] grid = new char[unsorted.length][max]; int[] count = new int[max]; for (int i = 0; i < unsorted.length; i++) { for (int j = 0; j < max; j++) { grid[i][j] = '-'; } } for (int i = 0; i < max; i++) { count[i] = 0; } for (int i = 0; i < unsorted.length; i++) { int k = 0; for (int j = 0; j < unsorted[i]; j++) { grid[count[max - k - 1]++][k] = '*'; k++; } } for (int i = 0; i < unsorted.length; i++) { int k = 0; for (int j = 0; j < max && grid[unsorted.length - 1 - i][j] == '*'; j++) { k++; } sorted[i] = k; } return sorted; } }
satishppawar/Java
src/main/java/com/thealgorithms/sorts/BeadSort.java
853
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * This project is based on a modification of https://github.com/uber/h3 which is licensed under the Apache 2.0 License. * * Copyright 2016-2021 Uber Technologies, Inc. */ package org.elasticsearch.h3; import java.util.Objects; /** pair of latitude/longitude */ public final class LatLng { /** Minimum Angular resolution. */ private static final double MINIMUM_ANGULAR_RESOLUTION = Math.PI * 1.0e-12; // taken from lucene's spatial3d /** * pi / 2.0 */ private static final double M_PI_2 = 1.5707963267948966; // lat / lon in radians private final double lon; private final double lat; LatLng(double lat, double lon) { this.lon = lon; this.lat = lat; } /** Returns latitude in radians */ public double getLatRad() { return lat; } /** Returns longitude in radians */ public double getLonRad() { return lon; } /** Returns latitude in degrees */ public double getLatDeg() { return Math.toDegrees(getLatRad()); } /** Returns longitude in degrees */ public double getLonDeg() { return Math.toDegrees(getLonRad()); } /** * Determines the azimuth to the provided LatLng in radians. * * @param lat The latitude in radians. * @param lon The longitude in radians. * @return The azimuth in radians. */ double geoAzimuthRads(double lat, double lon) { // algorithm from the original H3 library final double cosLat = FastMath.cos(lat); return FastMath.atan2( cosLat * FastMath.sin(lon - this.lon), FastMath.cos(this.lat) * FastMath.sin(lat) - FastMath.sin(this.lat) * cosLat * FastMath.cos(lon - this.lon) ); } /** * Computes the point on the sphere with a specified azimuth and distance from * this point. * * @param az The desired azimuth. * @param distance The desired distance. * @return The LatLng point. */ LatLng geoAzDistanceRads(double az, double distance) { // algorithm from the original H3 library az = Vec2d.posAngleRads(az); final double sinDistance = FastMath.sin(distance); final double cosDistance = FastMath.cos(distance); final double sinP1Lat = FastMath.sin(getLatRad()); final double cosP1Lat = FastMath.cos(getLatRad()); final double sinlat = Math.max(-1.0, Math.min(1.0, sinP1Lat * cosDistance + cosP1Lat * sinDistance * FastMath.cos(az))); final double lat = FastMath.asin(sinlat); if (Math.abs(lat - M_PI_2) < Constants.EPSILON) { // north pole return new LatLng(M_PI_2, 0.0); } else if (Math.abs(lat + M_PI_2) < Constants.EPSILON) { // south pole return new LatLng(-M_PI_2, 0.0); } else { final double cosLat = FastMath.cos(lat); final double sinlng = Math.max(-1.0, Math.min(1.0, FastMath.sin(az) * sinDistance / cosLat)); final double coslng = Math.max(-1.0, Math.min(1.0, (cosDistance - sinP1Lat * FastMath.sin(lat)) / cosP1Lat / cosLat)); return new LatLng(lat, constrainLng(getLonRad() + FastMath.atan2(sinlng, coslng))); } } /** * constrainLng makes sure longitudes are in the proper bounds * * @param lng The origin lng value * @return The corrected lng value */ private static double constrainLng(double lng) { while (lng > Math.PI) { lng = lng - Constants.M_2PI; } while (lng < -Math.PI) { lng = lng + Constants.M_2PI; } return lng; } /** * Determines the maximum latitude of the great circle defined by this LatLng to the provided LatLng. * * @param latLng The LatLng. * @return The maximum latitude of the great circle in radians. */ public double greatCircleMaxLatitude(LatLng latLng) { if (isNumericallyIdentical(latLng)) { return latLng.lat; } return latLng.lat > this.lat ? greatCircleMaxLatitude(latLng, this) : greatCircleMaxLatitude(this, latLng); } private static double greatCircleMaxLatitude(LatLng latLng1, LatLng latLng2) { // we compute the max latitude using Clairaut's formula (https://streckenflug.at/download/formeln.pdf) assert latLng1.lat >= latLng2.lat; final double az = latLng1.geoAzimuthRads(latLng2.lat, latLng2.lon); // the great circle contains the maximum latitude only if the azimuth is between -90 and 90 degrees. if (Math.abs(az) < M_PI_2) { return FastMath.acos(Math.abs(FastMath.sin(az) * FastMath.cos(latLng1.lat))); } return latLng1.lat; } /** * Determines the minimum latitude of the great circle defined by this LatLng to the provided LatLng. * * @param latLng The LatLng. * @return The minimum latitude of the great circle in radians. */ public double greatCircleMinLatitude(LatLng latLng) { if (isNumericallyIdentical(latLng)) { return latLng.lat; } return latLng.lat < this.lat ? greatCircleMinLatitude(latLng, this) : greatCircleMinLatitude(this, latLng); } private static double greatCircleMinLatitude(LatLng latLng1, LatLng latLng2) { assert latLng1.lat <= latLng2.lat; // we compute the min latitude using Clairaut's formula (https://streckenflug.at/download/formeln.pdf) final double az = latLng1.geoAzimuthRads(latLng2.lat, latLng2.lon); // the great circle contains the minimum latitude only if the azimuth is not between -90 and 90 degrees. if (Math.abs(az) > M_PI_2) { // note the sign return -FastMath.acos(Math.abs(FastMath.sin(az) * FastMath.cos(latLng1.lat))); } return latLng1.lat; } boolean isNumericallyIdentical(LatLng latLng) { return Math.abs(this.lat - latLng.lat) < MINIMUM_ANGULAR_RESOLUTION && Math.abs(this.lon - latLng.lon) < MINIMUM_ANGULAR_RESOLUTION; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final LatLng latLng = (LatLng) o; return Double.compare(latLng.lon, lon) == 0 && Double.compare(latLng.lat, lat) == 0; } @Override public int hashCode() { return Objects.hash(lon, lat); } }
elastic/elasticsearch
libs/h3/src/main/java/org/elasticsearch/h3/LatLng.java
854
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.tasks; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.telemetry.tracing.Traceable; import org.elasticsearch.xcontent.ToXContent; import org.elasticsearch.xcontent.ToXContentObject; import java.io.IOException; import java.util.Map; import java.util.Set; /** * Current task information */ public class Task implements Traceable { /** * The request header to mark tasks with specific ids */ public static final String X_OPAQUE_ID_HTTP_HEADER = "X-Opaque-Id"; /** * The request header which is contained in HTTP request. We parse trace.id from it and store it in thread context. * TRACE_PARENT once parsed in RestController.tryAllHandler is not preserved * has to be declared as a header copied over from http request. * May also be used internally when APM is enabled. */ public static final String TRACE_PARENT_HTTP_HEADER = "traceparent"; /** * A request header that indicates the origin of the request from Elastic stack. The value will stored in ThreadContext * and emitted to ES logs */ public static final String X_ELASTIC_PRODUCT_ORIGIN_HTTP_HEADER = "X-elastic-product-origin"; public static final String TRACE_STATE = "tracestate"; /** * Used internally to pass the apm trace context between the nodes */ public static final String APM_TRACE_CONTEXT = "apm.local.context"; /** * Parsed part of traceparent. It is stored in thread context and emitted in logs. * Has to be declared as a header copied over for tasks. */ public static final String TRACE_ID = "trace.id"; public static final String TRACE_START_TIME = "trace.starttime"; public static final String TRACE_PARENT = "traceparent"; public static final Set<String> HEADERS_TO_COPY = Set.of( X_OPAQUE_ID_HTTP_HEADER, TRACE_PARENT_HTTP_HEADER, TRACE_ID, X_ELASTIC_PRODUCT_ORIGIN_HTTP_HEADER ); private final long id; private final String type; private final String action; private final String description; private final TaskId parentTask; private final Map<String, String> headers; /** * The task's start time as a wall clock time since epoch ({@link System#currentTimeMillis()} style). */ private final long startTime; /** * The task's start time as a relative time ({@link System#nanoTime()} style). */ private final long startTimeNanos; public Task(long id, String type, String action, String description, TaskId parentTask, Map<String, String> headers) { this(id, type, action, description, parentTask, System.currentTimeMillis(), System.nanoTime(), headers); } public Task( long id, String type, String action, String description, TaskId parentTask, long startTime, long startTimeNanos, Map<String, String> headers ) { this.id = id; this.type = type; this.action = action; this.description = description; this.parentTask = parentTask; this.startTime = startTime; this.startTimeNanos = startTimeNanos; this.headers = headers; } /** * Build a version of the task status you can throw over the wire and back * to the user. * * @param localNodeId * the id of the node this task is running on * @param detailed * should the information include detailed, potentially slow to * generate data? */ public final TaskInfo taskInfo(String localNodeId, boolean detailed) { String description = null; Task.Status status = null; if (detailed) { description = getDescription(); status = getStatus(); } return taskInfo(localNodeId, description, status); } /** * Build a proper {@link TaskInfo} for this task. */ protected final TaskInfo taskInfo(String localNodeId, String description, Status status) { return new TaskInfo( new TaskId(localNodeId, getId()), getType(), localNodeId, getAction(), description, status, startTime, System.nanoTime() - startTimeNanos, this instanceof CancellableTask, this instanceof CancellableTask && ((CancellableTask) this).isCancelled(), parentTask, headers ); } /** * Returns task id */ public long getId() { return id; } /** * Returns task channel type (netty, transport, direct) */ public String getType() { return type; } /** * Returns task action */ public String getAction() { return action; } /** * Generates task description */ public String getDescription() { return description; } /** * Returns the task's start time as a wall clock time since epoch ({@link System#currentTimeMillis()} style). */ public long getStartTime() { return startTime; } /** * Returns the task's start time in nanoseconds ({@link System#nanoTime()} style). */ public long getStartTimeNanos() { return startTimeNanos; } /** * Returns id of the parent task or NO_PARENT_ID if the task doesn't have any parent tasks */ public TaskId getParentTaskId() { return parentTask; } /** * Build a status for this task or null if this task doesn't have status. * Since most tasks don't have status this defaults to returning null. While * this can never perform IO it might be a costly operation, requiring * collating lists of results, etc. So only use it if you need the value. */ public Status getStatus() { return null; } @Override public String toString() { return "Task{id=" + id + ", type='" + type + "', action='" + action + "', description='" + description + "', parentTask=" + parentTask + ", startTime=" + startTime + ", startTimeNanos=" + startTimeNanos + '}'; } /** * Report of the internal status of a task. These can vary wildly from task * to task because each task is implemented differently but we should try * to keep each task consistent from version to version where possible. * That means each implementation of {@linkplain Task.Status#toXContent} * should avoid making backwards incompatible changes to the rendered * result. But if we change the way a request is implemented it might not * be possible to preserve backwards compatibility. In that case, we * <b>can</b> change this on version upgrade but we should be careful * because some statuses (reindex) have become defacto standardized because * they are used by systems like Kibana. */ public interface Status extends ToXContentObject, NamedWriteable {} /** * Returns stored task header associated with the task */ public String getHeader(String header) { return headers.get(header); } public Map<String, String> headers() { return headers; } public TaskResult result(DiscoveryNode node, Exception error) throws IOException { return new TaskResult(taskInfo(node.getId(), true), error); } public TaskResult result(DiscoveryNode node, ActionResponse response) throws IOException { if (response instanceof ToXContent) { return new TaskResult(taskInfo(node.getId(), true), (ToXContent) response); } else { throw new IllegalStateException("response has to implement ToXContent to be able to store the results"); } } @Override public String getSpanId() { return "task-" + getId(); } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/tasks/Task.java
855
/* * @notice * Copyright 2012 Jeff Hain * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= * Notice of fdlibm package this program is partially derived from: * * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ============================================================================= * * This code sourced from: * https://github.com/jeffhain/jafama/blob/d7d2a7659e96e148d827acc24cf385b872cda365/src/main/java/net/jafama/FastMath.java */ package org.elasticsearch.h3; /** * This file is forked from https://github.com/jeffhain/jafama. In particular, it forks the following file: * https://github.com/jeffhain/jafama/blob/master/src/main/java/net/jafama/FastMath.java * * It modifies the original implementation by removing not needed methods leaving the following trigonometric function: * <ul> * <li>{@link #cos(double)}</li> * <li>{@link #sin(double)}</li> * <li>{@link #tan(double)}</li> * <li>{@link #acos(double)}</li> * <li>{@link #asin(double)}</li> * <li>{@link #atan(double)}</li> * <li>{@link #atan2(double, double)}</li> * </ul> */ final class FastMath { /* * For trigonometric functions, use of look-up tables and Taylor-Lagrange formula * with 4 derivatives (more take longer to compute and don't add much accuracy, * less require larger tables (which use more memory, take more time to initialize, * and are slower to access (at least on the machine they were developed on))). * * For angles reduction of cos/sin/tan functions: * - for small values, instead of reducing angles, and then computing the best index * for look-up tables, we compute this index right away, and use it for reduction, * - for large values, treatments derived from fdlibm package are used, as done in * java.lang.Math. They are faster but still "slow", so if you work with * large numbers and need speed over accuracy for them, you might want to use * normalizeXXXFast treatments before your function, or modify cos/sin/tan * so that they call the fast normalization treatments instead of the accurate ones. * NB: If an angle is huge (like PI*1e20), in double precision format its last digits * are zeros, which most likely is not the case for the intended value, and doing * an accurate reduction on a very inaccurate value is most likely pointless. * But it gives some sort of coherence that could be needed in some cases. * * Multiplication on double appears to be about as fast (or not much slower) than call * to <double_array>[<index>], and regrouping some doubles in a private class, to use * index only once, does not seem to speed things up, so: * - for uniformly tabulated values, to retrieve the parameter corresponding to * an index, we recompute it rather than using an array to store it, * - for cos/sin, we recompute derivatives divided by (multiplied by inverse of) * factorial each time, rather than storing them in arrays. * * Lengths of look-up tables are usually of the form 2^n+1, for their values to be * of the form (<a_constant> * k/2^n, k in 0 .. 2^n), so that particular values * (PI/2, etc.) are "exactly" computed, as well as for other reasons. * * Most math treatments I could find on the web, including "fast" ones, * usually take care of special cases (NaN, etc.) at the beginning, and * then deal with the general case, which adds a useless overhead for the * general (and common) case. In this class, special cases are only dealt * with when needed, and if the general case does not already handle them. */ // -------------------------------------------------------------------------- // GENERAL CONSTANTS // -------------------------------------------------------------------------- private static final double ONE_DIV_F2 = 1 / 2.0; private static final double ONE_DIV_F3 = 1 / 6.0; private static final double ONE_DIV_F4 = 1 / 24.0; private static final double TWO_POW_24 = Double.longBitsToDouble(0x4170000000000000L); private static final double TWO_POW_N24 = Double.longBitsToDouble(0x3E70000000000000L); private static final double TWO_POW_66 = Double.longBitsToDouble(0x4410000000000000L); private static final int MIN_DOUBLE_EXPONENT = -1074; private static final int MAX_DOUBLE_EXPONENT = 1023; // -------------------------------------------------------------------------- // CONSTANTS FOR NORMALIZATIONS // -------------------------------------------------------------------------- /* * Table of constants for 1/(2*PI), 282 Hex digits (enough for normalizing doubles). * 1/(2*PI) approximation = sum of ONE_OVER_TWOPI_TAB[i]*2^(-24*(i+1)). */ private static final double[] ONE_OVER_TWOPI_TAB = { 0x28BE60, 0xDB9391, 0x054A7F, 0x09D5F4, 0x7D4D37, 0x7036D8, 0xA5664F, 0x10E410, 0x7F9458, 0xEAF7AE, 0xF1586D, 0xC91B8E, 0x909374, 0xB80192, 0x4BBA82, 0x746487, 0x3F877A, 0xC72C4A, 0x69CFBA, 0x208D7D, 0x4BAED1, 0x213A67, 0x1C09AD, 0x17DF90, 0x4E6475, 0x8E60D4, 0xCE7D27, 0x2117E2, 0xEF7E4A, 0x0EC7FE, 0x25FFF7, 0x816603, 0xFBCBC4, 0x62D682, 0x9B47DB, 0x4D9FB3, 0xC9F2C2, 0x6DD3D1, 0x8FD9A7, 0x97FA8B, 0x5D49EE, 0xB1FAF9, 0x7C5ECF, 0x41CE7D, 0xE294A4, 0xBA9AFE, 0xD7EC47 }; /* * Constants for 2*PI. Only the 23 most significant bits of each mantissa are used. * 2*PI approximation = sum of TWOPI_TAB<i>. */ private static final double TWOPI_TAB0 = Double.longBitsToDouble(0x401921FB40000000L); private static final double TWOPI_TAB1 = Double.longBitsToDouble(0x3E94442D00000000L); private static final double TWOPI_TAB2 = Double.longBitsToDouble(0x3D18469880000000L); private static final double TWOPI_TAB3 = Double.longBitsToDouble(0x3B98CC5160000000L); private static final double TWOPI_TAB4 = Double.longBitsToDouble(0x3A101B8380000000L); private static final double INVPIO2 = Double.longBitsToDouble(0x3FE45F306DC9C883L); // 6.36619772367581382433e-01 53 bits of 2/pi private static final double PIO2_HI = Double.longBitsToDouble(0x3FF921FB54400000L); // 1.57079632673412561417e+00 first 33 bits of pi/2 private static final double PIO2_LO = Double.longBitsToDouble(0x3DD0B4611A626331L); // 6.07710050650619224932e-11 pi/2 - PIO2_HI private static final double INVTWOPI = INVPIO2 / 4; private static final double TWOPI_HI = 4 * PIO2_HI; private static final double TWOPI_LO = 4 * PIO2_LO; // fdlibm uses 2^19*PI/2 here, but we normalize with % 2*PI instead of % PI/2, // and we can bear some more error. private static final double NORMALIZE_ANGLE_MAX_MEDIUM_DOUBLE = StrictMath.pow(2, 20) * (2 * Math.PI); // -------------------------------------------------------------------------- // CONSTANTS AND TABLES FOR COS, SIN // -------------------------------------------------------------------------- private static final int SIN_COS_TABS_SIZE = (1 << getTabSizePower(11)) + 1; private static final double SIN_COS_DELTA_HI = TWOPI_HI / (SIN_COS_TABS_SIZE - 1); private static final double SIN_COS_DELTA_LO = TWOPI_LO / (SIN_COS_TABS_SIZE - 1); private static final double SIN_COS_INDEXER = 1 / (SIN_COS_DELTA_HI + SIN_COS_DELTA_LO); private static final double[] sinTab = new double[SIN_COS_TABS_SIZE]; private static final double[] cosTab = new double[SIN_COS_TABS_SIZE]; // Max abs value for fast modulo, above which we use regular angle normalization. // This value must be < (Integer.MAX_VALUE / SIN_COS_INDEXER), to stay in range of int type. // The higher it is, the higher the error, but also the faster it is for lower values. // If you set it to ((Integer.MAX_VALUE / SIN_COS_INDEXER) * 0.99), worse accuracy on double range is about 1e-10. private static final double SIN_COS_MAX_VALUE_FOR_INT_MODULO = ((Integer.MAX_VALUE >> 9) / SIN_COS_INDEXER) * 0.99; // -------------------------------------------------------------------------- // CONSTANTS AND TABLES FOR TAN // -------------------------------------------------------------------------- // We use the following formula: // 1) tan(-x) = -tan(x) // 2) tan(x) = 1/tan(PI/2-x) // ---> we only have to compute tan(x) on [0,A] with PI/4<=A<PI/2. // We use indexing past look-up tables, so that indexing information // allows for fast recomputation of angle in [0,PI/2] range. private static final int TAN_VIRTUAL_TABS_SIZE = (1 << getTabSizePower(12)) + 1; // Must be >= 45deg, and supposed to be >= 51.4deg, as fdlibm code is not // supposed to work with values inferior to that (51.4deg is about // (PI/2-Double.longBitsToDouble(0x3FE5942800000000L))). private static final double TAN_MAX_VALUE_FOR_TABS = Math.toRadians(77.0); private static final int TAN_TABS_SIZE = (int) ((TAN_MAX_VALUE_FOR_TABS / (Math.PI / 2)) * (TAN_VIRTUAL_TABS_SIZE - 1)) + 1; private static final double TAN_DELTA_HI = PIO2_HI / (TAN_VIRTUAL_TABS_SIZE - 1); private static final double TAN_DELTA_LO = PIO2_LO / (TAN_VIRTUAL_TABS_SIZE - 1); private static final double TAN_INDEXER = 1 / (TAN_DELTA_HI + TAN_DELTA_LO); private static final double[] tanTab = new double[TAN_TABS_SIZE]; private static final double[] tanDer1DivF1Tab = new double[TAN_TABS_SIZE]; private static final double[] tanDer2DivF2Tab = new double[TAN_TABS_SIZE]; private static final double[] tanDer3DivF3Tab = new double[TAN_TABS_SIZE]; private static final double[] tanDer4DivF4Tab = new double[TAN_TABS_SIZE]; // Max abs value for fast modulo, above which we use regular angle normalization. // This value must be < (Integer.MAX_VALUE / TAN_INDEXER), to stay in range of int type. // The higher it is, the higher the error, but also the faster it is for lower values. private static final double TAN_MAX_VALUE_FOR_INT_MODULO = (((Integer.MAX_VALUE >> 9) / TAN_INDEXER) * 0.99); // -------------------------------------------------------------------------- // CONSTANTS AND TABLES FOR ACOS, ASIN // -------------------------------------------------------------------------- // We use the following formula: // 1) acos(x) = PI/2 - asin(x) // 2) asin(-x) = -asin(x) // ---> we only have to compute asin(x) on [0,1]. // For values not close to +-1, we use look-up tables; // for values near +-1, we use code derived from fdlibm. // Supposed to be >= sin(77.2deg), as fdlibm code is supposed to work with values > 0.975, // but seems to work well enough as long as value >= sin(25deg). private static final double ASIN_MAX_VALUE_FOR_TABS = StrictMath.sin(Math.toRadians(73.0)); private static final int ASIN_TABS_SIZE = (1 << getTabSizePower(13)) + 1; private static final double ASIN_DELTA = ASIN_MAX_VALUE_FOR_TABS / (ASIN_TABS_SIZE - 1); private static final double ASIN_INDEXER = 1 / ASIN_DELTA; private static final double[] asinTab = new double[ASIN_TABS_SIZE]; private static final double[] asinDer1DivF1Tab = new double[ASIN_TABS_SIZE]; private static final double[] asinDer2DivF2Tab = new double[ASIN_TABS_SIZE]; private static final double[] asinDer3DivF3Tab = new double[ASIN_TABS_SIZE]; private static final double[] asinDer4DivF4Tab = new double[ASIN_TABS_SIZE]; private static final double ASIN_MAX_VALUE_FOR_POWTABS = StrictMath.sin(Math.toRadians(88.6)); private static final int ASIN_POWTABS_POWER = 84; private static final double ASIN_POWTABS_ONE_DIV_MAX_VALUE = 1 / ASIN_MAX_VALUE_FOR_POWTABS; private static final int ASIN_POWTABS_SIZE = (1 << getTabSizePower(12)) + 1; private static final int ASIN_POWTABS_SIZE_MINUS_ONE = ASIN_POWTABS_SIZE - 1; private static final double[] asinParamPowTab = new double[ASIN_POWTABS_SIZE]; private static final double[] asinPowTab = new double[ASIN_POWTABS_SIZE]; private static final double[] asinDer1DivF1PowTab = new double[ASIN_POWTABS_SIZE]; private static final double[] asinDer2DivF2PowTab = new double[ASIN_POWTABS_SIZE]; private static final double[] asinDer3DivF3PowTab = new double[ASIN_POWTABS_SIZE]; private static final double[] asinDer4DivF4PowTab = new double[ASIN_POWTABS_SIZE]; private static final double ASIN_PIO2_HI = Double.longBitsToDouble(0x3FF921FB54442D18L); // 1.57079632679489655800e+00 private static final double ASIN_PIO2_LO = Double.longBitsToDouble(0x3C91A62633145C07L); // 6.12323399573676603587e-17 private static final double ASIN_PS0 = Double.longBitsToDouble(0x3fc5555555555555L); // 1.66666666666666657415e-01 private static final double ASIN_PS1 = Double.longBitsToDouble(0xbfd4d61203eb6f7dL); // -3.25565818622400915405e-01 private static final double ASIN_PS2 = Double.longBitsToDouble(0x3fc9c1550e884455L); // 2.01212532134862925881e-01 private static final double ASIN_PS3 = Double.longBitsToDouble(0xbfa48228b5688f3bL); // -4.00555345006794114027e-02 private static final double ASIN_PS4 = Double.longBitsToDouble(0x3f49efe07501b288L); // 7.91534994289814532176e-04 private static final double ASIN_PS5 = Double.longBitsToDouble(0x3f023de10dfdf709L); // 3.47933107596021167570e-05 private static final double ASIN_QS1 = Double.longBitsToDouble(0xc0033a271c8a2d4bL); // -2.40339491173441421878e+00 private static final double ASIN_QS2 = Double.longBitsToDouble(0x40002ae59c598ac8L); // 2.02094576023350569471e+00 private static final double ASIN_QS3 = Double.longBitsToDouble(0xbfe6066c1b8d0159L); // -6.88283971605453293030e-01 private static final double ASIN_QS4 = Double.longBitsToDouble(0x3fb3b8c5b12e9282L); // 7.70381505559019352791e-02 // -------------------------------------------------------------------------- // CONSTANTS AND TABLES FOR ATAN // -------------------------------------------------------------------------- // We use the formula atan(-x) = -atan(x) // ---> we only have to compute atan(x) on [0,+infinity[. // For values corresponding to angles not close to +-PI/2, we use look-up tables; // for values corresponding to angles near +-PI/2, we use code derived from fdlibm. // Supposed to be >= tan(67.7deg), as fdlibm code is supposed to work with values > 2.4375. private static final double ATAN_MAX_VALUE_FOR_TABS = StrictMath.tan(Math.toRadians(74.0)); private static final int ATAN_TABS_SIZE = (1 << getTabSizePower(12)) + 1; private static final double ATAN_DELTA = ATAN_MAX_VALUE_FOR_TABS / (ATAN_TABS_SIZE - 1); private static final double ATAN_INDEXER = 1 / ATAN_DELTA; private static final double[] atanTab = new double[ATAN_TABS_SIZE]; private static final double[] atanDer1DivF1Tab = new double[ATAN_TABS_SIZE]; private static final double[] atanDer2DivF2Tab = new double[ATAN_TABS_SIZE]; private static final double[] atanDer3DivF3Tab = new double[ATAN_TABS_SIZE]; private static final double[] atanDer4DivF4Tab = new double[ATAN_TABS_SIZE]; private static final double ATAN_HI3 = Double.longBitsToDouble(0x3ff921fb54442d18L); // 1.57079632679489655800e+00 atan(inf)hi private static final double ATAN_LO3 = Double.longBitsToDouble(0x3c91a62633145c07L); // 6.12323399573676603587e-17 atan(inf)lo private static final double ATAN_AT0 = Double.longBitsToDouble(0x3fd555555555550dL); // 3.33333333333329318027e-01 private static final double ATAN_AT1 = Double.longBitsToDouble(0xbfc999999998ebc4L); // -1.99999999998764832476e-01 private static final double ATAN_AT2 = Double.longBitsToDouble(0x3fc24924920083ffL); // 1.42857142725034663711e-01 private static final double ATAN_AT3 = Double.longBitsToDouble(0xbfbc71c6fe231671L); // -1.11111104054623557880e-01 private static final double ATAN_AT4 = Double.longBitsToDouble(0x3fb745cdc54c206eL); // 9.09088713343650656196e-02 private static final double ATAN_AT5 = Double.longBitsToDouble(0xbfb3b0f2af749a6dL); // -7.69187620504482999495e-02 private static final double ATAN_AT6 = Double.longBitsToDouble(0x3fb10d66a0d03d51L); // 6.66107313738753120669e-02 private static final double ATAN_AT7 = Double.longBitsToDouble(0xbfadde2d52defd9aL); // -5.83357013379057348645e-02 private static final double ATAN_AT8 = Double.longBitsToDouble(0x3fa97b4b24760debL); // 4.97687799461593236017e-02 private static final double ATAN_AT9 = Double.longBitsToDouble(0xbfa2b4442c6a6c2fL); // -3.65315727442169155270e-02 private static final double ATAN_AT10 = Double.longBitsToDouble(0x3f90ad3ae322da11L); // 1.62858201153657823623e-02 // -------------------------------------------------------------------------- // TABLE FOR POWERS OF TWO // -------------------------------------------------------------------------- private static final double[] twoPowTab = new double[(MAX_DOUBLE_EXPONENT - MIN_DOUBLE_EXPONENT) + 1]; // -------------------------------------------------------------------------- // PUBLIC TREATMENTS // -------------------------------------------------------------------------- /** * @param angle Angle in radians. * @return Angle cosine. */ public static double cos(double angle) { angle = Math.abs(angle); if (angle > SIN_COS_MAX_VALUE_FOR_INT_MODULO) { // Faster than using normalizeZeroTwoPi. angle = remainderTwoPi(angle); if (angle < 0.0) { angle += 2 * Math.PI; } } // index: possibly outside tables range. int index = (int) (angle * SIN_COS_INDEXER + 0.5); double delta = (angle - index * SIN_COS_DELTA_HI) - index * SIN_COS_DELTA_LO; // Making sure index is within tables range. // Last value of each table is the same than first, so we ignore it (tabs size minus one) for modulo. index &= (SIN_COS_TABS_SIZE - 2); // index % (SIN_COS_TABS_SIZE-1) double indexCos = cosTab[index]; double indexSin = sinTab[index]; return indexCos + delta * (-indexSin + delta * (-indexCos * ONE_DIV_F2 + delta * (indexSin * ONE_DIV_F3 + delta * indexCos * ONE_DIV_F4))); } /** * @param angle Angle in radians. * @return Angle sine. */ public static double sin(double angle) { boolean negateResult; if (angle < 0.0) { angle = -angle; negateResult = true; } else { negateResult = false; } if (angle > SIN_COS_MAX_VALUE_FOR_INT_MODULO) { // Faster than using normalizeZeroTwoPi. angle = remainderTwoPi(angle); if (angle < 0.0) { angle += 2 * Math.PI; } } int index = (int) (angle * SIN_COS_INDEXER + 0.5); double delta = (angle - index * SIN_COS_DELTA_HI) - index * SIN_COS_DELTA_LO; index &= (SIN_COS_TABS_SIZE - 2); // index % (SIN_COS_TABS_SIZE-1) double indexSin = sinTab[index]; double indexCos = cosTab[index]; double result = indexSin + delta * (indexCos + delta * (-indexSin * ONE_DIV_F2 + delta * (-indexCos * ONE_DIV_F3 + delta * indexSin * ONE_DIV_F4))); return negateResult ? -result : result; } /** * @param angle Angle in radians. * @return Angle tangent. */ public static double tan(double angle) { if (Math.abs(angle) > TAN_MAX_VALUE_FOR_INT_MODULO) { // Faster than using normalizeMinusHalfPiHalfPi. angle = remainderTwoPi(angle); if (angle < -Math.PI / 2) { angle += Math.PI; } else if (angle > Math.PI / 2) { angle -= Math.PI; } } boolean negateResult; if (angle < 0.0) { angle = -angle; negateResult = true; } else { negateResult = false; } int index = (int) (angle * TAN_INDEXER + 0.5); double delta = (angle - index * TAN_DELTA_HI) - index * TAN_DELTA_LO; // index modulo PI, i.e. 2*(virtual tab size minus one). index &= (2 * (TAN_VIRTUAL_TABS_SIZE - 1) - 1); // index % (2*(TAN_VIRTUAL_TABS_SIZE-1)) // Here, index is in [0,2*(TAN_VIRTUAL_TABS_SIZE-1)-1], i.e. indicates an angle in [0,PI[. if (index > (TAN_VIRTUAL_TABS_SIZE - 1)) { index = (2 * (TAN_VIRTUAL_TABS_SIZE - 1)) - index; delta = -delta; negateResult = negateResult == false; } double result; if (index < TAN_TABS_SIZE) { result = tanTab[index] + delta * (tanDer1DivF1Tab[index] + delta * (tanDer2DivF2Tab[index] + delta * (tanDer3DivF3Tab[index] + delta * tanDer4DivF4Tab[index]))); } else { // angle in ]TAN_MAX_VALUE_FOR_TABS,TAN_MAX_VALUE_FOR_INT_MODULO], or angle is NaN // Using tan(angle) == 1/tan(PI/2-angle) formula: changing angle (index and delta), and inverting. index = (TAN_VIRTUAL_TABS_SIZE - 1) - index; result = 1 / (tanTab[index] - delta * (tanDer1DivF1Tab[index] - delta * (tanDer2DivF2Tab[index] - delta * (tanDer3DivF3Tab[index] - delta * tanDer4DivF4Tab[index])))); } return negateResult ? -result : result; } /** * @param value Value in [-1,1]. * @return Value arccosine, in radians, in [0,PI]. */ public static double acos(double value) { return Math.PI / 2 - FastMath.asin(value); } /** * @param value Value in [-1,1]. * @return Value arcsine, in radians, in [-PI/2,PI/2]. */ public static double asin(double value) { boolean negateResult; if (value < 0.0) { value = -value; negateResult = true; } else { negateResult = false; } if (value <= ASIN_MAX_VALUE_FOR_TABS) { int index = (int) (value * ASIN_INDEXER + 0.5); double delta = value - index * ASIN_DELTA; double result = asinTab[index] + delta * (asinDer1DivF1Tab[index] + delta * (asinDer2DivF2Tab[index] + delta * (asinDer3DivF3Tab[index] + delta * asinDer4DivF4Tab[index]))); return negateResult ? -result : result; } else if (value <= ASIN_MAX_VALUE_FOR_POWTABS) { int index = (int) (FastMath.powFast(value * ASIN_POWTABS_ONE_DIV_MAX_VALUE, ASIN_POWTABS_POWER) * ASIN_POWTABS_SIZE_MINUS_ONE + 0.5); double delta = value - asinParamPowTab[index]; double result = asinPowTab[index] + delta * (asinDer1DivF1PowTab[index] + delta * (asinDer2DivF2PowTab[index] + delta * (asinDer3DivF3PowTab[index] + delta * asinDer4DivF4PowTab[index]))); return negateResult ? -result : result; } else { // value > ASIN_MAX_VALUE_FOR_TABS, or value is NaN // This part is derived from fdlibm. if (value < 1.0) { double t = (1.0 - value) * 0.5; double p = t * (ASIN_PS0 + t * (ASIN_PS1 + t * (ASIN_PS2 + t * (ASIN_PS3 + t * (ASIN_PS4 + t * ASIN_PS5))))); double q = 1.0 + t * (ASIN_QS1 + t * (ASIN_QS2 + t * (ASIN_QS3 + t * ASIN_QS4))); double s = Math.sqrt(t); double z = s + s * (p / q); double result = ASIN_PIO2_HI - ((z + z) - ASIN_PIO2_LO); return negateResult ? -result : result; } else { // value >= 1.0, or value is NaN if (value == 1.0) { return negateResult ? -Math.PI / 2 : Math.PI / 2; } else { return Double.NaN; } } } } /** * @param value A double value. * @return Value arctangent, in radians, in [-PI/2,PI/2]. */ public static double atan(double value) { boolean negateResult; if (value < 0.0) { value = -value; negateResult = true; } else { negateResult = false; } if (value == 1.0) { // We want "exact" result for 1.0. return negateResult ? -Math.PI / 4 : Math.PI / 4; } else if (value <= ATAN_MAX_VALUE_FOR_TABS) { int index = (int) (value * ATAN_INDEXER + 0.5); double delta = value - index * ATAN_DELTA; double result = atanTab[index] + delta * (atanDer1DivF1Tab[index] + delta * (atanDer2DivF2Tab[index] + delta * (atanDer3DivF3Tab[index] + delta * atanDer4DivF4Tab[index]))); return negateResult ? -result : result; } else { // value > ATAN_MAX_VALUE_FOR_TABS, or value is NaN // This part is derived from fdlibm. if (value < TWO_POW_66) { double x = -1 / value; double x2 = x * x; double x4 = x2 * x2; double s1 = x2 * (ATAN_AT0 + x4 * (ATAN_AT2 + x4 * (ATAN_AT4 + x4 * (ATAN_AT6 + x4 * (ATAN_AT8 + x4 * ATAN_AT10))))); double s2 = x4 * (ATAN_AT1 + x4 * (ATAN_AT3 + x4 * (ATAN_AT5 + x4 * (ATAN_AT7 + x4 * ATAN_AT9)))); double result = ATAN_HI3 - ((x * (s1 + s2) - ATAN_LO3) - x); return negateResult ? -result : result; } else { // value >= 2^66, or value is NaN if (Double.isNaN(value)) { return Double.NaN; } else { return negateResult ? -Math.PI / 2 : Math.PI / 2; } } } } /** * For special values for which multiple conventions could be adopted, behaves like Math.atan2(double,double). * * @param y Coordinate on y axis. * @param x Coordinate on x axis. * @return Angle from x axis positive side to (x,y) position, in radians, in [-PI,PI]. * Angle measure is positive when going from x axis to y axis (positive sides). */ public static double atan2(double y, double x) { if (x > 0.0) { if (y == 0.0) { return (1 / y == Double.NEGATIVE_INFINITY) ? -0.0 : 0.0; } if (x == Double.POSITIVE_INFINITY) { if (y == Double.POSITIVE_INFINITY) { return Math.PI / 4; } else if (y == Double.NEGATIVE_INFINITY) { return -Math.PI / 4; } else if (y > 0.0) { return 0.0; } else if (y < 0.0) { return -0.0; } else { return Double.NaN; } } else { return FastMath.atan(y / x); } } else if (x < 0.0) { if (y == 0.0) { return (1 / y == Double.NEGATIVE_INFINITY) ? -Math.PI : Math.PI; } if (x == Double.NEGATIVE_INFINITY) { if (y == Double.POSITIVE_INFINITY) { return 3 * Math.PI / 4; } else if (y == Double.NEGATIVE_INFINITY) { return -3 * Math.PI / 4; } else if (y > 0.0) { return Math.PI; } else if (y < 0.0) { return -Math.PI; } else { return Double.NaN; } } else if (y > 0.0) { return Math.PI / 2 + FastMath.atan(-x / y); } else if (y < 0.0) { return -Math.PI / 2 - FastMath.atan(x / y); } else { return Double.NaN; } } else if (x == 0.0) { if (y == 0.0) { if (1 / x == Double.NEGATIVE_INFINITY) { return (1 / y == Double.NEGATIVE_INFINITY) ? -Math.PI : Math.PI; } else { return (1 / y == Double.NEGATIVE_INFINITY) ? -0.0 : 0.0; } } if (y > 0.0) { return Math.PI / 2; } else if (y < 0.0) { return -Math.PI / 2; } else { return Double.NaN; } } else { return Double.NaN; } } /** * This treatment is somehow accurate for low values of |power|, * and for |power*getExponent(value)| &lt; 1023 or so (to stay away * from double extreme magnitudes (large and small)). * * @param value A double value. * @param power A power. * @return value^power. */ private static double powFast(double value, int power) { if (power > 5) { // Most common case first. double oddRemains = 1.0; do { // Test if power is odd. if ((power & 1) != 0) { oddRemains *= value; } value *= value; power >>= 1; // power = power / 2 } while (power > 5); // Here, power is in [3,5]: faster to finish outside the loop. if (power == 3) { return oddRemains * value * value * value; } else { double v2 = value * value; if (power == 4) { return oddRemains * v2 * v2; } else { // power == 5 return oddRemains * v2 * v2 * value; } } } else if (power >= 0) { // power in [0,5] if (power < 3) { // power in [0,2] if (power == 2) { // Most common case first. return value * value; } else if (power != 0) { // faster than == 1 return value; } else { // power == 0 return 1.0; } } else { // power in [3,5] if (power == 3) { return value * value * value; } else { // power in [4,5] double v2 = value * value; if (power == 4) { return v2 * v2; } else { // power == 5 return v2 * v2 * value; } } } } else { // power < 0 // Opposite of Integer.MIN_VALUE does not exist as int. if (power == Integer.MIN_VALUE) { // Integer.MAX_VALUE = -(power+1) return 1.0 / (FastMath.powFast(value, Integer.MAX_VALUE) * value); } else { return 1.0 / FastMath.powFast(value, -power); } } } // -------------------------------------------------------------------------- // PRIVATE TREATMENTS // -------------------------------------------------------------------------- /** * FastMath is non-instantiable. */ private FastMath() {} /** * Use look-up tables size power through this method, * to make sure is it small in case java.lang.Math * is directly used. */ private static int getTabSizePower(int tabSizePower) { return tabSizePower; } /** * Remainder using an accurate definition of PI. * Derived from a fdlibm treatment called __ieee754_rem_pio2. * * This method can return values slightly (like one ULP or so) outside [-Math.PI,Math.PI] range. * * @param angle Angle in radians. * @return Remainder of (angle % (2*PI)), which is in [-PI,PI] range. */ private static double remainderTwoPi(double angle) { boolean negateResult; if (angle < 0.0) { negateResult = true; angle = -angle; } else { negateResult = false; } if (angle <= NORMALIZE_ANGLE_MAX_MEDIUM_DOUBLE) { double fn = (double) (int) (angle * INVTWOPI + 0.5); double result = (angle - fn * TWOPI_HI) - fn * TWOPI_LO; return negateResult ? -result : result; } else if (angle < Double.POSITIVE_INFINITY) { // Reworking exponent to have a value < 2^24. long lx = Double.doubleToRawLongBits(angle); long exp = ((lx >> 52) & 0x7FF) - 1046; double z = Double.longBitsToDouble(lx - (exp << 52)); double x0 = (double) ((int) z); z = (z - x0) * TWO_POW_24; double x1 = (double) ((int) z); double x2 = (z - x1) * TWO_POW_24; double result = subRemainderTwoPi(x0, x1, x2, (int) exp, (x2 == 0) ? 2 : 3); return negateResult ? -result : result; } else { // angle is +infinity or NaN return Double.NaN; } } /** * Remainder using an accurate definition of PI. * Derived from a fdlibm treatment called __kernel_rem_pio2. * * @param x0 Most significant part of the value, as an integer &lt; 2^24, in double precision format. Must be >= 0. * @param x1 Following significant part of the value, as an integer &lt; 2^24, in double precision format. * @param x2 Least significant part of the value, as an integer &lt; 2^24, in double precision format. * @param e0 Exponent of x0 (value is (2^e0)*(x0+(2^-24)*(x1+(2^-24)*x2))). Must be &ge; -20. * @param nx Number of significant parts to take into account. Must be 2 or 3. * @return Remainder of (value % (2*PI)), which is in [-PI,PI] range. */ private static double subRemainderTwoPi(double x0, double x1, double x2, int e0, int nx) { int ih; double z, fw; double f0, f1, f2, f3, f4, f5, f6 = 0.0, f7; double q0, q1, q2, q3, q4, q5; int iq0, iq1, iq2, iq3, iq4; final int jx = nx - 1; // jx in [1,2] (nx in [2,3]) // Could use a table to avoid division, but the gain isn't worth it most likely... final int jv = (e0 - 3) / 24; // We do not handle the case (e0-3 < -23). int q = e0 - ((jv << 4) + (jv << 3)) - 24; // e0-24*(jv+1) final int j = jv + 4; if (jx == 1) { f5 = (j >= 0) ? ONE_OVER_TWOPI_TAB[j] : 0.0; f4 = (j >= 1) ? ONE_OVER_TWOPI_TAB[j - 1] : 0.0; f3 = (j >= 2) ? ONE_OVER_TWOPI_TAB[j - 2] : 0.0; f2 = (j >= 3) ? ONE_OVER_TWOPI_TAB[j - 3] : 0.0; f1 = (j >= 4) ? ONE_OVER_TWOPI_TAB[j - 4] : 0.0; f0 = (j >= 5) ? ONE_OVER_TWOPI_TAB[j - 5] : 0.0; q0 = x0 * f1 + x1 * f0; q1 = x0 * f2 + x1 * f1; q2 = x0 * f3 + x1 * f2; q3 = x0 * f4 + x1 * f3; q4 = x0 * f5 + x1 * f4; } else { // jx == 2 f6 = (j >= 0) ? ONE_OVER_TWOPI_TAB[j] : 0.0; f5 = (j >= 1) ? ONE_OVER_TWOPI_TAB[j - 1] : 0.0; f4 = (j >= 2) ? ONE_OVER_TWOPI_TAB[j - 2] : 0.0; f3 = (j >= 3) ? ONE_OVER_TWOPI_TAB[j - 3] : 0.0; f2 = (j >= 4) ? ONE_OVER_TWOPI_TAB[j - 4] : 0.0; f1 = (j >= 5) ? ONE_OVER_TWOPI_TAB[j - 5] : 0.0; f0 = (j >= 6) ? ONE_OVER_TWOPI_TAB[j - 6] : 0.0; q0 = x0 * f2 + x1 * f1 + x2 * f0; q1 = x0 * f3 + x1 * f2 + x2 * f1; q2 = x0 * f4 + x1 * f3 + x2 * f2; q3 = x0 * f5 + x1 * f4 + x2 * f3; q4 = x0 * f6 + x1 * f5 + x2 * f4; } z = q4; fw = (double) ((int) (TWO_POW_N24 * z)); iq0 = (int) (z - TWO_POW_24 * fw); z = q3 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq1 = (int) (z - TWO_POW_24 * fw); z = q2 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq2 = (int) (z - TWO_POW_24 * fw); z = q1 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq3 = (int) (z - TWO_POW_24 * fw); z = q0 + fw; // Here, q is in [-25,2] range or so, so we can use the table right away. double twoPowQ = twoPowTab[q - MIN_DOUBLE_EXPONENT]; z = (z * twoPowQ) % 8.0; z -= (double) ((int) z); if (q > 0) { iq3 &= 0xFFFFFF >> q; ih = iq3 >> (23 - q); } else if (q == 0) { ih = iq3 >> 23; } else if (z >= 0.5) { ih = 2; } else { ih = 0; } if (ih > 0) { int carry; if (iq0 != 0) { carry = 1; iq0 = 0x1000000 - iq0; iq1 = 0x0FFFFFF - iq1; iq2 = 0x0FFFFFF - iq2; iq3 = 0x0FFFFFF - iq3; } else { if (iq1 != 0) { carry = 1; iq1 = 0x1000000 - iq1; iq2 = 0x0FFFFFF - iq2; iq3 = 0x0FFFFFF - iq3; } else { if (iq2 != 0) { carry = 1; iq2 = 0x1000000 - iq2; iq3 = 0x0FFFFFF - iq3; } else { if (iq3 != 0) { carry = 1; iq3 = 0x1000000 - iq3; } else { carry = 0; } } } } if (q > 0) { switch (q) { case 1 -> iq3 &= 0x7FFFFF; case 2 -> iq3 &= 0x3FFFFF; } } if (ih == 2) { z = 1.0 - z; if (carry != 0) { z -= twoPowQ; } } } if (z == 0.0) { if (jx == 1) { f6 = ONE_OVER_TWOPI_TAB[jv + 5]; q5 = x0 * f6 + x1 * f5; } else { // jx == 2 f7 = ONE_OVER_TWOPI_TAB[jv + 5]; q5 = x0 * f7 + x1 * f6 + x2 * f5; } z = q5; fw = (double) ((int) (TWO_POW_N24 * z)); iq0 = (int) (z - TWO_POW_24 * fw); z = q4 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq1 = (int) (z - TWO_POW_24 * fw); z = q3 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq2 = (int) (z - TWO_POW_24 * fw); z = q2 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq3 = (int) (z - TWO_POW_24 * fw); z = q1 + fw; fw = (double) ((int) (TWO_POW_N24 * z)); iq4 = (int) (z - TWO_POW_24 * fw); z = q0 + fw; z = (z * twoPowQ) % 8.0; z -= (double) ((int) z); if (q > 0) { // some parentheses for Eclipse formatter's weaknesses with bits shifts iq4 &= (0xFFFFFF >> q); ih = (iq4 >> (23 - q)); } else if (q == 0) { ih = iq4 >> 23; } else if (z >= 0.5) { ih = 2; } else { ih = 0; } if (ih > 0) { if (iq0 != 0) { iq0 = 0x1000000 - iq0; iq1 = 0x0FFFFFF - iq1; iq2 = 0x0FFFFFF - iq2; iq3 = 0x0FFFFFF - iq3; iq4 = 0x0FFFFFF - iq4; } else { if (iq1 != 0) { iq1 = 0x1000000 - iq1; iq2 = 0x0FFFFFF - iq2; iq3 = 0x0FFFFFF - iq3; iq4 = 0x0FFFFFF - iq4; } else { if (iq2 != 0) { iq2 = 0x1000000 - iq2; iq3 = 0x0FFFFFF - iq3; iq4 = 0x0FFFFFF - iq4; } else { if (iq3 != 0) { iq3 = 0x1000000 - iq3; iq4 = 0x0FFFFFF - iq4; } else { if (iq4 != 0) { iq4 = 0x1000000 - iq4; } } } } } if (q > 0) { switch (q) { case 1 -> iq4 &= 0x7FFFFF; case 2 -> iq4 &= 0x3FFFFF; } } } fw = twoPowQ * TWO_POW_N24; // q -= 24, so initializing fw with ((2^q)*(2^-24)=2^(q-24)) } else { // Here, q is in [-25,-2] range or so, so we could use twoPow's table right away with // iq4 = (int)(z*twoPowTab[-q-TWO_POW_TAB_MIN_POW]); // but tests show using division is faster... iq4 = (int) (z / twoPowQ); fw = twoPowQ; } q4 = fw * (double) iq4; fw *= TWO_POW_N24; q3 = fw * (double) iq3; fw *= TWO_POW_N24; q2 = fw * (double) iq2; fw *= TWO_POW_N24; q1 = fw * (double) iq1; fw *= TWO_POW_N24; q0 = fw * (double) iq0; fw *= TWO_POW_N24; fw = TWOPI_TAB0 * q4; fw += TWOPI_TAB0 * q3 + TWOPI_TAB1 * q4; fw += TWOPI_TAB0 * q2 + TWOPI_TAB1 * q3 + TWOPI_TAB2 * q4; fw += TWOPI_TAB0 * q1 + TWOPI_TAB1 * q2 + TWOPI_TAB2 * q3 + TWOPI_TAB3 * q4; fw += TWOPI_TAB0 * q0 + TWOPI_TAB1 * q1 + TWOPI_TAB2 * q2 + TWOPI_TAB3 * q3 + TWOPI_TAB4 * q4; return (ih == 0) ? fw : -fw; } // -------------------------------------------------------------------------- // STATIC INITIALIZATIONS // -------------------------------------------------------------------------- /** * Initializes look-up tables. * * Might use some FastMath methods in there, not to spend * an hour in it, but must take care not to use methods * which look-up tables have not yet been initialized, * or that are not accurate enough. */ static { // sin and cos final int SIN_COS_PI_INDEX = (SIN_COS_TABS_SIZE - 1) / 2; final int SIN_COS_PI_MUL_2_INDEX = 2 * SIN_COS_PI_INDEX; final int SIN_COS_PI_MUL_0_5_INDEX = SIN_COS_PI_INDEX / 2; final int SIN_COS_PI_MUL_1_5_INDEX = 3 * SIN_COS_PI_INDEX / 2; for (int i = 0; i < SIN_COS_TABS_SIZE; i++) { // angle: in [0,2*PI]. double angle = i * SIN_COS_DELTA_HI + i * SIN_COS_DELTA_LO; double sinAngle = StrictMath.sin(angle); double cosAngle = StrictMath.cos(angle); // For indexes corresponding to null cosine or sine, we make sure the value is zero // and not an epsilon. This allows for a much better accuracy for results close to zero. if (i == SIN_COS_PI_INDEX) { sinAngle = 0.0; } else if (i == SIN_COS_PI_MUL_2_INDEX) { sinAngle = 0.0; } else if (i == SIN_COS_PI_MUL_0_5_INDEX) { cosAngle = 0.0; } else if (i == SIN_COS_PI_MUL_1_5_INDEX) { cosAngle = 0.0; } sinTab[i] = sinAngle; cosTab[i] = cosAngle; } // tan for (int i = 0; i < TAN_TABS_SIZE; i++) { // angle: in [0,TAN_MAX_VALUE_FOR_TABS]. double angle = i * TAN_DELTA_HI + i * TAN_DELTA_LO; tanTab[i] = StrictMath.tan(angle); double cosAngle = StrictMath.cos(angle); double sinAngle = StrictMath.sin(angle); double cosAngleInv = 1 / cosAngle; double cosAngleInv2 = cosAngleInv * cosAngleInv; double cosAngleInv3 = cosAngleInv2 * cosAngleInv; double cosAngleInv4 = cosAngleInv2 * cosAngleInv2; double cosAngleInv5 = cosAngleInv3 * cosAngleInv2; tanDer1DivF1Tab[i] = cosAngleInv2; tanDer2DivF2Tab[i] = ((2 * sinAngle) * cosAngleInv3) * ONE_DIV_F2; tanDer3DivF3Tab[i] = ((2 * (1 + 2 * sinAngle * sinAngle)) * cosAngleInv4) * ONE_DIV_F3; tanDer4DivF4Tab[i] = ((8 * sinAngle * (2 + sinAngle * sinAngle)) * cosAngleInv5) * ONE_DIV_F4; } // asin for (int i = 0; i < ASIN_TABS_SIZE; i++) { // x: in [0,ASIN_MAX_VALUE_FOR_TABS]. double x = i * ASIN_DELTA; asinTab[i] = StrictMath.asin(x); double oneMinusXSqInv = 1.0 / (1 - x * x); double oneMinusXSqInv0_5 = StrictMath.sqrt(oneMinusXSqInv); double oneMinusXSqInv1_5 = oneMinusXSqInv0_5 * oneMinusXSqInv; double oneMinusXSqInv2_5 = oneMinusXSqInv1_5 * oneMinusXSqInv; double oneMinusXSqInv3_5 = oneMinusXSqInv2_5 * oneMinusXSqInv; asinDer1DivF1Tab[i] = oneMinusXSqInv0_5; asinDer2DivF2Tab[i] = (x * oneMinusXSqInv1_5) * ONE_DIV_F2; asinDer3DivF3Tab[i] = ((1 + 2 * x * x) * oneMinusXSqInv2_5) * ONE_DIV_F3; asinDer4DivF4Tab[i] = ((5 + 2 * x * (2 + x * (5 - 2 * x))) * oneMinusXSqInv3_5) * ONE_DIV_F4; } for (int i = 0; i < ASIN_POWTABS_SIZE; i++) { // x: in [0,ASIN_MAX_VALUE_FOR_POWTABS]. double x = StrictMath.pow(i * (1.0 / ASIN_POWTABS_SIZE_MINUS_ONE), 1.0 / ASIN_POWTABS_POWER) * ASIN_MAX_VALUE_FOR_POWTABS; asinParamPowTab[i] = x; asinPowTab[i] = StrictMath.asin(x); double oneMinusXSqInv = 1.0 / (1 - x * x); double oneMinusXSqInv0_5 = StrictMath.sqrt(oneMinusXSqInv); double oneMinusXSqInv1_5 = oneMinusXSqInv0_5 * oneMinusXSqInv; double oneMinusXSqInv2_5 = oneMinusXSqInv1_5 * oneMinusXSqInv; double oneMinusXSqInv3_5 = oneMinusXSqInv2_5 * oneMinusXSqInv; asinDer1DivF1PowTab[i] = oneMinusXSqInv0_5; asinDer2DivF2PowTab[i] = (x * oneMinusXSqInv1_5) * ONE_DIV_F2; asinDer3DivF3PowTab[i] = ((1 + 2 * x * x) * oneMinusXSqInv2_5) * ONE_DIV_F3; asinDer4DivF4PowTab[i] = ((5 + 2 * x * (2 + x * (5 - 2 * x))) * oneMinusXSqInv3_5) * ONE_DIV_F4; } // atan for (int i = 0; i < ATAN_TABS_SIZE; i++) { // x: in [0,ATAN_MAX_VALUE_FOR_TABS]. double x = i * ATAN_DELTA; double onePlusXSqInv = 1.0 / (1 + x * x); double onePlusXSqInv2 = onePlusXSqInv * onePlusXSqInv; double onePlusXSqInv3 = onePlusXSqInv2 * onePlusXSqInv; double onePlusXSqInv4 = onePlusXSqInv2 * onePlusXSqInv2; atanTab[i] = StrictMath.atan(x); atanDer1DivF1Tab[i] = onePlusXSqInv; atanDer2DivF2Tab[i] = (-2 * x * onePlusXSqInv2) * ONE_DIV_F2; atanDer3DivF3Tab[i] = ((-2 + 6 * x * x) * onePlusXSqInv3) * ONE_DIV_F3; atanDer4DivF4Tab[i] = ((24 * x * (1 - x * x)) * onePlusXSqInv4) * ONE_DIV_F4; } // twoPow for (int i = MIN_DOUBLE_EXPONENT; i <= MAX_DOUBLE_EXPONENT; i++) { twoPowTab[i - MIN_DOUBLE_EXPONENT] = StrictMath.pow(2.0, i); } } }
elastic/elasticsearch
libs/h3/src/main/java/org/elasticsearch/h3/FastMath.java
857
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ package org.tensorflow.lite; /** * An internal wrapper that wraps native SignatureRunner. * * <p>Note: This class is not thread safe. */ final class NativeSignatureRunnerWrapper { NativeSignatureRunnerWrapper(long interpreterHandle, long errorHandle, String signatureKey) { this.errorHandle = errorHandle; signatureRunnerHandle = nativeGetSignatureRunner(interpreterHandle, signatureKey); if (signatureRunnerHandle == -1) { throw new IllegalArgumentException("Input error: Signature " + signatureKey + " not found."); } } /** * Attempts to get the subgraph index associated with this Signature. Returns the subgraph index, * or -1 on error. */ public int getSubgraphIndex() { return nativeGetSubgraphIndex(signatureRunnerHandle); } /** Gets the inputs of this Signature. */ public String[] inputNames() { return nativeInputNames(signatureRunnerHandle); } /** Gets the outputs of this Signature. */ public String[] outputNames() { return nativeOutputNames(signatureRunnerHandle); } /** Gets the input tensor specified by {@code inputName}. */ public TensorImpl getInputTensor(String inputName) { return TensorImpl.fromSignatureInput(signatureRunnerHandle, inputName); } /** Gets the output tensor specified by {@code outputName}. */ public TensorImpl getOutputTensor(String outputName) { return TensorImpl.fromSignatureOutput(signatureRunnerHandle, outputName); } /** Gets the index of the input specified by {@code inputName}. */ public int getInputIndex(String inputName) { int inputIndex = nativeGetInputIndex(signatureRunnerHandle, inputName); if (inputIndex == -1) { throw new IllegalArgumentException("Input error: input " + inputName + " not found."); } return inputIndex; } /** Gets the index of the output specified by {@code outputName}. */ public int getOutputIndex(String outputName) { int outputIndex = nativeGetOutputIndex(signatureRunnerHandle, outputName); if (outputIndex == -1) { throw new IllegalArgumentException("Input error: output " + outputName + " not found."); } return outputIndex; } /** Resizes dimensions of a specific input. */ public boolean resizeInput(String inputName, int[] dims) { isMemoryAllocated = false; return nativeResizeInput(signatureRunnerHandle, errorHandle, inputName, dims); } /** Allocates tensor memory space. */ public void allocateTensorsIfNeeded() { if (isMemoryAllocated) { return; } nativeAllocateTensors(signatureRunnerHandle, errorHandle); isMemoryAllocated = true; } /** Runs inference for this Signature. */ public void invoke() { nativeInvoke(signatureRunnerHandle, errorHandle); } private final long signatureRunnerHandle; private final long errorHandle; private boolean isMemoryAllocated = false; private static native long nativeGetSignatureRunner(long interpreterHandle, String signatureKey); private static native int nativeGetSubgraphIndex(long signatureRunnerHandle); private static native String[] nativeInputNames(long signatureRunnerHandle); private static native String[] nativeOutputNames(long signatureRunnerHandle); private static native int nativeGetInputIndex(long signatureRunnerHandle, String inputName); private static native int nativeGetOutputIndex(long signatureRunnerHandle, String outputName); private static native boolean nativeResizeInput( long signatureRunnerHandle, long errorHandle, String inputName, int[] dims); private static native void nativeAllocateTensors(long signatureRunnerHandle, long errorHandle); private static native void nativeInvoke(long signatureRunnerHandle, long errorHandle); }
tensorflow/tensorflow
tensorflow/lite/java/src/main/java/org/tensorflow/lite/NativeSignatureRunnerWrapper.java
858
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.repository; import java.util.List; import java.util.Properties; import javax.sql.DataSource; import lombok.extern.slf4j.Slf4j; import org.apache.commons.dbcp.BasicDataSource; import org.hibernate.jpa.HibernatePersistenceProvider; import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; /** * This is the same example as in {@link App} but with annotations based configuration for Spring. */ @EnableJpaRepositories @SpringBootConfiguration @Slf4j public class AppConfig { /** * Creation of H2 db. * * @return A new Instance of DataSource */ @Bean(destroyMethod = "close") public DataSource dataSource() { var basicDataSource = new BasicDataSource(); basicDataSource.setDriverClassName("org.h2.Driver"); basicDataSource.setUrl("jdbc:h2:mem:databases-person"); basicDataSource.setUsername("sa"); basicDataSource.setPassword("sa"); return basicDataSource; } /** * Factory to create a especific instance of Entity Manager. */ @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { var entityManager = new LocalContainerEntityManagerFactoryBean(); entityManager.setDataSource(dataSource()); entityManager.setPackagesToScan("com.iluwatar"); entityManager.setPersistenceProvider(new HibernatePersistenceProvider()); entityManager.setJpaProperties(jpaProperties()); return entityManager; } /** * Properties for Jpa. */ private static Properties jpaProperties() { var properties = new Properties(); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); return properties; } /** * Get transaction manager. */ @Bean public JpaTransactionManager transactionManager() { var transactionManager = new JpaTransactionManager(); transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); return transactionManager; } /** * Program entry point. * * @param args command line args */ public static void main(String[] args) { var context = new AnnotationConfigApplicationContext(AppConfig.class); var repository = context.getBean(PersonRepository.class); var peter = new Person("Peter", "Sagan", 17); var nasta = new Person("Nasta", "Kuzminova", 25); var john = new Person("John", "lawrence", 35); var terry = new Person("Terry", "Law", 36); // Add new Person records repository.save(peter); repository.save(nasta); repository.save(john); repository.save(terry); // Count Person records LOGGER.info("Count Person records: {}", repository.count()); // Print all records var persons = (List<Person>) repository.findAll(); persons.stream().map(Person::toString).forEach(LOGGER::info); // Update Person nasta.setName("Barbora"); nasta.setSurname("Spotakova"); repository.save(nasta); repository.findById(2L).ifPresent(p -> LOGGER.info("Find by id 2: {}", p)); // Remove record from Person repository.deleteById(2L); // count records LOGGER.info("Count Person records: {}", repository.count()); // find by name repository .findOne(new PersonSpecifications.NameEqualSpec("John")) .ifPresent(p -> LOGGER.info("Find by John is {}", p)); // find by age persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40)); LOGGER.info("Find Person with age between 20,40: "); persons.stream().map(Person::toString).forEach(LOGGER::info); context.close(); } }
arasgungore/java-design-patterns
repository/src/main/java/com/iluwatar/repository/AppConfig.java
861
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.bridge; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; /** * Sword. */ @Slf4j @AllArgsConstructor public class Sword implements Weapon { private final Enchantment enchantment; @Override public void wield() { LOGGER.info("The sword is wielded."); enchantment.onActivate(); } @Override public void swing() { LOGGER.info("The sword is swung."); enchantment.apply(); } @Override public void unwield() { LOGGER.info("The sword is unwielded."); enchantment.onDeactivate(); } @Override public Enchantment getEnchantment() { return enchantment; } }
smedals/java-design-patterns
bridge/src/main/java/com/iluwatar/bridge/Sword.java
862
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.rest; public enum Scope { PUBLIC, // available to all requests INTERNAL // available only to requests from an operator user }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/rest/Scope.java
863
package com.thealgorithms.sorts; /** * ExchangeSort is an implementation of the Exchange Sort algorithm. * * <p> * Exchange sort works by comparing each element with all subsequent elements, * swapping where needed, to ensure the correct placement of each element * in the final sorted order. It iteratively performs this process for each * element in the array. While it lacks the advantage of bubble sort in * detecting sorted lists in one pass, it can be more efficient than bubble sort * due to a constant factor (one less pass over the data to be sorted; half as * many total comparisons) in worst-case scenarios. * </p> * * <p> * Reference: https://en.wikipedia.org/wiki/Sorting_algorithm#Exchange_sort * </p> * * @author 555vedant (Vedant Kasar) */ class ExchangeSort implements SortAlgorithm { /** * Implementation of Exchange Sort Algorithm * * @param array the array to be sorted. * @param <T> the type of elements in the array. * @return the sorted array. */ @Override public <T extends Comparable<T>> T[] sort(T[] array) { for (int i = 0; i < array.length - 1; i++) { for (int j = i + 1; j < array.length; j++) { if (array[i].compareTo(array[j]) > 0) { swap(array, i, j); } } } return array; } private <T> void swap(T[] array, int i, int j) { T temp = array[i]; array[i] = array[j]; array[j] = temp; } }
JackHuynh0610/Java-Algo-
src/main/java/com/thealgorithms/sorts/ExchangeSort.java
865
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.execute.around; import java.io.File; import java.io.IOException; import java.util.Scanner; import lombok.extern.slf4j.Slf4j; /** * The Execute Around idiom specifies executable code before and after a method. Typically, * the idiom is used when the API has methods to be executed in pairs, such as resource * allocation/deallocation or lock acquisition/release. * * <p>In this example, we have {@link SimpleFileWriter} class that opens and closes the file for * the user. The user specifies only what to do with the file by providing the {@link * FileWriterAction} implementation. */ @Slf4j public class App { /** * Program entry point. */ public static void main(String[] args) throws IOException { // create the file writer and execute the custom action FileWriterAction writeHello = writer -> writer.write("Gandalf was here"); new SimpleFileWriter("testfile.txt", writeHello); // print the file contents try (var scanner = new Scanner(new File("testfile.txt"))) { while (scanner.hasNextLine()) { LOGGER.info(scanner.nextLine()); } } } }
iluwatar/java-design-patterns
execute-around/src/main/java/com/iluwatar/execute/around/App.java
866
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.context.object; import lombok.extern.slf4j.Slf4j; /** * In the context object pattern, information and data from underlying protocol-specific classes/systems is decoupled * and stored into a protocol-independent object in an organised format. The pattern ensures the data contained within * the context object can be shared and further structured between different layers of a software system. * * <p> In this example we show how a context object {@link ServiceContext} can be initiated, edited and passed/retrieved * in different layers of the program ({@link LayerA}, {@link LayerB}, {@link LayerC}) through use of static methods. </p> */ @Slf4j public class App { private static final String SERVICE = "SERVICE"; /** * Program entry point. * * @param args command line args */ public static void main(String[] args) { //Initiate first layer and add service information into context var layerA = new LayerA(); layerA.addAccountInfo(SERVICE); logContext(layerA.getContext()); //Initiate second layer and preserving information retrieved in first layer through passing context object var layerB = new LayerB(layerA); layerB.addSessionInfo(SERVICE); logContext(layerB.getContext()); //Initiate third layer and preserving information retrieved in first and second layer through passing context object var layerC = new LayerC(layerB); layerC.addSearchInfo(SERVICE); logContext(layerC.getContext()); } private static void logContext(ServiceContext context) { LOGGER.info("Context = {}", context); } }
iluwatar/java-design-patterns
context-object/src/main/java/com/iluwatar/context/object/App.java
867
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.plugins; import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; import org.elasticsearch.cluster.routing.RerouteService; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.features.FeatureService; import org.elasticsearch.index.IndexModule; import org.elasticsearch.index.IndexSettingProvider; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.plugins.internal.DocumentParsingProvider; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.telemetry.TelemetryProvider; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.XContentParser; import java.io.Closeable; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Supplier; import java.util.function.UnaryOperator; /** * An extension point allowing to plug in custom functionality. This class has a number of extension points that are available to all * plugins, in addition you can implement any of the following interfaces to further customize Elasticsearch: * <ul> * <li>{@link ActionPlugin} * <li>{@link AnalysisPlugin} * <li>{@link ClusterPlugin} * <li>{@link DiscoveryPlugin} * <li>{@link HealthPlugin} * <li>{@link IngestPlugin} * <li>{@link MapperPlugin} * <li>{@link NetworkPlugin} * <li>{@link RepositoryPlugin} * <li>{@link ScriptPlugin} * <li>{@link SearchPlugin} * <li>{@link ReloadablePlugin} * </ul> */ public abstract class Plugin implements Closeable { /** * Provides access to various Elasticsearch services. */ public interface PluginServices { /** * A client to make requests to the system */ Client client(); /** * A service to allow watching and updating cluster state */ ClusterService clusterService(); /** * A service to reroute shards to other nodes */ RerouteService rerouteService(); /** * A service to allow retrieving an executor to run an async action */ ThreadPool threadPool(); /** * A service to watch for changes to node local files */ ResourceWatcherService resourceWatcherService(); /** * A service to allow running scripts on the local node */ ScriptService scriptService(); /** * The registry for extensible xContent parsing */ NamedXContentRegistry xContentRegistry(); /** * The environment for path and setting configurations */ Environment environment(); /** * The node environment used coordinate access to the data paths */ NodeEnvironment nodeEnvironment(); /** * The registry for {@link NamedWriteable} object parsing */ NamedWriteableRegistry namedWriteableRegistry(); /** * A service that resolves expression to index and alias names */ IndexNameExpressionResolver indexNameExpressionResolver(); /** * A supplier for the service that manages snapshot repositories. * This will return null when {@link #createComponents(PluginServices)} is called, * but will return the repositories service once the node is initialized. */ Supplier<RepositoriesService> repositoriesServiceSupplier(); /** * An interface for distributed tracing */ TelemetryProvider telemetryProvider(); /** * A service to manage shard allocation in the cluster */ AllocationService allocationService(); /** * A service to manage indices in the cluster */ IndicesService indicesService(); /** * A service to access features supported by nodes in the cluster */ FeatureService featureService(); /** * The system indices for the cluster */ SystemIndices systemIndices(); /** * A service that resolves the data stream global retention that applies to * data streams managed by the data stream lifecycle. */ DataStreamGlobalRetentionResolver dataStreamGlobalRetentionResolver(); /** * A provider of utilities to observe and report parsing of documents */ DocumentParsingProvider documentParsingProvider(); } /** * Returns components added by this plugin. * <p> * Any components returned that implement {@link LifecycleComponent} will have their lifecycle managed. * Note: To aid in the migration away from guice, all objects returned as components will be bound in guice * to themselves. * * @param services Provides access to various Elasticsearch services */ public Collection<?> createComponents(PluginServices services) { return Collections.emptyList(); } /** * Additional node settings loaded by the plugin. Note that settings that are explicit in the nodes settings can't be * overwritten with the additional settings. These settings added if they don't exist. */ public Settings additionalSettings() { return Settings.EMPTY; } /** * Returns parsers for {@link NamedWriteable} this plugin will use over the transport protocol. * @see NamedWriteableRegistry */ public List<NamedWriteableRegistry.Entry> getNamedWriteables() { return Collections.emptyList(); } /** * Returns parsers for named objects this plugin will parse from {@link XContentParser#namedObject(Class, String, Object)}. * @see NamedWriteableRegistry */ public List<NamedXContentRegistry.Entry> getNamedXContent() { return Collections.emptyList(); } /** * Called before a new index is created on a node. The given module can be used to register index-level * extensions. */ public void onIndexModule(IndexModule indexModule) {} /** * Returns a list of additional {@link Setting} definitions for this plugin. */ public List<Setting<?>> getSettings() { return Collections.emptyList(); } /** * Returns a list of additional settings filter for this plugin */ public List<String> getSettingsFilter() { return Collections.emptyList(); } /** * Provides a function to modify index template meta data on startup. * <p> * Plugins should return the input template map via {@link UnaryOperator#identity()} if no upgrade is required. * <p> * The order of the template upgrader calls is undefined and can change between runs so, it is expected that * plugins will modify only templates owned by them to avoid conflicts. * * @return Never {@code null}. The same or upgraded {@code IndexTemplateMetadata} map. * @throws IllegalStateException if the node should not start because at least one {@code IndexTemplateMetadata} * cannot be upgraded */ public UnaryOperator<Map<String, IndexTemplateMetadata>> getIndexTemplateMetadataUpgrader() { return UnaryOperator.identity(); } /** * Provides the list of this plugin's custom thread pools, empty if * none. * * @param settings the current settings * @return executors builders for this plugin's custom thread pools */ public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) { return Collections.emptyList(); } /** * Returns a list of checks that are enforced when a node starts up once a node has the transport protocol bound to a non-loopback * interface. In this case we assume the node is running in production and all bootstrap checks must pass. This allows plugins * to provide a better out of the box experience by pre-configuring otherwise (in production) mandatory settings or to enforce certain * configurations like OS settings or 3rd party resources. */ public List<BootstrapCheck> getBootstrapChecks() { return Collections.emptyList(); } /** * Close the resources opened by this plugin. * * @throws IOException if the plugin failed to close its resources */ @Override public void close() throws IOException { } /** * An {@link IndexSettingProvider} allows hooking in to parts of an index * lifecycle to provide explicit default settings for newly created indices. Rather than changing * the default values for an index-level setting, these act as though the setting has been set * explicitly, but still allow the setting to be overridden by a template or creation request body. */ public Collection<IndexSettingProvider> getAdditionalIndexSettingProviders(IndexSettingProvider.Parameters parameters) { return Collections.emptyList(); } }
pmpailis/elasticsearch
server/src/main/java/org/elasticsearch/plugins/Plugin.java
869
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.proxy; /** * WizardTower interface. */ public interface WizardTower { void enter(Wizard wizard); }
smedals/java-design-patterns
proxy/src/main/java/com/iluwatar/proxy/WizardTower.java
870
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.gradle; import java.util.EnumMap; import java.util.EnumSet; import java.util.Map; import java.util.Set; import java.util.function.Supplier; public enum OS { WINDOWS, MAC, LINUX; public static OS current() { String os = System.getProperty("os.name", ""); if (os.startsWith("Windows")) { return OS.WINDOWS; } if (os.startsWith("Linux") || os.startsWith("LINUX")) { return OS.LINUX; } if (os.startsWith("Mac")) { return OS.MAC; } throw new IllegalStateException("Can't determine OS from: " + os); } public static class Conditional<T> { private final Map<OS, Supplier<T>> conditions = new EnumMap<>(OS.class); public Conditional<T> onWindows(Supplier<T> supplier) { conditions.put(WINDOWS, supplier); return this; } public Conditional<T> onLinux(Supplier<T> supplier) { conditions.put(LINUX, supplier); return this; } public Conditional<T> onMac(Supplier<T> supplier) { conditions.put(MAC, supplier); return this; } public Conditional<T> onUnix(Supplier<T> supplier) { conditions.put(MAC, supplier); conditions.put(LINUX, supplier); return this; } public T supply() { Set<OS> missingOS = EnumSet.allOf(OS.class); missingOS.removeAll(conditions.keySet()); if (missingOS.isEmpty() == false) { throw new IllegalArgumentException("No condition specified for " + missingOS); } return conditions.get(OS.current()).get(); } } public static <T> Conditional<T> conditional() { return new Conditional<>(); } public static Conditional<String> conditionalString() { return conditional(); } }
elastic/elasticsearch
build-tools/src/main/java/org/elasticsearch/gradle/OS.java
872
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ package org.tensorflow.lite; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; import org.tensorflow.lite.InterpreterApi.Options.TfLiteRuntime; /** Static utility methods for loading the TensorFlowLite runtime and native code. */ public final class TensorFlowLite { // We use Java logging here (java.util.logging), rather than Android logging (android.util.Log), // to avoid unnecessary platform dependencies. This also makes unit testing simpler and faster, // since we can use plain Java tests rather than needing to use Robolectric (android_local_test). // // WARNING: some care is required when using Java logging on Android. In particular, avoid // logging with severity levels lower than "INFO", since the default Java log handler on Android // will discard those, and avoid logging messages with parameters (call String.format instead), // since the default Java log handler on Android only logs the raw message string and doesn't // apply the parameters. private static final Logger logger = Logger.getLogger(TensorFlowLite.class.getName()); private static final String[][] TFLITE_RUNTIME_LIBNAMES = new String[][] { // We load the first library that we find in each group. new String[] { // Regular TF Lite. "tensorflowlite_jni", // Full library, including experimental features. "tensorflowlite_jni_stable", // Subset excluding experimental features. }, new String[] { // TF Lite from system. "tensorflowlite_jni_gms_client" } }; private static final Throwable LOAD_LIBRARY_EXCEPTION; private static volatile boolean isInit = false; static { // Attempt to load the TF Lite runtime's JNI library, trying each alternative name in turn. // If unavailable, catch and save the exception(s); the client may choose to link the native // deps into their own custom native library, so it's not an error if the default library names // can't be loaded. Throwable loadLibraryException = null; for (String[] group : TFLITE_RUNTIME_LIBNAMES) { for (String libName : group) { try { System.loadLibrary(libName); logger.info("Loaded native library: " + libName); break; } catch (UnsatisfiedLinkError e) { logger.info("Didn't load native library: " + libName); if (loadLibraryException == null) { loadLibraryException = e; } else { loadLibraryException.addSuppressed(e); } } } } LOAD_LIBRARY_EXCEPTION = loadLibraryException; } private TensorFlowLite() {} /** * Returns the version of the underlying TensorFlowLite model schema. * * @deprecated Prefer using {@link #runtimeVersion() or #schemaVersion()}. */ @Deprecated public static String version() { return schemaVersion(); } /** Returns the version of the specified TensorFlowLite runtime. */ public static String runtimeVersion(TfLiteRuntime runtime) { return getFactory(runtime, "org.tensorflow.lite.TensorFlowLite", "runtimeVersion") .runtimeVersion(); } /** Returns the version of the default TensorFlowLite runtime. */ public static String runtimeVersion() { return runtimeVersion(null); } /** * Returns the version of the TensorFlowLite model schema that is supported by the specified * TensorFlowLite runtime. */ public static String schemaVersion(TfLiteRuntime runtime) { return getFactory(runtime, "org.tensorflow.lite.TensorFlowLite", "schemaVersion") .schemaVersion(); } /** * Returns the version of the TensorFlowLite model schema that is supported by the default * TensorFlowLite runtime. */ public static String schemaVersion() { return schemaVersion(null); } /** * Ensure the TensorFlowLite native library has been loaded. * * <p>If unsuccessful, throws an UnsatisfiedLinkError with the appropriate error message. */ public static void init() { if (isInit) { return; } try { // Try to invoke a native method (which itself does nothing) to ensure that native libs are // available. nativeDoNothing(); isInit = true; } catch (UnsatisfiedLinkError e) { // Prefer logging the original library loading exception if native methods are unavailable. Throwable exceptionToLog = LOAD_LIBRARY_EXCEPTION != null ? LOAD_LIBRARY_EXCEPTION : e; UnsatisfiedLinkError exceptionToThrow = new UnsatisfiedLinkError( "Failed to load native TensorFlow Lite methods. Check that the correct native" + " libraries are present, and, if using a custom native library, have been" + " properly loaded via System.loadLibrary():\n" + " " + exceptionToLog); exceptionToThrow.initCause(e); throw exceptionToThrow; } } private static native void nativeDoNothing(); /** Encapsulates the use of reflection to find an available TF Lite runtime. */ private static class PossiblyAvailableRuntime { private final InterpreterFactoryApi factory; private final Exception exception; /** * @param namespace: "org.tensorflow.lite" or "com.google.android.gms.tflite". * @param category: "application" or "system". */ PossiblyAvailableRuntime(String namespace, String category) { InterpreterFactoryApi factory = null; Exception exception = null; try { Class<?> clazz = Class.forName(namespace + ".InterpreterFactoryImpl"); Constructor<?> factoryConstructor = clazz.getDeclaredConstructor(); factoryConstructor.setAccessible(true); factory = (InterpreterFactoryApi) factoryConstructor.newInstance(); if (factory != null) { logger.info(String.format("Found %s TF Lite runtime client in %s", category, namespace)); } else { logger.warning( String.format("Failed to construct TF Lite runtime client from %s", namespace)); } } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { logger.info( String.format("Didn't find %s TF Lite runtime client in %s", category, namespace)); exception = e; } this.exception = exception; this.factory = factory; } /** * @return the InterpreterFactoryApi for this runtime, or null if this runtime wasn't found. */ public InterpreterFactoryApi getFactory() { return factory; } /** * @return The exception that occurred when trying to find this runtime, if any, or null. */ public Exception getException() { return exception; } } // We use static members here for caching, to ensure that we only do the reflective lookups once // and then afterwards re-use the previously computed results. // // We put these static members in nested static classes to ensure that Java will // delay the initialization of these static members until their respective first use; // that's needed to ensure that we only log messages about TF Lite runtime not found // for TF Lite runtimes that the application actually tries to use. private static class RuntimeFromSystem { static final PossiblyAvailableRuntime TFLITE = new PossiblyAvailableRuntime("com.google.android.gms.tflite", "system"); } private static class RuntimeFromApplication { static final PossiblyAvailableRuntime TFLITE = new PossiblyAvailableRuntime("org.tensorflow.lite", "application"); } // We log at most once for each different options.runtime value. private static final AtomicBoolean[] haveLogged = new AtomicBoolean[TfLiteRuntime.values().length]; static { for (int i = 0; i < TfLiteRuntime.values().length; i++) { haveLogged[i] = new AtomicBoolean(); } } static InterpreterFactoryApi getFactory(TfLiteRuntime runtime) { return getFactory(runtime, "org.tensorflow.lite.InterpreterApi.Options", "setRuntime"); } /** * Internal method for finding the TF Lite runtime implementation. * * @param className Class name for method to mention in exception messages. * @param methodName Method name for method to mention in exception messages. */ private static InterpreterFactoryApi getFactory( TfLiteRuntime runtime, String className, String methodName) { Exception exception = null; if (runtime == null) { runtime = TfLiteRuntime.FROM_APPLICATION_ONLY; } if (runtime == TfLiteRuntime.PREFER_SYSTEM_OVER_APPLICATION || runtime == TfLiteRuntime.FROM_SYSTEM_ONLY) { if (RuntimeFromSystem.TFLITE.getFactory() != null) { if (!haveLogged[runtime.ordinal()].getAndSet(true)) { logger.info( String.format( "TfLiteRuntime.%s: " + "Using system TF Lite runtime client from com.google.android.gms", runtime.name())); } return RuntimeFromSystem.TFLITE.getFactory(); } else { exception = RuntimeFromSystem.TFLITE.getException(); } } if (runtime == TfLiteRuntime.PREFER_SYSTEM_OVER_APPLICATION || runtime == TfLiteRuntime.FROM_APPLICATION_ONLY) { if (RuntimeFromApplication.TFLITE.getFactory() != null) { if (!haveLogged[runtime.ordinal()].getAndSet(true)) { logger.info( String.format( "TfLiteRuntime.%s: " + "Using application TF Lite runtime client from org.tensorflow.lite", runtime.name())); } return RuntimeFromApplication.TFLITE.getFactory(); } else { if (exception == null) { exception = RuntimeFromApplication.TFLITE.getException(); } else if (exception.getSuppressed().length == 0) { exception.addSuppressed(RuntimeFromApplication.TFLITE.getException()); } } } String message; switch (runtime) { case FROM_APPLICATION_ONLY: message = String.format( "You should declare a build dependency on org.tensorflow.lite:tensorflow-lite," + " or call .%s with a value other than TfLiteRuntime.FROM_APPLICATION_ONLY" + " (see docs for %s#%s(TfLiteRuntime)).", methodName, className, methodName); break; case FROM_SYSTEM_ONLY: message = String.format( "You should declare a build dependency on" + " com.google.android.gms:play-services-tflite-java," + " or call .%s with a value other than TfLiteRuntime.FROM_SYSTEM_ONLY " + " (see docs for %s#%s).", methodName, className, methodName); break; default: message = "You should declare a build dependency on" + " org.tensorflow.lite:tensorflow-lite or" + " com.google.android.gms:play-services-tflite-java"; break; } throw new IllegalStateException( "Couldn't find TensorFlow Lite runtime's InterpreterFactoryImpl class --" + " make sure your app links in the right TensorFlow Lite runtime. " + message, exception); } }
tensorflow/tensorflow
tensorflow/lite/java/src/main/java/org/tensorflow/lite/TensorFlowLite.java
875
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * This project is based on a modification of https://github.com/uber/h3 which is licensed under the Apache 2.0 License. * * Copyright 2016-2017, 2020 Uber Technologies, Inc. */ package org.elasticsearch.h3; /** * Constants used by more than one source code file. */ final class Constants { /** * sqrt(3) / 2.0 */ public static double M_SQRT3_2 = 0.8660254037844386467637231707529361834714; /** * 2.0 * PI */ public static final double M_2PI = 6.28318530717958647692528676655900576839433; /** * max H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15 */ public static int MAX_H3_RES = 15; /** * The number of H3 base cells */ public static int NUM_BASE_CELLS = 122; /** * The number of vertices in a hexagon */ public static int NUM_HEX_VERTS = 6; /** * The number of vertices in a pentagon */ public static int NUM_PENT_VERTS = 5; /** * H3 index modes */ public static int H3_CELL_MODE = 1; /** * square root of 7 */ public static final double M_SQRT7 = 2.6457513110645905905016157536392604257102; /** * scaling factor from hex2d resolution 0 unit length * (or distance between adjacent cell center points * on the plane) to gnomonic unit length. */ public static double RES0_U_GNOMONIC = 0.38196601125010500003; /** * rotation angle between Class II and Class III resolution axes * (asin(sqrt(3.0 / 28.0))) */ public static double M_AP7_ROT_RADS = 0.333473172251832115336090755351601070065900389; /** * threshold epsilon */ public static double EPSILON = 0.0000000000000001; }
elastic/elasticsearch
libs/h3/src/main/java/org/elasticsearch/h3/Constants.java
876
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ package org.elasticsearch.node; import org.elasticsearch.Build; import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.node.info.ComponentVersionNumber; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.search.SearchTransportService; import org.elasticsearch.cluster.coordination.Coordinator; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import org.elasticsearch.core.Assertions; import org.elasticsearch.core.IOUtils; import org.elasticsearch.core.Nullable; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.IndexingPressure; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.ingest.IngestService; import org.elasticsearch.monitor.MonitorService; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.aggregations.support.AggregationUsageService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.Closeable; import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import java.util.stream.Collectors; public class NodeService implements Closeable { private final Settings settings; private final ThreadPool threadPool; private final MonitorService monitorService; private final TransportService transportService; private final IndicesService indicesService; private final PluginsService pluginService; private final CircuitBreakerService circuitBreakerService; private final IngestService ingestService; private final SettingsFilter settingsFilter; private final ScriptService scriptService; private final HttpServerTransport httpServerTransport; private final ResponseCollectorService responseCollectorService; private final SearchTransportService searchTransportService; private final IndexingPressure indexingPressure; private final AggregationUsageService aggregationUsageService; private final Coordinator coordinator; private final RepositoriesService repositoriesService; private final Map<String, Integer> componentVersions; NodeService( Settings settings, ThreadPool threadPool, MonitorService monitorService, Coordinator coordinator, TransportService transportService, IndicesService indicesService, PluginsService pluginService, CircuitBreakerService circuitBreakerService, ScriptService scriptService, @Nullable HttpServerTransport httpServerTransport, IngestService ingestService, ClusterService clusterService, SettingsFilter settingsFilter, ResponseCollectorService responseCollectorService, SearchTransportService searchTransportService, IndexingPressure indexingPressure, AggregationUsageService aggregationUsageService, RepositoriesService repositoriesService ) { this.settings = settings; this.threadPool = threadPool; this.monitorService = monitorService; this.transportService = transportService; this.indicesService = indicesService; this.coordinator = coordinator; this.pluginService = pluginService; this.circuitBreakerService = circuitBreakerService; this.httpServerTransport = httpServerTransport; this.ingestService = ingestService; this.settingsFilter = settingsFilter; this.scriptService = scriptService; this.responseCollectorService = responseCollectorService; this.searchTransportService = searchTransportService; this.indexingPressure = indexingPressure; this.aggregationUsageService = aggregationUsageService; this.repositoriesService = repositoriesService; this.componentVersions = findComponentVersions(pluginService); clusterService.addStateApplier(ingestService); } public NodeInfo info( boolean settings, boolean os, boolean process, boolean jvm, boolean threadPool, boolean transport, boolean http, boolean remoteClusterServer, boolean plugin, boolean ingest, boolean aggs, boolean indices ) { return new NodeInfo( // TODO: revert to Build.current().version() when Kibana is updated Version.CURRENT.toString(), TransportVersion.current(), IndexVersion.current(), componentVersions, Build.current(), transportService.getLocalNode(), settings ? settingsFilter.filter(this.settings) : null, os ? monitorService.osService().info() : null, process ? monitorService.processService().info() : null, jvm ? monitorService.jvmService().info() : null, threadPool ? this.threadPool.info() : null, transport ? transportService.info() : null, http ? (httpServerTransport == null ? null : httpServerTransport.info()) : null, remoteClusterServer ? transportService.getRemoteClusterService().info() : null, plugin ? (pluginService == null ? null : pluginService.info()) : null, ingest ? (ingestService == null ? null : ingestService.info()) : null, aggs ? (aggregationUsageService == null ? null : aggregationUsageService.info()) : null, indices ? indicesService.getTotalIndexingBufferBytes() : null ); } private static Map<String, Integer> findComponentVersions(PluginsService pluginService) { var versions = pluginService.loadServiceProviders(ComponentVersionNumber.class) .stream() .collect(Collectors.toUnmodifiableMap(ComponentVersionNumber::componentId, cvn -> cvn.versionNumber().id())); if (Assertions.ENABLED) { var isSnakeCase = Pattern.compile("[a-z_]+").asMatchPredicate(); for (String key : versions.keySet()) { assert isSnakeCase.test(key) : "Version component " + key + " should use snake_case"; } } return versions; } public NodeStats stats( CommonStatsFlags indices, boolean includeShardsStats, boolean os, boolean process, boolean jvm, boolean threadPool, boolean fs, boolean transport, boolean http, boolean circuitBreaker, boolean script, boolean discoveryStats, boolean ingest, boolean adaptiveSelection, boolean scriptCache, boolean indexingPressure, boolean repositoriesStats ) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) return new NodeStats( transportService.getLocalNode(), System.currentTimeMillis(), indices.anySet() ? indicesService.stats(indices, includeShardsStats) : null, os ? monitorService.osService().stats() : null, process ? monitorService.processService().stats() : null, jvm ? monitorService.jvmService().stats() : null, threadPool ? this.threadPool.stats() : null, fs ? monitorService.fsService().stats() : null, transport ? transportService.stats() : null, http ? (httpServerTransport == null ? null : httpServerTransport.stats()) : null, circuitBreaker ? circuitBreakerService.stats() : null, script ? scriptService.stats() : null, discoveryStats ? coordinator.stats() : null, ingest ? ingestService.stats() : null, adaptiveSelection ? responseCollectorService.getAdaptiveStats(searchTransportService.getPendingSearchRequests()) : null, scriptCache ? scriptService.cacheStats() : null, indexingPressure ? this.indexingPressure.stats() : null, repositoriesStats ? this.repositoriesService.getRepositoriesThrottlingStats() : null, null ); } public IngestService getIngestService() { return ingestService; } public MonitorService getMonitorService() { return monitorService; } @Override public void close() throws IOException { IOUtils.close(indicesService); } /** * Wait for the node to be effectively closed. * @see IndicesService#awaitClose(long, TimeUnit) */ public boolean awaitClose(long timeout, TimeUnit timeUnit) throws InterruptedException { return indicesService.awaitClose(timeout, timeUnit); } }
elastic/elasticsearch
server/src/main/java/org/elasticsearch/node/NodeService.java
877
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.promise; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.Map.Entry; import java.util.function.Function; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; /** * Utility to perform various operations. */ @Slf4j public class Utility { /** * Calculates character frequency of the file provided. * * @param fileLocation location of the file. * @return a map of character to its frequency, an empty map if file does not exist. */ public static Map<Character, Long> characterFrequency(String fileLocation) { try (var bufferedReader = new BufferedReader(new FileReader(fileLocation))) { return bufferedReader.lines() .flatMapToInt(String::chars) .mapToObj(x -> (char) x) .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); } catch (IOException ex) { ex.printStackTrace(); } return Collections.emptyMap(); } /** * Return the character with the lowest frequency, if exists. * * @return the character, {@code Optional.empty()} otherwise. */ public static Character lowestFrequencyChar(Map<Character, Long> charFrequency) { return charFrequency .entrySet() .stream() .min(Comparator.comparingLong(Entry::getValue)) .map(Entry::getKey) .orElseThrow(); } /** * Count the number of lines in a file. * * @return number of lines, 0 if file does not exist. */ public static Integer countLines(String fileLocation) { try (var bufferedReader = new BufferedReader(new FileReader(fileLocation))) { return (int) bufferedReader.lines().count(); } catch (IOException ex) { ex.printStackTrace(); } return 0; } /** * Downloads the contents from the given urlString, and stores it in a temporary directory. * * @return the absolute path of the file downloaded. */ public static String downloadFile(String urlString) throws IOException { LOGGER.info("Downloading contents from url: {}", urlString); var url = new URL(urlString); var file = File.createTempFile("promise_pattern", null); try (var bufferedReader = new BufferedReader(new InputStreamReader(url.openStream())); var writer = new FileWriter(file)) { String line; while ((line = bufferedReader.readLine()) != null) { writer.write(line); writer.write("\n"); } LOGGER.info("File downloaded at: {}", file.getAbsolutePath()); return file.getAbsolutePath(); } } }
smedals/java-design-patterns
promise/src/main/java/com/iluwatar/promise/Utility.java
879
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.retry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * The <em>Retry</em> pattern enables applications to handle potentially recoverable failures from * the environment if the business requirements and nature of the failures allow it. By retrying * failed operations on external dependencies, the application may maintain stability and minimize * negative impact on the user experience. * * <p>In our example, we have the {@link BusinessOperation} interface as an abstraction over all * operations that our application performs involving remote systems. The calling code should remain * decoupled from implementations. * * <p>{@link FindCustomer} is a business operation that looks up a customer's record and returns * its ID. Imagine its job is performed by looking up the customer in our local database and * returning its ID. We can pass {@link CustomerNotFoundException} as one of its {@link * FindCustomer#FindCustomer(java.lang.String, com.iluwatar.retry.BusinessException...) constructor * parameters} in order to simulate not finding the customer. * * <p>Imagine that, lately, this operation has experienced intermittent failures due to some weird * corruption and/or locking in the data. After retrying a few times the customer is found. The * database is still, however, expected to always be available. While a definitive solution is * found to the problem, our engineers advise us to retry the operation a set number of times with a * set delay between retries, although not too many retries otherwise the end user will be left * waiting for a long time, while delays that are too short will not allow the database to recover * from the load. * * <p>To keep the calling code as decoupled as possible from this workaround, we have implemented * the retry mechanism as a {@link BusinessOperation} named {@link Retry}. * * @author George Aristy ([email protected]) * @see <a href="https://docs.microsoft.com/en-us/azure/architecture/patterns/retry">Retry pattern * (Microsoft Azure Docs)</a> */ public final class App { private static final Logger LOG = LoggerFactory.getLogger(App.class); public static final String NOT_FOUND = "not found"; private static BusinessOperation<String> op; /** * Entry point. * * @param args not used * @throws Exception not expected */ public static void main(String[] args) throws Exception { noErrors(); errorNoRetry(); errorWithRetry(); errorWithRetryExponentialBackoff(); } private static void noErrors() throws Exception { op = new FindCustomer("123"); op.perform(); LOG.info("Sometimes the operation executes with no errors."); } private static void errorNoRetry() throws Exception { op = new FindCustomer("123", new CustomerNotFoundException(NOT_FOUND)); try { op.perform(); } catch (CustomerNotFoundException e) { LOG.info("Yet the operation will throw an error every once in a while."); } } private static void errorWithRetry() throws Exception { final var retry = new Retry<>( new FindCustomer("123", new CustomerNotFoundException(NOT_FOUND)), 3, //3 attempts 100, //100 ms delay between attempts e -> CustomerNotFoundException.class.isAssignableFrom(e.getClass()) ); op = retry; final var customerId = op.perform(); LOG.info(String.format( "However, retrying the operation while ignoring a recoverable error will eventually yield " + "the result %s after a number of attempts %s", customerId, retry.attempts() )); } private static void errorWithRetryExponentialBackoff() throws Exception { final var retry = new RetryExponentialBackoff<>( new FindCustomer("123", new CustomerNotFoundException(NOT_FOUND)), 6, //6 attempts 30000, //30 s max delay between attempts e -> CustomerNotFoundException.class.isAssignableFrom(e.getClass()) ); op = retry; final var customerId = op.perform(); LOG.info(String.format( "However, retrying the operation while ignoring a recoverable error will eventually yield " + "the result %s after a number of attempts %s", customerId, retry.attempts() )); } }
smedals/java-design-patterns
retry/src/main/java/com/iluwatar/retry/App.java
880
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ import org.elasticsearch.index.codec.Elasticsearch814Codec; import org.elasticsearch.index.codec.tsdb.ES87TSDBDocValuesFormat; import org.elasticsearch.plugins.internal.RestExtension; /** The Elasticsearch Server Module. */ module org.elasticsearch.server { requires java.logging; requires java.security.jgss; requires java.sql; requires java.management; requires jdk.unsupported; requires java.net.http; // required by ingest-geoip's dependency maxmind.geoip2 https://github.com/elastic/elasticsearch/issues/93553 requires org.elasticsearch.cli; requires org.elasticsearch.base; requires org.elasticsearch.nativeaccess; requires org.elasticsearch.geo; requires org.elasticsearch.lz4; requires org.elasticsearch.pluginclassloader; requires org.elasticsearch.securesm; requires org.elasticsearch.xcontent; requires org.elasticsearch.logging; requires org.elasticsearch.plugin; requires org.elasticsearch.plugin.analysis; requires org.elasticsearch.grok; requires org.elasticsearch.tdigest; requires org.elasticsearch.vec; requires com.sun.jna; requires hppc; requires HdrHistogram; requires jopt.simple; requires log4j2.ecs.layout; requires org.lz4.java; requires org.apache.logging.log4j; requires org.apache.logging.log4j.core; requires org.apache.lucene.analysis.common; requires org.apache.lucene.backward_codecs; requires org.apache.lucene.core; requires org.apache.lucene.grouping; requires org.apache.lucene.highlighter; requires org.apache.lucene.join; requires org.apache.lucene.memory; requires org.apache.lucene.misc; requires org.apache.lucene.queries; requires org.apache.lucene.queryparser; requires org.apache.lucene.sandbox; requires org.apache.lucene.suggest; exports org.elasticsearch; exports org.elasticsearch.action; exports org.elasticsearch.action.admin.cluster.allocation; exports org.elasticsearch.action.admin.cluster.configuration; exports org.elasticsearch.action.admin.cluster.coordination; exports org.elasticsearch.action.admin.cluster.desirednodes; exports org.elasticsearch.action.admin.cluster.health; exports org.elasticsearch.action.admin.cluster.migration; exports org.elasticsearch.action.admin.cluster.node.capabilities; exports org.elasticsearch.action.admin.cluster.node.hotthreads; exports org.elasticsearch.action.admin.cluster.node.info; exports org.elasticsearch.action.admin.cluster.node.reload; exports org.elasticsearch.action.admin.cluster.node.shutdown; exports org.elasticsearch.action.admin.cluster.node.stats; exports org.elasticsearch.action.admin.cluster.node.tasks.cancel; exports org.elasticsearch.action.admin.cluster.node.tasks.get; exports org.elasticsearch.action.admin.cluster.node.tasks.list; exports org.elasticsearch.action.admin.cluster.node.usage; exports org.elasticsearch.action.admin.cluster.remote; exports org.elasticsearch.action.admin.cluster.repositories.cleanup; exports org.elasticsearch.action.admin.cluster.repositories.delete; exports org.elasticsearch.action.admin.cluster.repositories.get; exports org.elasticsearch.action.admin.cluster.repositories.put; exports org.elasticsearch.action.admin.cluster.repositories.verify; exports org.elasticsearch.action.admin.cluster.reroute; exports org.elasticsearch.action.admin.cluster.settings; exports org.elasticsearch.action.admin.cluster.shards; exports org.elasticsearch.action.admin.cluster.snapshots.clone; exports org.elasticsearch.action.admin.cluster.snapshots.create; exports org.elasticsearch.action.admin.cluster.snapshots.delete; exports org.elasticsearch.action.admin.cluster.snapshots.features; exports org.elasticsearch.action.admin.cluster.snapshots.get; exports org.elasticsearch.action.admin.cluster.snapshots.get.shard; exports org.elasticsearch.action.admin.cluster.snapshots.restore; exports org.elasticsearch.action.admin.cluster.snapshots.status; exports org.elasticsearch.action.admin.cluster.state; exports org.elasticsearch.action.admin.cluster.stats; exports org.elasticsearch.action.admin.cluster.storedscripts; exports org.elasticsearch.action.admin.cluster.tasks; exports org.elasticsearch.action.admin.indices.alias; exports org.elasticsearch.action.admin.indices.alias.get; exports org.elasticsearch.action.admin.indices.analyze; exports org.elasticsearch.action.admin.indices.cache.clear; exports org.elasticsearch.action.admin.indices.close; exports org.elasticsearch.action.admin.indices.create; exports org.elasticsearch.action.admin.indices.dangling; exports org.elasticsearch.action.admin.indices.dangling.delete; exports org.elasticsearch.action.admin.indices.dangling.find; exports org.elasticsearch.action.admin.indices.dangling.import_index; exports org.elasticsearch.action.admin.indices.dangling.list; exports org.elasticsearch.action.admin.indices.delete; exports org.elasticsearch.action.admin.indices.diskusage; exports org.elasticsearch.action.admin.indices.flush; exports org.elasticsearch.action.admin.indices.forcemerge; exports org.elasticsearch.action.admin.indices.get; exports org.elasticsearch.action.admin.indices.mapping.get; exports org.elasticsearch.action.admin.indices.mapping.put; exports org.elasticsearch.action.admin.indices.open; exports org.elasticsearch.action.admin.indices.readonly; exports org.elasticsearch.action.admin.indices.recovery; exports org.elasticsearch.action.admin.indices.refresh; exports org.elasticsearch.action.admin.indices.resolve; exports org.elasticsearch.action.admin.indices.rollover; exports org.elasticsearch.action.admin.indices.segments; exports org.elasticsearch.action.admin.indices.settings.get; exports org.elasticsearch.action.admin.indices.settings.put; exports org.elasticsearch.action.admin.indices.shards; exports org.elasticsearch.action.admin.indices.shrink; exports org.elasticsearch.action.admin.indices.stats; exports org.elasticsearch.action.admin.indices.template.delete; exports org.elasticsearch.action.admin.indices.template.get; exports org.elasticsearch.action.admin.indices.template.post; exports org.elasticsearch.action.admin.indices.template.put; exports org.elasticsearch.action.admin.indices.validate.query; exports org.elasticsearch.action.bulk; exports org.elasticsearch.action.datastreams; exports org.elasticsearch.action.delete; exports org.elasticsearch.action.explain; exports org.elasticsearch.action.fieldcaps; exports org.elasticsearch.action.get; exports org.elasticsearch.action.index; exports org.elasticsearch.action.ingest; exports org.elasticsearch.action.resync; exports org.elasticsearch.action.search; exports org.elasticsearch.action.support; exports org.elasticsearch.action.support.broadcast; exports org.elasticsearch.action.support.broadcast.node; exports org.elasticsearch.action.support.broadcast.unpromotable; exports org.elasticsearch.action.support.master; exports org.elasticsearch.action.support.master.info; exports org.elasticsearch.action.support.nodes; exports org.elasticsearch.action.support.replication; exports org.elasticsearch.action.support.single.instance; exports org.elasticsearch.action.support.single.shard; exports org.elasticsearch.action.support.tasks; exports org.elasticsearch.action.termvectors; exports org.elasticsearch.action.update; exports org.elasticsearch.bootstrap; exports org.elasticsearch.client.internal; exports org.elasticsearch.client.internal.node; exports org.elasticsearch.client.internal.support; exports org.elasticsearch.client.internal.transport; exports org.elasticsearch.cluster; exports org.elasticsearch.cluster.ack; exports org.elasticsearch.cluster.action.index; exports org.elasticsearch.cluster.action.shard; exports org.elasticsearch.cluster.block; exports org.elasticsearch.cluster.coordination; exports org.elasticsearch.cluster.coordination.stateless; exports org.elasticsearch.cluster.health; exports org.elasticsearch.cluster.metadata; exports org.elasticsearch.cluster.node; exports org.elasticsearch.cluster.routing; exports org.elasticsearch.cluster.routing.allocation; exports org.elasticsearch.cluster.routing.allocation.allocator; exports org.elasticsearch.cluster.routing.allocation.command; exports org.elasticsearch.cluster.routing.allocation.decider; exports org.elasticsearch.cluster.service; exports org.elasticsearch.cluster.version; exports org.elasticsearch.common; exports org.elasticsearch.common.blobstore; exports org.elasticsearch.common.blobstore.fs; exports org.elasticsearch.common.blobstore.support; exports org.elasticsearch.common.breaker; exports org.elasticsearch.common.bytes; exports org.elasticsearch.common.cache; exports org.elasticsearch.common.cli; exports org.elasticsearch.common.collect; exports org.elasticsearch.common.component; exports org.elasticsearch.common.compress; exports org.elasticsearch.common.document; exports org.elasticsearch.common.file; exports org.elasticsearch.common.filesystem; exports org.elasticsearch.common.geo; exports org.elasticsearch.common.hash; exports org.elasticsearch.common.inject; exports org.elasticsearch.common.inject.binder; exports org.elasticsearch.common.inject.internal; exports org.elasticsearch.common.inject.matcher; exports org.elasticsearch.common.inject.multibindings; exports org.elasticsearch.common.inject.name; exports org.elasticsearch.common.inject.spi; exports org.elasticsearch.common.inject.util; exports org.elasticsearch.common.io; exports org.elasticsearch.common.io.stream; exports org.elasticsearch.common.logging; exports org.elasticsearch.common.lucene; exports org.elasticsearch.common.lucene.index; exports org.elasticsearch.common.lucene.search; exports org.elasticsearch.common.lucene.search.function; exports org.elasticsearch.common.lucene.store; exports org.elasticsearch.common.lucene.uid; exports org.elasticsearch.common.metrics; exports org.elasticsearch.common.network; exports org.elasticsearch.common.path; exports org.elasticsearch.common.recycler; exports org.elasticsearch.common.regex; exports org.elasticsearch.common.scheduler; exports org.elasticsearch.common.settings; exports org.elasticsearch.common.text; exports org.elasticsearch.common.time; exports org.elasticsearch.common.transport; exports org.elasticsearch.common.unit; exports org.elasticsearch.common.util; exports org.elasticsearch.common.util.concurrent; exports org.elasticsearch.common.util.iterable; exports org.elasticsearch.common.util.set; exports org.elasticsearch.common.xcontent; exports org.elasticsearch.common.xcontent.support; exports org.elasticsearch.discovery; exports org.elasticsearch.env; exports org.elasticsearch.features; exports org.elasticsearch.gateway; exports org.elasticsearch.health; exports org.elasticsearch.health.node; exports org.elasticsearch.health.node.tracker; exports org.elasticsearch.health.node.selection; exports org.elasticsearch.health.stats; exports org.elasticsearch.http; exports org.elasticsearch.index; exports org.elasticsearch.index.analysis; exports org.elasticsearch.index.bulk.stats; exports org.elasticsearch.index.cache; exports org.elasticsearch.index.cache.bitset; exports org.elasticsearch.index.cache.query; exports org.elasticsearch.index.cache.request; exports org.elasticsearch.index.codec; exports org.elasticsearch.index.codec.tsdb; exports org.elasticsearch.index.codec.bloomfilter; exports org.elasticsearch.index.codec.zstd; exports org.elasticsearch.index.engine; exports org.elasticsearch.index.fielddata; exports org.elasticsearch.index.fielddata.fieldcomparator; exports org.elasticsearch.index.fielddata.ordinals; exports org.elasticsearch.index.fielddata.plain; exports org.elasticsearch.index.fieldvisitor; exports org.elasticsearch.index.flush; exports org.elasticsearch.index.get; exports org.elasticsearch.index.mapper; exports org.elasticsearch.index.mapper.flattened; exports org.elasticsearch.index.mapper.vectors; exports org.elasticsearch.index.merge; exports org.elasticsearch.index.query; exports org.elasticsearch.index.query.functionscore; exports org.elasticsearch.index.query.support; exports org.elasticsearch.index.recovery; exports org.elasticsearch.index.refresh; exports org.elasticsearch.index.reindex; exports org.elasticsearch.index.search; exports org.elasticsearch.index.search.stats; exports org.elasticsearch.index.seqno; exports org.elasticsearch.index.shard; exports org.elasticsearch.index.similarity; exports org.elasticsearch.index.snapshots; exports org.elasticsearch.index.snapshots.blobstore; exports org.elasticsearch.index.stats; exports org.elasticsearch.index.store; exports org.elasticsearch.index.termvectors; exports org.elasticsearch.index.translog; exports org.elasticsearch.index.warmer; exports org.elasticsearch.indices; exports org.elasticsearch.indices.analysis; exports org.elasticsearch.indices.breaker; exports org.elasticsearch.indices.cluster; exports org.elasticsearch.indices.fielddata.cache; exports org.elasticsearch.indices.recovery; exports org.elasticsearch.indices.recovery.plan; exports org.elasticsearch.indices.store; exports org.elasticsearch.inference; exports org.elasticsearch.ingest; exports org.elasticsearch.internal to org.elasticsearch.serverless.version, org.elasticsearch.serverless.buildinfo, org.elasticsearch.serverless.constants; exports org.elasticsearch.lucene.analysis.miscellaneous; exports org.elasticsearch.lucene.grouping; exports org.elasticsearch.lucene.queries; exports org.elasticsearch.lucene.search.uhighlight; exports org.elasticsearch.lucene.search.vectorhighlight; exports org.elasticsearch.lucene.similarity; exports org.elasticsearch.lucene.util; exports org.elasticsearch.monitor; exports org.elasticsearch.monitor.fs; exports org.elasticsearch.monitor.jvm; exports org.elasticsearch.monitor.os; exports org.elasticsearch.monitor.process; exports org.elasticsearch.node; exports org.elasticsearch.node.internal to org.elasticsearch.internal.sigterm; exports org.elasticsearch.persistent; exports org.elasticsearch.persistent.decider; exports org.elasticsearch.plugins; exports org.elasticsearch.plugins.interceptor to org.elasticsearch.security, org.elasticsearch.serverless.rest; exports org.elasticsearch.plugins.spi; exports org.elasticsearch.repositories; exports org.elasticsearch.repositories.blobstore; exports org.elasticsearch.repositories.fs; exports org.elasticsearch.reservedstate; exports org.elasticsearch.rest; exports org.elasticsearch.rest.action; exports org.elasticsearch.rest.action.admin.cluster; exports org.elasticsearch.rest.action.admin.cluster.dangling; exports org.elasticsearch.rest.action.admin.indices; exports org.elasticsearch.rest.action.cat; exports org.elasticsearch.rest.action.document; exports org.elasticsearch.rest.action.ingest; exports org.elasticsearch.rest.action.search; exports org.elasticsearch.script; exports org.elasticsearch.script.field; exports org.elasticsearch.script.field.vectors; exports org.elasticsearch.search; exports org.elasticsearch.search.aggregations; exports org.elasticsearch.search.aggregations.bucket; exports org.elasticsearch.search.aggregations.bucket.composite; exports org.elasticsearch.search.aggregations.bucket.countedterms; exports org.elasticsearch.search.aggregations.bucket.filter; exports org.elasticsearch.search.aggregations.bucket.geogrid; exports org.elasticsearch.search.aggregations.bucket.global; exports org.elasticsearch.search.aggregations.bucket.histogram; exports org.elasticsearch.search.aggregations.bucket.missing; exports org.elasticsearch.search.aggregations.bucket.nested; exports org.elasticsearch.search.aggregations.bucket.range; exports org.elasticsearch.search.aggregations.bucket.sampler; exports org.elasticsearch.search.aggregations.bucket.sampler.random; exports org.elasticsearch.search.aggregations.bucket.terms; exports org.elasticsearch.search.aggregations.bucket.terms.heuristic; exports org.elasticsearch.search.aggregations.metrics; exports org.elasticsearch.search.aggregations.pipeline; exports org.elasticsearch.search.aggregations.support; exports org.elasticsearch.search.aggregations.support.values; exports org.elasticsearch.search.builder; exports org.elasticsearch.search.collapse; exports org.elasticsearch.search.dfs; exports org.elasticsearch.search.fetch; exports org.elasticsearch.search.fetch.subphase; exports org.elasticsearch.search.fetch.subphase.highlight; exports org.elasticsearch.search.internal; exports org.elasticsearch.search.lookup; exports org.elasticsearch.search.profile; exports org.elasticsearch.search.profile.aggregation; exports org.elasticsearch.search.profile.dfs; exports org.elasticsearch.search.profile.query; exports org.elasticsearch.search.query; exports org.elasticsearch.search.rank; exports org.elasticsearch.search.rank.context; exports org.elasticsearch.search.rescore; exports org.elasticsearch.search.retriever; exports org.elasticsearch.search.runtime; exports org.elasticsearch.search.searchafter; exports org.elasticsearch.search.slice; exports org.elasticsearch.search.sort; exports org.elasticsearch.search.suggest; exports org.elasticsearch.search.suggest.completion; exports org.elasticsearch.search.suggest.completion.context; exports org.elasticsearch.search.suggest.phrase; exports org.elasticsearch.search.suggest.term; exports org.elasticsearch.search.vectors; exports org.elasticsearch.shutdown; exports org.elasticsearch.snapshots; exports org.elasticsearch.synonyms; exports org.elasticsearch.tasks; exports org.elasticsearch.threadpool; exports org.elasticsearch.transport; exports org.elasticsearch.upgrades; exports org.elasticsearch.usage; exports org.elasticsearch.watcher; opens org.elasticsearch.common.logging to org.apache.logging.log4j.core; exports org.elasticsearch.action.datastreams.lifecycle; exports org.elasticsearch.action.datastreams.autosharding; exports org.elasticsearch.action.downsample; exports org.elasticsearch.plugins.internal to org.elasticsearch.metering, org.elasticsearch.stateless, org.elasticsearch.settings.secure, org.elasticsearch.serverless.constants, org.elasticsearch.serverless.apifiltering, org.elasticsearch.internal.security; exports org.elasticsearch.telemetry.tracing; exports org.elasticsearch.telemetry; exports org.elasticsearch.telemetry.metric; provides java.util.spi.CalendarDataProvider with org.elasticsearch.common.time.IsoCalendarDataProvider; provides org.elasticsearch.xcontent.ErrorOnUnknown with org.elasticsearch.common.xcontent.SuggestingErrorOnUnknown; provides org.elasticsearch.xcontent.XContentBuilderExtension with org.elasticsearch.common.xcontent.XContentElasticsearchExtension; provides org.elasticsearch.cli.CliToolProvider with org.elasticsearch.cluster.coordination.NodeToolCliProvider, org.elasticsearch.index.shard.ShardToolCliProvider; uses org.elasticsearch.reservedstate.ReservedClusterStateHandlerProvider; uses org.elasticsearch.jdk.ModuleQualifiedExportsService; uses org.elasticsearch.node.internal.TerminationHandlerProvider; uses org.elasticsearch.internal.VersionExtension; uses org.elasticsearch.internal.BuildExtension; uses org.elasticsearch.features.FeatureSpecification; uses org.elasticsearch.plugins.internal.LoggingDataProvider; uses org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; provides org.elasticsearch.features.FeatureSpecification with org.elasticsearch.features.FeatureInfrastructureFeatures, org.elasticsearch.health.HealthFeatures, org.elasticsearch.cluster.service.TransportFeatures, org.elasticsearch.cluster.metadata.MetadataFeatures, org.elasticsearch.rest.RestFeatures, org.elasticsearch.indices.IndicesFeatures, org.elasticsearch.action.admin.cluster.allocation.AllocationStatsFeatures, org.elasticsearch.index.mapper.MapperFeatures, org.elasticsearch.search.retriever.RetrieversFeatures; uses org.elasticsearch.plugins.internal.SettingsExtension; uses RestExtension; uses org.elasticsearch.action.admin.cluster.node.info.ComponentVersionNumber; provides org.apache.lucene.codecs.PostingsFormat with org.elasticsearch.index.codec.bloomfilter.ES85BloomFilterPostingsFormat, org.elasticsearch.index.codec.bloomfilter.ES87BloomFilterPostingsFormat, org.elasticsearch.index.codec.postings.ES812PostingsFormat; provides org.apache.lucene.codecs.DocValuesFormat with ES87TSDBDocValuesFormat; provides org.apache.lucene.codecs.KnnVectorsFormat with org.elasticsearch.index.codec.vectors.ES813FlatVectorFormat, org.elasticsearch.index.codec.vectors.ES813Int8FlatVectorFormat, org.elasticsearch.index.codec.vectors.ES814HnswScalarQuantizedVectorsFormat; provides org.apache.lucene.codecs.Codec with Elasticsearch814Codec; provides org.apache.logging.log4j.core.util.ContextDataProvider with org.elasticsearch.common.logging.DynamicContextDataProvider; exports org.elasticsearch.cluster.routing.allocation.shards to org.elasticsearch.shardhealth, org.elasticsearch.serverless.shardhealth, org.elasticsearch.serverless.apifiltering; exports org.elasticsearch.lucene.spatial; }
elastic/elasticsearch
server/src/main/java/module-info.java
881
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.flux.view; import com.iluwatar.flux.action.MenuItem; import com.iluwatar.flux.dispatcher.Dispatcher; import com.iluwatar.flux.store.MenuStore; import com.iluwatar.flux.store.Store; import lombok.extern.slf4j.Slf4j; /** * MenuView is a concrete view. */ @Slf4j public class MenuView implements View { private MenuItem selected = MenuItem.HOME; @Override public void storeChanged(Store store) { var menuStore = (MenuStore) store; selected = menuStore.getSelected(); render(); } @Override public void render() { for (var item : MenuItem.values()) { if (selected.equals(item)) { LOGGER.info("* {}", item); } else { LOGGER.info(item.toString()); } } } public void itemClicked(MenuItem item) { Dispatcher.getInstance().menuItemSelected(item); } }
smedals/java-design-patterns
flux/src/main/java/com/iluwatar/flux/view/MenuView.java
883
/* * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.iluwatar.gateway; import lombok.extern.slf4j.Slf4j; /** * ExternalServiceC is one of external services. */ @Slf4j class ExternalServiceC implements Gateway { @Override public void execute() throws Exception { LOGGER.info("Executing Service C"); // Simulate a time-consuming task Thread.sleep(1000); } public void error() { // Simulate an exception throw new RuntimeException("Service C encountered an error"); } }
iluwatar/java-design-patterns
gateway/src/main/java/com/iluwatar/gateway/ExternalServiceC.java