id
stringlengths
7
14
text
stringlengths
1
106k
369176_8
public Response process(ResponseChain chain, Response response) { if (shouldRedirect(response)) { String uri = response.getHeader("Location").get(0); Request request = response.getRequest(); if (uri.charAt(0) == '/') { URI target = request.getURI().resolve(uri); return client.at(target).addHeaders(request....
369176_9
public Response process(ResponseChain chain, Response response) { if (shouldRedirect(response)) { String uri = response.getHeader("Location").get(0); Request request = response.getRequest(); if (uri.charAt(0) == '/') { URI target = request.getURI().resolve(uri); return client.at(target).addHeaders(request....
376975_0
@Override public void write(char[] cbuf, int off, int len) throws IOException { writer.write(cbuf, off, len); }
376975_1
@Override public void flush() throws IOException { writer.flush(); }
376975_2
@Override public void close() throws IOException { }
376975_3
@Override public void write(int b) throws IOException { outputStream.write(b); }
376975_4
public void close() { }
376975_5
public static String defaultIfNull(String text) { return defaultIfNull(text, ""); }
376975_6
public static String defaultIfNull(String text) { return defaultIfNull(text, ""); }
376975_7
public static boolean isEmpty(String text) { return (text == null) || (text.length() == 0); }
376975_8
public static boolean isBlank(String text) { if (isEmpty(text)) { return true; } for (int i = 0; i < text.length(); i++) { if (!Character.isWhitespace(text.charAt(i))) { return false; } } return true; }
376975_9
public static boolean isNotBlank(String text) { return !isBlank(text); }
394387_0
public Collection getBaseCollection() throws XMLDBException { baseCollection = DatabaseManager.getCollection(baseCollectionURI); return baseCollection; }
403568_0
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry.getEnvelope()); } } }
403568_1
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry.getEnvelope()); } } }
403568_2
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry.getEnvelope()); } } }
403568_3
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry.getEnvelope()); } } }
403568_4
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry); } } }
403568_5
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry); } } }
403568_6
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry); } } }
403568_7
@Override protected void add(Geometry geometry) { if (result == null) { result = geometry; } else { if (geometry != null) { result = result.union(geometry); } } }
446195_0
public static void main(String[] args) { System.out.println("Starting JMX Monitor"); Options options = new Options(); Option configurationFileOption = new Option("c", true, "Configuration Path"); configurationFileOption.setRequired(true); configurationFileOption.setArgs(1); options.addOption(configurationFileOpti...
446195_1
public static void main(String[] args) { System.out.println("Starting JMX Monitor"); Options options = new Options(); Option configurationFileOption = new Option("c", true, "Configuration Path"); configurationFileOption.setRequired(true); configurationFileOption.setArgs(1); options.addOption(configurationFileOpti...
446195_2
public static void main(String[] args) { System.out.println("Starting JMX Monitor"); Options options = new Options(); Option configurationFileOption = new Option("c", true, "Configuration Path"); configurationFileOption.setRequired(true); configurationFileOption.setArgs(1); options.addOption(configurationFileOpti...
446195_3
public static boolean isBetween(long reading, long floor, long ceiling) { return reading < ceiling && reading > floor; }
446195_4
public static boolean isBelow(long reading, long value) { return reading < value; }
446195_5
public static boolean isAbove(long reading, long value) { return reading > value; }
457158_0
public void allUnresolvedIssues(IssueHandler handler) throws Failure { TicketManager ticketManager = connections.getTicketManager(); ticketManager.lock(); try { IssueManager issueManager = ticketManager.getIssueManager(); Iterator<Issue> issues = issueManager.allIssuesIterator(); whi...
457158_1
public void allUnresolvedIssues(IssueHandler handler) throws Failure { TicketManager ticketManager = connections.getTicketManager(); ticketManager.lock(); try { retrieveUnresolvedIssues(ticketManager.getIssueManager(), handler); } finally { ticketManager.unlock(); } }
457158_2
public void sendMessageTo(String message, Iterable<AuctionDescription> auctionDescriptions) { for (AuctionDescription auctionDescription : auctionDescriptions) { final AuctionConnection connection = connectionFinder.findConnectionFor(auctionDescription); if (connection != null) { connect...
457158_3
public void sendMessageTo(String message, Iterable<AuctionDescription> auctionDescriptions) { for (AuctionDescription auctionDescription : auctionDescriptions) { final AuctionConnection connection = connectionFinder.findConnectionFor(auctionDescription); if (connection != null) { connect...
457158_4
public void search(Set<String> keywords) { for (AuctionHouse auctionHouse : auctionHouses) { search(auctionHouse, keywords); } consumer.auctionSearchFinished(); }
457158_5
public void search(Set<String> keywords) { for (AuctionHouse auctionHouse : auctionHouses) { search(auctionHouse, keywords); } consumer.auctionSearchFinished(); }
457158_6
public void search(Set<String> keywords) { for (AuctionHouse auctionHouse : auctionHouses) { search(auctionHouse, keywords); } consumer.auctionSearchFinished(); }
457158_7
public void search(Set<String> keywords) { for (AuctionHouse auctionHouse : auctionHouses) { search(auctionHouse, keywords); } consumer.auctionSearchFinished(); }
457158_8
public void searchFor(Set<String> keywords) { for (Auction auction : auctions) { announceIfAuctionMatches(auction, keywords); } searchListener.searchFinished(); }
457158_9
public void searchFor(Set<String> keywords) { for (Auction auction : auctions) { announceIfAuctionMatches(auction, keywords); } searchListener.searchFinished(); }
459348_0
@Nullable public static String getVersionName(Context context) { PackageInfo pInfo; try { pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA); return pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { Log.e(TAG...
459348_1
@SuppressWarnings("deprecation") public static int getVersionCode(Context context) { PackageInfo pInfo; try { pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA); return pInfo.versionCode; } catch (PackageManager.NameNotFoundException e)...
459348_2
public static boolean isInstalledOnSDCard(Context context) { PackageInfo pInfo; try { pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA); return (pInfo.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0; } catch (Packag...
459348_3
@NonNull protected RestoreState doInBackground(RestoreConfig... params) { if (params == null || params.length == 0) throw new IllegalArgumentException("No config passed"); RestoreConfig config = params[0]; if (!config.restoreSms && !config.restoreCallLog) { return new RestoreState(FINISHED_RESTORE, ...
459348_4
@NonNull protected RestoreState doInBackground(RestoreConfig... params) { if (params == null || params.length == 0) throw new IllegalArgumentException("No config passed"); RestoreConfig config = params[0]; if (!config.restoreSms && !config.restoreCallLog) { return new RestoreState(FINISHED_RESTORE, ...
459348_5
@NonNull protected RestoreState doInBackground(RestoreConfig... params) { if (params == null || params.length == 0) throw new IllegalArgumentException("No config passed"); RestoreConfig config = params[0]; if (!config.restoreSms && !config.restoreCallLog) { return new RestoreState(FINISHED_RESTORE, ...
459348_6
public @Nullable Job scheduleImmediate() { return schedule(-1, BROADCAST_INTENT, true); }
459348_7
public Job scheduleRegular() { return schedule(preferences.getRegularTimeoutSecs(), REGULAR, false); }
459348_8
public @Nullable Job scheduleContentTriggerJob() { return schedule(createContentUriTriggerJob()); }
459348_9
public @Nullable Job scheduleContentTriggerJob() { return schedule(createContentUriTriggerJob()); }
466802_0
public String getBiography() { return biography; }
473362_0
@Override public int nextInt() { /* Each single bit including the sign bit will be random */ if (mti == N) { nextBlock(); } // generate N ints at one time int y = mt[mti++]; y ^= y >>> 11; // y ^= TEMPERING_SHIFT_U(y ); y ^= (y << 7) & TEMPERING_MASK_B; // y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; ...
473362_1
@Override public Object clone() { MersenneTwister clone = (MersenneTwister) super.clone(); clone.mt = this.mt.clone(); return clone; }
473362_2
public static double entropy(int... elements) { double sum = 0.0; double result = 0.0; for (int element : elements) { if (element < 0) { throw new IllegalArgumentException("Should not have negative count for entropy computation: (" + element + ')'); } if (element > 0) { result += element *...
473362_3
private LogLikelihood() { }
473362_4
public static double rootLogLikelihoodRatio(int k11, int k12, int k21, int k22) { double llr = logLikelihoodRatio(k11, k12, k21, k22); double sqrt = Math.sqrt(llr); if (((double) k11 / (k11+k12)) < ((double) k21 / (k21+k22))) { sqrt = -sqrt; } return sqrt; }
473362_5
public static double rootLogLikelihoodRatio(int k11, int k12, int k21, int k22) { double llr = logLikelihoodRatio(k11, k12, k21, k22); double sqrt = Math.sqrt(llr); if (((double) k11 / (k11+k12)) < ((double) k21 / (k21+k22))) { sqrt = -sqrt; } return sqrt; }
473362_6
@Override public void reduce(GramKey key, Iterator<Gram> values, OutputCollector<Gram,Gram> output, Reporter reporter) throws IOException { Gram.Type keyType = key.getType(); if (keyType == Gram.Type.UNIGRAM) { // sum frequencies for unigrams. proc...
473362_7
@Override public void reduce(Gram ngram, Iterator<Gram> values, OutputCollector<Text,DoubleWritable> output, Reporter reporter) throws IOException { int[] gramFreq = {-1, -1}; if (ngram.getType() == Gram.Type.UNIGRAM && emitUnigrams) { DoubleWritabl...
473362_8
@SuppressWarnings("unchecked") @Override public int compare(WritableComparable a, WritableComparable b) { GramKey gka = (GramKey) a; GramKey gkb = (GramKey) b; return WritableComparator.compareBytes(gka.getBytes(), 0, gka.getPrimaryLength(), gkb.getBytes(), 0, gkb.getPrima...
473362_9
@Override public int getPartition(GramKey key, Gram value, int numPartitions) { // see: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/partition/BinaryPartitioner.java?revision=816664&view=markup int length = key.getLength() - 1; int right = (offset + length) % length...
474905_0
public void setName(String name) { this.name = name; }
474905_1
public void setArchived(boolean archived) { this.archived = archived; }
478661_0
public static String calcLookupPrefix(String lookup, String content) { for (int i = lookup.length() - 1; i >= 0; i--) { int i2 = i; for (int j = content.length() - 1; j >= 0 && i2 >= 0; j--) { if (lookup.charAt(i2) == content.charAt(j)) { // Check boundary ...
478661_1
public static String calcLookupPrefix(String lookup, String content) { for (int i = lookup.length() - 1; i >= 0; i--) { int i2 = i; for (int j = content.length() - 1; j >= 0 && i2 >= 0; j--) { if (lookup.charAt(i2) == content.charAt(j)) { // Check boundary ...
478661_2
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
478661_3
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
478661_4
public List<String[]> readAll() throws IOException { List<String[]> allElements = new ArrayList<String[]>(); while (hasNext) { String[] nextLineAsTokens = readNext(); if (nextLineAsTokens != null) allElements.add(nextLineAsTokens); } return allElements; }
478661_5
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
478661_6
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
478661_7
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
478661_8
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
478661_9
public String[] readNext() throws IOException { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (r...
489859_0
public GetOptions ifModifiedSince(Date ifModifiedSince) { checkArgument(getIfMatch() == null, "ifETagMatches() is not compatible with ifModifiedSince()"); checkArgument(getIfUnmodifiedSince() == null, "ifUnmodifiedSince() is not compatible with ifModifiedSince()"); this.ifModifiedSince = checkNotNull(ifModifie...
489859_1
public Date getIfModifiedSince() { return this.ifModifiedSince; }
489859_2
public GetOptions ifModifiedSince(Date ifModifiedSince) { checkArgument(getIfMatch() == null, "ifETagMatches() is not compatible with ifModifiedSince()"); checkArgument(getIfUnmodifiedSince() == null, "ifUnmodifiedSince() is not compatible with ifModifiedSince()"); this.ifModifiedSince = checkNotNull(ifModifie...
489859_3
public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.ifUnmodifiedSince = checkNot...
489859_4
public Date getIfUnmodifiedSince() { return this.ifUnmodifiedSince; }
489859_5
public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.ifUnmodifiedSince = checkNot...
489859_6
public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.ifUnmodifiedSince = checkNot...
489859_7
public GetOptions range(long start, long end) { checkArgument(start >= 0, "start must be >= 0"); checkArgument(end >= 0, "end must be >= 0"); getRanges().add(String.format("%d-%d", start, end)); return this; }
489859_8
public List<String> getRanges() { return ranges; }
489859_9
public GetOptions range(long start, long end) { checkArgument(start >= 0, "start must be >= 0"); checkArgument(end >= 0, "end must be >= 0"); getRanges().add(String.format("%d-%d", start, end)); return this; }
500697_0
public static String writeNumber(Number x, boolean jags) { if (x == null) { return "NA"; } String suffix = jags && isInteger(x) ? "L" : ""; return String.valueOf(x) + suffix; }
500697_1
public static String writeNumber(Number x, boolean jags) { if (x == null) { return "NA"; } String suffix = jags && isInteger(x) ? "L" : ""; return String.valueOf(x) + suffix; }
500697_2
public static String writeMatrix(Number[][] m, boolean jags) { int rows = m.length; int cols = m[0].length; String cells[] = new String[rows * cols]; for (int i = 0; i < cells.length; ++i) { cells[i] = writeNumber(jags ? m[i % rows][i / rows] : m[i / cols][i % cols], jags); } return "structure(" + (jags ? "" ...
500697_3
public static String writeMatrix(Number[][] m, boolean jags) { int rows = m.length; int cols = m[0].length; String cells[] = new String[rows * cols]; for (int i = 0; i < cells.length; ++i) { cells[i] = writeNumber(jags ? m[i % rows][i / rows] : m[i / cols][i % cols], jags); } return "structure(" + (jags ? "" ...
500697_4
public boolean containsTreatment(final Treatment t) { return CollectionUtils.exists(getMeasurements(), new Predicate<Measurement>() { public boolean evaluate(Measurement m) { return m.getTreatment().equals(t); } }); }
500697_5
public Measurement restrict(DataType type) { Measurement m = new Measurement(); m.setTreatment(getTreatment()); switch (type) { case NONE: break; case RATE: m.setSampleSize(getSampleSize()); m.setResponders(getResponders()); break; case CONTINUOUS: m.setMean(getMean()); m.setStdDev(getStdDev()); m.s...
500697_6
public int compare(Treatment o1, Treatment o2) { return o1.getId().compareTo(o2.getId()); }
500697_7
public Map<Study, Treatment> getInitialState() { Map<Study, Treatment> state = new HashMap<Study, Treatment>(); for (Study s : d_studies) { Set<Treatment> treatments = s.getTreatments(); if (treatments.size() == 2) { state.put(s, CompareUtil.findLeast(treatments, TreatmentComparator.INSTANCE)); } } return ...
500697_8
public static Hypergraph<Treatment, Study> createStudyGraph(Network network) { Hypergraph<Treatment, Study> graph = new SetHypergraph<Treatment, Study>(); for (Treatment t : network.getTreatments()) { graph.addVertex(t); } for (Study s : network.getStudies()) { graph.addEdge(s, s.getTreatments()); } return gr...
500697_9
public static List<Treatment> standardizeCycle(List<Treatment> cycle) { assertCycle(cycle); List<Treatment> std = rebaseCycle(cycle); // reverse the order if necessary if (TreatmentComparator.INSTANCE.compare(std.get(1), std.get(std.size() - 2)) > 0) { Collections.reverse(std); } return std; }
500806_0
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (receivedMessage.getPayload() instanceof byte[]) { receivedMessage.setPayload(Base64.encodeBase64String...
500806_1
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (receivedMessage.getPayload() instanceof byte[]) { receivedMessage.setPayload(Base64.encodeBase64String...
500806_2
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (receivedMessage.getPayload() instanceof byte[]) { receivedMessage.setPayload(Base64.encodeBase64String...
500806_3
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...
500806_4
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...
500806_5
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...
500806_6
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...
500806_7
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...
500806_8
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...
500806_9
@Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { log.debug("Skip message payload valid...