_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q180000 | StateMachineParser.toJSON | test | protected String toJSON() {
ObjectMapper mapper = new ObjectMapper();
try {
String jsonINString = mapper.writeValueAsString(notationContainer);
jsonINString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(notationContainer);
return jsonINString;
} catch (Exception e)... | java | {
"resource": ""
} |
q180001 | HELM2Notation.getSimplePolymer | test | public PolymerNotation getSimplePolymer(String string) {
for (PolymerNotation polymer : listOfPolymers) {
if (polymer.getPolymerID().getId().equals(string)) {
return polymer;
}
}
return null;
} | java | {
"resource": ""
} |
q180002 | HELM2Notation.getCurrentGroupingNotation | test | @JsonIgnore
public GroupingNotation getCurrentGroupingNotation() {
if (listOfGroupings.size() == 0) {
return null;
}
return listOfGroupings.get(listOfGroupings.size() - 1);
} | java | {
"resource": ""
} |
q180003 | HELM2Notation.toHELM2 | test | public String toHELM2() {
String output = "";
/* first section: simple polymer section */
output += polymerToHELM2() + "$";
/* second section: connection section */
output += connectionToHELM2() + "$";
/* third section: grouping section */
output += groupingToHELM2() + "$";
... | java | {
"resource": ""
} |
q180004 | HELM2Notation.polymerToHELM2 | test | public String polymerToHELM2() {
StringBuilder notation = new StringBuilder();
for (int i = 0; i < listOfPolymers.size(); i++) {
if (listOfPolymers.get(i).isAnnotationHere()) {
notation.append(listOfPolymers.get(i).getPolymerID() + "{" + listOfPolymers.get(i).toHELM2() + "}\""
+ l... | java | {
"resource": ""
} |
q180005 | HELM2Notation.connectionToHELM2 | test | public String connectionToHELM2() {
if (listOfConnections.size() == 0) {
return "";
}
StringBuilder notation = new StringBuilder();
for (int i = 0; i < listOfConnections.size(); i++) {
notation.append(listOfConnections.get(i).toHELM2() + "|");
}
notation.setLength(notation.... | java | {
"resource": ""
} |
q180006 | HELM2Notation.groupingToHELM2 | test | public String groupingToHELM2() {
if (listOfGroupings.size() == 0) {
return "";
}
StringBuilder notation = new StringBuilder();
for (int i = 0; i < listOfGroupings.size(); i++) {
notation.append(listOfGroupings.get(i).toHELM2() + "|");
}
notation.setLength(notation.length()... | java | {
"resource": ""
} |
q180007 | HELM2Notation.annotationToHELM2 | test | public String annotationToHELM2() {
if (!(annotationSection.isEmpty())) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < annotationSection.size(); i++) {
sb.append(annotationSection.get(i).toHELM2() + "|");
}
sb.setLength(sb.length() - 1);
return sb.toStri... | java | {
"resource": ""
} |
q180008 | HELM2Notation.getPolymerAndGroupingIDs | test | @JsonIgnore
public List<String> getPolymerAndGroupingIDs() {
List<String> listOfIDs = new ArrayList<String>();
for (PolymerNotation polymer : listOfPolymers) {
listOfIDs.add(polymer.getPolymerID().getId());
}
for (GroupingNotation grouping : listOfGroupings) {
listOfIDs.add(groupi... | java | {
"resource": ""
} |
q180009 | HELM2Notation.getPolymerNotation | test | @JsonIgnore
public PolymerNotation getPolymerNotation(String id) {
for (PolymerNotation polymer : listOfPolymers) {
if (polymer.getPolymerID().getId().equals(id)) {
return polymer;
}
}
return null;
} | java | {
"resource": ""
} |
q180010 | PolymerNotation.setPolymerElements | test | private void setPolymerElements() {
if (polymerID instanceof RNAEntity || polymerID instanceof PeptideEntity) {
this.polymerElements = new PolymerListElements(polymerID);
} else {
this.polymerElements = new PolymerSingleElements(polymerID);
}
} | java | {
"resource": ""
} |
q180011 | ConverterHELM1ToHELM2.doConvert | test | public String doConvert(String str) {
//check for just missing V2.0
ParserHELM2 parser = new ParserHELM2();
try{
parser.parse(str + "V2.0");
return str + "V2.0";
}
catch(Exception e){
/* Use String Builder */
/* simple add character -> split works then */
String helm1... | java | {
"resource": ""
} |
q180012 | MonomerNotation.setAnnotation | test | public void setAnnotation(String str) {
if (str != null) {
annotation = str;
isAnnotationHere = true;
} else {
annotation = null;
isAnnotationHere = false;
}
} | java | {
"resource": ""
} |
q180013 | MonomerNotation.setCount | test | public void setCount(String str) {
isDefault = false;
if (str.equals("1")) {
isDefault = true;
}
count = str;
} | java | {
"resource": ""
} |
q180014 | ValidationMethod.decideWhichMonomerNotation | test | public static MonomerNotation decideWhichMonomerNotation(String str, String type)
throws NotationException {
MonomerNotation mon;
/* group ? */
if (str.startsWith("(") && str.endsWith(")")) {
String str2 = str.substring(1, str.length() - 1);
Pattern patternAND = Pattern.compile("\\+");
Patter... | java | {
"resource": ""
} |
q180015 | ValidationMethod.decideWhichMonomerNotationInGroup | test | public static MonomerNotationGroupElement decideWhichMonomerNotationInGroup(String str, String type, double one,
double two, boolean interval, boolean isDefault) throws NotationException{
MonomerNotation element;
element = decideWhichMonomerNotation(str, type);
if (interval) {
return new MonomerNot... | java | {
"resource": ""
} |
q180016 | ValidationMethod.decideWhichEntity | test | public static HELMEntity decideWhichEntity(String str) throws NotationException {
HELMEntity item;
if (str.toUpperCase().matches("PEPTIDE[1-9][0-9]*")) {
item = new PeptideEntity(str.toUpperCase());
} else if (str.toUpperCase().matches("RNA[1-9][0-9]*")) {
item = new RNAEntity(str.toUpperCase());
... | java | {
"resource": ""
} |
q180017 | MonomerNotationGroupElement.getValue | test | public List<Double> getValue() {
if (this.isInterval) {
return new ArrayList<Double>(Arrays.asList(numberOne, numberTwo));
} else {
return new ArrayList<Double>(Arrays.asList(numberOne));
}
} | java | {
"resource": ""
} |
q180018 | ParserHELM2.parse | test | public void parse(String test) throws ExceptionState {
parser = new StateMachineParser();
test = test.trim();
if (test.substring(test.length() - 4).matches("V2\\.0") || test.substring(test.length() - 4).matches("v2\\.0")) {
for (int i = 0; i < test.length() - 4; i++) {
parser.doAction... | java | {
"resource": ""
} |
q180019 | MonomerNotationUnitRNA.setRNAContents | test | private void setRNAContents(String str) throws NotationException {
/* Nucleotide with all contents */
String[] list;
// if (str.contains("(")) {
List<String> items = extractContents(str);
for (String item : items) {
if(item.length()> 1){
if(!(item.startsWith("[") && item.endsWith... | java | {
"resource": ""
} |
q180020 | GroupingNotation.defineAmbiguity | test | private void defineAmbiguity(String a) throws NotationException {
Pattern patternAND = Pattern.compile("\\+");
Matcher m = patternAND.matcher(a);
/* mixture */
if (m.find()) {
setAmbiguity(new GroupingMixture(a));
} /* or case */ else {
setAmbiguity(new GroupingOr(a));
}
... | java | {
"resource": ""
} |
q180021 | WorkerThread.getStatistics | test | AWorkerThreadStatistics getStatistics() {
return new AWorkerThreadStatistics (getState (), getId (),
stat_numTasksExecuted, stat_numSharedTasksExecuted, stat_numSteals, stat_numExceptions, stat_numParks, stat_numFalseAlarmUnparks, stat_numSharedQueueSwitches, stat_numLocalSubmits, localQueue.app... | java | {
"resource": ""
} |
q180022 | ADiGraph.create | test | public static <N, E extends AEdge<N>> ADiGraph<N,E> create (Collection<E> edges) {
final Set<N> result = new HashSet<> ();
for (E edge: edges) {
result.add (edge.getFrom ());
result.add (edge.getTo ());
}
return create (result, edges);
} | java | {
"resource": ""
} |
q180023 | ADiGraph.create | test | public static <N, E extends AEdge<N>> ADiGraph<N,E> create (Collection<N> nodes, Collection<E> edges) {
final Object[] nodeArr = new Object[nodes.size ()];
final AEdge[] edgeArr = new AEdge[edges.size ()];
int idx = 0;
for (N node: nodes) {
nodeArr[idx] = node;
i... | java | {
"resource": ""
} |
q180024 | ADiGraph.initPathsInternal | test | private void initPathsInternal() {
synchronized (LOCK) {
if (_incomingPathsInternal == null) {
AMap<N, AList<AEdgePath<N, E>>> incomingPaths = AHashMap.empty ();
//noinspection unchecked
incomingPaths = incomingPaths.withDefaultValue (AList.nil);
... | java | {
"resource": ""
} |
q180025 | ADiGraph.sortedNodesByReachability | test | public List<N> sortedNodesByReachability() throws AGraphCircularityException {
if (hasCycles()) {
throw new AGraphCircularityException ();
}
final Object[] result = new Object[nodes.length];
int nextIdx = 0;
final Set<N> unprocessed = new HashSet<> ();
for (... | java | {
"resource": ""
} |
q180026 | API.subscribe | test | public void subscribe(final String pattern,
final Class<?> clazz,
final String methodName)
throws NoSuchMethodException
{
this.subscribe(pattern, new FunctionObject9(this, clazz, methodName));
} | java | {
"resource": ""
} |
q180027 | API.subscribe_count | test | public int subscribe_count(final String pattern)
throws InvalidInputException,
TerminateException
{
OtpOutputStream subscribe_count = new OtpOutputStream();
subscribe_count.write(OtpExternal.versionTag);
final OtpErlangObject[] tuple = {new OtpErlangAtom("subscribe_cou... | java | {
"resource": ""
} |
q180028 | API.unsubscribe | test | public void unsubscribe(final String pattern)
throws InvalidInputException
{
final String s = this.prefix + pattern;
LinkedList<FunctionInterface9> callback_list = this.callbacks.get(s);
if (callback_list == null)
{
throw new InvalidInputException();
}
... | java | {
"resource": ""
} |
q180029 | API.return_ | test | public void return_(final Integer request_type,
final String name,
final String pattern,
final byte[] response_info,
final byte[] response,
final Integer timeout,
final byte[] ... | java | {
"resource": ""
} |
q180030 | API.return_sync | test | public void return_sync(final String name,
final String pattern,
byte[] response_info,
byte[] response,
Integer timeout,
final byte[] trans_id,
final Ot... | java | {
"resource": ""
} |
q180031 | API.poll | test | public boolean poll(final int timeout)
throws InvalidInputException,
MessageDecodingException,
TerminateException
{
if (Boolean.TRUE == poll_request(timeout, true))
return true;
return false;
} | java | {
"resource": ""
} |
q180032 | API.shutdown | test | public void shutdown(final String reason)
{
OtpOutputStream shutdown = new OtpOutputStream();
shutdown.write(OtpExternal.versionTag);
final OtpErlangObject[] tuple = {new OtpErlangAtom("shutdown"),
new OtpErlangString(reason)};
shutdown.write_... | java | {
"resource": ""
} |
q180033 | AExceptionFilter.forLocalHandling | test | public static <T extends Throwable> T forLocalHandling (T th) {
if (requiresNonLocalHandling (th)) {
AUnchecker.throwUnchecked (th);
}
return th;
} | java | {
"resource": ""
} |
q180034 | ForkJoinPool.unlockRunState | test | private void unlockRunState(int oldRunState, int newRunState) {
if (!U.compareAndSwapInt(this, RUNSTATE, oldRunState, newRunState)) {
Object lock = stealCounter;
runState = newRunState; // clears RSIGNAL bit
if (lock != null)
synchronized (lock) {... | java | {
"resource": ""
} |
q180035 | ForkJoinPool.createWorker | test | private boolean createWorker() {
ForkJoinWorkerThreadFactory fac = factory;
Throwable ex = null;
ForkJoinWorkerThread wt = null;
try {
if (fac != null && (wt = fac.newThread(this)) != null) {
wt.start();
return true;
}
} cat... | java | {
"resource": ""
} |
q180036 | ForkJoinPool.tryAddWorker | test | private void tryAddWorker(long c) {
boolean add = false;
do {
long nc = ((AC_MASK & (c + AC_UNIT)) |
(TC_MASK & (c + TC_UNIT)));
if (ctl == c) {
int rs, stop; // check if terminating
if ((stop = (rs = lockRunS... | java | {
"resource": ""
} |
q180037 | ForkJoinPool.registerWorker | test | final WorkQueue registerWorker(ForkJoinWorkerThread wt) {
UncaughtExceptionHandler handler;
wt.setDaemon(true); // configure thread
if ((handler = ueh) != null)
wt.setUncaughtExceptionHandler(handler);
WorkQueue w = new WorkQueue(this, wt);
i... | java | {
"resource": ""
} |
q180038 | ForkJoinPool.deregisterWorker | test | final void deregisterWorker(ForkJoinWorkerThread wt, Throwable ex) {
WorkQueue w = null;
if (wt != null && (w = wt.workQueue) != null) {
WorkQueue[] ws; // remove index from array
int idx = w.config & SMASK;
int rs = lockRunState();
... | java | {
"resource": ""
} |
q180039 | ForkJoinPool.signalWork | test | final void signalWork(WorkQueue[] ws, WorkQueue q) {
long c; int sp, i; WorkQueue v; Thread p;
while ((c = ctl) < 0L) { // too few active
if ((sp = (int)c) == 0) { // no idle workers
if ((c & ADD_WORKER) != 0L) // too few work... | java | {
"resource": ""
} |
q180040 | ForkJoinPool.runWorker | test | final void runWorker(WorkQueue w) {
w.growArray(); // allocate queue
int seed = w.hint; // initially holds randomization hint
int r = (seed == 0) ? 1 : seed; // avoid 0 for xorShift
for (ForkJoinTask<?> t;;) {
if ((t = scan(w, r)) != null)
... | java | {
"resource": ""
} |
q180041 | ForkJoinPool.awaitWork | test | private boolean awaitWork(WorkQueue w, int r) {
if (w == null || w.qlock < 0) // w is terminating
return false;
for (int pred = w.stackPred, spins = SPINS, ss;;) {
if ((ss = w.scanState) >= 0)
break;
else if (spins > 0) {
... | java | {
"resource": ""
} |
q180042 | ForkJoinPool.getSurplusQueuedTaskCount | test | static int getSurplusQueuedTaskCount() {
Thread t; ForkJoinWorkerThread wt; ForkJoinPool pool; WorkQueue q;
if (((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)) {
int p = (pool = (wt = (ForkJoinWorkerThread)t).pool).
config & SMASK;
int n = (q = wt.... | java | {
"resource": ""
} |
q180043 | ForkJoinPool.commonSubmitterQueue | test | static WorkQueue commonSubmitterQueue() {
ForkJoinPool p = common;
int r = ThreadLocalRandomHelper.getProbe();
WorkQueue[] ws; int m;
return (p != null && (ws = p.workQueues) != null &&
(m = ws.length - 1) >= 0) ?
ws[m & r & SQMASK] : null;
} | java | {
"resource": ""
} |
q180044 | ForkJoinPool.externalHelpComplete | test | final int externalHelpComplete(CountedCompleter<?> task, int maxTasks) {
WorkQueue[] ws; int n;
int r = ThreadLocalRandomHelper.getProbe();
return ((ws = workQueues) == null || (n = ws.length) == 0) ? 0 :
helpComplete(ws[(n - 1) & r & SQMASK], task, maxTasks);
} | java | {
"resource": ""
} |
q180045 | ForkJoinPool.submit | test | public <T> ForkJoinTask<T> submit(ForkJoinTask<T> task) {
if (task == null)
throw new NullPointerException();
externalPush(task);
return task;
} | java | {
"resource": ""
} |
q180046 | ForkJoinPool.makeCommonPool | test | private static ForkJoinPool makeCommonPool() {
int parallelism = -1;
ForkJoinWorkerThreadFactory factory = null;
UncaughtExceptionHandler handler = null;
try { // ignore exceptions in accessing/parsing properties
String pp = System.getProperty
("java.util.con... | java | {
"resource": ""
} |
q180047 | ForkJoinTask.get | test | public final V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
int s;
long nanos = unit.toNanos(timeout);
if (Thread.interrupted())
throw new InterruptedException();
if ((s = status) >= 0 && nanos > 0L) {
... | java | {
"resource": ""
} |
q180048 | AJsonSerHelper.buildString | test | public static <E extends Throwable> String buildString (AStatement1<AJsonSerHelper, E> code) throws E {
final ByteArrayOutputStream baos = new ByteArrayOutputStream ();
code.apply (new AJsonSerHelper (baos));
return new String (baos.toByteArray (), UTF_8);
} | java | {
"resource": ""
} |
q180049 | AThreadPoolImpl.getStatistics | test | @Override public AThreadPoolStatistics getStatistics() {
final AWorkerThreadStatistics[] workerStats = new AWorkerThreadStatistics[localQueues.length];
for (int i=0; i<localQueues.length; i++) {
//noinspection ConstantConditions
workerStats[i] = localQueues[i].thread.getStatistic... | java | {
"resource": ""
} |
q180050 | AList.create | test | @SafeVarargs
public static <T> AList<T> create(T... elements) {
return create(Arrays.asList(elements));
} | java | {
"resource": ""
} |
q180051 | AList.reverse | test | public AList<T> reverse() {
AList<T> remaining = this;
AList<T> result = nil();
while(! remaining.isEmpty()) {
result = result.cons(remaining.head());
remaining = remaining.tail();
}
return result;
} | java | {
"resource": ""
} |
q180052 | ACollectionHelper.forAll | test | public static <T, E extends Throwable> boolean forAll(Iterable<T> coll, APredicate<? super T, E> pred) throws E {
for(T o: coll) {
if(!pred.apply(o)) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q180053 | ACollectionHelper.foldLeft | test | public static <T, R, E extends Throwable> R foldLeft (Iterable<T> coll, R startValue, AFunction2<R, ? super T, R, E> f) throws E {
R result = startValue;
for (T e: coll) {
result = f.apply (result, e);
}
return result;
} | java | {
"resource": ""
} |
q180054 | ACollectionHelper.foldRight | test | public static <T, R, E extends Throwable> R foldRight (List<T> coll, R startValue, AFunction2<R, ? super T, R, E> f) throws E {
R result = startValue;
ListIterator<T> i = coll.listIterator(coll.size());
while ( i.hasPrevious() ) {
result = f.apply (result, i.previous());
}
... | java | {
"resource": ""
} |
q180055 | LocalQueue.push | test | void push (Runnable task) {
final long _base = UNSAFE.getLongVolatile (this, OFFS_BASE); // read base first (and only once)
final long _top = top;
if (_top == _base + mask) {
throw new RejectedExecutionExceptionWithoutStacktrace ("local queue overflow");
}
tasks[asAr... | java | {
"resource": ""
} |
q180056 | AOption.fromNullable | test | public static <T> AOption<T> fromNullable(T nullable) {
return nullable != null ? some(nullable) : AOption.<T>none();
} | java | {
"resource": ""
} |
q180057 | ALongHashMap.fromKeysAndValues | test | public static <V> ALongHashMap<V> fromKeysAndValues(Iterable<? extends Number> keys, Iterable<V> values) {
final Iterator<? extends Number> ki = keys.iterator();
final Iterator<V> vi = values.iterator();
ALongHashMap<V> result = ALongHashMap.empty ();
while(ki.hasNext()) {
... | java | {
"resource": ""
} |
q180058 | AListMap.empty | test | @SuppressWarnings("unchecked")
public static <K,V> AListMap<K,V> empty(AEquality equality) {
if(equality == AEquality.EQUALS) return (AListMap<K, V>) emptyEquals;
if(equality == AEquality.IDENTITY) return (AListMap<K, V>) emptyIdentity;
return new AListMap<> (equality);
} | java | {
"resource": ""
} |
q180059 | AListMap.fromKeysAndValues | test | public static <K,V> AListMap<K,V> fromKeysAndValues(AEquality equality, Iterable<ATuple2<K,V>> elements) {
AListMap<K,V> result = empty(equality);
for(ATuple2<K,V> el: elements) {
result = result.updated(el._1, el._2);
}
return result;
} | java | {
"resource": ""
} |
q180060 | AListMap.fromKeysAndValues | test | public static <K,V> AListMap<K,V> fromKeysAndValues(AEquality equality, Iterable<K> keys, Iterable<V> values) {
final Iterator<K> ki = keys.iterator();
final Iterator<V> vi = values.iterator();
AListMap<K,V> result = empty (equality);
while(ki.hasNext()) {
final K key = ki.... | java | {
"resource": ""
} |
q180061 | JavaUtilMapWrapper.keySet | test | @Override
public Set<K> keySet() {
return new AbstractSet<K>() {
@Override
public Iterator<K> iterator() {
return new Iterator<K>() {
final Iterator<AMapEntry<K,V>> it = inner.iterator();
@Override
public bo... | java | {
"resource": ""
} |
q180062 | UriLoader.normalizeResourceName | test | private String normalizeResourceName(String name) {
if (name.startsWith("//")) {
return "classpath:" + name;
}
final int firstProtocol = name.indexOf("://");
final int secondProtocol = name.indexOf("://", firstProtocol + 1);
final int protocol = secondProtocol < 0 ? f... | java | {
"resource": ""
} |
q180063 | ValueTypeXmlAdapter.marshal | test | @Override
public String marshal(BoundType v) throws Exception {
Class<? extends Object> type = v.getClass();
if (!Types.isUserDefinedValueType(type)) {
throw new IllegalArgumentException("Type [" + type
+ "] must be an user-defined value type; "
+ "@XmlJavaTypeAdapter(ValueTypeXmlAdapter.class) "
... | java | {
"resource": ""
} |
q180064 | FastCharBuffer.subSequence | test | public CharSequence subSequence(int start, int end) {
int len = end - start;
return new StringBuilder(len).append(toArray(start, len));
} | java | {
"resource": ""
} |
q180065 | BinarySearch.forList | test | public static <T extends Comparable> BinarySearch<T> forList(final List<T> list) {
return new BinarySearch<T>() {
@Override
@SuppressWarnings({"unchecked"})
protected int compare(int index, T element) {
return list.get(index).compareTo(element);
}
... | java | {
"resource": ""
} |
q180066 | BinarySearch.forList | test | public static <T> BinarySearch<T> forList(final List<T> list, final Comparator<T> comparator) {
return new BinarySearch<T>() {
@Override
@SuppressWarnings({"unchecked"})
protected int compare(int index, T element) {
return comparator.compare(list.get(index), e... | java | {
"resource": ""
} |
q180067 | EMail.send | test | public static Future<Boolean> send(Email email) {
try {
email = buildMessage(email);
if (GojaConfig.getProperty("mail.smtp", StringPool.EMPTY).equals("mock")
&& GojaConfig.getApplicationMode().isDev()) {
Mock.send(email);
return new Fu... | java | {
"resource": ""
} |
q180068 | EMail.sendMessage | test | public static Future<Boolean> sendMessage(final Email msg) {
if (asynchronousSend) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
try {
msg.setSentDate(new Date());
msg.send();
... | java | {
"resource": ""
} |
q180069 | ApplicationRouter.bind | test | public void bind( final RouteBinding handler )
{
final Method method = handler.getMethod();
logger.info( "Using appId: {} and default version: {}", appAcceptId, defaultVersion );
List<String> versions = handler.getVersions();
if ( versions == null || versions.isEmpty() )
{
... | java | {
"resource": ""
} |
q180070 | ApplicationRouter.bind | test | public void bind( final FilterBinding handler )
{
final Method method = handler.getMethod();
final String path = handler.getPath();
logger.info( "Using appId: {} and default version: {}", appAcceptId, defaultVersion );
List<String> versions = handler.getVersions();
if ( vers... | java | {
"resource": ""
} |
q180071 | HasAnyRolesTag.showTagBody | test | @Override
protected boolean showTagBody(String roleName) {
boolean hasAnyRole = false;
Subject subject = getSubject();
if (subject != null) {
// Iterate through roles and check to see if the user has one of the roles
for (String role : roleName.split(StringPool.COMMA... | java | {
"resource": ""
} |
q180072 | DataKit.getInt | test | public static int getInt(Long l) {
return (l == null || l > Integer.MAX_VALUE) ? 0 : l.intValue();
} | java | {
"resource": ""
} |
q180073 | Strs.removeDuplicateStrings | test | public static String[] removeDuplicateStrings(String[] array) {
if (ObjectKit.isEmpty(array)) {
return array;
}
Set<String> set = new TreeSet<String>();
for (String element : array) {
set.add(element);
}
return toStringArray(set);
} | java | {
"resource": ""
} |
q180074 | Strs.like | test | public static String like(String value) {
return StringPool.PERCENT + Strings.nullToEmpty(value) + StringPool.PERCENT;
} | java | {
"resource": ""
} |
q180075 | PeriodicService.doRun | test | public void doRun() throws Exception {
if (inProgress.compareAndSet(false,true)) {
try {
run();
} finally {
inProgress.set(false);
}
} else {
throw new IllegalStateException("Another run is already in progress");
}
... | java | {
"resource": ""
} |
q180076 | SecurityKit.login | test | public static <T extends Model> boolean login(T user, String password, boolean remember
, HttpServletRequest request, HttpServletResponse response) {
boolean matcher =
SecurityKit.checkPassword(user.getStr("salt"), user.getStr("password"), password);
if (matcher) {
... | java | {
"resource": ""
} |
q180077 | SecurityKit.getLoginWithDb | test | public static <T extends Model> T getLoginWithDb(HttpServletRequest req
, HttpServletResponse response
, Function<Long, T> function) {
T loginUser = getLoginUser(req);
if (loginUser == null) {
//从Cookie中解析出用户id
CookieUser cookie_user = getUserFromCookie(re... | java | {
"resource": ""
} |
q180078 | SecurityKit.getLoginUser | test | public static <T extends Model> T getLoginUser(HttpServletRequest req) {
return (T) req.getSession().getAttribute(LOGIN_SESSION_KEY);
} | java | {
"resource": ""
} |
q180079 | SecurityKit.checkPassword | test | public static boolean checkPassword(String salt, String password, String plainPassword) {
byte[] saltHex = EncodeKit.decodeHex(salt);
byte[] hashPassword =
DigestsKit.sha1(plainPassword.getBytes(), saltHex, EncodeKit.HASH_INTERATIONS);
return StringUtils.equals(EncodeKit.encodeHe... | java | {
"resource": ""
} |
q180080 | SecurityKit.saveMemberInCookie | test | public static <T extends Model> void saveMemberInCookie(T user, boolean save,
HttpServletRequest request, HttpServletResponse response) {
String new_value =
getLoginKey(user, Requests.remoteIP(request), request.getHeader("user-agent"));... | java | {
"resource": ""
} |
q180081 | SecurityKit.getLoginKey | test | private static <T extends Model> String getLoginKey(T user, String ip, String user_agent) {
return encrypt(String.valueOf(user.getNumber(StringPool.PK_COLUMN)) + '|'
+ user.getStr("password") + '|' + ip + '|' + ((user_agent == null) ? 0
: user_agent.hashCode()) + '|' + System.cur... | java | {
"resource": ""
} |
q180082 | SecurityKit.userForCookie | test | private static CookieUser userForCookie(String uuid, HttpServletRequest request) {
if (StringUtils.isBlank(uuid)) {
return null;
}
String ck = decrypt(uuid);
final String[] items = StringUtils.split(ck, '|');
if (items.length == 5) {
String ua = request.ge... | java | {
"resource": ""
} |
q180083 | Forward.to | test | public void to(WebContext context) {
HttpServletRequest request = context.request();
HttpServletResponse response = context.response();
try {
request.getRequestDispatcher(path).forward(request, response);
} catch (ServletException e) {
throw new UncheckedException(e);
} catch (IOException e) {
thr... | java | {
"resource": ""
} |
q180084 | FileRenamePolicyWrapper.appendFileSeparator | test | public String appendFileSeparator(String path) {
if (null == path) {
return File.separator;
}
// add "/" prefix
if (!path.startsWith(StringPool.SLASH) && !path.startsWith(StringPool.BACK_SLASH)) {
path = File.separator + path;
}
// add "/" postfix... | java | {
"resource": ""
} |
q180085 | Requests.param | test | public static long param(HttpServletRequest request, String param, long defaultValue) {
return NumberUtils.toLong(request.getParameter(param), defaultValue);
} | java | {
"resource": ""
} |
q180086 | Logger.debug | test | public static void debug(String message, Object... args) {
if (recordCaller) {
LoggerFactory.getLogger(getCallerClassName()).debug(message, args);
} else {
slf4j.debug(message, args);
}
} | java | {
"resource": ""
} |
q180087 | Logger.getCallerInformations | test | static CallInfo getCallerInformations(int level) {
StackTraceElement[] callStack = Thread.currentThread().getStackTrace();
StackTraceElement caller = callStack[level];
return new CallInfo(caller.getClassName(), caller.getMethodName());
} | java | {
"resource": ""
} |
q180088 | CharKit.toSimpleByteArray | test | public static byte[] toSimpleByteArray(char[] carr) {
byte[] barr = new byte[carr.length];
for (int i = 0; i < carr.length; i++) {
barr[i] = (byte) carr[i];
}
return barr;
} | java | {
"resource": ""
} |
q180089 | CharKit.toSimpleByteArray | test | public static byte[] toSimpleByteArray(CharSequence charSequence) {
byte[] barr = new byte[charSequence.length()];
for (int i = 0; i < barr.length; i++) {
barr[i] = (byte) charSequence.charAt(i);
}
return barr;
} | java | {
"resource": ""
} |
q180090 | CharKit.toSimpleCharArray | test | public static char[] toSimpleCharArray(byte[] barr) {
char[] carr = new char[barr.length];
for (int i = 0; i < barr.length; i++) {
carr[i] = (char) (barr[i] & 0xFF);
}
return carr;
} | java | {
"resource": ""
} |
q180091 | CharKit.toAsciiByteArray | test | public static byte[] toAsciiByteArray(CharSequence charSequence) {
byte[] barr = new byte[charSequence.length()];
for (int i = 0; i < barr.length; i++) {
char c = charSequence.charAt(i);
barr[i] = (byte) ((int) (c <= 0xFF ? c : 0x3F));
}
return barr;
} | java | {
"resource": ""
} |
q180092 | LocaleKit.lookupLocaleData | test | protected static LocaleData lookupLocaleData(String code) {
LocaleData localeData = locales.get(code);
if (localeData == null) {
String[] data = decodeLocaleCode(code);
localeData = new LocaleData(new Locale(data[0], data[1], data[2]));
locales.put(code, localeData);
... | java | {
"resource": ""
} |
q180093 | Job.in | test | public Promise<V> in(int seconds) {
final Promise<V> smartFuture = new Promise<V>();
JobsPlugin.executor.schedule(getJobCallingCallable(smartFuture), seconds, TimeUnit.SECONDS);
return smartFuture;
} | java | {
"resource": ""
} |
q180094 | Images.crop | test | public static void crop(File originalImage, File to, int x1, int y1, int x2, int y2) {
try {
BufferedImage source = ImageIO.read(originalImage);
String mimeType = "image/jpeg";
if (to.getName().endsWith(".png")) {
mimeType = "image/png";
}
... | java | {
"resource": ""
} |
q180095 | Invoker.invoke | test | public static Future<?> invoke(final Invocation invocation, long millis) {
return executor.schedule(invocation, millis, TimeUnit.MILLISECONDS);
} | java | {
"resource": ""
} |
q180096 | Invoker.invokeInThread | test | public static void invokeInThread(DirectInvocation invocation) {
boolean retry = true;
while (retry) {
invocation.run();
if (invocation.retry == null) {
retry = false;
} else {
try {
if (invocation.retry.task != null... | java | {
"resource": ""
} |
q180097 | RestOperationsFactory.getRestOperations | test | @Nonnull
public RestOperations getRestOperations() {
final HttpClientBuilder builder = HttpClientBuilder.create();
initDefaultHttpClientBuilder(builder);
httpRequestFactory = new HttpComponentsClientHttpRequestFactory(builder.build());
final RestTemplate restTemplate = new RestTemplate(messageConvert... | java | {
"resource": ""
} |
q180098 | Controller.renderAjaxError | test | protected void renderAjaxError(String error, Exception e) {
renderJson(AjaxMessage.error(error, e));
} | java | {
"resource": ""
} |
q180099 | Controller.renderAjaxForbidden | test | protected <T> void renderAjaxForbidden(String message, T data) {
renderJson(AjaxMessage.forbidden(message, data));
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.