_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q177900 | ColorMap.subrange | test | void subrange(int from, int to, State lp, State rp) throws RegexException {
/* Avoid one call to map.get() for each character in the range.
* This map will usually contain one item, but in complex cases more.
* For example, if we had [a-f][g-h] and then someone asked for [f-g], there
* would be two. Each of these new ranges will get a new color via subcolor.
*/
Map<Range<Integer>, Short> curColors = map.subRangeMap(Range.closed(from, to)).asMapOfRanges();
/*
* To avoid concurrent mod problems, we need to copy the ranges we are working from.
*/
List<Range<Integer>> ranges = Lists.newArrayList(curColors.keySet());
for (Range<Integer> rangeToProcess : ranges) {
// bound management here irritating.
int start = rangeToProcess.lowerEndpoint();
if (rangeToProcess.lowerBoundType() == BoundType.OPEN) {
start++;
}
int end = rangeToProcess.upperEndpoint();
if (rangeToProcess.upperBoundType() == BoundType.CLOSED) {
end++;
}
// allocate a new subcolor and account it owning the entire range.
short color = subcolor(start, end - start);
compiler.getNfa().newarc(Compiler.PLAIN, color, lp, rp);
}
} | java | {
"resource": ""
} |
q177901 | ColorMap.okcolors | test | void okcolors(Nfa nfa) {
ColorDesc cd;
ColorDesc scd;
Arc a;
short sco;
for (short co = 0; co < colorDescs.size(); co++) {
cd = colorDescs.get(co);
if (cd == null) {
continue; // not in use at all, so can't have a subcolor.
}
sco = cd.sub;
if (sco == Constants.NOSUB) {
/* has no subcolor, no further action */
} else if (sco == co) {
/* is subcolor, let parent deal with it */
} else if (cd.getNChars() == 0) {
/* parent empty, its arcs change color to subcolor */
cd.sub = Constants.NOSUB;
scd = colorDescs.get(sco);
assert scd.getNChars() > 0;
assert scd.sub == sco;
scd.sub = Constants.NOSUB;
while ((a = cd.arcs) != null) {
assert a.co == co;
cd.arcs = a.colorchain;
a.setColor(sco);
a.colorchain = scd.arcs;
scd.arcs = a;
}
freecolor(co);
} else {
/* parent's arcs must gain parallel subcolor arcs */
cd.sub = Constants.NOSUB;
scd = colorDescs.get(sco);
assert scd.getNChars() > 0;
assert scd.sub == sco;
scd.sub = Constants.NOSUB;
for (a = cd.arcs; a != null; a = a.colorchain) {
assert a.co == co;
nfa.newarc(a.type, sco, a.from, a.to);
}
}
}
} | java | {
"resource": ""
} |
q177902 | ColorMap.colorchain | test | void colorchain(Arc a) {
ColorDesc cd = colorDescs.get(a.co);
a.colorchain = cd.arcs;
cd.arcs = a;
} | java | {
"resource": ""
} |
q177903 | ColorMap.uncolorchain | test | void uncolorchain(Arc a) {
ColorDesc cd = colorDescs.get(a.co);
Arc aa;
aa = cd.arcs;
if (aa == a) { /* easy case */
cd.arcs = a.colorchain;
} else {
for (; aa != null && aa.colorchain != a; aa = aa.colorchain) {
//
}
assert aa != null;
aa.colorchain = a.colorchain;
}
a.colorchain = null; /* paranoia */
} | java | {
"resource": ""
} |
q177904 | ColorMap.dumpcolors | test | void dumpcolors() {
/*
* we want to organize this by colors.
*/
for (int co = 0; co < colorDescs.size(); co++) {
ColorDesc cd = colorDescs.get(co);
if (cd != null) {
dumpcolor(co, cd);
}
}
} | java | {
"resource": ""
} |
q177905 | Lex.lexstart | test | void lexstart() throws RegexException {
prefixes(); /* may turn on new type bits etc. */
if (0 != (v.cflags & Flags.REG_QUOTE)) {
assert 0 == (v.cflags & (Flags.REG_ADVANCED | Flags.REG_EXPANDED | Flags.REG_NEWLINE));
intocon(L_Q);
} else if (0 != (v.cflags & Flags.REG_EXTENDED)) {
assert 0 == (v.cflags & Flags.REG_QUOTE);
intocon(L_ERE);
} else {
assert 0 == (v.cflags & (Flags.REG_QUOTE | Flags.REG_ADVF));
intocon(L_BRE);
}
v.nexttype = Compiler.EMPTY; /* remember we were at the start */
next(); /* set up the first token */
} | java | {
"resource": ""
} |
q177906 | Lex.prefixes | test | void prefixes() throws RegexException {
/* literal string doesn't get any of this stuff */
if (0 != (v.cflags & Flags.REG_QUOTE)) {
return;
}
/* initial "***" gets special things */
if (have(4) && next3('*', '*', '*')) {
switch (charAtNowPlus(3)) {
case '?': /* "***?" error, msg shows version */
throw new RegexException("REG_BADPAT");
case '=': /* "***=" shifts to literal string */
v.note(Flags.REG_UNONPOSIX);
v.cflags |= Flags.REG_QUOTE;
v.cflags &= ~(Flags.REG_ADVANCED | Flags.REG_EXPANDED | Flags.REG_NEWLINE);
v.now += 4;
return; /* and there can be no more prefixes */
case ':': /* "***:" shifts to AREs */
v.note(Flags.REG_UNONPOSIX);
v.cflags |= Flags.REG_ADVANCED;
v.now += 4;
break;
default: /* otherwise *** is just an error */
throw new RegexException("REG_BADRPT");
}
}
/* BREs and EREs don't get embedded options */
if ((v.cflags & Flags.REG_ADVANCED) != Flags.REG_ADVANCED) {
return;
}
/* embedded options (AREs only) */
if (have(3) && next2('(', '?') && iscalpha(charAtNowPlus(2))) {
v.note(Flags.REG_UNONPOSIX);
v.now += 2;
for (; !ateos() && iscalpha(charAtNow()); v.now++) {
switch (charAtNow()) {
case 'b': /* BREs (but why???) */
v.cflags &= ~(Flags.REG_ADVANCED | Flags.REG_QUOTE);
break;
case 'c': /* case sensitive */
v.cflags &= ~Flags.REG_ICASE;
break;
case 'e': /* plain EREs */
v.cflags |= Flags.REG_EXTENDED;
v.cflags &= ~(Flags.REG_ADVF | Flags.REG_QUOTE);
break;
case 'i': /* case insensitive */
v.cflags |= Flags.REG_ICASE;
break;
case 'm': /* Perloid synonym for n */
case 'n': /* \n affects ^ $ . [^ */
v.cflags |= Flags.REG_NEWLINE;
break;
case 'p': /* ~Perl, \n affects . [^ */
v.cflags |= Flags.REG_NLSTOP;
v.cflags &= ~Flags.REG_NLANCH;
break;
case 'q': /* literal string */
v.cflags |= Flags.REG_QUOTE;
v.cflags &= ~Flags.REG_ADVANCED;
break;
case 's': /* single line, \n ordinary */
v.cflags &= ~Flags.REG_NEWLINE;
break;
case 't': /* tight syntax */
v.cflags &= ~Flags.REG_EXPANDED;
break;
case 'w': /* weird, \n affects ^ $ only */
v.cflags &= ~Flags.REG_NLSTOP;
v.cflags |= Flags.REG_NLANCH;
break;
case 'x': /* expanded syntax */
v.cflags |= Flags.REG_EXPANDED;
break;
default:
throw new RegexException("REG_BADOPT");
}
}
if (!next1(')')) {
throw new RegexException("REG_BADOPT");
}
v.now++;
if (0 != (v.cflags & Flags.REG_QUOTE)) {
v.cflags &= ~(Flags.REG_EXPANDED | Flags.REG_NEWLINE);
}
}
} | java | {
"resource": ""
} |
q177907 | Lex.lexnest | test | void lexnest(char[] interpolated) {
assert v.savepattern == null; /* only one level of nesting */
v.savepattern = v.pattern;
v.savenow = v.now;
v.savestop = v.stop;
v.savenow = v.now;
v.pattern = interpolated;
v.now = 0;
v.stop = v.pattern.length;
} | java | {
"resource": ""
} |
q177908 | RuntimeColorMap.getcolor | test | short getcolor(int codepoint) {
try {
return fullMap.get(codepoint);
} catch (NullPointerException npe) {
throw new RuntimeException(String.format(" CP %08x no mapping", codepoint));
}
} | java | {
"resource": ""
} |
q177909 | Dfa.initialize | test | StateSet initialize(int start) {
// Discard state sets; reuse would be faster if we kept them,
// but then we'd need the real cache.
stateSets.clear();
StateSet stateSet = new StateSet(nstates, ncolors);
stateSet.states.set(cnfa.pre);
stateSet.noprogress = true;
// Insert into hash table based on that one state.
stateSets.put(stateSet.states, stateSet);
stateSet.setLastSeen(start);
return stateSet;
} | java | {
"resource": ""
} |
q177910 | Dfa.lastcold | test | int lastcold() {
int nopr = 0;
for (StateSet ss : stateSets.values()) {
if (ss.noprogress && nopr < ss.getLastSeen()) {
nopr = ss.getLastSeen();
}
}
return nopr;
} | java | {
"resource": ""
} |
q177911 | Locale.eclass | test | static UnicodeSet eclass(char c, boolean cases) {
/* otherwise, none */
if (cases) {
return allcases(c);
} else {
UnicodeSet set = new UnicodeSet();
set.add(c);
return set;
}
} | java | {
"resource": ""
} |
q177912 | Locale.cclass | test | public static UnicodeSet cclass(String cclassName, boolean casefold) throws RegexException {
try {
if (casefold) {
return KNOWN_SETS_CI.get(cclassName);
} else {
return KNOWN_SETS_CS.get(cclassName);
}
} catch (ExecutionException e) {
Throwables.propagateIfInstanceOf(e.getCause(), RegexException.class);
throw new RegexRuntimeException(e.getCause());
}
} | java | {
"resource": ""
} |
q177913 | CnfaBuilder.carcsort | test | void carcsort(int first, int last) {
int p;
int q;
long tmp;
if (last - first <= 1) {
return;
}
for (p = first; p <= last; p++) {
for (q = p; q <= last; q++) {
short pco = Cnfa.carcColor(arcs[p]);
short qco = Cnfa.carcColor(arcs[q]);
int pto = Cnfa.carcTarget(arcs[p]);
int qto = Cnfa.carcTarget(arcs[q]);
if (pco > qco || (pco == qco && pto > qto)) {
assert p != q;
tmp = arcs[p];
arcs[p] = arcs[q];
arcs[q] = tmp;
}
}
}
} | java | {
"resource": ""
} |
q177914 | Subre.dumpst | test | String dumpst(boolean nfapresent) {
StringBuilder sb = new StringBuilder();
sb.append(String.format("%s. `%c'", shortId(), op));
if (0 != (flags & LONGER)) {
sb.append(" longest");
}
if (0 != (flags & SHORTER)) {
sb.append(" shortest");
}
if (0 != (flags & MIXED)) {
sb.append(" hasmixed");
}
if (0 != (flags & CAP)) {
sb.append(" hascapture");
}
if (0 != (flags & BACKR)) {
sb.append(" hasbackref");
}
if (0 == (flags & INUSE)) {
sb.append(" UNUSED");
}
if (subno != 0) {
sb.append(String.format(" (#%d)", subno));
}
if (min != 1 || max != 1) {
sb.append(String.format(" {%d,", min));
if (max != Compiler.INFINITY) {
sb.append(String.format("%d", max));
}
sb.append("}");
}
if (nfapresent) {
sb.append(String.format(" %d-%d", begin.no, end.no));
}
if (left != null) {
sb.append(String.format(" L:%s", left.toString()));
}
if (right != null) {
sb.append(String.format(" R:%s", right.toString()));
}
sb.append("\n");
if (left != null) {
left.dumpst(nfapresent);
}
if (right != null) {
right.dumpst(nfapresent);
}
return sb.toString();
} | java | {
"resource": ""
} |
q177915 | Nfa.newstate | test | State newstate(int flag) {
State newState = new State();
newState.no = nstates++; // a unique number.
if (states == null) {
states = newState;
}
if (slast != null) {
assert slast.next == null;
slast.next = newState;
}
newState.prev = slast;
slast = newState;
newState.flag = flag;
return newState;
} | java | {
"resource": ""
} |
q177916 | Nfa.moveouts | test | void moveouts(State old, State newState) {
Arc a;
assert old != newState;
while ((a = old.outs) != null) {
cparc(a, newState, a.to);
freearc(a);
}
} | java | {
"resource": ""
} |
q177917 | Nfa.moveins | test | void moveins(State old, State newState) {
Arc a;
assert old != newState;
while ((a = old.ins) != null) {
cparc(a, a.from, newState);
freearc(a);
}
assert old.nins == 0;
assert old.ins == null;
} | java | {
"resource": ""
} |
q177918 | Nfa.copyins | test | void copyins(State old, State newState) {
Arc a;
assert old != newState;
for (a = old.ins; a != null; a = a.inchain) {
cparc(a, a.from, newState);
}
} | java | {
"resource": ""
} |
q177919 | Nfa.copyouts | test | void copyouts(State old, State newState) {
Arc a;
assert old != newState;
for (a = old.outs; a != null; a = a.outchain) {
cparc(a, newState, a.to);
}
} | java | {
"resource": ""
} |
q177920 | Nfa.dropstate | test | void dropstate(State s) {
Arc a;
while ((a = s.ins) != null) {
freearc(a);
}
while ((a = s.outs) != null) {
freearc(a);
}
freestate(s);
} | java | {
"resource": ""
} |
q177921 | Nfa.freestate | test | void freestate(State s) {
assert s != null;
assert s.nins == 0;
assert s.nouts == 0;
if (s.next != null) {
s.next.prev = s.prev;
} else {
assert s == slast;
slast = s.prev;
}
if (s.prev != null) {
s.prev.next = s.next;
} else {
assert s == states;
states = s.next;
}
} | java | {
"resource": ""
} |
q177922 | Nfa.cparc | test | void cparc(Arc oa, State from, State to) {
newarc(oa.type, oa.co, from, to);
} | java | {
"resource": ""
} |
q177923 | Nfa.duptraverse | test | void duptraverse(State s, State stmp) {
Arc a;
if (s.tmp != null) {
return; /* already done */
}
s.tmp = (stmp == null) ? newstate() : stmp;
if (s.tmp == null) {
return;
}
for (a = s.outs; a != null; a = a.outchain) {
duptraverse(a.to, null);
assert a.to.tmp != null;
cparc(a, s.tmp, a.to.tmp);
}
} | java | {
"resource": ""
} |
q177924 | Nfa.specialcolors | test | void specialcolors() {
/* false colors for BOS, BOL, EOS, EOL */
if (parent == null) {
bos[0] = cm.pseudocolor();
bos[1] = cm.pseudocolor();
eos[0] = cm.pseudocolor();
eos[1] = cm.pseudocolor();
} else {
assert parent.bos[0] != Constants.COLORLESS;
bos[0] = parent.bos[0];
assert parent.bos[1] != Constants.COLORLESS;
bos[1] = parent.bos[1];
assert parent.eos[0] != Constants.COLORLESS;
eos[0] = parent.eos[0];
assert parent.eos[1] != Constants.COLORLESS;
eos[1] = parent.eos[1];
}
} | java | {
"resource": ""
} |
q177925 | Nfa.dumpnfa | test | void dumpnfa() {
if (!LOG.isDebugEnabled() || !IS_DEBUG) {
return;
}
LOG.debug("dump nfa");
StringBuilder sb = new StringBuilder();
sb.append(String.format("pre %d, post %d init %d final %d", pre.no, post.no, init.no, finalState.no));
if (bos[0] != Constants.COLORLESS) {
sb.append(String.format(", bos [%d]", bos[0]));
}
if (bos[1] != Constants.COLORLESS) {
sb.append(String.format(", bol [%d]", bos[1]));
}
if (eos[0] != Constants.COLORLESS) {
sb.append(String.format(", eos [%d]", eos[0]));
}
if (eos[1] != Constants.COLORLESS) {
sb.append(String.format(", eol [%d]", eos[1]));
}
LOG.debug(sb.toString());
for (State s = states; s != null; s = s.next) {
dumpstate(s);
}
if (parent == null) {
cm.dumpcolors();
}
} | java | {
"resource": ""
} |
q177926 | Nfa.dumpstate | test | void dumpstate(State s) {
Arc a;
if (!LOG.isDebugEnabled() || !IS_DEBUG) {
return;
}
StringBuilder sb = new StringBuilder();
sb.append(String.format("State %d%s%c", s.no, (s.tmp != null) ? "T" : "",
(s.flag != 0) ? (char)s.flag : '.'));
if (s.prev != null && s.prev.next != s) {
sb.append(String.format("\tstate chain bad"));
}
if (s.nouts == 0) {
sb.append("\tno out arcs");
} else {
dumparcs(s, sb);
}
LOG.debug(sb.toString());
for (a = s.ins; a != null; a = a.inchain) {
if (a.to != s) {
LOG.debug(String.format("\tlink from %d to %d on %d's in-chain",
a.from.no, a.to.no, s.no));
}
}
} | java | {
"resource": ""
} |
q177927 | Nfa.dumparcs | test | void dumparcs(State s, StringBuilder sb) {
int pos;
assert s.nouts > 0;
/* printing arcs in reverse order is usually clearer */
pos = dumprarcs(s.outs, s, 1, sb);
if (pos != 1) {
//sb.append("\n");
}
} | java | {
"resource": ""
} |
q177928 | Nfa.dumprarcs | test | int dumprarcs(Arc a, State s, int pos, StringBuilder sb) {
if (a.outchain != null) {
pos = dumprarcs(a.outchain, s, pos, sb);
}
dumparc(a, s, sb);
if (pos == 5) {
sb.append("\n");
pos = 1;
} else {
pos++;
}
return pos;
} | java | {
"resource": ""
} |
q177929 | Nfa.dumparc | test | void dumparc(Arc a, State s, StringBuilder sb) {
sb.append("\t");
switch (a.type) {
case Compiler.PLAIN:
sb.append(String.format("[%d]", a.co));
break;
case Compiler.AHEAD:
sb.append(String.format(">%d>", a.co));
break;
case Compiler.BEHIND:
sb.append(String.format("<%d<", a.co));
break;
case Compiler.LACON:
sb.append(String.format(":%d:", a.co));
break;
case '^':
case '$':
sb.append(String.format("%c%d", (char)a.type, a.co));
break;
case Compiler.EMPTY:
break;
default:
sb.append(String.format("0x%x/0%d", a.type, a.co));
break;
}
if (a.from != s) {
sb.append(String.format("?%d?", a.from.no));
}
sb.append("->");
if (a.to == null) {
sb.append("null");
Arc aa;
for (aa = a.to.ins; aa != null; aa = aa.inchain) {
if (aa == a) {
break; /* NOTE BREAK OUT */
}
}
if (aa == null) {
LOG.debug("?!?"); /* missing from in-chain */
}
} else {
sb.append(String.format("%d", a.to.no));
}
} | java | {
"resource": ""
} |
q177930 | Nfa.optimize | test | long optimize() throws RegexException {
LOG.debug("initial cleanup");
cleanup(); /* may simplify situation */
dumpnfa();
LOG.debug("empties");
fixempties(); /* get rid of EMPTY arcs */
LOG.debug("constraints");
pullback(); /* pull back constraints backward */
pushfwd(); /* push fwd constraints forward */
LOG.debug("final cleanup");
cleanup(); /* final tidying */
return analyze(); /* and analysis */
} | java | {
"resource": ""
} |
q177931 | Nfa.analyze | test | long analyze() {
Arc a;
Arc aa;
if (pre.outs == null) {
return Flags.REG_UIMPOSSIBLE;
}
for (a = pre.outs; a != null; a = a.outchain) {
for (aa = a.to.outs; aa != null; aa = aa.outchain) {
if (aa.to == post) {
return Flags.REG_UEMPTYMATCH;
}
}
}
return 0;
} | java | {
"resource": ""
} |
q177932 | Nfa.combine | test | int combine(Arc con, Arc a) throws RegexException {
//# define CA(ct,at) (((ct)<<CHAR_BIT) | (at))
//CA(con->type, a->type)) {
switch ((con.type << 8) | a.type) {
case '^' << 8 | Compiler.PLAIN: /* newlines are handled separately */
case '$' << 8 | Compiler.PLAIN:
return INCOMPATIBLE;
case Compiler.AHEAD << 8 | Compiler.PLAIN: /* color constraints meet colors */
case Compiler.BEHIND << 8 | Compiler.PLAIN:
if (con.co == a.co) {
return SATISFIED;
}
return INCOMPATIBLE;
case '^' << 8 | '^': /* collision, similar constraints */
case '$' << 8 | '$':
case Compiler.AHEAD << 8 | Compiler.AHEAD:
case Compiler.BEHIND << 8 | Compiler.BEHIND:
if (con.co == a.co) { /* true duplication */
return SATISFIED;
}
return INCOMPATIBLE;
case '^' << 8 | Compiler.BEHIND: /* collision, dissimilar constraints */
case Compiler.BEHIND << 8 | '^':
case '$' << 8 | Compiler.AHEAD:
case Compiler.AHEAD << 8 | '$':
return INCOMPATIBLE;
case '^' << 8 | Compiler.AHEAD:
case Compiler.BEHIND << 8 | '$':
case Compiler.BEHIND << 8 | Compiler.AHEAD:
case '$' << 8 | '^':
case '$' << 8 | Compiler.BEHIND:
case Compiler.AHEAD << 8 | '^':
case Compiler.AHEAD << 8 | Compiler.BEHIND:
case '^' << 8 | Compiler.LACON:
case Compiler.BEHIND << 8 | Compiler.LACON:
case '$' << 8 | Compiler.LACON:
case Compiler.AHEAD << 8 | Compiler.LACON:
return COMPATIBLE;
default:
throw new RuntimeException("Impossible arc");
}
} | java | {
"resource": ""
} |
q177933 | Nfa.cleanup | test | void cleanup() {
State s;
State nexts;
int n;
/* clear out unreachable or dead-end states */
/* use pre to mark reachable, then post to mark can-reach-post */
markreachable(pre, null, pre);
markcanreach(post, pre, post);
for (s = states; s != null; s = nexts) {
nexts = s.next;
if (s.tmp != post && 0 == s.flag) {
dropstate(s);
}
}
assert post.nins == 0 || post.tmp == post;
cleartraverse(pre);
assert post.nins == 0 || post.tmp == null;
/* the nins==0 (final unreachable) case will be caught later */
/* renumber surviving states */
n = 0;
for (s = states; s != null; s = s.next) {
s.no = n++;
}
nstates = n;
} | java | {
"resource": ""
} |
q177934 | Nfa.markreachable | test | void markreachable(State s, State okay, State mark) {
Arc a;
if (s.tmp != okay) {
return;
}
s.tmp = mark;
for (a = s.outs; a != null; a = a.outchain) {
markreachable(a.to, okay, mark);
}
} | java | {
"resource": ""
} |
q177935 | Nfa.markcanreach | test | void markcanreach(State s, State okay, State mark) {
Arc a;
if (s.tmp != okay) {
return;
}
s.tmp = mark;
for (a = s.ins; a != null; a = a.inchain) {
markcanreach(a.from, okay, mark);
}
} | java | {
"resource": ""
} |
q177936 | Nfa.fixempties | test | void fixempties() {
State s;
State nexts;
Arc a;
Arc nexta;
boolean progress;
/* find and eliminate empties until there are no more */
do {
progress = false;
for (s = states; s != null; s = nexts) {
nexts = s.next;
for (a = s.outs; a != null; a = nexta) {
nexta = a.outchain;
if (a.type == Compiler.EMPTY && unempty(a)) {
progress = true;
}
assert nexta == null || s.no != State.FREESTATE;
}
}
if (progress) {
dumpnfa();
}
} while (progress);
} | java | {
"resource": ""
} |
q177937 | Nfa.unempty | test | boolean unempty(Arc a) {
State from = a.from;
State to = a.to;
boolean usefrom; /* work on from, as opposed to to? */
assert a.type == Compiler.EMPTY;
assert from != pre && to != post;
if (from == to) { /* vacuous loop */
freearc(a);
return true;
}
/* decide which end to work on */
usefrom = true; /* default: attack from */
if (from.nouts > to.nins) {
usefrom = false;
} else if (from.nouts == to.nins) {
/* decide on secondary issue: move/copy fewest arcs */
if (from.nins > to.nouts) {
usefrom = false;
}
}
freearc(a);
if (usefrom) {
if (from.nouts == 0) {
/* was the state's only outarc */
moveins(from, to);
freestate(from);
} else {
copyins(from, to);
}
} else {
if (to.nins == 0) {
/* was the state's only inarc */
moveouts(to, from);
freestate(to);
} else {
copyouts(to, from);
}
}
return true;
} | java | {
"resource": ""
} |
q177938 | AnalyzeTask.getRuleParameters | test | private Map<String, String> getRuleParameters() throws CliExecutionException {
Map<String, String> ruleParameters;
if (ruleParametersFile == null) {
ruleParameters = Collections.emptyMap();
} else {
Properties properties = new Properties();
try {
properties.load(new FileInputStream(ruleParametersFile));
} catch (IOException e) {
throw new CliExecutionException("Cannot read rule parameters file '" + ruleParametersFile.getPath() + "'.");
}
ruleParameters = new TreeMap<>();
for (String name : properties.stringPropertyNames()) {
ruleParameters.put(name, properties.getProperty(name));
}
}
return ruleParameters;
} | java | {
"resource": ""
} |
q177939 | AnalyzeTask.getRuleInterpreterPlugins | test | private Map<String, Collection<RuleInterpreterPlugin>> getRuleInterpreterPlugins() throws CliExecutionException {
try {
return pluginRepository.getRuleInterpreterPluginRepository().getRuleInterpreterPlugins(Collections.<String, Object> emptyMap());
} catch (PluginRepositoryException e) {
throw new CliExecutionException("Cannot get report plugins.", e);
}
} | java | {
"resource": ""
} |
q177940 | AnalyzeTask.getReportPlugins | test | private Map<String, ReportPlugin> getReportPlugins(ReportContext reportContext) throws CliExecutionException {
ReportPluginRepository reportPluginRepository;
try {
reportPluginRepository = pluginRepository.getReportPluginRepository();
return reportPluginRepository.getReportPlugins(reportContext, pluginProperties);
} catch (PluginRepositoryException e) {
throw new CliExecutionException("Cannot get report plugins.", e);
}
} | java | {
"resource": ""
} |
q177941 | AbstractAnalyzeTask.getRuleSelection | test | protected RuleSelection getRuleSelection(RuleSet ruleSet) {
return RuleSelection.select(ruleSet, groupIds,constraintIds, conceptIds);
} | java | {
"resource": ""
} |
q177942 | Main.run | test | public void run(String[] args) throws CliExecutionException {
Options options = gatherOptions(taskFactory);
CommandLine commandLine = getCommandLine(args, options);
interpretCommandLine(commandLine, options, taskFactory);
} | java | {
"resource": ""
} |
q177943 | Main.getErrorMessage | test | private static String getErrorMessage(CliExecutionException e) {
StringBuffer messageBuilder = new StringBuffer();
Throwable current = e;
do {
messageBuilder.append("-> ");
messageBuilder.append(current.getMessage());
current = current.getCause();
}
while (current != null);
return messageBuilder.toString();
} | java | {
"resource": ""
} |
q177944 | Main.gatherStandardOptions | test | @SuppressWarnings("static-access")
private void gatherStandardOptions(final Options options) {
options.addOption(OptionBuilder.withArgName("p").withDescription(
"Path to property file; default is jqassistant.properties in the class path").withLongOpt("properties").hasArg().create("p"));
options.addOption(new Option("help", "print this message"));
} | java | {
"resource": ""
} |
q177945 | Main.gatherTasksOptions | test | private void gatherTasksOptions(TaskFactory taskFactory, Options options) {
for (Task task : taskFactory.getTasks()) {
for (Option option : task.getOptions()) {
options.addOption(option);
}
}
} | java | {
"resource": ""
} |
q177946 | Main.gatherTaskNames | test | private String gatherTaskNames(TaskFactory taskFactory) {
final StringBuilder builder = new StringBuilder();
for (String taskName : taskFactory.getTaskNames()) {
builder.append("'").append(taskName).append("' ");
}
return builder.toString().trim();
} | java | {
"resource": ""
} |
q177947 | Main.interpretCommandLine | test | private void interpretCommandLine(CommandLine commandLine, Options options, TaskFactory taskFactory) throws CliExecutionException {
if(commandLine.hasOption(OPTION_HELP)) {
printUsage(options, null);
System.exit(1);
}
List<String> taskNames = commandLine.getArgList();
if (taskNames.isEmpty()) {
printUsage(options, "A task must be specified, i.e. one of " + gatherTaskNames(taskFactory));
System.exit(1);
}
List<Task> tasks = new ArrayList<>();
for (String taskName : taskNames) {
Task task = taskFactory.fromName(taskName);
if (task == null) {
printUsage(options, "Unknown task " + taskName);
}
tasks.add(task);
}
Map<String, Object> properties = readProperties(commandLine);
PluginRepository pluginRepository = getPluginRepository();
try {
executeTasks(tasks, options, commandLine, pluginRepository, properties);
} catch (PluginRepositoryException e) {
throw new CliExecutionException("Unexpected plugin repository problem while executing tasks.", e);
}
} | java | {
"resource": ""
} |
q177948 | Main.getCommandLine | test | private CommandLine getCommandLine(String[] args, Options options) {
final CommandLineParser parser = new BasicParser();
CommandLine commandLine = null;
try {
commandLine = parser.parse(options, args);
} catch (ParseException e) {
printUsage(options, e.getMessage());
System.exit(1);
}
return commandLine;
} | java | {
"resource": ""
} |
q177949 | Main.executeTask | test | private void executeTask(Task task, Options option, CommandLine commandLine, PluginRepository pluginRepository,
Map<String, Object> properties) throws CliExecutionException {
try {
task.withStandardOptions(commandLine);
task.withOptions(commandLine);
} catch (CliConfigurationException e) {
printUsage(option, e.getMessage());
System.exit(1);
}
task.initialize(pluginRepository, properties);
task.run();
} | java | {
"resource": ""
} |
q177950 | Main.readProperties | test | private Map<String, Object> readProperties(CommandLine commandLine) throws CliConfigurationException {
final Properties properties = new Properties();
InputStream propertiesStream;
if (commandLine.hasOption("p")) {
File propertyFile = new File(commandLine.getOptionValue("p"));
if (!propertyFile.exists()) {
throw new CliConfigurationException("Property file given by command line does not exist: " + propertyFile.getAbsolutePath());
}
try {
propertiesStream = new FileInputStream(propertyFile);
} catch (FileNotFoundException e) {
throw new CliConfigurationException("Cannot open property file.", e);
}
} else {
propertiesStream = Main.class.getResourceAsStream("/jqassistant.properties");
}
Map<String, Object> result = new HashMap<>();
if (propertiesStream != null) {
try {
properties.load(propertiesStream);
} catch (IOException e) {
throw new CliConfigurationException("Cannot load properties from file.", e);
}
for (String name : properties.stringPropertyNames()) {
result.put(name, properties.getProperty(name));
}
}
return result;
} | java | {
"resource": ""
} |
q177951 | Main.printUsage | test | private void printUsage(final Options options, final String errorMessage) {
if(errorMessage != null) {
System.out.println("Error: " + errorMessage);
}
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(Main.class.getCanonicalName() + " <task> [options]", options);
System.out.println("Tasks are: " + gatherTaskNames(taskFactory));
System.out.println("Example: " + Main.class.getCanonicalName() + " scan -f java:classpath::target/classes java:classpath::target/test-classes");
} | java | {
"resource": ""
} |
q177952 | Main.getHomeDirectory | test | private File getHomeDirectory() {
String dirName = System.getenv(ENV_JQASSISTANT_HOME);
if (dirName != null) {
File dir = new File(dirName);
if (dir.exists()) {
LOGGER.debug("Using JQASSISTANT_HOME '" + dir.getAbsolutePath() + "'.");
return dir;
} else {
LOGGER.warn("JQASSISTANT_HOME '" + dir.getAbsolutePath() + "' points to a non-existing directory.");
return null;
}
}
LOGGER.warn("JQASSISTANT_HOME is not set.");
return null;
} | java | {
"resource": ""
} |
q177953 | Main.createPluginClassLoader | test | private ClassLoader createPluginClassLoader() throws CliExecutionException {
ClassLoader parentClassLoader = Task.class.getClassLoader();
File homeDirectory = getHomeDirectory();
if (homeDirectory != null) {
File pluginDirectory = new File(homeDirectory, DIRECTORY_PLUGINS);
if (pluginDirectory.exists()) {
final List<URL> urls = new ArrayList<>();
final Path pluginDirectoryPath = pluginDirectory.toPath();
SimpleFileVisitor<Path> visitor = new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.toFile().getName().endsWith(".jar")) {
urls.add(file.toFile().toURI().toURL());
}
return FileVisitResult.CONTINUE;
}
};
try {
Files.walkFileTree(pluginDirectoryPath, visitor);
} catch (IOException e) {
throw new CliExecutionException("Cannot read plugin directory.", e);
}
LOGGER.debug("Using plugin URLs: " + urls);
return new com.buschmais.jqassistant.commandline.PluginClassLoader(urls, parentClassLoader);
}
}
return parentClassLoader;
} | java | {
"resource": ""
} |
q177954 | CountryBoundaries.getContainingIds | test | public Set<String> getContainingIds(
double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
{
Set<String> ids = new HashSet<>();
forCellsIn(minLongitude, minLatitude, maxLongitude, maxLatitude, cell ->
{
if(ids.isEmpty())
{
ids.addAll(cell.getContainingIds());
}
else
{
ids.retainAll(cell.getContainingIds());
}
});
return ids;
} | java | {
"resource": ""
} |
q177955 | CountryBoundaries.getIntersectingIds | test | public Set<String> getIntersectingIds(
double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
{
Set<String> ids = new HashSet<>();
forCellsIn(minLongitude, minLatitude, maxLongitude, maxLatitude, cell ->
{
ids.addAll(cell.getAllIds());
});
return ids;
} | java | {
"resource": ""
} |
q177956 | Router.uri | test | public String uri(HttpMethod method, T target, Object... params) {
MethodlessRouter<T> router = (method == null) ? anyMethodRouter : routers.get(method);
// Fallback to anyMethodRouter if no router is found for the method
if (router == null) {
router = anyMethodRouter;
}
String ret = router.uri(target, params);
if (ret != null) {
return ret;
}
// Fallback to anyMethodRouter if the router was not anyMethodRouter and no path is found
return (router != anyMethodRouter) ? anyMethodRouter.uri(target, params) : null;
} | java | {
"resource": ""
} |
q177957 | OrderlessRouter.addRoute | test | public OrderlessRouter<T> addRoute(String pathPattern, T target) {
PathPattern p = new PathPattern(pathPattern);
if (routes.containsKey(p)) {
return this;
}
routes.put(p, target);
addReverseRoute(target, p);
return this;
} | java | {
"resource": ""
} |
q177958 | MethodlessRouter.size | test | public int size() {
return first.routes().size() + other.routes().size() + last.routes().size();
} | java | {
"resource": ""
} |
q177959 | MethodlessRouter.addRouteFirst | test | public MethodlessRouter<T> addRouteFirst(String pathPattern, T target) {
first.addRoute(pathPattern, target);
return this;
} | java | {
"resource": ""
} |
q177960 | MethodlessRouter.addRoute | test | public MethodlessRouter<T> addRoute(String pathPattern, T target) {
other.addRoute(pathPattern, target);
return this;
} | java | {
"resource": ""
} |
q177961 | MethodlessRouter.addRouteLast | test | public MethodlessRouter<T> addRouteLast(String pathPattern, T target) {
last.addRoute(pathPattern, target);
return this;
} | java | {
"resource": ""
} |
q177962 | MethodlessRouter.anyMatched | test | public boolean anyMatched(String[] requestPathTokens) {
return first.anyMatched(requestPathTokens) ||
other.anyMatched(requestPathTokens) ||
last.anyMatched(requestPathTokens);
} | java | {
"resource": ""
} |
q177963 | HibernateBookmarkStore.smartEqual | test | private Criterion smartEqual(String property, Object value) {
if (value == null) {
return Restrictions.isNull(property);
}
else {
return Restrictions.eq(property, value);
}
} | java | {
"resource": ""
} |
q177964 | FileSystemBookmarkStore.getStoreFileName | test | protected String getStoreFileName(String owner, String name) {
final StringBuilder fileNameBuff = new StringBuilder();
fileNameBuff.append(owner != null ? "_" + owner : "null");
fileNameBuff.append("_");
fileNameBuff.append(name != null ? "_" + name : "null");
fileNameBuff.append(".bms.xml");
return fileNameBuff.toString();
} | java | {
"resource": ""
} |
q177965 | DefaultBookmarksComparator.compareFolders | test | protected int compareFolders(final Entry e1, final Entry e2) {
final boolean f1 = e1 instanceof Folder;
final boolean f2 = e2 instanceof Folder;
if (f1 && !f2) {
return -1;
}
else if (!f1 && f2) {
return 1;
}
else {
return 0;
}
} | java | {
"resource": ""
} |
q177966 | DefaultBookmarksComparator.compareEntries | test | protected int compareEntries(final Entry e1, final Entry e2) {
return new CompareToBuilder()
.append(e1.getName(), e2.getName())
.append(e1.getNote(), e2.getNote())
.append(e1.getCreated(), e2.getCreated())
.append(e1.getModified(), e2.getModified())
.toComparison();
} | java | {
"resource": ""
} |
q177967 | DefaultBookmarksComparator.compareBookmarks | test | protected int compareBookmarks(final Entry e1, final Entry e2) {
if (e1 instanceof Bookmark && e2 instanceof Bookmark) {
final Bookmark b1 = (Bookmark)e1;
final Bookmark b2 = (Bookmark)e2;
return new CompareToBuilder()
.append(b1.getUrl(), b2.getUrl())
.append(b1.isNewWindow(), b2.isNewWindow())
.toComparison();
}
else {
return 0;
}
} | java | {
"resource": ""
} |
q177968 | JspServletWrapper.setServletClassLastModifiedTime | test | public void setServletClassLastModifiedTime(long lastModified) {
if (this.servletClassLastModifiedTime < lastModified) {
synchronized (this) {
if (this.servletClassLastModifiedTime < lastModified) {
this.servletClassLastModifiedTime = lastModified;
reload = true;
}
}
}
} | java | {
"resource": ""
} |
q177969 | JspServletWrapper.getDependants | test | public java.util.List<String> getDependants() {
try {
Object target;
if (isTagFile) {
if (reload) {
tagHandlerClass = ctxt.load();
}
target = tagHandlerClass.newInstance();
} else {
target = getServlet();
}
if (target != null && target instanceof JspSourceDependent) {
return ((JspSourceDependent) target).getDependants();
}
} catch (Throwable ex) {
}
return null;
} | java | {
"resource": ""
} |
q177970 | JasperLoader.findClass | test | public Class findClass(String className) throws ClassNotFoundException {
// If the class file is in memory, use it
byte[] cdata = this.bytecodes.get(className);
String path = className.replace('.', '/') + ".class";
if (cdata == null) {
// If the bytecode preprocessor is not enabled, use super.findClass
// as usual.
/* XXX
if (!PreprocessorUtil.isPreprocessorEnabled()) {
return super.findClass(className);
}
*/
// read class data from file
cdata = loadClassDataFromFile(path);
if (cdata == null) {
throw new ClassNotFoundException(className);
}
}
// Preprocess the loaded byte code
/* XXX
if (PreprocessorUtil.isPreprocessorEnabled()) {
cdata = PreprocessorUtil.processClass(path, cdata);
}
*/
Class clazz = null;
if (securityManager != null) {
ProtectionDomain pd
= new ProtectionDomain(codeSource, permissionCollection);
clazz = defineClass(className, cdata, 0, cdata.length, pd);
} else {
clazz = defineClass(className, cdata, 0, cdata.length);
}
return clazz;
} | java | {
"resource": ""
} |
q177971 | BasicAuthentication.parseAuthorization | test | public static String[] parseAuthorization ( final HttpServletRequest request )
{
final String auth = request.getHeader ( "Authorization" );
logger.debug ( "Auth header: {}", auth );
if ( auth == null || auth.isEmpty () )
{
return null;
}
final String[] toks = auth.split ( "\\s" );
if ( toks.length < 2 )
{
return null;
}
if ( !"Basic".equalsIgnoreCase ( toks[0] ) )
{
return null;
}
final byte[] authData = Base64.getDecoder ().decode ( toks[1] );
final String authStr = StandardCharsets.ISO_8859_1.decode ( ByteBuffer.wrap ( authData ) ).toString ();
logger.debug ( "Auth String: {}", authStr );
final String[] authToks = authStr.split ( ":", 2 );
logger.debug ( "Auth tokens: {}", new Object[] { authToks } );
if ( authToks.length != 2 )
{
return null;
}
return authToks;
} | java | {
"resource": ""
} |
q177972 | ProtectedFunctionMapper.getInstance | test | public static ProtectedFunctionMapper getInstance() {
ProtectedFunctionMapper funcMapper;
if (SecurityUtil.isPackageProtectionEnabled()) {
funcMapper = AccessController.doPrivileged(
new PrivilegedAction<ProtectedFunctionMapper>() {
public ProtectedFunctionMapper run() {
return new ProtectedFunctionMapper();
}
} );
} else {
funcMapper = new ProtectedFunctionMapper();
}
funcMapper.fnmap = new java.util.HashMap<String, Method>();
return funcMapper;
} | java | {
"resource": ""
} |
q177973 | ProtectedFunctionMapper.mapFunction | test | public void mapFunction(String fnQName, final Class<?> c,
final String methodName, final Class<?>[] args )
{
java.lang.reflect.Method method;
if (SecurityUtil.isPackageProtectionEnabled()){
try{
method = AccessController.doPrivileged(
new PrivilegedExceptionAction<Method>(){
public Method run() throws Exception{
return c.getDeclaredMethod(methodName, args);
}
});
} catch (PrivilegedActionException ex){
throw new RuntimeException(
"Invalid function mapping - no such method: "
+ ex.getException().getMessage());
}
} else {
try {
method = c.getDeclaredMethod(methodName, args);
} catch( NoSuchMethodException e ) {
throw new RuntimeException(
"Invalid function mapping - no such method: "
+ e.getMessage());
}
}
this.fnmap.put(fnQName, method );
} | java | {
"resource": ""
} |
q177974 | ProtectedFunctionMapper.getMapForFunction | test | public static ProtectedFunctionMapper getMapForFunction(
String fnQName, final Class<?> c,
final String methodName, final Class<?>[] args )
{
java.lang.reflect.Method method;
ProtectedFunctionMapper funcMapper;
if (SecurityUtil.isPackageProtectionEnabled()){
funcMapper = AccessController.doPrivileged(
new PrivilegedAction<ProtectedFunctionMapper>(){
public ProtectedFunctionMapper run() {
return new ProtectedFunctionMapper();
}
});
try{
method = AccessController.doPrivileged(
new PrivilegedExceptionAction<Method>(){
public Method run() throws Exception{
return c.getDeclaredMethod(methodName, args);
}
});
} catch (PrivilegedActionException ex){
throw new RuntimeException(
"Invalid function mapping - no such method: "
+ ex.getException().getMessage());
}
} else {
funcMapper = new ProtectedFunctionMapper();
try {
method = c.getDeclaredMethod(methodName, args);
} catch( NoSuchMethodException e ) {
throw new RuntimeException(
"Invalid function mapping - no such method: "
+ e.getMessage());
}
}
funcMapper.theMethod = method;
return funcMapper;
} | java | {
"resource": ""
} |
q177975 | ProtectedFunctionMapper.resolveFunction | test | public Method resolveFunction(String prefix, String localName) {
if (this.fnmap != null) {
return this.fnmap.get(prefix + ":" + localName);
}
return theMethod;
} | java | {
"resource": ""
} |
q177976 | XMLString.setValues | test | public void setValues(char[] ch, int offset, int length) {
this.ch = ch;
this.offset = offset;
this.length = length;
} | java | {
"resource": ""
} |
q177977 | VariableResolverImpl.resolveVariable | test | public Object resolveVariable (String pName)
throws javax.servlet.jsp.el.ELException {
ELContext elContext = pageContext.getELContext();
ELResolver elResolver = elContext.getELResolver();
try {
return elResolver.getValue(elContext, null, pName);
} catch (javax.el.ELException ex) {
throw new javax.servlet.jsp.el.ELException();
}
} | java | {
"resource": ""
} |
q177978 | ParserController.parse | test | public Node.Nodes parse(String inFileName)
throws FileNotFoundException, JasperException, IOException {
// If we're parsing a packaged tag file or a resource included by it
// (using an include directive), ctxt.getTagFileJar() returns the
// JAR file from which to read the tag file or included resource,
// respectively.
isTagFile = ctxt.isTagFile();
directiveOnly = false;
return doParse(inFileName, null, ctxt.getTagFileJarUrl());
} | java | {
"resource": ""
} |
q177979 | ParserController.parse | test | public Node.Nodes parse(String inFileName, Node parent,
URL jarFileUrl)
throws FileNotFoundException, JasperException, IOException {
// For files that are statically included, isTagfile and directiveOnly
// remain unchanged.
return doParse(inFileName, parent, jarFileUrl);
} | java | {
"resource": ""
} |
q177980 | ParserController.parseTagFileDirectives | test | public Node.Nodes parseTagFileDirectives(String inFileName)
throws FileNotFoundException, JasperException, IOException {
boolean isTagFileSave = isTagFile;
boolean directiveOnlySave = directiveOnly;
isTagFile = true;
directiveOnly = true;
Node.Nodes page = doParse(inFileName, null,
(URL) ctxt.getTagFileJarUrls().get(inFileName));
directiveOnly = directiveOnlySave;
isTagFile = isTagFileSave;
return page;
} | java | {
"resource": ""
} |
q177981 | ParserController.doParse | test | private Node.Nodes doParse(String inFileName,
Node parent,
URL jarFileUrl)
throws FileNotFoundException, JasperException, IOException {
Node.Nodes parsedPage = null;
isEncodingSpecifiedInProlog = false;
isDefaultPageEncoding = false;
hasBom = false;
JarFile jarFile = getJarFile(jarFileUrl);
String absFileName = resolveFileName(inFileName);
String jspConfigPageEnc = getJspConfigPageEncoding(absFileName);
// Figure out what type of JSP document and encoding type we are
// dealing with
determineSyntaxAndEncoding(absFileName, jarFile, jspConfigPageEnc);
if (parent != null) {
// Included resource, add to dependent list
compiler.getPageInfo().addDependant(absFileName);
}
comparePageEncodings(jspConfigPageEnc);
// Dispatch to the appropriate parser
if (isXml) {
// JSP document (XML syntax)
// InputStream for jspx page is created and properly closed in
// JspDocumentParser.
parsedPage = JspDocumentParser.parse(this, absFileName,
jarFile, parent,
isTagFile, directiveOnly,
sourceEnc,
jspConfigPageEnc,
isEncodingSpecifiedInProlog);
} else {
// Standard syntax
InputStreamReader inStreamReader = null;
try {
inStreamReader = JspUtil.getReader(absFileName, sourceEnc,
jarFile, ctxt, err);
JspReader jspReader = new JspReader(ctxt, absFileName,
sourceEnc, inStreamReader,
err);
parsedPage = Parser.parse(this, absFileName, jspReader, parent,
isTagFile, directiveOnly, jarFileUrl,
sourceEnc, jspConfigPageEnc,
isDefaultPageEncoding, hasBom);
} finally {
if (inStreamReader != null) {
try {
inStreamReader.close();
} catch (Exception any) {
}
}
}
}
if (jarFile != null) {
try {
jarFile.close();
} catch (Throwable t) {}
}
baseDirStack.pop();
return parsedPage;
} | java | {
"resource": ""
} |
q177982 | JspCompilationContext.createCompiler | test | public Compiler createCompiler(boolean jspcMode) throws JasperException {
if (jspCompiler != null ) {
return jspCompiler;
}
jspCompiler = new Compiler(this, jsw, jspcMode);
return jspCompiler;
} | java | {
"resource": ""
} |
q177983 | JspCompilationContext.getResourceAsStream | test | public java.io.InputStream getResourceAsStream(String res)
throws JasperException {
return context.getResourceAsStream(canonicalURI(res));
} | java | {
"resource": ""
} |
q177984 | OsgiSitemapGenerator.calcLastMod | test | private Optional<Instant> calcLastMod ()
{
Instant globalLastMod = null;
for ( final ChannelInformation ci : this.channelService.list () )
{
final Optional<Instant> lastMod = ofNullable ( ci.getState ().getModificationTimestamp () );
if ( globalLastMod == null || lastMod.get ().isAfter ( globalLastMod ) )
{
globalLastMod = lastMod.get ();
}
}
return Optional.ofNullable ( globalLastMod );
} | java | {
"resource": ""
} |
q177985 | JSPContextFinder.basicFindClassLoaders | test | ArrayList basicFindClassLoaders() {
Class[] stack = contextFinder.getClassContext();
ArrayList result = new ArrayList(1);
ClassLoader previousLoader = null;
for (int i = 1; i < stack.length; i++) {
ClassLoader tmp = stack[i].getClassLoader();
if (checkClass(stack[i]) && tmp != null && tmp != this) {
if (checkClassLoader(tmp)) {
if (previousLoader != tmp) {
result.add(tmp);
previousLoader = tmp;
}
}
// stop at the framework classloader or the first bundle classloader
if (Activator.getBundle(stack[i]) != null)
break;
}
}
return result;
} | java | {
"resource": ""
} |
q177986 | JSPContextFinder.checkClassLoader | test | private boolean checkClassLoader(ClassLoader classloader) {
if (classloader == null || classloader == getParent())
return false;
for (ClassLoader parent = classloader.getParent(); parent != null; parent = parent.getParent())
if (parent == this)
return false;
return true;
} | java | {
"resource": ""
} |
q177987 | JSPContextFinder.startLoading | test | private boolean startLoading(String name) {
Set classesAndResources = (Set) cycleDetector.get();
if (classesAndResources != null && classesAndResources.contains(name))
return false;
if (classesAndResources == null) {
classesAndResources = new HashSet(3);
cycleDetector.set(classesAndResources);
}
classesAndResources.add(name);
return true;
} | java | {
"resource": ""
} |
q177988 | SingleXZInputStream.readStreamHeader | test | private static byte[] readStreamHeader(InputStream in) throws IOException {
byte[] streamHeader = new byte[DecoderUtil.STREAM_HEADER_SIZE];
new DataInputStream(in).readFully(streamHeader);
return streamHeader;
} | java | {
"resource": ""
} |
q177989 | Pagination.paginate | test | public static <T> PaginationResult<T> paginate ( final Integer startPage, final int pageSize, final List<T> fullDataSet )
{
return paginate ( startPage, pageSize, ( start, length ) -> {
final int len = fullDataSet.size ();
if ( start > len )
{
return Collections.emptyList ();
}
return fullDataSet.subList ( start, Math.min ( start + length, len ) );
} );
} | java | {
"resource": ""
} |
q177990 | MetaKey.fromString | test | public static MetaKey fromString ( final String string )
{
final int idx = string.indexOf ( ':' );
if ( idx < 1 )
{
// -1: none at all, 0: empty namespace
return null;
}
if ( idx + 1 >= string.length () )
{
// empty key segment
return null;
}
return new MetaKey ( string.substring ( 0, idx ), string.substring ( idx + 1 ), true );
} | java | {
"resource": ""
} |
q177991 | RpmBuilder.fillRequirements | test | private void fillRequirements () throws IOException
{
this.requirements.add ( new Dependency ( "rpmlib(CompressedFileNames)", "3.0.4-1", RpmDependencyFlags.LESS, RpmDependencyFlags.EQUAL, RpmDependencyFlags.RPMLIB ) );
if ( !this.options.getFileDigestAlgorithm ().equals ( DigestAlgorithm.MD5 ) )
{
this.requirements.add ( new Dependency ( "rpmlib(FileDigests)", "4.6.0-1", RpmDependencyFlags.LESS, RpmDependencyFlags.EQUAL, RpmDependencyFlags.RPMLIB ) );
}
this.requirements.add ( new Dependency ( "rpmlib(PayloadFilesHavePrefix)", "4.0-1", RpmDependencyFlags.LESS, RpmDependencyFlags.EQUAL, RpmDependencyFlags.RPMLIB ) );
this.options.getPayloadCoding ().createProvider ().fillRequirements ( this.requirements::add );
} | java | {
"resource": ""
} |
q177992 | ImplicitTagLibraryInfo.getTagFile | test | public TagFileInfo getTagFile(String shortName) {
TagFileInfo tagFile = super.getTagFile(shortName);
if (tagFile == null) {
String path = tagFileMap.get(shortName);
if (path == null) {
return null;
}
TagInfo tagInfo = null;
try {
tagInfo = TagFileProcessor.parseTagFileDirectives(pc,
shortName,
path,
this);
} catch (JasperException je) {
throw new RuntimeException(je.toString());
}
tagFile = new TagFileInfo(shortName, path, tagInfo);
vec.add(tagFile);
this.tagFiles = vec.toArray(new TagFileInfo[vec.size()]);
}
return tagFile;
} | java | {
"resource": ""
} |
q177993 | ImplicitTagLibraryInfo.parseImplicitTld | test | private void parseImplicitTld(JspCompilationContext ctxt, String path)
throws JasperException {
InputStream is = null;
TreeNode tld = null;
try {
URL uri = ctxt.getResource(path);
if (uri == null) {
// no implicit.tld
return;
}
is = uri.openStream();
/* SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(IMPLICIT_TLD, is);
*/
// START SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(
IMPLICIT_TLD, is, ctxt.getOptions().isValidationEnabled());
// END SJSAS 6384538
} catch (Exception ex) {
throw new JasperException(ex);
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
this.jspversion = tld.findAttribute("version");
Iterator list = tld.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
String tname = element.getName();
if ("tlibversion".equals(tname)
|| "tlib-version".equals(tname)) {
this.tlibversion = element.getBody();
} else if ("jspversion".equals(tname)
|| "jsp-version".equals(tname)) {
this.jspversion = element.getBody();
} else if (!"shortname".equals(tname)
&& !"short-name".equals(tname)) {
err.jspError("jsp.error.implicitTld.additionalElements",
path, tname);
}
}
// JSP version in implicit.tld must be 2.0 or greater
Double jspVersionDouble = Double.valueOf(this.jspversion);
if (Double.compare(jspVersionDouble, Constants.JSP_VERSION_2_0) < 0) {
err.jspError("jsp.error.implicitTld.jspVersion", path,
this.jspversion);
}
} | java | {
"resource": ""
} |
q177994 | OutputSpooler.getChecksum | test | public String getChecksum ( final String fileName, final String algorithm )
{
if ( !this.digests.contains ( algorithm ) )
{
return null;
}
final String result = this.checksums.get ( fileName + ":" + algorithm );
if ( result == null )
{
throw new IllegalStateException ( String.format ( "Stream '%s' not closed.", fileName ) );
}
return result;
} | java | {
"resource": ""
} |
q177995 | OutputSpooler.getSize | test | public long getSize ( final String fileName )
{
final Long result = this.sizes.get ( fileName );
if ( result == null )
{
throw new IllegalStateException ( String.format ( "Stream '%s' not closed or was not added", fileName ) );
}
return result;
} | java | {
"resource": ""
} |
q177996 | ChannelController.validateChannelName | test | private static void validateChannelName ( final String name, final ValidationContext ctx )
{
if ( name == null || name.isEmpty () )
{
return;
}
final Matcher m = ChannelService.NAME_PATTERN.matcher ( name );
if ( !m.matches () )
{
ctx.error ( "names", String.format ( "The channel name '%s' must match the pattern '%s'", name, ChannelService.NAME_PATTERN.pattern () ) );
}
} | java | {
"resource": ""
} |
q177997 | SeekableXZInputStream.seekToBlock | test | public void seekToBlock(int blockNumber) throws IOException {
if (in == null)
throw new XZIOException("Stream closed");
if (blockNumber < 0 || blockNumber >= blockCount)
throw new XZIOException("Invalid XZ Block number: " + blockNumber);
// This is a bit silly implementation. Here we locate the uncompressed
// offset of the specified Block, then when doing the actual seek in
// seek(), we need to find the Block number based on seekPos.
seekPos = getBlockPos(blockNumber);
seekNeeded = true;
} | java | {
"resource": ""
} |
q177998 | SeekableXZInputStream.locateBlockByPos | test | private void locateBlockByPos(BlockInfo info, long pos) {
if (pos < 0 || pos >= uncompressedSize)
throw new IndexOutOfBoundsException(
"Invalid uncompressed position: " + pos);
// Locate the Stream that contains the target position.
IndexDecoder index;
for (int i = 0; ; ++i) {
index = streams.get(i);
if (index.hasUncompressedOffset(pos))
break;
}
// Locate the Block from the Stream that contains the target position.
index.locateBlock(info, pos);
assert (info.compressedOffset & 3) == 0;
assert info.uncompressedSize > 0;
assert pos >= info.uncompressedOffset;
assert pos < info.uncompressedOffset + info.uncompressedSize;
} | java | {
"resource": ""
} |
q177999 | UnzipServlet.getMavenArtifacts | test | protected static List<MavenVersionedArtifact> getMavenArtifacts ( final String channelId, final Supplier<Collection<ArtifactInformation>> artifactsSupplier, final String groupId, final String artifactId, final boolean snapshot, final Predicate<ComparableVersion> versionFilter )
{
final List<MavenVersionedArtifact> arts = new ArrayList<> ();
for ( final ArtifactInformation ai : artifactsSupplier.get () )
{
if ( !isZip ( ai ) )
{
// if is is anot a zip, then this is not for the unzip plugin
continue;
}
// fetch meta data
final String mvnGroupId = ai.getMetaData ().get ( MK_GROUP_ID );
final String mvnArtifactId = ai.getMetaData ().get ( MK_ARTIFACT_ID );
final String classifier = ai.getMetaData ().get ( MK_CLASSIFIER );
final String mvnVersion = ai.getMetaData ().get ( MK_VERSION );
final String mvnSnapshotVersion = ai.getMetaData ().get ( MK_SNAPSHOT_VERSION );
if ( mvnGroupId == null || mvnArtifactId == null || mvnVersion == null )
{
// no GAV information
continue;
}
if ( classifier != null && !classifier.isEmpty () )
{
// no classifiers right now
continue;
}
if ( !mvnGroupId.equals ( groupId ) || !mvnArtifactId.equals ( artifactId ) )
{
// wrong group or artifact id
continue;
}
if ( !snapshot && ( mvnSnapshotVersion != null || mvnVersion.endsWith ( "-SNAPSHOT" ) ) )
{
// we are not looking for snapshots
continue;
}
final ComparableVersion v = parseVersion ( mvnVersion );
final ComparableVersion sv = parseVersion ( mvnSnapshotVersion );
if ( v == null )
{
// unable to parse v
continue;
}
if ( versionFilter == null )
{
// no filter, add it
arts.add ( new MavenVersionedArtifact ( sv != null ? sv : v, channelId, ai ) );
}
else if ( versionFilter.test ( v ) )
{
// filter matched, add it
arts.add ( new MavenVersionedArtifact ( sv != null ? sv : v, channelId, ai ) );
}
else if ( sv != null && versionFilter.test ( sv ) )
{
// we have a snapshot version and it matched, add it
arts.add ( new MavenVersionedArtifact ( sv, channelId, ai ) );
}
}
return arts;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.