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.getHeaders()).get();
}
return client.at(uri).addHeaders(request.getHeaders()).get();
}
return response;
}
|
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.getHeaders()).get();
}
return client.at(uri).addHeaders(request.getHeaders()).get();
}
return response;
}
|
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(configurationFileOption);
Option stopOption = new Option(STOP, false, "Pass to " + STOP + " the process");
options.addOption(stopOption);
CommandLineParser parser = new PosixParser();
try {
CommandLine cmd = parser.parse(options, args);
String configurationFile = cmd.getOptionValue("c");
System.out.println("ConfigurationFile is " + configurationFile);
File file = new File(configurationFile);
if (file.exists() && file.canRead()) {
if (cmd.hasOption(STOP)) {
logger.debug("Stopping existing JMXMonitor");
new RegistryManager(configurationFile).stop();
} else {
logger.debug("Starting new JMXMonitor");
new RegistryManager(configurationFile).start();
}
} else {
logger.error("Unable to read configuration exiting {}", file);
}
} catch (ParseException e) {
logger.error("Exception occured {}", e);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("jmxMonitor", options);
} catch (InitialisationException e) {
logger.error("{}", e);
throw new RuntimeException(e);
} catch (IOException e) {
logger.error("{}", e);
throw new RuntimeException(e);
}
System.out.println("Exiting JMX Monitor");
}
|
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(configurationFileOption);
Option stopOption = new Option(STOP, false, "Pass to " + STOP + " the process");
options.addOption(stopOption);
CommandLineParser parser = new PosixParser();
try {
CommandLine cmd = parser.parse(options, args);
String configurationFile = cmd.getOptionValue("c");
System.out.println("ConfigurationFile is " + configurationFile);
File file = new File(configurationFile);
if (file.exists() && file.canRead()) {
if (cmd.hasOption(STOP)) {
logger.debug("Stopping existing JMXMonitor");
new RegistryManager(configurationFile).stop();
} else {
logger.debug("Starting new JMXMonitor");
new RegistryManager(configurationFile).start();
}
} else {
logger.error("Unable to read configuration exiting {}", file);
}
} catch (ParseException e) {
logger.error("Exception occured {}", e);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("jmxMonitor", options);
} catch (InitialisationException e) {
logger.error("{}", e);
throw new RuntimeException(e);
} catch (IOException e) {
logger.error("{}", e);
throw new RuntimeException(e);
}
System.out.println("Exiting JMX Monitor");
}
|
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(configurationFileOption);
Option stopOption = new Option(STOP, false, "Pass to " + STOP + " the process");
options.addOption(stopOption);
CommandLineParser parser = new PosixParser();
try {
CommandLine cmd = parser.parse(options, args);
String configurationFile = cmd.getOptionValue("c");
System.out.println("ConfigurationFile is " + configurationFile);
File file = new File(configurationFile);
if (file.exists() && file.canRead()) {
if (cmd.hasOption(STOP)) {
logger.debug("Stopping existing JMXMonitor");
new RegistryManager(configurationFile).stop();
} else {
logger.debug("Starting new JMXMonitor");
new RegistryManager(configurationFile).start();
}
} else {
logger.error("Unable to read configuration exiting {}", file);
}
} catch (ParseException e) {
logger.error("Exception occured {}", e);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("jmxMonitor", options);
} catch (InitialisationException e) {
logger.error("{}", e);
throw new RuntimeException(e);
} catch (IOException e) {
logger.error("{}", e);
throw new RuntimeException(e);
}
System.out.println("Exiting JMX Monitor");
}
|
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();
while (issues.hasNext()) {
Issue issue = issues.next();
if (issue.isUnresolved()) {
handler.accept(issue);
}
}
} finally {
ticketManager.unlock();
}
}
|
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) {
connection.send(message);
return;
}
}
}
|
457158_3
|
public void sendMessageTo(String message, Iterable<AuctionDescription> auctionDescriptions) {
for (AuctionDescription auctionDescription : auctionDescriptions) {
final AuctionConnection connection = connectionFinder.findConnectionFor(auctionDescription);
if (connection != null) {
connection.send(message);
return;
}
}
}
|
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, null, e);
return null;
}
}
|
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) {
Log.e(TAG, null, e);
return -1;
}
}
|
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 (PackageManager.NameNotFoundException e) {
Log.e(TAG, "error", e);
return false;
}
}
|
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, 0, 0, 0, 0, null, null);
} else {
try {
service.acquireLocks();
return restore(config);
} finally {
service.releaseLocks();
}
}
}
|
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, 0, 0, 0, 0, null, null);
} else {
try {
service.acquireLocks();
return restore(config);
} finally {
service.releaseLocks();
}
}
}
|
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, 0, 0, 0, 0, null, null);
} else {
try {
service.acquireLocks();
return restore(config);
} finally {
service.releaseLocks();
}
}
}
|
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;
y ^= (y << 15) & TEMPERING_MASK_C; // y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
// y &= 0xffffffff; //you may delete this line if word size = 32
y ^= y >>> 18; // y ^= TEMPERING_SHIFT_L(y);
return y;
}
|
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 * Math.log(element);
sum += element;
}
}
result -= sum * Math.log(sum);
return -result;
}
|
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.
processUnigram(key, values, output, reporter);
} else if (keyType == Gram.Type.HEAD || keyType == Gram.Type.TAIL) {
// sum frequencies for subgrams, ngram and collect for each ngram.
processSubgram(key, values, output, reporter);
} else {
reporter.incrCounter(Skipped.MALFORMED_TYPES, 1);
}
}
|
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) {
DoubleWritable dd = new DoubleWritable(ngram.getFrequency());
Text t = new Text(ngram.getString());
output.collect(t, dd);
return;
}
// FIXME: better way to handle errors? Wouldn't an exception thrown here
// cause hadoop to re-try the job?
String[] gram = new String[2];
while (values.hasNext()) {
Gram value = values.next();
int pos = value.getType() == Gram.Type.HEAD ? 0 : 1;
if (gramFreq[pos] != -1) {
log.warn("Extra {} for {}, skipping", value.getType(), ngram);
if (value.getType() == Gram.Type.HEAD) {
reporter.incrCounter(Skipped.EXTRA_HEAD, 1);
} else {
reporter.incrCounter(Skipped.EXTRA_TAIL, 1);
}
return;
}
gram[pos] = value.getString();
gramFreq[pos] = value.getFrequency();
}
if (gramFreq[0] == -1) {
log.warn("Missing head for {}, skipping.", ngram);
reporter.incrCounter(Skipped.MISSING_HEAD, 1);
return;
} else if (gramFreq[1] == -1) {
log.warn("Missing tail for {}, skipping", ngram);
reporter.incrCounter(Skipped.MISSING_TAIL, 1);
return;
}
int k11 = ngram.getFrequency(); /* a&b */
int k12 = gramFreq[0] - ngram.getFrequency(); /* a&!b */
int k21 = gramFreq[1] - ngram.getFrequency(); /* !b&a */
int k22 = (int) (ngramTotal - (gramFreq[0] + gramFreq[1] - ngram.getFrequency())); /* !a&!b */
try {
double llr = ll.logLikelihoodRatio(k11, k12, k21, k22);
if (llr < minLLRValue) {
reporter.incrCounter(Skipped.LESS_THAN_MIN_LLR, 1);
return;
}
DoubleWritable dd = new DoubleWritable(llr);
Text t = new Text(ngram.getString());
output.collect(t, dd);
} catch (IllegalArgumentException ex) {
reporter.incrCounter(Skipped.LLR_CALCULATION_ERROR, 1);
log.error("Problem calculating LLR ratio: " + ex.getMessage());
log.error("NGram: " + ngram);
log.error("HEAD: " + gram[0] + ':' + gramFreq[0]);
log.error("TAIL: " + gram[1] + ':' + gramFreq[1]);
log.error("k11: " + k11 + " k12: " + k12 + " k21: " + k21 + " k22: " + k22);
}
}
|
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.getPrimaryLength());
}
|
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;
int hash = WritableComparator.hashBytes(key.getBytes(), right);
return (hash & Integer.MAX_VALUE) % numPartitions;
}
|
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
if (i2 == 0) {
return (j == 0 || content.charAt(j - 1) == ' ' || content.charAt(j - 1) == '\t'
|| content.charAt(j - 1) == '\n') ? lookup.substring(0, i + 1) : "";
}
} else if (content.charAt(j) == ' ' || content.charAt(j) == '\n' || content.charAt(j) == '\t') {
// Skip whitespaces
continue;
} else {
break;
}
i2--;
}
}
return "";
}
|
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
if (i2 == 0) {
return (j == 0 || content.charAt(j - 1) == ' ' || content.charAt(j - 1) == '\t'
|| content.charAt(j - 1) == '\n') ? lookup.substring(0, i + 1) : "";
}
} else if (content.charAt(j) == ' ' || content.charAt(j) == '\n' || content.charAt(j) == '\t') {
// Skip whitespaces
continue;
} else {
break;
}
i2--;
}
}
return "";
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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 (result == null) {
result = r;
} else {
String[] t = new String[result.length + r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
|
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(ifModifiedSince, "ifModifiedSince");
return this;
}
|
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(ifModifiedSince, "ifModifiedSince");
return this;
}
|
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 = checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince");
return this;
}
|
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 = checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince");
return this;
}
|
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 = checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince");
return this;
}
|
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 ? "" : ".Data = ") + "c(" + StringUtils.join(cells, ", ") + "), .Dim = c(" +
writeNumber(rows, jags) + ", " + writeNumber(cols, 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 ? "" : ".Data = ") + "c(" + StringUtils.join(cells, ", ") + "), .Dim = c(" +
writeNumber(rows, jags) + ", " + writeNumber(cols, 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.setSampleSize(getSampleSize());
break;
}
return m;
}
|
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 state;
}
|
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 graph ;
}
|
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(receivedMessage.getPayload(byte[].class)));
}
super.validateMessage(receivedMessage, controlMessage, context, validationContext);
}
|
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(receivedMessage.getPayload(byte[].class)));
}
super.validateMessage(receivedMessage, controlMessage, context, validationContext);
}
|
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(receivedMessage.getPayload(byte[].class)));
}
super.validateMessage(receivedMessage, controlMessage, context, validationContext);
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
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 validation as no control message was defined");
return;
}
log.debug("Start text message validation");
if (log.isDebugEnabled()) {
log.debug("Received message:\n" + receivedMessage);
log.debug("Control message:\n" + controlMessage);
}
try {
String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim());
String controlValue = normalizeWhitespace(context.replaceDynamicContentInString(controlMessage.getPayload(String.class).trim()));
controlValue = processIgnoreStatements(controlValue, resultValue);
controlValue = processVariableStatements(controlValue, resultValue, context);
if (ValidationMatcherUtils.isValidationMatcherExpression(controlValue)) {
ValidationMatcherUtils.resolveValidationMatcher("payload", resultValue, controlValue, context);
return;
} else {
validateText(resultValue, controlValue);
}
} catch (IllegalArgumentException e) {
throw new ValidationException("Failed to validate text content", e);
}
log.info("Text validation successful: All values OK");
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.