id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
143,500 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.recordMerge | public static InputStream recordMerge(File directory, String branchName, long... revisions) throws IOException {
// svn merge -c 3328 --record-only ^/calc/trunk
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument(CMD_MERGE);
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument("--record-only");
cmdLine.addArgument("-c");
StringBuilder revs = new StringBuilder();
for (long revision : revisions) {
revs.append(revision).append(",");
}
cmdLine.addArgument(revs.toString());
// leads to "non-inheritable merges"
// cmdLine.addArgument("--depth");
// cmdLine.addArgument("empty");
cmdLine.addArgument("^" + branchName);
//cmdLine.addArgument("."); // current dir
return ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000);
} | java | public static InputStream recordMerge(File directory, String branchName, long... revisions) throws IOException {
// svn merge -c 3328 --record-only ^/calc/trunk
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument(CMD_MERGE);
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument("--record-only");
cmdLine.addArgument("-c");
StringBuilder revs = new StringBuilder();
for (long revision : revisions) {
revs.append(revision).append(",");
}
cmdLine.addArgument(revs.toString());
// leads to "non-inheritable merges"
// cmdLine.addArgument("--depth");
// cmdLine.addArgument("empty");
cmdLine.addArgument("^" + branchName);
//cmdLine.addArgument("."); // current dir
return ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000);
} | [
"public",
"static",
"InputStream",
"recordMerge",
"(",
"File",
"directory",
",",
"String",
"branchName",
",",
"long",
"...",
"revisions",
")",
"throws",
"IOException",
"{",
"// \t\t\t\tsvn merge -c 3328 --record-only ^/calc/trunk",
"CommandLine",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"CMD_MERGE",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"null",
",",
"null",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"--record-only\"",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"-c\"",
")",
";",
"StringBuilder",
"revs",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"long",
"revision",
":",
"revisions",
")",
"{",
"revs",
".",
"append",
"(",
"revision",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"cmdLine",
".",
"addArgument",
"(",
"revs",
".",
"toString",
"(",
")",
")",
";",
"// leads to \"non-inheritable merges\"",
"// cmdLine.addArgument(\"--depth\");",
"// cmdLine.addArgument(\"empty\");",
"cmdLine",
".",
"addArgument",
"(",
"\"^\"",
"+",
"branchName",
")",
";",
"//cmdLine.addArgument(\".\");\t// current dir",
"return",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"directory",
",",
"0",
",",
"120000",
")",
";",
"}"
] | Record a manual merge from one branch to the local working directory.
@param directory The local working directory
@param branchName The branch that was merged in manually
@param revisions The list of merged revisions.
@return A stream which provides the output of the "svn merge" command, should be closed by the caller
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Record",
"a",
"manual",
"merge",
"from",
"one",
"branch",
"to",
"the",
"local",
"working",
"directory",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L491-L510 |
143,501 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.verifyNoPendingChanges | public static boolean verifyNoPendingChanges(File directory) throws IOException {
log.info("Checking that there are no pending changes on trunk-working copy");
try (InputStream inStr = getPendingCheckins(directory)) {
List<String> lines = IOUtils.readLines(inStr, "UTF-8");
if (lines.size() > 0) {
log.info("Found the following checkouts:\n" + ArrayUtils.toString(lines.toArray(), "\n"));
return true;
}
}
return false;
} | java | public static boolean verifyNoPendingChanges(File directory) throws IOException {
log.info("Checking that there are no pending changes on trunk-working copy");
try (InputStream inStr = getPendingCheckins(directory)) {
List<String> lines = IOUtils.readLines(inStr, "UTF-8");
if (lines.size() > 0) {
log.info("Found the following checkouts:\n" + ArrayUtils.toString(lines.toArray(), "\n"));
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"verifyNoPendingChanges",
"(",
"File",
"directory",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"\"Checking that there are no pending changes on trunk-working copy\"",
")",
";",
"try",
"(",
"InputStream",
"inStr",
"=",
"getPendingCheckins",
"(",
"directory",
")",
")",
"{",
"List",
"<",
"String",
">",
"lines",
"=",
"IOUtils",
".",
"readLines",
"(",
"inStr",
",",
"\"UTF-8\"",
")",
";",
"if",
"(",
"lines",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"log",
".",
"info",
"(",
"\"Found the following checkouts:\\n\"",
"+",
"ArrayUtils",
".",
"toString",
"(",
"lines",
".",
"toArray",
"(",
")",
",",
"\"\\n\"",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if there are pending changes on the branch, returns true if changes are found.
@param directory The local working directory
@return True if there are pending changes, false otherwise
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Check",
"if",
"there",
"are",
"pending",
"changes",
"on",
"the",
"branch",
"returns",
"true",
"if",
"changes",
"are",
"found",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L520-L531 |
143,502 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.mergeRevision | public static MergeResult mergeRevision(long revision, File directory, String branch, String baseUrl) throws IOException {
// svn merge -r 1288:1351 http://svn.example.com/myrepos/branch
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument(CMD_MERGE);
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument("-x");
cmdLine.addArgument("-uw --ignore-eol-style"); // unified-diff and ignore all whitespace changes
cmdLine.addArgument("--accept");
cmdLine.addArgument("postpone");
cmdLine.addArgument("-c");
cmdLine.addArgument(Long.toString(revision));
cmdLine.addArgument(baseUrl + branch);
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000)) {
String output = extractResult(result);
boolean foundActualMerge = false;
boolean foundConflict = false;
// check if only svn-properties were updated
for (String line : output.split("\n")) {
// ignore the comments about what is done
if (line.startsWith("--- ")) {
continue;
}
if (line.length() >= 4 && line.substring(0, 4).contains("C")) {
// C..Conflict
foundConflict = true;
log.info("Found conflict!");
break;
} else if (!line.startsWith(" U ") && !line.startsWith(" G ")) {
// U..Updated, G..Merged, on second position means "property", any other change is an actual merge
foundActualMerge = true;
log.info("Found actual merge: " + line);
}
}
log.info("Svn-Merge reported:\n" + output);
if (foundConflict) {
return MergeResult.Conflicts;
}
if (!foundActualMerge) {
log.info("Only mergeinfo updates found after during merge.");
return MergeResult.OnlyMergeInfo;
}
}
return MergeResult.Normal;
} | java | public static MergeResult mergeRevision(long revision, File directory, String branch, String baseUrl) throws IOException {
// svn merge -r 1288:1351 http://svn.example.com/myrepos/branch
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument(CMD_MERGE);
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument("-x");
cmdLine.addArgument("-uw --ignore-eol-style"); // unified-diff and ignore all whitespace changes
cmdLine.addArgument("--accept");
cmdLine.addArgument("postpone");
cmdLine.addArgument("-c");
cmdLine.addArgument(Long.toString(revision));
cmdLine.addArgument(baseUrl + branch);
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000)) {
String output = extractResult(result);
boolean foundActualMerge = false;
boolean foundConflict = false;
// check if only svn-properties were updated
for (String line : output.split("\n")) {
// ignore the comments about what is done
if (line.startsWith("--- ")) {
continue;
}
if (line.length() >= 4 && line.substring(0, 4).contains("C")) {
// C..Conflict
foundConflict = true;
log.info("Found conflict!");
break;
} else if (!line.startsWith(" U ") && !line.startsWith(" G ")) {
// U..Updated, G..Merged, on second position means "property", any other change is an actual merge
foundActualMerge = true;
log.info("Found actual merge: " + line);
}
}
log.info("Svn-Merge reported:\n" + output);
if (foundConflict) {
return MergeResult.Conflicts;
}
if (!foundActualMerge) {
log.info("Only mergeinfo updates found after during merge.");
return MergeResult.OnlyMergeInfo;
}
}
return MergeResult.Normal;
} | [
"public",
"static",
"MergeResult",
"mergeRevision",
"(",
"long",
"revision",
",",
"File",
"directory",
",",
"String",
"branch",
",",
"String",
"baseUrl",
")",
"throws",
"IOException",
"{",
"// svn merge -r 1288:1351 http://svn.example.com/myrepos/branch",
"CommandLine",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"CMD_MERGE",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"null",
",",
"null",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"-x\"",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"-uw --ignore-eol-style\"",
")",
";",
"// unified-diff and ignore all whitespace changes",
"cmdLine",
".",
"addArgument",
"(",
"\"--accept\"",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"postpone\"",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"-c\"",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"Long",
".",
"toString",
"(",
"revision",
")",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"baseUrl",
"+",
"branch",
")",
";",
"try",
"(",
"InputStream",
"result",
"=",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"directory",
",",
"0",
",",
"120000",
")",
")",
"{",
"String",
"output",
"=",
"extractResult",
"(",
"result",
")",
";",
"boolean",
"foundActualMerge",
"=",
"false",
";",
"boolean",
"foundConflict",
"=",
"false",
";",
"// check if only svn-properties were updated",
"for",
"(",
"String",
"line",
":",
"output",
".",
"split",
"(",
"\"\\n\"",
")",
")",
"{",
"// ignore the comments about what is done",
"if",
"(",
"line",
".",
"startsWith",
"(",
"\"--- \"",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"line",
".",
"length",
"(",
")",
">=",
"4",
"&&",
"line",
".",
"substring",
"(",
"0",
",",
"4",
")",
".",
"contains",
"(",
"\"C\"",
")",
")",
"{",
"// C..Conflict",
"foundConflict",
"=",
"true",
";",
"log",
".",
"info",
"(",
"\"Found conflict!\"",
")",
";",
"break",
";",
"}",
"else",
"if",
"(",
"!",
"line",
".",
"startsWith",
"(",
"\" U \"",
")",
"&&",
"!",
"line",
".",
"startsWith",
"(",
"\" G \"",
")",
")",
"{",
"// U..Updated, G..Merged, on second position means \"property\", any other change is an actual merge",
"foundActualMerge",
"=",
"true",
";",
"log",
".",
"info",
"(",
"\"Found actual merge: \"",
"+",
"line",
")",
";",
"}",
"}",
"log",
".",
"info",
"(",
"\"Svn-Merge reported:\\n\"",
"+",
"output",
")",
";",
"if",
"(",
"foundConflict",
")",
"{",
"return",
"MergeResult",
".",
"Conflicts",
";",
"}",
"if",
"(",
"!",
"foundActualMerge",
")",
"{",
"log",
".",
"info",
"(",
"\"Only mergeinfo updates found after during merge.\"",
")",
";",
"return",
"MergeResult",
".",
"OnlyMergeInfo",
";",
"}",
"}",
"return",
"MergeResult",
".",
"Normal",
";",
"}"
] | Merge the given revision and return true if only mergeinfo changes were done on trunk.
@param revision The revision to merge, this should be on a different branch
@param directory The local working directory
@param branch The name of the branch to merge
@param baseUrl The SVN url to connect to
@return true if only mergeinfo changes were done, false otherwise.
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Merge",
"the",
"given",
"revision",
"and",
"return",
"true",
"if",
"only",
"mergeinfo",
"changes",
"were",
"done",
"on",
"trunk",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L561-L609 |
143,503 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.getMergedRevisions | public static String getMergedRevisions(File directory, String... branches) throws IOException {
// we could also use svn mergeinfo --show-revs merged ^/trunk ^/branches/test
CommandLine cmdLine;
cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("propget");
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument("svn:mergeinfo");
StringBuilder MERGED_REVISIONS_BUILD = new StringBuilder();
try (InputStream ignoreStr = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000)) {
List<String> lines = IOUtils.readLines(ignoreStr, "UTF-8");
for (String line : lines) {
for (String source : branches) {
if (line.startsWith(source + ":")) {
log.info("Found merged revisions for branch: " + source);
MERGED_REVISIONS_BUILD.append(",").append(line.substring(source.length() + 1)); // + 1 for ":"
break;
}
}
}
}
String MERGED_REVISIONS = StringUtils.removeStart(MERGED_REVISIONS_BUILD.toString(), ",");
if (MERGED_REVISIONS.equals("")) {
throw new IllegalStateException("Could not read merged revision with command " + cmdLine + " in directory " + directory);
}
// expand ranges r1-r2 into separate numbers for easier search in the string later on
List<Long> revList = new ArrayList<>();
String[] revs = MERGED_REVISIONS.split(",");
for (String rev : revs) {
if (rev.contains("-")) {
String[] revRange = rev.split("-");
if (revRange.length != 2) {
throw new IllegalStateException("Expected to have start and end of range, but had: " + rev);
}
for (long r = Long.parseLong(revRange[0]); r <= Long.parseLong(revRange[1]); r++) {
revList.add(r);
}
} else {
// non-inheritable merge adds a "*" to the rev, see https://groups.google.com/forum/?fromgroups=#!topic/subversion-svn/ArXTv1rUk5w
rev = StringUtils.removeEnd(rev, "*");
revList.add(Long.parseLong(rev));
}
}
return revList.toString();
} | java | public static String getMergedRevisions(File directory, String... branches) throws IOException {
// we could also use svn mergeinfo --show-revs merged ^/trunk ^/branches/test
CommandLine cmdLine;
cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("propget");
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument("svn:mergeinfo");
StringBuilder MERGED_REVISIONS_BUILD = new StringBuilder();
try (InputStream ignoreStr = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000)) {
List<String> lines = IOUtils.readLines(ignoreStr, "UTF-8");
for (String line : lines) {
for (String source : branches) {
if (line.startsWith(source + ":")) {
log.info("Found merged revisions for branch: " + source);
MERGED_REVISIONS_BUILD.append(",").append(line.substring(source.length() + 1)); // + 1 for ":"
break;
}
}
}
}
String MERGED_REVISIONS = StringUtils.removeStart(MERGED_REVISIONS_BUILD.toString(), ",");
if (MERGED_REVISIONS.equals("")) {
throw new IllegalStateException("Could not read merged revision with command " + cmdLine + " in directory " + directory);
}
// expand ranges r1-r2 into separate numbers for easier search in the string later on
List<Long> revList = new ArrayList<>();
String[] revs = MERGED_REVISIONS.split(",");
for (String rev : revs) {
if (rev.contains("-")) {
String[] revRange = rev.split("-");
if (revRange.length != 2) {
throw new IllegalStateException("Expected to have start and end of range, but had: " + rev);
}
for (long r = Long.parseLong(revRange[0]); r <= Long.parseLong(revRange[1]); r++) {
revList.add(r);
}
} else {
// non-inheritable merge adds a "*" to the rev, see https://groups.google.com/forum/?fromgroups=#!topic/subversion-svn/ArXTv1rUk5w
rev = StringUtils.removeEnd(rev, "*");
revList.add(Long.parseLong(rev));
}
}
return revList.toString();
} | [
"public",
"static",
"String",
"getMergedRevisions",
"(",
"File",
"directory",
",",
"String",
"...",
"branches",
")",
"throws",
"IOException",
"{",
"// we could also use svn mergeinfo --show-revs merged ^/trunk ^/branches/test",
"CommandLine",
"cmdLine",
";",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"propget\"",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"null",
",",
"null",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"svn:mergeinfo\"",
")",
";",
"StringBuilder",
"MERGED_REVISIONS_BUILD",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"(",
"InputStream",
"ignoreStr",
"=",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"directory",
",",
"0",
",",
"120000",
")",
")",
"{",
"List",
"<",
"String",
">",
"lines",
"=",
"IOUtils",
".",
"readLines",
"(",
"ignoreStr",
",",
"\"UTF-8\"",
")",
";",
"for",
"(",
"String",
"line",
":",
"lines",
")",
"{",
"for",
"(",
"String",
"source",
":",
"branches",
")",
"{",
"if",
"(",
"line",
".",
"startsWith",
"(",
"source",
"+",
"\":\"",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Found merged revisions for branch: \"",
"+",
"source",
")",
";",
"MERGED_REVISIONS_BUILD",
".",
"append",
"(",
"\",\"",
")",
".",
"append",
"(",
"line",
".",
"substring",
"(",
"source",
".",
"length",
"(",
")",
"+",
"1",
")",
")",
";",
"// + 1 for \":\"",
"break",
";",
"}",
"}",
"}",
"}",
"String",
"MERGED_REVISIONS",
"=",
"StringUtils",
".",
"removeStart",
"(",
"MERGED_REVISIONS_BUILD",
".",
"toString",
"(",
")",
",",
"\",\"",
")",
";",
"if",
"(",
"MERGED_REVISIONS",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not read merged revision with command \"",
"+",
"cmdLine",
"+",
"\" in directory \"",
"+",
"directory",
")",
";",
"}",
"// expand ranges r1-r2 into separate numbers for easier search in the string later on",
"List",
"<",
"Long",
">",
"revList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"[",
"]",
"revs",
"=",
"MERGED_REVISIONS",
".",
"split",
"(",
"\",\"",
")",
";",
"for",
"(",
"String",
"rev",
":",
"revs",
")",
"{",
"if",
"(",
"rev",
".",
"contains",
"(",
"\"-\"",
")",
")",
"{",
"String",
"[",
"]",
"revRange",
"=",
"rev",
".",
"split",
"(",
"\"-\"",
")",
";",
"if",
"(",
"revRange",
".",
"length",
"!=",
"2",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected to have start and end of range, but had: \"",
"+",
"rev",
")",
";",
"}",
"for",
"(",
"long",
"r",
"=",
"Long",
".",
"parseLong",
"(",
"revRange",
"[",
"0",
"]",
")",
";",
"r",
"<=",
"Long",
".",
"parseLong",
"(",
"revRange",
"[",
"1",
"]",
")",
";",
"r",
"++",
")",
"{",
"revList",
".",
"add",
"(",
"r",
")",
";",
"}",
"}",
"else",
"{",
"// non-inheritable merge adds a \"*\" to the rev, see https://groups.google.com/forum/?fromgroups=#!topic/subversion-svn/ArXTv1rUk5w",
"rev",
"=",
"StringUtils",
".",
"removeEnd",
"(",
"rev",
",",
"\"*\"",
")",
";",
"revList",
".",
"add",
"(",
"Long",
".",
"parseLong",
"(",
"rev",
")",
")",
";",
"}",
"}",
"return",
"revList",
".",
"toString",
"(",
")",
";",
"}"
] | Retrieve a list of all merged revisions.
@param directory The local working directory
@param branches The list of branches to fetch logs for
@return A string listing all SVN revision numbers that were merged, formatted via List.toString()
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Retrieve",
"a",
"list",
"of",
"all",
"merged",
"revisions",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L620-L671 |
143,504 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.revertAll | public static void revertAll(File directory) throws IOException {
log.info("Reverting SVN Working copy at " + directory);
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument(CMD_REVERT);
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument(OPT_DEPTH);
cmdLine.addArgument(INFINITY);
cmdLine.addArgument(directory.getAbsolutePath());
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000)) {
log.info("Svn-RevertAll reported:\n" + extractResult(result));
}
} | java | public static void revertAll(File directory) throws IOException {
log.info("Reverting SVN Working copy at " + directory);
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument(CMD_REVERT);
addDefaultArguments(cmdLine, null, null);
cmdLine.addArgument(OPT_DEPTH);
cmdLine.addArgument(INFINITY);
cmdLine.addArgument(directory.getAbsolutePath());
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 120000)) {
log.info("Svn-RevertAll reported:\n" + extractResult(result));
}
} | [
"public",
"static",
"void",
"revertAll",
"(",
"File",
"directory",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"\"Reverting SVN Working copy at \"",
"+",
"directory",
")",
";",
"CommandLine",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"CMD_REVERT",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"null",
",",
"null",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"OPT_DEPTH",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"INFINITY",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"directory",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"try",
"(",
"InputStream",
"result",
"=",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"directory",
",",
"0",
",",
"120000",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Svn-RevertAll reported:\\n\"",
"+",
"extractResult",
"(",
"result",
")",
")",
";",
"}",
"}"
] | Revert all changes pending in the given SVN Working Copy.
@param directory The local working directory
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Revert",
"all",
"changes",
"pending",
"in",
"the",
"given",
"SVN",
"Working",
"Copy",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L680-L693 |
143,505 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.cleanup | public static void cleanup(File directory) throws IOException {
log.info("Cleaning SVN Working copy at " + directory);
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("cleanup");
addDefaultArguments(cmdLine, null, null);
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 360000)) {
log.info("Svn-Cleanup reported:\n" + extractResult(result));
}
} | java | public static void cleanup(File directory) throws IOException {
log.info("Cleaning SVN Working copy at " + directory);
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("cleanup");
addDefaultArguments(cmdLine, null, null);
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, directory, 0, 360000)) {
log.info("Svn-Cleanup reported:\n" + extractResult(result));
}
} | [
"public",
"static",
"void",
"cleanup",
"(",
"File",
"directory",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"\"Cleaning SVN Working copy at \"",
"+",
"directory",
")",
";",
"CommandLine",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"cleanup\"",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"null",
",",
"null",
")",
";",
"try",
"(",
"InputStream",
"result",
"=",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"directory",
",",
"0",
",",
"360000",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Svn-Cleanup reported:\\n\"",
"+",
"extractResult",
"(",
"result",
")",
")",
";",
"}",
"}"
] | Run "svn cleanup" on the given working copy.
@param directory The local working directory
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Run",
"svn",
"cleanup",
"on",
"the",
"given",
"working",
"copy",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L702-L712 |
143,506 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.checkout | public static InputStream checkout(String url, File directory, String user, String pwd) throws IOException {
if (!directory.exists() && !directory.mkdirs()) {
throw new IOException("Could not create new working copy directory at " + directory);
}
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("co");
addDefaultArguments(cmdLine, user, pwd);
cmdLine.addArgument(url);
cmdLine.addArgument(directory.toString());
// allow up to two hour for new checkouts
return ExecutionHelper.getCommandResult(cmdLine, directory, -1, 2 * 60 * 60 * 1000);
} | java | public static InputStream checkout(String url, File directory, String user, String pwd) throws IOException {
if (!directory.exists() && !directory.mkdirs()) {
throw new IOException("Could not create new working copy directory at " + directory);
}
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("co");
addDefaultArguments(cmdLine, user, pwd);
cmdLine.addArgument(url);
cmdLine.addArgument(directory.toString());
// allow up to two hour for new checkouts
return ExecutionHelper.getCommandResult(cmdLine, directory, -1, 2 * 60 * 60 * 1000);
} | [
"public",
"static",
"InputStream",
"checkout",
"(",
"String",
"url",
",",
"File",
"directory",
",",
"String",
"user",
",",
"String",
"pwd",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
"&&",
"!",
"directory",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not create new working copy directory at \"",
"+",
"directory",
")",
";",
"}",
"CommandLine",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"co\"",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"user",
",",
"pwd",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"url",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"directory",
".",
"toString",
"(",
")",
")",
";",
"// allow up to two hour for new checkouts",
"return",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"directory",
",",
"-",
"1",
",",
"2",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"}"
] | Performs a SVN Checkout of the given URL to the given directory
@param url The SVN URL that should be checked out
@param directory The location where the working copy is created.
@param user The SVN user or null if the default user from the machine should be used
@param pwd The SVN password or null if the default user from the machine should be used @return The contents of the file.
@return A stream with output from the command, should be closed by the caller
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Performs",
"a",
"SVN",
"Checkout",
"of",
"the",
"given",
"URL",
"to",
"the",
"given",
"directory"
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L725-L738 |
143,507 | centic9/commons-dost | src/main/java/org/dstadler/commons/svn/SVNCommands.java | SVNCommands.copyBranch | public static void copyBranch(String base, String branch, long revision, String baseUrl) throws IOException {
log.info("Copying branch " + base + AT_REVISION + revision + " to branch " + branch);
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("cp");
addDefaultArguments(cmdLine, null, null);
if (revision > 0) {
cmdLine.addArgument("-r" + revision);
}
cmdLine.addArgument("-m");
cmdLine.addArgument("Branch automatically created from " + base + (revision > 0 ? AT_REVISION + revision : ""));
cmdLine.addArgument(baseUrl + base);
cmdLine.addArgument(baseUrl + branch);
/*
svn copy -r123 http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch
*/
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) {
log.info("Svn-Copy reported:\n" + extractResult(result));
}
} | java | public static void copyBranch(String base, String branch, long revision, String baseUrl) throws IOException {
log.info("Copying branch " + base + AT_REVISION + revision + " to branch " + branch);
CommandLine cmdLine = new CommandLine(SVN_CMD);
cmdLine.addArgument("cp");
addDefaultArguments(cmdLine, null, null);
if (revision > 0) {
cmdLine.addArgument("-r" + revision);
}
cmdLine.addArgument("-m");
cmdLine.addArgument("Branch automatically created from " + base + (revision > 0 ? AT_REVISION + revision : ""));
cmdLine.addArgument(baseUrl + base);
cmdLine.addArgument(baseUrl + branch);
/*
svn copy -r123 http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch
*/
try (InputStream result = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) {
log.info("Svn-Copy reported:\n" + extractResult(result));
}
} | [
"public",
"static",
"void",
"copyBranch",
"(",
"String",
"base",
",",
"String",
"branch",
",",
"long",
"revision",
",",
"String",
"baseUrl",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"\"Copying branch \"",
"+",
"base",
"+",
"AT_REVISION",
"+",
"revision",
"+",
"\" to branch \"",
"+",
"branch",
")",
";",
"CommandLine",
"cmdLine",
"=",
"new",
"CommandLine",
"(",
"SVN_CMD",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"cp\"",
")",
";",
"addDefaultArguments",
"(",
"cmdLine",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"revision",
">",
"0",
")",
"{",
"cmdLine",
".",
"addArgument",
"(",
"\"-r\"",
"+",
"revision",
")",
";",
"}",
"cmdLine",
".",
"addArgument",
"(",
"\"-m\"",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"\"Branch automatically created from \"",
"+",
"base",
"+",
"(",
"revision",
">",
"0",
"?",
"AT_REVISION",
"+",
"revision",
":",
"\"\"",
")",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"baseUrl",
"+",
"base",
")",
";",
"cmdLine",
".",
"addArgument",
"(",
"baseUrl",
"+",
"branch",
")",
";",
"/*\n\t\tsvn copy -r123 http://svn.example.com/repos/calc/trunk \\\n \t\thttp://svn.example.com/repos/calc/branches/my-calc-branch\n \t\t */",
"try",
"(",
"InputStream",
"result",
"=",
"ExecutionHelper",
".",
"getCommandResult",
"(",
"cmdLine",
",",
"new",
"File",
"(",
"\".\"",
")",
",",
"0",
",",
"120000",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Svn-Copy reported:\\n\"",
"+",
"extractResult",
"(",
"result",
")",
")",
";",
"}",
"}"
] | Make a branch by calling the "svn cp" operation.
@param base The source of the SVN copy operation
@param branch The name and location of the new branch
@param revision The revision to base the branch off
@param baseUrl The SVN url to connect to
@throws IOException Execution of the SVN sub-process failed or the
sub-process returned a exit value indicating a failure | [
"Make",
"a",
"branch",
"by",
"calling",
"the",
"svn",
"cp",
"operation",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/svn/SVNCommands.java#L756-L778 |
143,508 | Bedework/bw-util | bw-util-jmx/src/main/java/org/bedework/util/jmx/ConfBase.java | ConfBase.getStore | public ConfigurationStore getStore() throws ConfigException {
if (store != null) {
return store;
}
String uriStr = getConfigUri();
if (uriStr == null) {
getPfile();
String configPname = getConfigPname();
if (configPname == null) {
throw new ConfigException("Either a uri or property name must be specified");
}
uriStr = pfile.getProperty(configPname);
if (uriStr == null) {
/* If configPname ends with ".confuri" we'll take the
preceding segment as a possible directory
*/
if (configPname.endsWith(".confuri")) {
final int lastDotpos = configPname.length() - 8;
final int pos = configPname
.lastIndexOf('.', lastDotpos - 1);
if (pos > 0) {
uriStr = configPname.substring(pos + 1, lastDotpos);
}
}
}
if (uriStr == null) {
throw new ConfigException("No property with name \"" +
configPname + "\"");
}
}
try {
URI uri= new URI(uriStr);
String scheme = uri.getScheme();
if (scheme == null) {
// Possible non-absolute path
String path = uri.getPath();
File f = new File(path);
if (!f.isAbsolute() && configBase != null) {
path = configBase + path;
}
uri= new URI(path);
scheme = uri.getScheme();
}
if ((scheme == null) || (scheme.equals("file"))) {
String path = uri.getPath();
if (getPathSuffix() != null) {
if (!path.endsWith(File.separator)) {
path += File.separator;
}
path += getPathSuffix() + File.separator;
}
store = new ConfigurationFileStore(path);
return store;
}
throw new ConfigException("Unsupported ConfigurationStore: " + uri);
} catch (URISyntaxException use) {
throw new ConfigException(use);
}
} | java | public ConfigurationStore getStore() throws ConfigException {
if (store != null) {
return store;
}
String uriStr = getConfigUri();
if (uriStr == null) {
getPfile();
String configPname = getConfigPname();
if (configPname == null) {
throw new ConfigException("Either a uri or property name must be specified");
}
uriStr = pfile.getProperty(configPname);
if (uriStr == null) {
/* If configPname ends with ".confuri" we'll take the
preceding segment as a possible directory
*/
if (configPname.endsWith(".confuri")) {
final int lastDotpos = configPname.length() - 8;
final int pos = configPname
.lastIndexOf('.', lastDotpos - 1);
if (pos > 0) {
uriStr = configPname.substring(pos + 1, lastDotpos);
}
}
}
if (uriStr == null) {
throw new ConfigException("No property with name \"" +
configPname + "\"");
}
}
try {
URI uri= new URI(uriStr);
String scheme = uri.getScheme();
if (scheme == null) {
// Possible non-absolute path
String path = uri.getPath();
File f = new File(path);
if (!f.isAbsolute() && configBase != null) {
path = configBase + path;
}
uri= new URI(path);
scheme = uri.getScheme();
}
if ((scheme == null) || (scheme.equals("file"))) {
String path = uri.getPath();
if (getPathSuffix() != null) {
if (!path.endsWith(File.separator)) {
path += File.separator;
}
path += getPathSuffix() + File.separator;
}
store = new ConfigurationFileStore(path);
return store;
}
throw new ConfigException("Unsupported ConfigurationStore: " + uri);
} catch (URISyntaxException use) {
throw new ConfigException(use);
}
} | [
"public",
"ConfigurationStore",
"getStore",
"(",
")",
"throws",
"ConfigException",
"{",
"if",
"(",
"store",
"!=",
"null",
")",
"{",
"return",
"store",
";",
"}",
"String",
"uriStr",
"=",
"getConfigUri",
"(",
")",
";",
"if",
"(",
"uriStr",
"==",
"null",
")",
"{",
"getPfile",
"(",
")",
";",
"String",
"configPname",
"=",
"getConfigPname",
"(",
")",
";",
"if",
"(",
"configPname",
"==",
"null",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"Either a uri or property name must be specified\"",
")",
";",
"}",
"uriStr",
"=",
"pfile",
".",
"getProperty",
"(",
"configPname",
")",
";",
"if",
"(",
"uriStr",
"==",
"null",
")",
"{",
"/* If configPname ends with \".confuri\" we'll take the \n preceding segment as a possible directory\n */",
"if",
"(",
"configPname",
".",
"endsWith",
"(",
"\".confuri\"",
")",
")",
"{",
"final",
"int",
"lastDotpos",
"=",
"configPname",
".",
"length",
"(",
")",
"-",
"8",
";",
"final",
"int",
"pos",
"=",
"configPname",
".",
"lastIndexOf",
"(",
"'",
"'",
",",
"lastDotpos",
"-",
"1",
")",
";",
"if",
"(",
"pos",
">",
"0",
")",
"{",
"uriStr",
"=",
"configPname",
".",
"substring",
"(",
"pos",
"+",
"1",
",",
"lastDotpos",
")",
";",
"}",
"}",
"}",
"if",
"(",
"uriStr",
"==",
"null",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"No property with name \\\"\"",
"+",
"configPname",
"+",
"\"\\\"\"",
")",
";",
"}",
"}",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"uriStr",
")",
";",
"String",
"scheme",
"=",
"uri",
".",
"getScheme",
"(",
")",
";",
"if",
"(",
"scheme",
"==",
"null",
")",
"{",
"// Possible non-absolute path",
"String",
"path",
"=",
"uri",
".",
"getPath",
"(",
")",
";",
"File",
"f",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"!",
"f",
".",
"isAbsolute",
"(",
")",
"&&",
"configBase",
"!=",
"null",
")",
"{",
"path",
"=",
"configBase",
"+",
"path",
";",
"}",
"uri",
"=",
"new",
"URI",
"(",
"path",
")",
";",
"scheme",
"=",
"uri",
".",
"getScheme",
"(",
")",
";",
"}",
"if",
"(",
"(",
"scheme",
"==",
"null",
")",
"||",
"(",
"scheme",
".",
"equals",
"(",
"\"file\"",
")",
")",
")",
"{",
"String",
"path",
"=",
"uri",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"getPathSuffix",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"path",
".",
"endsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"path",
"+=",
"File",
".",
"separator",
";",
"}",
"path",
"+=",
"getPathSuffix",
"(",
")",
"+",
"File",
".",
"separator",
";",
"}",
"store",
"=",
"new",
"ConfigurationFileStore",
"(",
"path",
")",
";",
"return",
"store",
";",
"}",
"throw",
"new",
"ConfigException",
"(",
"\"Unsupported ConfigurationStore: \"",
"+",
"uri",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"use",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"use",
")",
";",
"}",
"}"
] | Get a ConfigurationStore based on the uri or property value.
@return store
@throws ConfigException | [
"Get",
"a",
"ConfigurationStore",
"based",
"on",
"the",
"uri",
"or",
"property",
"value",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jmx/src/main/java/org/bedework/util/jmx/ConfBase.java#L271-L345 |
143,509 | Bedework/bw-util | bw-util-jmx/src/main/java/org/bedework/util/jmx/ConfBase.java | ConfBase.loadOnlyConfig | protected String loadOnlyConfig(final Class<T> cl) {
try {
/* Load up the config */
ConfigurationStore cs = getStore();
List<String> configNames = cs.getConfigs();
if (configNames.isEmpty()) {
error("No configuration on path " + cs.getLocation());
return "No configuration on path " + cs.getLocation();
}
if (configNames.size() != 1) {
error("1 and only 1 configuration allowed");
return "1 and only 1 configuration allowed";
}
String configName = configNames.iterator().next();
cfg = getConfigInfo(cs, configName, cl);
if (cfg == null) {
error("Unable to read configuration");
return "Unable to read configuration";
}
setConfigName(configName);
return null;
} catch (Throwable t) {
error("Failed to load configuration: " + t.getLocalizedMessage());
error(t);
return "failed";
}
} | java | protected String loadOnlyConfig(final Class<T> cl) {
try {
/* Load up the config */
ConfigurationStore cs = getStore();
List<String> configNames = cs.getConfigs();
if (configNames.isEmpty()) {
error("No configuration on path " + cs.getLocation());
return "No configuration on path " + cs.getLocation();
}
if (configNames.size() != 1) {
error("1 and only 1 configuration allowed");
return "1 and only 1 configuration allowed";
}
String configName = configNames.iterator().next();
cfg = getConfigInfo(cs, configName, cl);
if (cfg == null) {
error("Unable to read configuration");
return "Unable to read configuration";
}
setConfigName(configName);
return null;
} catch (Throwable t) {
error("Failed to load configuration: " + t.getLocalizedMessage());
error(t);
return "failed";
}
} | [
"protected",
"String",
"loadOnlyConfig",
"(",
"final",
"Class",
"<",
"T",
">",
"cl",
")",
"{",
"try",
"{",
"/* Load up the config */",
"ConfigurationStore",
"cs",
"=",
"getStore",
"(",
")",
";",
"List",
"<",
"String",
">",
"configNames",
"=",
"cs",
".",
"getConfigs",
"(",
")",
";",
"if",
"(",
"configNames",
".",
"isEmpty",
"(",
")",
")",
"{",
"error",
"(",
"\"No configuration on path \"",
"+",
"cs",
".",
"getLocation",
"(",
")",
")",
";",
"return",
"\"No configuration on path \"",
"+",
"cs",
".",
"getLocation",
"(",
")",
";",
"}",
"if",
"(",
"configNames",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"error",
"(",
"\"1 and only 1 configuration allowed\"",
")",
";",
"return",
"\"1 and only 1 configuration allowed\"",
";",
"}",
"String",
"configName",
"=",
"configNames",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"cfg",
"=",
"getConfigInfo",
"(",
"cs",
",",
"configName",
",",
"cl",
")",
";",
"if",
"(",
"cfg",
"==",
"null",
")",
"{",
"error",
"(",
"\"Unable to read configuration\"",
")",
";",
"return",
"\"Unable to read configuration\"",
";",
"}",
"setConfigName",
"(",
"configName",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"error",
"(",
"\"Failed to load configuration: \"",
"+",
"t",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"error",
"(",
"t",
")",
";",
"return",
"\"failed\"",
";",
"}",
"}"
] | Load the configuration if we only expect one and we don't care or know
what it's called.
@param cl
@return null for success or an error message (logged already) | [
"Load",
"the",
"configuration",
"if",
"we",
"only",
"expect",
"one",
"and",
"we",
"don",
"t",
"care",
"or",
"know",
"what",
"it",
"s",
"called",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jmx/src/main/java/org/bedework/util/jmx/ConfBase.java#L597-L632 |
143,510 | sebastiangraf/treetank | coremodules/core/src/main/java/org/treetank/access/conf/StorageConfiguration.java | StorageConfiguration.deserialize | public static StorageConfiguration deserialize(final File pFile) throws TTIOException {
try {
FileReader fileReader = new FileReader(new File(pFile, Paths.ConfigBinary.getFile().getName()));
JsonReader jsonReader = new JsonReader(fileReader);
jsonReader.beginObject();
jsonReader.nextName();
File file = new File(jsonReader.nextString());
jsonReader.endObject();
jsonReader.close();
fileReader.close();
return new StorageConfiguration(file);
} catch (IOException ioexc) {
throw new TTIOException(ioexc);
}
} | java | public static StorageConfiguration deserialize(final File pFile) throws TTIOException {
try {
FileReader fileReader = new FileReader(new File(pFile, Paths.ConfigBinary.getFile().getName()));
JsonReader jsonReader = new JsonReader(fileReader);
jsonReader.beginObject();
jsonReader.nextName();
File file = new File(jsonReader.nextString());
jsonReader.endObject();
jsonReader.close();
fileReader.close();
return new StorageConfiguration(file);
} catch (IOException ioexc) {
throw new TTIOException(ioexc);
}
} | [
"public",
"static",
"StorageConfiguration",
"deserialize",
"(",
"final",
"File",
"pFile",
")",
"throws",
"TTIOException",
"{",
"try",
"{",
"FileReader",
"fileReader",
"=",
"new",
"FileReader",
"(",
"new",
"File",
"(",
"pFile",
",",
"Paths",
".",
"ConfigBinary",
".",
"getFile",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
";",
"JsonReader",
"jsonReader",
"=",
"new",
"JsonReader",
"(",
"fileReader",
")",
";",
"jsonReader",
".",
"beginObject",
"(",
")",
";",
"jsonReader",
".",
"nextName",
"(",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"jsonReader",
".",
"nextString",
"(",
")",
")",
";",
"jsonReader",
".",
"endObject",
"(",
")",
";",
"jsonReader",
".",
"close",
"(",
")",
";",
"fileReader",
".",
"close",
"(",
")",
";",
"return",
"new",
"StorageConfiguration",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioexc",
")",
"{",
"throw",
"new",
"TTIOException",
"(",
"ioexc",
")",
";",
"}",
"}"
] | Generate a StorageConfiguration out of a file.
@param pFile
where the StorageConfiguration lies in as json
@return a new {@link StorageConfiguration} class
@throws TTIOException | [
"Generate",
"a",
"StorageConfiguration",
"out",
"of",
"a",
"file",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/core/src/main/java/org/treetank/access/conf/StorageConfiguration.java#L172-L186 |
143,511 | Bedework/bw-util | bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java | ConfigBase.getProperty | @ConfInfo(dontSave = true)
public String getProperty(final Collection<String> col,
final String name) {
String key = name + "=";
for (String p: col) {
if (p.startsWith(key)) {
return p.substring(key.length());
}
}
return null;
} | java | @ConfInfo(dontSave = true)
public String getProperty(final Collection<String> col,
final String name) {
String key = name + "=";
for (String p: col) {
if (p.startsWith(key)) {
return p.substring(key.length());
}
}
return null;
} | [
"@",
"ConfInfo",
"(",
"dontSave",
"=",
"true",
")",
"public",
"String",
"getProperty",
"(",
"final",
"Collection",
"<",
"String",
">",
"col",
",",
"final",
"String",
"name",
")",
"{",
"String",
"key",
"=",
"name",
"+",
"\"=\"",
";",
"for",
"(",
"String",
"p",
":",
"col",
")",
"{",
"if",
"(",
"p",
".",
"startsWith",
"(",
"key",
")",
")",
"{",
"return",
"p",
".",
"substring",
"(",
"key",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get a property stored as a String name = val
@param col of property name+val
@param name
@return value or null | [
"Get",
"a",
"property",
"stored",
"as",
"a",
"String",
"name",
"=",
"val"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java#L206-L217 |
143,512 | Bedework/bw-util | bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java | ConfigBase.removeProperty | public void removeProperty(final Collection<String> col,
final String name) {
try {
String v = getProperty(col, name);
if (v == null) {
return;
}
col.remove(name + "=" + v);
} catch (Throwable t) {
throw new RuntimeException(t);
}
} | java | public void removeProperty(final Collection<String> col,
final String name) {
try {
String v = getProperty(col, name);
if (v == null) {
return;
}
col.remove(name + "=" + v);
} catch (Throwable t) {
throw new RuntimeException(t);
}
} | [
"public",
"void",
"removeProperty",
"(",
"final",
"Collection",
"<",
"String",
">",
"col",
",",
"final",
"String",
"name",
")",
"{",
"try",
"{",
"String",
"v",
"=",
"getProperty",
"(",
"col",
",",
"name",
")",
";",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"return",
";",
"}",
"col",
".",
"remove",
"(",
"name",
"+",
"\"=\"",
"+",
"v",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"t",
")",
";",
"}",
"}"
] | Remove a property stored as a String name = val
@param col
@param name | [
"Remove",
"a",
"property",
"stored",
"as",
"a",
"String",
"name",
"=",
"val"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java#L224-L237 |
143,513 | Bedework/bw-util | bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java | ConfigBase.setListProperty | @SuppressWarnings("unchecked")
public <L extends List> L setListProperty(final L list,
final String name,
final String val) {
removeProperty(list, name);
return addListProperty(list, name, val);
} | java | @SuppressWarnings("unchecked")
public <L extends List> L setListProperty(final L list,
final String name,
final String val) {
removeProperty(list, name);
return addListProperty(list, name, val);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"L",
"extends",
"List",
">",
"L",
"setListProperty",
"(",
"final",
"L",
"list",
",",
"final",
"String",
"name",
",",
"final",
"String",
"val",
")",
"{",
"removeProperty",
"(",
"list",
",",
"name",
")",
";",
"return",
"addListProperty",
"(",
"list",
",",
"name",
",",
"val",
")",
";",
"}"
] | Set a property
@param list the list - possibly null
@param name of property
@param val of property
@return possibly newly created list | [
"Set",
"a",
"property"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java#L246-L252 |
143,514 | Bedework/bw-util | bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java | ConfigBase.toXml | public void toXml(final Writer wtr) throws ConfigException {
try {
XmlEmit xml = new XmlEmit();
xml.addNs(new NameSpace(ns, "BW"), true);
xml.startEmit(wtr);
dump(xml, false);
xml.flush();
} catch (ConfigException cfe) {
throw cfe;
} catch (Throwable t) {
throw new ConfigException(t);
}
} | java | public void toXml(final Writer wtr) throws ConfigException {
try {
XmlEmit xml = new XmlEmit();
xml.addNs(new NameSpace(ns, "BW"), true);
xml.startEmit(wtr);
dump(xml, false);
xml.flush();
} catch (ConfigException cfe) {
throw cfe;
} catch (Throwable t) {
throw new ConfigException(t);
}
} | [
"public",
"void",
"toXml",
"(",
"final",
"Writer",
"wtr",
")",
"throws",
"ConfigException",
"{",
"try",
"{",
"XmlEmit",
"xml",
"=",
"new",
"XmlEmit",
"(",
")",
";",
"xml",
".",
"addNs",
"(",
"new",
"NameSpace",
"(",
"ns",
",",
"\"BW\"",
")",
",",
"true",
")",
";",
"xml",
".",
"startEmit",
"(",
"wtr",
")",
";",
"dump",
"(",
"xml",
",",
"false",
")",
";",
"xml",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"ConfigException",
"cfe",
")",
"{",
"throw",
"cfe",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"t",
")",
";",
"}",
"}"
] | Output to a writer
@param wtr
@throws ConfigException | [
"Output",
"to",
"a",
"writer"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java#L287-L300 |
143,515 | Bedework/bw-util | bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java | ConfigBase.fromXml | public ConfigBase fromXml(final InputStream is,
final Class cl) throws ConfigException {
try {
return fromXml(parseXml(is), cl);
} catch (final ConfigException ce) {
throw ce;
} catch (final Throwable t) {
throw new ConfigException(t);
}
} | java | public ConfigBase fromXml(final InputStream is,
final Class cl) throws ConfigException {
try {
return fromXml(parseXml(is), cl);
} catch (final ConfigException ce) {
throw ce;
} catch (final Throwable t) {
throw new ConfigException(t);
}
} | [
"public",
"ConfigBase",
"fromXml",
"(",
"final",
"InputStream",
"is",
",",
"final",
"Class",
"cl",
")",
"throws",
"ConfigException",
"{",
"try",
"{",
"return",
"fromXml",
"(",
"parseXml",
"(",
"is",
")",
",",
"cl",
")",
";",
"}",
"catch",
"(",
"final",
"ConfigException",
"ce",
")",
"{",
"throw",
"ce",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"t",
")",
";",
"}",
"}"
] | XML root element must have type attribute if cl is null
@param is an input stream
@param cl class of object or null
@return parsed notification or null
@throws ConfigException on error | [
"XML",
"root",
"element",
"must",
"have",
"type",
"attribute",
"if",
"cl",
"is",
"null"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java#L319-L328 |
143,516 | Bedework/bw-util | bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java | ConfigBase.fromXml | public ConfigBase fromXml(final Element rootEl,
final Class cl) throws ConfigException {
try {
final ConfigBase cb = (ConfigBase)getObject(rootEl, cl);
if (cb == null) {
// Can't do this
return null;
}
for (final Element el: XmlUtil.getElementsArray(rootEl)) {
populate(el, cb, null, null);
}
return cb;
} catch (final ConfigException ce) {
throw ce;
} catch (final Throwable t) {
throw new ConfigException(t);
}
} | java | public ConfigBase fromXml(final Element rootEl,
final Class cl) throws ConfigException {
try {
final ConfigBase cb = (ConfigBase)getObject(rootEl, cl);
if (cb == null) {
// Can't do this
return null;
}
for (final Element el: XmlUtil.getElementsArray(rootEl)) {
populate(el, cb, null, null);
}
return cb;
} catch (final ConfigException ce) {
throw ce;
} catch (final Throwable t) {
throw new ConfigException(t);
}
} | [
"public",
"ConfigBase",
"fromXml",
"(",
"final",
"Element",
"rootEl",
",",
"final",
"Class",
"cl",
")",
"throws",
"ConfigException",
"{",
"try",
"{",
"final",
"ConfigBase",
"cb",
"=",
"(",
"ConfigBase",
")",
"getObject",
"(",
"rootEl",
",",
"cl",
")",
";",
"if",
"(",
"cb",
"==",
"null",
")",
"{",
"// Can't do this",
"return",
"null",
";",
"}",
"for",
"(",
"final",
"Element",
"el",
":",
"XmlUtil",
".",
"getElementsArray",
"(",
"rootEl",
")",
")",
"{",
"populate",
"(",
"el",
",",
"cb",
",",
"null",
",",
"null",
")",
";",
"}",
"return",
"cb",
";",
"}",
"catch",
"(",
"final",
"ConfigException",
"ce",
")",
"{",
"throw",
"ce",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"t",
")",
";",
"}",
"}"
] | XML root element must have type attribute
@param rootEl - root of parsed document
@param cl class of object or null
@return parsed notification or null
@throws ConfigException on error | [
"XML",
"root",
"element",
"must",
"have",
"type",
"attribute"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-config/src/main/java/org/bedework/util/config/ConfigBase.java#L337-L357 |
143,517 | Bedework/bw-util | bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/XSLTFilter.java | XSLTFilter.setPath | public void setPath(final String ideal, final String actual) {
synchronized (transformers) {
pathMap.put(ideal, actual);
}
} | java | public void setPath(final String ideal, final String actual) {
synchronized (transformers) {
pathMap.put(ideal, actual);
}
} | [
"public",
"void",
"setPath",
"(",
"final",
"String",
"ideal",
",",
"final",
"String",
"actual",
")",
"{",
"synchronized",
"(",
"transformers",
")",
"{",
"pathMap",
".",
"put",
"(",
"ideal",
",",
"actual",
")",
";",
"}",
"}"
] | Set ideal to actual mapping.
@param ideal
@param actual | [
"Set",
"ideal",
"to",
"actual",
"mapping",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/XSLTFilter.java#L126-L130 |
143,518 | centic9/commons-dost | src/main/java/org/dstadler/commons/logging/jdk/LoggerFactory.java | LoggerFactory.initLogging | public static void initLogging() throws IOException {
sendCommonsLogToJDKLog();
try (InputStream resource = Thread.currentThread().getContextClassLoader().getResourceAsStream("logging.properties")) {
// apply configuration
if(resource != null) {
try {
LogManager.getLogManager().readConfiguration(resource);
} finally {
resource.close();
}
}
// apply a default format to the log handlers here before throwing an exception further down
Logger log = Logger.getLogger(""); // NOSONAR - local logger used on purpose here
for (Handler handler : log.getHandlers()) {
handler.setFormatter(new DefaultFormatter());
}
if(resource == null) {
throw new IOException("Did not find a file 'logging.properties' in the classpath");
}
}
} | java | public static void initLogging() throws IOException {
sendCommonsLogToJDKLog();
try (InputStream resource = Thread.currentThread().getContextClassLoader().getResourceAsStream("logging.properties")) {
// apply configuration
if(resource != null) {
try {
LogManager.getLogManager().readConfiguration(resource);
} finally {
resource.close();
}
}
// apply a default format to the log handlers here before throwing an exception further down
Logger log = Logger.getLogger(""); // NOSONAR - local logger used on purpose here
for (Handler handler : log.getHandlers()) {
handler.setFormatter(new DefaultFormatter());
}
if(resource == null) {
throw new IOException("Did not find a file 'logging.properties' in the classpath");
}
}
} | [
"public",
"static",
"void",
"initLogging",
"(",
")",
"throws",
"IOException",
"{",
"sendCommonsLogToJDKLog",
"(",
")",
";",
"try",
"(",
"InputStream",
"resource",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"logging.properties\"",
")",
")",
"{",
"// apply configuration",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"try",
"{",
"LogManager",
".",
"getLogManager",
"(",
")",
".",
"readConfiguration",
"(",
"resource",
")",
";",
"}",
"finally",
"{",
"resource",
".",
"close",
"(",
")",
";",
"}",
"}",
"// apply a default format to the log handlers here before throwing an exception further down",
"Logger",
"log",
"=",
"Logger",
".",
"getLogger",
"(",
"\"\"",
")",
";",
"// NOSONAR - local logger used on purpose here",
"for",
"(",
"Handler",
"handler",
":",
"log",
".",
"getHandlers",
"(",
")",
")",
"{",
"handler",
".",
"setFormatter",
"(",
"new",
"DefaultFormatter",
"(",
")",
")",
";",
"}",
"if",
"(",
"resource",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Did not find a file 'logging.properties' in the classpath\"",
")",
";",
"}",
"}",
"}"
] | Initialize Logging from a file "logging.properties" which needs to be found in the classpath.
It also applies a default format to make JDK Logging use a more useful format for log messages.
Note: Call this method at the very first after main
@throws IOException If the file "logging.properties" is not found in the classpath.
@author dstadler | [
"Initialize",
"Logging",
"from",
"a",
"file",
"logging",
".",
"properties",
"which",
"needs",
"to",
"be",
"found",
"in",
"the",
"classpath",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/logging/jdk/LoggerFactory.java#L55-L78 |
143,519 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/Matching.java | Matching.add | public void add(final ITreeData paramNodeX, final ITreeData paramNodeY) throws TTIOException {
mMapping.put(paramNodeX, paramNodeY);
mReverseMapping.put(paramNodeY, paramNodeX);
updateSubtreeMap(paramNodeX, mRtxNew);
updateSubtreeMap(paramNodeY, mRtxOld);
} | java | public void add(final ITreeData paramNodeX, final ITreeData paramNodeY) throws TTIOException {
mMapping.put(paramNodeX, paramNodeY);
mReverseMapping.put(paramNodeY, paramNodeX);
updateSubtreeMap(paramNodeX, mRtxNew);
updateSubtreeMap(paramNodeY, mRtxOld);
} | [
"public",
"void",
"add",
"(",
"final",
"ITreeData",
"paramNodeX",
",",
"final",
"ITreeData",
"paramNodeY",
")",
"throws",
"TTIOException",
"{",
"mMapping",
".",
"put",
"(",
"paramNodeX",
",",
"paramNodeY",
")",
";",
"mReverseMapping",
".",
"put",
"(",
"paramNodeY",
",",
"paramNodeX",
")",
";",
"updateSubtreeMap",
"(",
"paramNodeX",
",",
"mRtxNew",
")",
";",
"updateSubtreeMap",
"(",
"paramNodeY",
",",
"mRtxOld",
")",
";",
"}"
] | Adds the matching x -> y.
@param paramNodeX
source node
@param paramNodeY
partner of paramNodeX
@throws TTIOException | [
"Adds",
"the",
"matching",
"x",
"-",
">",
"y",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/Matching.java#L106-L111 |
143,520 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/Matching.java | Matching.containedChildren | public long containedChildren(final ITreeData paramNodeX, final ITreeData paramNodeY) throws TTIOException {
assert paramNodeX != null;
assert paramNodeY != null;
long retVal = 0;
mRtxOld.moveTo(paramNodeX.getDataKey());
for (final AbsAxis axis = new DescendantAxis(mRtxOld, true); axis.hasNext(); axis.next()) {
retVal += mIsInSubtree.get(paramNodeY, partner(mRtxOld.getNode())) ? 1 : 0;
}
return retVal;
} | java | public long containedChildren(final ITreeData paramNodeX, final ITreeData paramNodeY) throws TTIOException {
assert paramNodeX != null;
assert paramNodeY != null;
long retVal = 0;
mRtxOld.moveTo(paramNodeX.getDataKey());
for (final AbsAxis axis = new DescendantAxis(mRtxOld, true); axis.hasNext(); axis.next()) {
retVal += mIsInSubtree.get(paramNodeY, partner(mRtxOld.getNode())) ? 1 : 0;
}
return retVal;
} | [
"public",
"long",
"containedChildren",
"(",
"final",
"ITreeData",
"paramNodeX",
",",
"final",
"ITreeData",
"paramNodeY",
")",
"throws",
"TTIOException",
"{",
"assert",
"paramNodeX",
"!=",
"null",
";",
"assert",
"paramNodeY",
"!=",
"null",
";",
"long",
"retVal",
"=",
"0",
";",
"mRtxOld",
".",
"moveTo",
"(",
"paramNodeX",
".",
"getDataKey",
"(",
")",
")",
";",
"for",
"(",
"final",
"AbsAxis",
"axis",
"=",
"new",
"DescendantAxis",
"(",
"mRtxOld",
",",
"true",
")",
";",
"axis",
".",
"hasNext",
"(",
")",
";",
"axis",
".",
"next",
"(",
")",
")",
"{",
"retVal",
"+=",
"mIsInSubtree",
".",
"get",
"(",
"paramNodeY",
",",
"partner",
"(",
"mRtxOld",
".",
"getNode",
"(",
")",
")",
")",
"?",
"1",
":",
"0",
";",
"}",
"return",
"retVal",
";",
"}"
] | Counts the number of child nodes in the subtrees of x and y that are also
in the matching.
@param paramNodeX
first subtree root node
@param paramNodeY
second subtree root node
@return number of children which have been matched
@throws TTIOException | [
"Counts",
"the",
"number",
"of",
"child",
"nodes",
"in",
"the",
"subtrees",
"of",
"x",
"and",
"y",
"that",
"are",
"also",
"in",
"the",
"matching",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/Matching.java#L160-L171 |
143,521 | Bedework/bw-util | bw-util-servlet/src/main/java/org/bedework/util/servlet/MethodBase.java | MethodBase.fixPath | public static List<String> fixPath(final String path) throws ServletException {
if (path == null) {
return null;
}
String decoded;
try {
decoded = URLDecoder.decode(path, "UTF8");
} catch (Throwable t) {
throw new ServletException("bad path: " + path);
}
if (decoded == null) {
return (null);
}
/** Make any backslashes into forward slashes.
*/
if (decoded.indexOf('\\') >= 0) {
decoded = decoded.replace('\\', '/');
}
/** Ensure a leading '/'
*/
if (!decoded.startsWith("/")) {
decoded = "/" + decoded;
}
/** Remove all instances of '//'.
*/
while (decoded.contains("//")) {
decoded = decoded.replaceAll("//", "/");
}
/** Somewhere we may have /./ or /../
*/
final StringTokenizer st = new StringTokenizer(decoded, "/");
ArrayList<String> al = new ArrayList<String>();
while (st.hasMoreTokens()) {
String s = st.nextToken();
if (s.equals(".")) {
// ignore
} else if (s.equals("..")) {
// Back up 1
if (al.size() == 0) {
// back too far
return null;
}
al.remove(al.size() - 1);
} else {
al.add(s);
}
}
return al;
} | java | public static List<String> fixPath(final String path) throws ServletException {
if (path == null) {
return null;
}
String decoded;
try {
decoded = URLDecoder.decode(path, "UTF8");
} catch (Throwable t) {
throw new ServletException("bad path: " + path);
}
if (decoded == null) {
return (null);
}
/** Make any backslashes into forward slashes.
*/
if (decoded.indexOf('\\') >= 0) {
decoded = decoded.replace('\\', '/');
}
/** Ensure a leading '/'
*/
if (!decoded.startsWith("/")) {
decoded = "/" + decoded;
}
/** Remove all instances of '//'.
*/
while (decoded.contains("//")) {
decoded = decoded.replaceAll("//", "/");
}
/** Somewhere we may have /./ or /../
*/
final StringTokenizer st = new StringTokenizer(decoded, "/");
ArrayList<String> al = new ArrayList<String>();
while (st.hasMoreTokens()) {
String s = st.nextToken();
if (s.equals(".")) {
// ignore
} else if (s.equals("..")) {
// Back up 1
if (al.size() == 0) {
// back too far
return null;
}
al.remove(al.size() - 1);
} else {
al.add(s);
}
}
return al;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"fixPath",
"(",
"final",
"String",
"path",
")",
"throws",
"ServletException",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"decoded",
";",
"try",
"{",
"decoded",
"=",
"URLDecoder",
".",
"decode",
"(",
"path",
",",
"\"UTF8\"",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"ServletException",
"(",
"\"bad path: \"",
"+",
"path",
")",
";",
"}",
"if",
"(",
"decoded",
"==",
"null",
")",
"{",
"return",
"(",
"null",
")",
";",
"}",
"/** Make any backslashes into forward slashes.\n */",
"if",
"(",
"decoded",
".",
"indexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
"{",
"decoded",
"=",
"decoded",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"}",
"/** Ensure a leading '/'\n */",
"if",
"(",
"!",
"decoded",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"decoded",
"=",
"\"/\"",
"+",
"decoded",
";",
"}",
"/** Remove all instances of '//'.\n */",
"while",
"(",
"decoded",
".",
"contains",
"(",
"\"//\"",
")",
")",
"{",
"decoded",
"=",
"decoded",
".",
"replaceAll",
"(",
"\"//\"",
",",
"\"/\"",
")",
";",
"}",
"/** Somewhere we may have /./ or /../\n */",
"final",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"decoded",
",",
"\"/\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"al",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"s",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"s",
".",
"equals",
"(",
"\".\"",
")",
")",
"{",
"// ignore",
"}",
"else",
"if",
"(",
"s",
".",
"equals",
"(",
"\"..\"",
")",
")",
"{",
"// Back up 1",
"if",
"(",
"al",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// back too far",
"return",
"null",
";",
"}",
"al",
".",
"remove",
"(",
"al",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"else",
"{",
"al",
".",
"add",
"(",
"s",
")",
";",
"}",
"}",
"return",
"al",
";",
"}"
] | Return a path, broken into its elements, after "." and ".." are removed.
If the parameter path attempts to go above the root we return null.
Other than the backslash thing why not use URI?
@param path String path to be fixed
@return String[] fixed path broken into elements
@throws ServletException | [
"Return",
"a",
"path",
"broken",
"into",
"its",
"elements",
"after",
".",
"and",
"..",
"are",
"removed",
".",
"If",
"the",
"parameter",
"path",
"attempts",
"to",
"go",
"above",
"the",
"root",
"we",
"return",
"null",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet/src/main/java/org/bedework/util/servlet/MethodBase.java#L192-L251 |
143,522 | Bedework/bw-util | bw-util-servlet/src/main/java/org/bedework/util/servlet/MethodBase.java | MethodBase.readJson | protected Object readJson(final InputStream is,
final Class cl,
final HttpServletResponse resp) throws ServletException {
if (is == null) {
return null;
}
try {
return getMapper().readValue(is, cl);
} catch (Throwable t) {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
if (debug()) {
error(t);
}
throw new ServletException(t);
}
} | java | protected Object readJson(final InputStream is,
final Class cl,
final HttpServletResponse resp) throws ServletException {
if (is == null) {
return null;
}
try {
return getMapper().readValue(is, cl);
} catch (Throwable t) {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
if (debug()) {
error(t);
}
throw new ServletException(t);
}
} | [
"protected",
"Object",
"readJson",
"(",
"final",
"InputStream",
"is",
",",
"final",
"Class",
"cl",
",",
"final",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
"{",
"if",
"(",
"is",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"getMapper",
"(",
")",
".",
"readValue",
"(",
"is",
",",
"cl",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"resp",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_INTERNAL_SERVER_ERROR",
")",
";",
"if",
"(",
"debug",
"(",
")",
")",
"{",
"error",
"(",
"t",
")",
";",
"}",
"throw",
"new",
"ServletException",
"(",
"t",
")",
";",
"}",
"}"
] | Parse the request body, and return the object.
@param is Input stream for content
@param cl The class we expect
@param resp for status
@return Object Parsed body or null for no body
@exception ServletException Some error occurred. | [
"Parse",
"the",
"request",
"body",
"and",
"return",
"the",
"object",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet/src/main/java/org/bedework/util/servlet/MethodBase.java#L295-L311 |
143,523 | centic9/commons-dost | src/main/java/org/dstadler/commons/date/DateParser.java | DateParser.timeToReadable | public static String timeToReadable(long millis, String suffix) {
StringBuilder builder = new StringBuilder();
boolean haveDays = false;
if(millis > ONE_DAY) {
millis = handleTime(builder, millis, ONE_DAY, "day", "s");
haveDays = true;
}
boolean haveHours = false;
if(millis >= ONE_HOUR) {
millis = handleTime(builder, millis, ONE_HOUR, "h", "");
haveHours = true;
}
if((!haveDays || !haveHours) && millis >= ONE_MINUTE) {
millis = handleTime(builder, millis, ONE_MINUTE, "min", "");
}
if(!haveDays && !haveHours && millis >= ONE_SECOND) {
/*millis =*/ handleTime(builder, millis, ONE_SECOND, "s", "");
}
if(builder.length() > 0) {
// cut off trailing ", "
builder.setLength(builder.length() - 2);
builder.append(suffix);
}
return builder.toString();
} | java | public static String timeToReadable(long millis, String suffix) {
StringBuilder builder = new StringBuilder();
boolean haveDays = false;
if(millis > ONE_DAY) {
millis = handleTime(builder, millis, ONE_DAY, "day", "s");
haveDays = true;
}
boolean haveHours = false;
if(millis >= ONE_HOUR) {
millis = handleTime(builder, millis, ONE_HOUR, "h", "");
haveHours = true;
}
if((!haveDays || !haveHours) && millis >= ONE_MINUTE) {
millis = handleTime(builder, millis, ONE_MINUTE, "min", "");
}
if(!haveDays && !haveHours && millis >= ONE_SECOND) {
/*millis =*/ handleTime(builder, millis, ONE_SECOND, "s", "");
}
if(builder.length() > 0) {
// cut off trailing ", "
builder.setLength(builder.length() - 2);
builder.append(suffix);
}
return builder.toString();
} | [
"public",
"static",
"String",
"timeToReadable",
"(",
"long",
"millis",
",",
"String",
"suffix",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"haveDays",
"=",
"false",
";",
"if",
"(",
"millis",
">",
"ONE_DAY",
")",
"{",
"millis",
"=",
"handleTime",
"(",
"builder",
",",
"millis",
",",
"ONE_DAY",
",",
"\"day\"",
",",
"\"s\"",
")",
";",
"haveDays",
"=",
"true",
";",
"}",
"boolean",
"haveHours",
"=",
"false",
";",
"if",
"(",
"millis",
">=",
"ONE_HOUR",
")",
"{",
"millis",
"=",
"handleTime",
"(",
"builder",
",",
"millis",
",",
"ONE_HOUR",
",",
"\"h\"",
",",
"\"\"",
")",
";",
"haveHours",
"=",
"true",
";",
"}",
"if",
"(",
"(",
"!",
"haveDays",
"||",
"!",
"haveHours",
")",
"&&",
"millis",
">=",
"ONE_MINUTE",
")",
"{",
"millis",
"=",
"handleTime",
"(",
"builder",
",",
"millis",
",",
"ONE_MINUTE",
",",
"\"min\"",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"!",
"haveDays",
"&&",
"!",
"haveHours",
"&&",
"millis",
">=",
"ONE_SECOND",
")",
"{",
"/*millis =*/",
"handleTime",
"(",
"builder",
",",
"millis",
",",
"ONE_SECOND",
",",
"\"s\"",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"builder",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"// cut off trailing \", \"",
"builder",
".",
"setLength",
"(",
"builder",
".",
"length",
"(",
")",
"-",
"2",
")",
";",
"builder",
".",
"append",
"(",
"suffix",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Format the given number of milliseconds as readable string, optionally
appending a suffix.
@param millis The number of milliseconds to print.
@param suffix A suffix that is appended if the millis is > 0, specify "" if not needed.
@return The readable string | [
"Format",
"the",
"given",
"number",
"of",
"milliseconds",
"as",
"readable",
"string",
"optionally",
"appending",
"a",
"suffix",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/date/DateParser.java#L199-L228 |
143,524 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/shredder/XMLShredder.java | XMLShredder.createFileReader | public static synchronized XMLEventReader createFileReader(final File paramFile) throws IOException,
XMLStreamException {
final XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
final InputStream in = new FileInputStream(paramFile);
return factory.createXMLEventReader(in);
} | java | public static synchronized XMLEventReader createFileReader(final File paramFile) throws IOException,
XMLStreamException {
final XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
final InputStream in = new FileInputStream(paramFile);
return factory.createXMLEventReader(in);
} | [
"public",
"static",
"synchronized",
"XMLEventReader",
"createFileReader",
"(",
"final",
"File",
"paramFile",
")",
"throws",
"IOException",
",",
"XMLStreamException",
"{",
"final",
"XMLInputFactory",
"factory",
"=",
"XMLInputFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setProperty",
"(",
"XMLInputFactory",
".",
"SUPPORT_DTD",
",",
"false",
")",
";",
"final",
"InputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"paramFile",
")",
";",
"return",
"factory",
".",
"createXMLEventReader",
"(",
"in",
")",
";",
"}"
] | Create a new StAX reader on a file.
@param paramFile
the XML file to parse
@return an {@link XMLEventReader}
@throws IOException
if I/O operation fails
@throws XMLStreamException
if any parsing error occurs | [
"Create",
"a",
"new",
"StAX",
"reader",
"on",
"a",
"file",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/shredder/XMLShredder.java#L397-L403 |
143,525 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/shredder/XMLShredder.java | XMLShredder.createStringReader | public static synchronized XMLEventReader createStringReader(final String paramString)
throws IOException, XMLStreamException {
final XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
final InputStream in = new ByteArrayInputStream(paramString.getBytes());
return factory.createXMLEventReader(in);
} | java | public static synchronized XMLEventReader createStringReader(final String paramString)
throws IOException, XMLStreamException {
final XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
final InputStream in = new ByteArrayInputStream(paramString.getBytes());
return factory.createXMLEventReader(in);
} | [
"public",
"static",
"synchronized",
"XMLEventReader",
"createStringReader",
"(",
"final",
"String",
"paramString",
")",
"throws",
"IOException",
",",
"XMLStreamException",
"{",
"final",
"XMLInputFactory",
"factory",
"=",
"XMLInputFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setProperty",
"(",
"XMLInputFactory",
".",
"SUPPORT_DTD",
",",
"false",
")",
";",
"final",
"InputStream",
"in",
"=",
"new",
"ByteArrayInputStream",
"(",
"paramString",
".",
"getBytes",
"(",
")",
")",
";",
"return",
"factory",
".",
"createXMLEventReader",
"(",
"in",
")",
";",
"}"
] | Create a new StAX reader on a string.
@param paramString
the XML file as a string to parse
@return an {@link XMLEventReader}
@throws IOException
if I/O operation fails
@throws XMLStreamException
if any parsing error occurs | [
"Create",
"a",
"new",
"StAX",
"reader",
"on",
"a",
"string",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/shredder/XMLShredder.java#L416-L422 |
143,526 | centic9/commons-dost | src/main/java/org/dstadler/commons/http/HttpClientWrapper.java | HttpClientWrapper.simpleGet | public String simpleGet(String url) throws IOException {
final AtomicReference<String> str = new AtomicReference<>();
simpleGetInternal(url, inputStream -> {
try {
str.set(IOUtils.toString(inputStream, "UTF-8"));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}, null);
return str.get();
} | java | public String simpleGet(String url) throws IOException {
final AtomicReference<String> str = new AtomicReference<>();
simpleGetInternal(url, inputStream -> {
try {
str.set(IOUtils.toString(inputStream, "UTF-8"));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}, null);
return str.get();
} | [
"public",
"String",
"simpleGet",
"(",
"String",
"url",
")",
"throws",
"IOException",
"{",
"final",
"AtomicReference",
"<",
"String",
">",
"str",
"=",
"new",
"AtomicReference",
"<>",
"(",
")",
";",
"simpleGetInternal",
"(",
"url",
",",
"inputStream",
"->",
"{",
"try",
"{",
"str",
".",
"set",
"(",
"IOUtils",
".",
"toString",
"(",
"inputStream",
",",
"\"UTF-8\"",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}",
",",
"null",
")",
";",
"return",
"str",
".",
"get",
"(",
")",
";",
"}"
] | Perform a simple get-operation and return the resulting String.
@param url The URL to query
@return The data returned when retrieving the data from the given url, converted to a String.
@throws IOException if the HTTP status code is not 200. | [
"Perform",
"a",
"simple",
"get",
"-",
"operation",
"and",
"return",
"the",
"resulting",
"String",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/HttpClientWrapper.java#L145-L156 |
143,527 | centic9/commons-dost | src/main/java/org/dstadler/commons/http/HttpClientWrapper.java | HttpClientWrapper.simpleGetBytes | public byte[] simpleGetBytes(String url) throws IOException {
final AtomicReference<byte[]> bytes = new AtomicReference<>();
simpleGetInternal(url, inputStream -> {
try {
bytes.set(IOUtils.toByteArray(inputStream));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}, null);
return bytes.get();
} | java | public byte[] simpleGetBytes(String url) throws IOException {
final AtomicReference<byte[]> bytes = new AtomicReference<>();
simpleGetInternal(url, inputStream -> {
try {
bytes.set(IOUtils.toByteArray(inputStream));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}, null);
return bytes.get();
} | [
"public",
"byte",
"[",
"]",
"simpleGetBytes",
"(",
"String",
"url",
")",
"throws",
"IOException",
"{",
"final",
"AtomicReference",
"<",
"byte",
"[",
"]",
">",
"bytes",
"=",
"new",
"AtomicReference",
"<>",
"(",
")",
";",
"simpleGetInternal",
"(",
"url",
",",
"inputStream",
"->",
"{",
"try",
"{",
"bytes",
".",
"set",
"(",
"IOUtils",
".",
"toByteArray",
"(",
"inputStream",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}",
",",
"null",
")",
";",
"return",
"bytes",
".",
"get",
"(",
")",
";",
"}"
] | Perform a simple get-operation and return the resulting byte-array.
@param url The URL to query
@return The data returned when retrieving the data from the given url.
@throws IOException if the HTTP status code is not 200. | [
"Perform",
"a",
"simple",
"get",
"-",
"operation",
"and",
"return",
"the",
"resulting",
"byte",
"-",
"array",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/HttpClientWrapper.java#L186-L197 |
143,528 | centic9/commons-dost | src/main/java/org/dstadler/commons/http/HttpClientWrapper.java | HttpClientWrapper.simpleGet | public void simpleGet(String url, Consumer<InputStream> consumer) throws IOException {
simpleGetInternal(url, consumer, null);
} | java | public void simpleGet(String url, Consumer<InputStream> consumer) throws IOException {
simpleGetInternal(url, consumer, null);
} | [
"public",
"void",
"simpleGet",
"(",
"String",
"url",
",",
"Consumer",
"<",
"InputStream",
">",
"consumer",
")",
"throws",
"IOException",
"{",
"simpleGetInternal",
"(",
"url",
",",
"consumer",
",",
"null",
")",
";",
"}"
] | Perform a simple get-operation and passes the resulting InputStream to the given Consumer
@param url The URL to query
@param consumer A Consumer which receives the InputStream and can process the data
on-the-fly in streaming fashion without retrieving all of the data into memory
at once.
@throws IOException if the HTTP status code is not 200. | [
"Perform",
"a",
"simple",
"get",
"-",
"operation",
"and",
"passes",
"the",
"resulting",
"InputStream",
"to",
"the",
"given",
"Consumer"
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/HttpClientWrapper.java#L209-L211 |
143,529 | centic9/commons-dost | src/main/java/org/dstadler/commons/http/HttpClientWrapper.java | HttpClientWrapper.retrieveData | public static String retrieveData(String url, String user, String password, int timeoutMs) throws IOException {
try (HttpClientWrapper wrapper = new HttpClientWrapper(user, password, timeoutMs)) {
return wrapper.simpleGet(url);
}
} | java | public static String retrieveData(String url, String user, String password, int timeoutMs) throws IOException {
try (HttpClientWrapper wrapper = new HttpClientWrapper(user, password, timeoutMs)) {
return wrapper.simpleGet(url);
}
} | [
"public",
"static",
"String",
"retrieveData",
"(",
"String",
"url",
",",
"String",
"user",
",",
"String",
"password",
",",
"int",
"timeoutMs",
")",
"throws",
"IOException",
"{",
"try",
"(",
"HttpClientWrapper",
"wrapper",
"=",
"new",
"HttpClientWrapper",
"(",
"user",
",",
"password",
",",
"timeoutMs",
")",
")",
"{",
"return",
"wrapper",
".",
"simpleGet",
"(",
"url",
")",
";",
"}",
"}"
] | Small helper method to simply query the URL without password and
return the resulting data.
@param url The URL to query data from.
@param user The username to send
@param password The password to send
@param timeoutMs How long in milliseconds to wait for the request
@return The resulting data read from the URL
@throws IOException If the URL is not accessible or the query returns
a HTTP code other than 200. | [
"Small",
"helper",
"method",
"to",
"simply",
"query",
"the",
"URL",
"without",
"password",
"and",
"return",
"the",
"resulting",
"data",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/HttpClientWrapper.java#L336-L340 |
143,530 | centic9/commons-dost | src/main/java/org/dstadler/commons/http/HttpClientWrapper.java | HttpClientWrapper.checkAndFetch | public static HttpEntity checkAndFetch(HttpResponse response, String url) throws IOException {
int statusCode = response.getStatusLine().getStatusCode();
if(statusCode > 206) {
String msg = "Had HTTP StatusCode " + statusCode + " for request: " + url + ", response: " +
response.getStatusLine().getReasonPhrase() + "\n" +
StringUtils.abbreviate(IOUtils.toString(response.getEntity().getContent(), "UTF-8"), 1024);
log.warning(msg);
throw new IOException(msg);
}
return response.getEntity();
} | java | public static HttpEntity checkAndFetch(HttpResponse response, String url) throws IOException {
int statusCode = response.getStatusLine().getStatusCode();
if(statusCode > 206) {
String msg = "Had HTTP StatusCode " + statusCode + " for request: " + url + ", response: " +
response.getStatusLine().getReasonPhrase() + "\n" +
StringUtils.abbreviate(IOUtils.toString(response.getEntity().getContent(), "UTF-8"), 1024);
log.warning(msg);
throw new IOException(msg);
}
return response.getEntity();
} | [
"public",
"static",
"HttpEntity",
"checkAndFetch",
"(",
"HttpResponse",
"response",
",",
"String",
"url",
")",
"throws",
"IOException",
"{",
"int",
"statusCode",
"=",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"statusCode",
">",
"206",
")",
"{",
"String",
"msg",
"=",
"\"Had HTTP StatusCode \"",
"+",
"statusCode",
"+",
"\" for request: \"",
"+",
"url",
"+",
"\", response: \"",
"+",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getReasonPhrase",
"(",
")",
"+",
"\"\\n\"",
"+",
"StringUtils",
".",
"abbreviate",
"(",
"IOUtils",
".",
"toString",
"(",
"response",
".",
"getEntity",
"(",
")",
".",
"getContent",
"(",
")",
",",
"\"UTF-8\"",
")",
",",
"1024",
")",
";",
"log",
".",
"warning",
"(",
"msg",
")",
";",
"throw",
"new",
"IOException",
"(",
"msg",
")",
";",
"}",
"return",
"response",
".",
"getEntity",
"(",
")",
";",
"}"
] | Helper method to check the status code of the response and throw an IOException if it is
an error or moved state.
@param response A HttpResponse that is resulting from executing a HttpMethod.
@param url The url, only used for building the error message of the exception.
@return The {@link HttpEntity} returned from response.getEntity().
@throws IOException if the HTTP status code is higher than 206. | [
"Helper",
"method",
"to",
"check",
"the",
"status",
"code",
"of",
"the",
"response",
"and",
"throw",
"an",
"IOException",
"if",
"it",
"is",
"an",
"error",
"or",
"moved",
"state",
"."
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/HttpClientWrapper.java#L353-L365 |
143,531 | sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java | DatabaseRepresentation.createResource | public void createResource(final InputStream inputStream, final String resourceName)
throws JaxRxException {
synchronized (resourceName) {
if (inputStream == null) {
throw new JaxRxException(400, "Bad user request");
} else {
try {
shred(inputStream, resourceName);
} catch (final TTException exce) {
throw new JaxRxException(exce);
}
}
}
} | java | public void createResource(final InputStream inputStream, final String resourceName)
throws JaxRxException {
synchronized (resourceName) {
if (inputStream == null) {
throw new JaxRxException(400, "Bad user request");
} else {
try {
shred(inputStream, resourceName);
} catch (final TTException exce) {
throw new JaxRxException(exce);
}
}
}
} | [
"public",
"void",
"createResource",
"(",
"final",
"InputStream",
"inputStream",
",",
"final",
"String",
"resourceName",
")",
"throws",
"JaxRxException",
"{",
"synchronized",
"(",
"resourceName",
")",
"{",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"throw",
"new",
"JaxRxException",
"(",
"400",
",",
"\"Bad user request\"",
")",
";",
"}",
"else",
"{",
"try",
"{",
"shred",
"(",
"inputStream",
",",
"resourceName",
")",
";",
"}",
"catch",
"(",
"final",
"TTException",
"exce",
")",
"{",
"throw",
"new",
"JaxRxException",
"(",
"exce",
")",
";",
"}",
"}",
"}",
"}"
] | This method is responsible to create a new database.
@param inputStream
The stream containing the XML document that has to be stored.
@param resourceName
The name of the new database.
@throws JaxRxException
The exception occurred. | [
"This",
"method",
"is",
"responsible",
"to",
"create",
"a",
"new",
"database",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java#L136-L149 |
143,532 | sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java | DatabaseRepresentation.add | public void add(final InputStream input, final String resource) throws JaxRxException {
synchronized (resource) {
try {
shred(input, resource);
} catch (final TTException exce) {
throw new JaxRxException(exce);
}
}
} | java | public void add(final InputStream input, final String resource) throws JaxRxException {
synchronized (resource) {
try {
shred(input, resource);
} catch (final TTException exce) {
throw new JaxRxException(exce);
}
}
} | [
"public",
"void",
"add",
"(",
"final",
"InputStream",
"input",
",",
"final",
"String",
"resource",
")",
"throws",
"JaxRxException",
"{",
"synchronized",
"(",
"resource",
")",
"{",
"try",
"{",
"shred",
"(",
"input",
",",
"resource",
")",
";",
"}",
"catch",
"(",
"final",
"TTException",
"exce",
")",
"{",
"throw",
"new",
"JaxRxException",
"(",
"exce",
")",
";",
"}",
"}",
"}"
] | This method is responsible to add a new XML document to a collection.
@param input
The new XML document packed in an {@link InputStream}.
@param resource
The name of the collection.
@throws JaxRxException
The exception occurred. | [
"This",
"method",
"is",
"responsible",
"to",
"add",
"a",
"new",
"XML",
"document",
"to",
"a",
"collection",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java#L257-L266 |
143,533 | sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java | DatabaseRepresentation.deleteResource | public void deleteResource(final String resourceName) throws WebApplicationException {
synchronized (resourceName) {
try {
mDatabase.truncateResource(new SessionConfiguration(resourceName, null));
} catch (TTException e) {
throw new WebApplicationException(e);
}
}
} | java | public void deleteResource(final String resourceName) throws WebApplicationException {
synchronized (resourceName) {
try {
mDatabase.truncateResource(new SessionConfiguration(resourceName, null));
} catch (TTException e) {
throw new WebApplicationException(e);
}
}
} | [
"public",
"void",
"deleteResource",
"(",
"final",
"String",
"resourceName",
")",
"throws",
"WebApplicationException",
"{",
"synchronized",
"(",
"resourceName",
")",
"{",
"try",
"{",
"mDatabase",
".",
"truncateResource",
"(",
"new",
"SessionConfiguration",
"(",
"resourceName",
",",
"null",
")",
")",
";",
"}",
"catch",
"(",
"TTException",
"e",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] | This method is responsible to delete an existing database.
@param resourceName
The name of the database.
@throws WebApplicationException
The exception occurred. | [
"This",
"method",
"is",
"responsible",
"to",
"delete",
"an",
"existing",
"database",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java#L276-L284 |
143,534 | sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java | DatabaseRepresentation.getLastRevision | public long getLastRevision(final String resourceName) throws JaxRxException, TTException {
long lastRevision;
if (mDatabase.existsResource(resourceName)) {
ISession session = null;
try {
session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY));
lastRevision = session.getMostRecentVersion();
} catch (final Exception globExcep) {
throw new JaxRxException(globExcep);
} finally {
session.close();
}
} else {
throw new JaxRxException(404, "Resource not found");
}
return lastRevision;
} | java | public long getLastRevision(final String resourceName) throws JaxRxException, TTException {
long lastRevision;
if (mDatabase.existsResource(resourceName)) {
ISession session = null;
try {
session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY));
lastRevision = session.getMostRecentVersion();
} catch (final Exception globExcep) {
throw new JaxRxException(globExcep);
} finally {
session.close();
}
} else {
throw new JaxRxException(404, "Resource not found");
}
return lastRevision;
} | [
"public",
"long",
"getLastRevision",
"(",
"final",
"String",
"resourceName",
")",
"throws",
"JaxRxException",
",",
"TTException",
"{",
"long",
"lastRevision",
";",
"if",
"(",
"mDatabase",
".",
"existsResource",
"(",
"resourceName",
")",
")",
"{",
"ISession",
"session",
"=",
"null",
";",
"try",
"{",
"session",
"=",
"mDatabase",
".",
"getSession",
"(",
"new",
"SessionConfiguration",
"(",
"resourceName",
",",
"StandardSettings",
".",
"KEY",
")",
")",
";",
"lastRevision",
"=",
"session",
".",
"getMostRecentVersion",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"globExcep",
")",
"{",
"throw",
"new",
"JaxRxException",
"(",
"globExcep",
")",
";",
"}",
"finally",
"{",
"session",
".",
"close",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"JaxRxException",
"(",
"404",
",",
"\"Resource not found\"",
")",
";",
"}",
"return",
"lastRevision",
";",
"}"
] | This method reads the existing database, and offers the last revision id
of the database
@param resourceName
The name of the existing database.
@return The {@link OutputStream} containing the result
@throws WebApplicationException
The Exception occurred.
@throws TTException | [
"This",
"method",
"reads",
"the",
"existing",
"database",
"and",
"offers",
"the",
"last",
"revision",
"id",
"of",
"the",
"database"
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java#L379-L397 |
143,535 | sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java | DatabaseRepresentation.serializIt | private void serializIt(final String resource, final Long revision, final OutputStream output,
final boolean nodeid) throws JaxRxException, TTException {
// Connection to treetank, creating a session
ISession session = null;
// INodeReadTrx rtx = null;
try {
session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
// and creating a transaction
// if (revision == null) {
// rtx = session.beginReadTransaction();
// } else {
// rtx = session.beginReadTransaction(revision);
// }
final XMLSerializerBuilder builder;
if (revision == null)
builder = new XMLSerializerBuilder(session, output);
else
builder = new XMLSerializerBuilder(session, output, revision);
builder.setREST(nodeid);
builder.setID(nodeid);
builder.setDeclaration(false);
final XMLSerializer serializer = builder.build();
serializer.call();
} catch (final Exception exce) {
throw new JaxRxException(exce);
} finally {
// closing the treetank storage
WorkerHelper.closeRTX(null, session);
}
} | java | private void serializIt(final String resource, final Long revision, final OutputStream output,
final boolean nodeid) throws JaxRxException, TTException {
// Connection to treetank, creating a session
ISession session = null;
// INodeReadTrx rtx = null;
try {
session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
// and creating a transaction
// if (revision == null) {
// rtx = session.beginReadTransaction();
// } else {
// rtx = session.beginReadTransaction(revision);
// }
final XMLSerializerBuilder builder;
if (revision == null)
builder = new XMLSerializerBuilder(session, output);
else
builder = new XMLSerializerBuilder(session, output, revision);
builder.setREST(nodeid);
builder.setID(nodeid);
builder.setDeclaration(false);
final XMLSerializer serializer = builder.build();
serializer.call();
} catch (final Exception exce) {
throw new JaxRxException(exce);
} finally {
// closing the treetank storage
WorkerHelper.closeRTX(null, session);
}
} | [
"private",
"void",
"serializIt",
"(",
"final",
"String",
"resource",
",",
"final",
"Long",
"revision",
",",
"final",
"OutputStream",
"output",
",",
"final",
"boolean",
"nodeid",
")",
"throws",
"JaxRxException",
",",
"TTException",
"{",
"// Connection to treetank, creating a session",
"ISession",
"session",
"=",
"null",
";",
"// INodeReadTrx rtx = null;",
"try",
"{",
"session",
"=",
"mDatabase",
".",
"getSession",
"(",
"new",
"SessionConfiguration",
"(",
"resource",
",",
"StandardSettings",
".",
"KEY",
")",
")",
";",
"// and creating a transaction",
"// if (revision == null) {",
"// rtx = session.beginReadTransaction();",
"// } else {",
"// rtx = session.beginReadTransaction(revision);",
"// }",
"final",
"XMLSerializerBuilder",
"builder",
";",
"if",
"(",
"revision",
"==",
"null",
")",
"builder",
"=",
"new",
"XMLSerializerBuilder",
"(",
"session",
",",
"output",
")",
";",
"else",
"builder",
"=",
"new",
"XMLSerializerBuilder",
"(",
"session",
",",
"output",
",",
"revision",
")",
";",
"builder",
".",
"setREST",
"(",
"nodeid",
")",
";",
"builder",
".",
"setID",
"(",
"nodeid",
")",
";",
"builder",
".",
"setDeclaration",
"(",
"false",
")",
";",
"final",
"XMLSerializer",
"serializer",
"=",
"builder",
".",
"build",
"(",
")",
";",
"serializer",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"exce",
")",
"{",
"throw",
"new",
"JaxRxException",
"(",
"exce",
")",
";",
"}",
"finally",
"{",
"// closing the treetank storage",
"WorkerHelper",
".",
"closeRTX",
"(",
"null",
",",
"session",
")",
";",
"}",
"}"
] | The XML serializer to a given tnk file.
@param resource
The resource that has to be serialized.
@param revision
The revision of the document.
@param output
The output stream where we write the XML file.
@param nodeid
<code>true</code> when you want the result nodes with node
id's. <code>false</code> otherwise.
@throws WebApplicationException
The exception occurred.
@throws TTException | [
"The",
"XML",
"serializer",
"to",
"a",
"given",
"tnk",
"file",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java#L568-L597 |
143,536 | sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java | DatabaseRepresentation.revertToRevision | public void revertToRevision(final String resourceName, final long backToRevision) throws JaxRxException,
TTException {
ISession session = null;
INodeWriteTrx wtx = null;
boolean abort = false;
try {
session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY));
wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling);
wtx.revertTo(backToRevision);
wtx.commit();
} catch (final TTException exce) {
abort = true;
throw new JaxRxException(exce);
} finally {
WorkerHelper.closeWTX(abort, wtx, session);
}
} | java | public void revertToRevision(final String resourceName, final long backToRevision) throws JaxRxException,
TTException {
ISession session = null;
INodeWriteTrx wtx = null;
boolean abort = false;
try {
session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY));
wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling);
wtx.revertTo(backToRevision);
wtx.commit();
} catch (final TTException exce) {
abort = true;
throw new JaxRxException(exce);
} finally {
WorkerHelper.closeWTX(abort, wtx, session);
}
} | [
"public",
"void",
"revertToRevision",
"(",
"final",
"String",
"resourceName",
",",
"final",
"long",
"backToRevision",
")",
"throws",
"JaxRxException",
",",
"TTException",
"{",
"ISession",
"session",
"=",
"null",
";",
"INodeWriteTrx",
"wtx",
"=",
"null",
";",
"boolean",
"abort",
"=",
"false",
";",
"try",
"{",
"session",
"=",
"mDatabase",
".",
"getSession",
"(",
"new",
"SessionConfiguration",
"(",
"resourceName",
",",
"StandardSettings",
".",
"KEY",
")",
")",
";",
"wtx",
"=",
"new",
"NodeWriteTrx",
"(",
"session",
",",
"session",
".",
"beginBucketWtx",
"(",
")",
",",
"HashKind",
".",
"Rolling",
")",
";",
"wtx",
".",
"revertTo",
"(",
"backToRevision",
")",
";",
"wtx",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"TTException",
"exce",
")",
"{",
"abort",
"=",
"true",
";",
"throw",
"new",
"JaxRxException",
"(",
"exce",
")",
";",
"}",
"finally",
"{",
"WorkerHelper",
".",
"closeWTX",
"(",
"abort",
",",
"wtx",
",",
"session",
")",
";",
"}",
"}"
] | This method reverts the latest revision data to the requested.
@param resourceName
The name of the XML resource.
@param backToRevision
The revision value, which has to be set as the latest.
@throws WebApplicationException
@throws TTException | [
"This",
"method",
"reverts",
"the",
"latest",
"revision",
"data",
"to",
"the",
"requested",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/DatabaseRepresentation.java#L609-L625 |
143,537 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/TzServer.java | TzServer.discover | private String discover(final String url) throws TimezonesException {
/* For the moment we'll try to find it via .well-known. We may have to
* use DNS SRV lookups
*/
// String domain = hi.getHostname();
// int lpos = domain.lastIndexOf(".");
//int lpos2 = domain.lastIndexOf(".", lpos - 1);
// if (lpos2 > 0) {
// domain = domain.substring(lpos2 + 1);
//}
String realUrl;
try {
/* See if it's a real url */
new URL(url);
realUrl = url;
} catch (final Throwable t) {
realUrl = "https://" + url + "/.well-known/timezone";
}
for (int redirects = 0; redirects < 10; redirects++) {
try (CloseableHttpResponse hresp =
doCall(realUrl,
"capabilities",
null,
null)) {
if ((status == HttpServletResponse.SC_MOVED_PERMANENTLY) ||
(status == HttpServletResponse.SC_MOVED_TEMPORARILY) ||
(status == HttpServletResponse.SC_TEMPORARY_REDIRECT)) {
//boolean permanent = rcode == HttpServletResponse.SC_MOVED_PERMANENTLY;
final String newLoc =
HttpUtil.getFirstHeaderValue(hresp,
"location");
if (newLoc != null) {
if (debug()) {
debug("Got redirected to " + newLoc +
" from " + url);
}
final int qpos = newLoc.indexOf("?");
if (qpos < 0) {
realUrl = newLoc;
} else {
realUrl = newLoc.substring(0, qpos);
}
// Try again
continue;
}
}
if (status != HttpServletResponse.SC_OK) {
// The response is invalid and did not provide the new location for
// the resource. Report an error or possibly handle the response
// like a 404 Not Found error.
error("================================================");
error("================================================");
error("================================================");
error("Got response " + status +
", from " + realUrl);
error("================================================");
error("================================================");
error("================================================");
throw new TimezonesException(TimezonesException.noPrimary,
"Got response " + status +
", from " + realUrl);
}
/* Should have a capabilities record. */
try {
capabilities = om.readValue(hresp.getEntity().getContent(),
CapabilitiesType.class);
} catch (final Throwable t) {
// Bad data - we'll just go with the url for the moment?
error(t);
}
return realUrl;
} catch (final TimezonesException tze) {
throw tze;
} catch (final Throwable t) {
if (debug()) {
error(t);
}
throw new TimezonesException(t);
}
}
if (debug()) {
error("Too many redirects: Got response " + status +
", from " + realUrl);
}
throw new TimezonesException("Too many redirects on " + realUrl);
} | java | private String discover(final String url) throws TimezonesException {
/* For the moment we'll try to find it via .well-known. We may have to
* use DNS SRV lookups
*/
// String domain = hi.getHostname();
// int lpos = domain.lastIndexOf(".");
//int lpos2 = domain.lastIndexOf(".", lpos - 1);
// if (lpos2 > 0) {
// domain = domain.substring(lpos2 + 1);
//}
String realUrl;
try {
/* See if it's a real url */
new URL(url);
realUrl = url;
} catch (final Throwable t) {
realUrl = "https://" + url + "/.well-known/timezone";
}
for (int redirects = 0; redirects < 10; redirects++) {
try (CloseableHttpResponse hresp =
doCall(realUrl,
"capabilities",
null,
null)) {
if ((status == HttpServletResponse.SC_MOVED_PERMANENTLY) ||
(status == HttpServletResponse.SC_MOVED_TEMPORARILY) ||
(status == HttpServletResponse.SC_TEMPORARY_REDIRECT)) {
//boolean permanent = rcode == HttpServletResponse.SC_MOVED_PERMANENTLY;
final String newLoc =
HttpUtil.getFirstHeaderValue(hresp,
"location");
if (newLoc != null) {
if (debug()) {
debug("Got redirected to " + newLoc +
" from " + url);
}
final int qpos = newLoc.indexOf("?");
if (qpos < 0) {
realUrl = newLoc;
} else {
realUrl = newLoc.substring(0, qpos);
}
// Try again
continue;
}
}
if (status != HttpServletResponse.SC_OK) {
// The response is invalid and did not provide the new location for
// the resource. Report an error or possibly handle the response
// like a 404 Not Found error.
error("================================================");
error("================================================");
error("================================================");
error("Got response " + status +
", from " + realUrl);
error("================================================");
error("================================================");
error("================================================");
throw new TimezonesException(TimezonesException.noPrimary,
"Got response " + status +
", from " + realUrl);
}
/* Should have a capabilities record. */
try {
capabilities = om.readValue(hresp.getEntity().getContent(),
CapabilitiesType.class);
} catch (final Throwable t) {
// Bad data - we'll just go with the url for the moment?
error(t);
}
return realUrl;
} catch (final TimezonesException tze) {
throw tze;
} catch (final Throwable t) {
if (debug()) {
error(t);
}
throw new TimezonesException(t);
}
}
if (debug()) {
error("Too many redirects: Got response " + status +
", from " + realUrl);
}
throw new TimezonesException("Too many redirects on " + realUrl);
} | [
"private",
"String",
"discover",
"(",
"final",
"String",
"url",
")",
"throws",
"TimezonesException",
"{",
"/* For the moment we'll try to find it via .well-known. We may have to\n * use DNS SRV lookups\n */",
"// String domain = hi.getHostname();",
"// int lpos = domain.lastIndexOf(\".\");",
"//int lpos2 = domain.lastIndexOf(\".\", lpos - 1);",
"// if (lpos2 > 0) {",
"// domain = domain.substring(lpos2 + 1);",
"//}",
"String",
"realUrl",
";",
"try",
"{",
"/* See if it's a real url */",
"new",
"URL",
"(",
"url",
")",
";",
"realUrl",
"=",
"url",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"realUrl",
"=",
"\"https://\"",
"+",
"url",
"+",
"\"/.well-known/timezone\"",
";",
"}",
"for",
"(",
"int",
"redirects",
"=",
"0",
";",
"redirects",
"<",
"10",
";",
"redirects",
"++",
")",
"{",
"try",
"(",
"CloseableHttpResponse",
"hresp",
"=",
"doCall",
"(",
"realUrl",
",",
"\"capabilities\"",
",",
"null",
",",
"null",
")",
")",
"{",
"if",
"(",
"(",
"status",
"==",
"HttpServletResponse",
".",
"SC_MOVED_PERMANENTLY",
")",
"||",
"(",
"status",
"==",
"HttpServletResponse",
".",
"SC_MOVED_TEMPORARILY",
")",
"||",
"(",
"status",
"==",
"HttpServletResponse",
".",
"SC_TEMPORARY_REDIRECT",
")",
")",
"{",
"//boolean permanent = rcode == HttpServletResponse.SC_MOVED_PERMANENTLY;",
"final",
"String",
"newLoc",
"=",
"HttpUtil",
".",
"getFirstHeaderValue",
"(",
"hresp",
",",
"\"location\"",
")",
";",
"if",
"(",
"newLoc",
"!=",
"null",
")",
"{",
"if",
"(",
"debug",
"(",
")",
")",
"{",
"debug",
"(",
"\"Got redirected to \"",
"+",
"newLoc",
"+",
"\" from \"",
"+",
"url",
")",
";",
"}",
"final",
"int",
"qpos",
"=",
"newLoc",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"if",
"(",
"qpos",
"<",
"0",
")",
"{",
"realUrl",
"=",
"newLoc",
";",
"}",
"else",
"{",
"realUrl",
"=",
"newLoc",
".",
"substring",
"(",
"0",
",",
"qpos",
")",
";",
"}",
"// Try again",
"continue",
";",
"}",
"}",
"if",
"(",
"status",
"!=",
"HttpServletResponse",
".",
"SC_OK",
")",
"{",
"// The response is invalid and did not provide the new location for",
"// the resource. Report an error or possibly handle the response",
"// like a 404 Not Found error.",
"error",
"(",
"\"================================================\"",
")",
";",
"error",
"(",
"\"================================================\"",
")",
";",
"error",
"(",
"\"================================================\"",
")",
";",
"error",
"(",
"\"Got response \"",
"+",
"status",
"+",
"\", from \"",
"+",
"realUrl",
")",
";",
"error",
"(",
"\"================================================\"",
")",
";",
"error",
"(",
"\"================================================\"",
")",
";",
"error",
"(",
"\"================================================\"",
")",
";",
"throw",
"new",
"TimezonesException",
"(",
"TimezonesException",
".",
"noPrimary",
",",
"\"Got response \"",
"+",
"status",
"+",
"\", from \"",
"+",
"realUrl",
")",
";",
"}",
"/* Should have a capabilities record. */",
"try",
"{",
"capabilities",
"=",
"om",
".",
"readValue",
"(",
"hresp",
".",
"getEntity",
"(",
")",
".",
"getContent",
"(",
")",
",",
"CapabilitiesType",
".",
"class",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"// Bad data - we'll just go with the url for the moment?",
"error",
"(",
"t",
")",
";",
"}",
"return",
"realUrl",
";",
"}",
"catch",
"(",
"final",
"TimezonesException",
"tze",
")",
"{",
"throw",
"tze",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"if",
"(",
"debug",
"(",
")",
")",
"{",
"error",
"(",
"t",
")",
";",
"}",
"throw",
"new",
"TimezonesException",
"(",
"t",
")",
";",
"}",
"}",
"if",
"(",
"debug",
"(",
")",
")",
"{",
"error",
"(",
"\"Too many redirects: Got response \"",
"+",
"status",
"+",
"\", from \"",
"+",
"realUrl",
")",
";",
"}",
"throw",
"new",
"TimezonesException",
"(",
"\"Too many redirects on \"",
"+",
"realUrl",
")",
";",
"}"
] | See if we have a url for the service. If not discover the real one.
<p>If the uri is parseable we won't even attempt the /.well-known approach.
It implies we have a scheme etc.
<p>Otherwise we will assume it's a host attempt to discover it through
/.well-known
@param url the service url
@return discovered url
@throws TimezonesException on error | [
"See",
"if",
"we",
"have",
"a",
"url",
"for",
"the",
"service",
".",
"If",
"not",
"discover",
"the",
"real",
"one",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/TzServer.java#L190-L292 |
143,538 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/XMLSerializer.java | XMLSerializer.emitEndElement | @Override
protected void emitEndElement(final INodeReadTrx paramRTX) {
try {
indent();
mOut.write(ECharsForSerializing.OPEN_SLASH.getBytes());
mOut.write(paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getNameKey()).getBytes());
mOut.write(ECharsForSerializing.CLOSE.getBytes());
if (mIndent) {
mOut.write(ECharsForSerializing.NEWLINE.getBytes());
}
} catch (final IOException exc) {
exc.printStackTrace();
}
} | java | @Override
protected void emitEndElement(final INodeReadTrx paramRTX) {
try {
indent();
mOut.write(ECharsForSerializing.OPEN_SLASH.getBytes());
mOut.write(paramRTX.nameForKey(((ITreeNameData)paramRTX.getNode()).getNameKey()).getBytes());
mOut.write(ECharsForSerializing.CLOSE.getBytes());
if (mIndent) {
mOut.write(ECharsForSerializing.NEWLINE.getBytes());
}
} catch (final IOException exc) {
exc.printStackTrace();
}
} | [
"@",
"Override",
"protected",
"void",
"emitEndElement",
"(",
"final",
"INodeReadTrx",
"paramRTX",
")",
"{",
"try",
"{",
"indent",
"(",
")",
";",
"mOut",
".",
"write",
"(",
"ECharsForSerializing",
".",
"OPEN_SLASH",
".",
"getBytes",
"(",
")",
")",
";",
"mOut",
".",
"write",
"(",
"paramRTX",
".",
"nameForKey",
"(",
"(",
"(",
"ITreeNameData",
")",
"paramRTX",
".",
"getNode",
"(",
")",
")",
".",
"getNameKey",
"(",
")",
")",
".",
"getBytes",
"(",
")",
")",
";",
"mOut",
".",
"write",
"(",
"ECharsForSerializing",
".",
"CLOSE",
".",
"getBytes",
"(",
")",
")",
";",
"if",
"(",
"mIndent",
")",
"{",
"mOut",
".",
"write",
"(",
"ECharsForSerializing",
".",
"NEWLINE",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"exc",
")",
"{",
"exc",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Emit end element.
@param paramRTX
Read Transaction | [
"Emit",
"end",
"element",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/XMLSerializer.java#L319-L332 |
143,539 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/XMLSerializer.java | XMLSerializer.indent | private void indent() throws IOException {
if (mIndent) {
for (int i = 0; i < mStack.size() * mIndentSpaces; i++) {
mOut.write(" ".getBytes());
}
}
} | java | private void indent() throws IOException {
if (mIndent) {
for (int i = 0; i < mStack.size() * mIndentSpaces; i++) {
mOut.write(" ".getBytes());
}
}
} | [
"private",
"void",
"indent",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mIndent",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mStack",
".",
"size",
"(",
")",
"*",
"mIndentSpaces",
";",
"i",
"++",
")",
"{",
"mOut",
".",
"write",
"(",
"\" \"",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Indentation of output.
@throws IOException
if can't indent output | [
"Indentation",
"of",
"output",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/XMLSerializer.java#L392-L398 |
143,540 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/XMLSerializer.java | XMLSerializer.write | private void write(final long mValue) throws IOException {
final int length = (int)Math.log10((double)mValue);
int digit = 0;
long remainder = mValue;
for (int i = length; i >= 0; i--) {
digit = (byte)(remainder / LONG_POWERS[i]);
mOut.write((byte)(digit + ASCII_OFFSET));
remainder -= digit * LONG_POWERS[i];
}
} | java | private void write(final long mValue) throws IOException {
final int length = (int)Math.log10((double)mValue);
int digit = 0;
long remainder = mValue;
for (int i = length; i >= 0; i--) {
digit = (byte)(remainder / LONG_POWERS[i]);
mOut.write((byte)(digit + ASCII_OFFSET));
remainder -= digit * LONG_POWERS[i];
}
} | [
"private",
"void",
"write",
"(",
"final",
"long",
"mValue",
")",
"throws",
"IOException",
"{",
"final",
"int",
"length",
"=",
"(",
"int",
")",
"Math",
".",
"log10",
"(",
"(",
"double",
")",
"mValue",
")",
";",
"int",
"digit",
"=",
"0",
";",
"long",
"remainder",
"=",
"mValue",
";",
"for",
"(",
"int",
"i",
"=",
"length",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"digit",
"=",
"(",
"byte",
")",
"(",
"remainder",
"/",
"LONG_POWERS",
"[",
"i",
"]",
")",
";",
"mOut",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"digit",
"+",
"ASCII_OFFSET",
")",
")",
";",
"remainder",
"-=",
"digit",
"*",
"LONG_POWERS",
"[",
"i",
"]",
";",
"}",
"}"
] | Write non-negative non-zero long as UTF-8 bytes.
@param mValue
Value to write
@throws IOException
if can't write to string | [
"Write",
"non",
"-",
"negative",
"non",
"-",
"zero",
"long",
"as",
"UTF",
"-",
"8",
"bytes",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/XMLSerializer.java#L422-L431 |
143,541 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.isoDate | public static String isoDate(final Date val) {
synchronized (isoDateFormat) {
try {
isoDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateFormat.format(val);
}
} | java | public static String isoDate(final Date val) {
synchronized (isoDateFormat) {
try {
isoDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateFormat.format(val);
}
} | [
"public",
"static",
"String",
"isoDate",
"(",
"final",
"Date",
"val",
")",
"{",
"synchronized",
"(",
"isoDateFormat",
")",
"{",
"try",
"{",
"isoDateFormat",
".",
"setTimeZone",
"(",
"Timezones",
".",
"getDefaultTz",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TimezonesException",
"tze",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"tze",
")",
";",
"}",
"return",
"isoDateFormat",
".",
"format",
"(",
"val",
")",
";",
"}",
"}"
] | Turn Date into "yyyyMMdd"
@param val date
@return String "yyyyMMdd" | [
"Turn",
"Date",
"into",
"yyyyMMdd"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L114-L123 |
143,542 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.rfcDate | public static String rfcDate(final Date val) {
synchronized (rfcDateFormat) {
try {
rfcDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return rfcDateFormat.format(val);
}
} | java | public static String rfcDate(final Date val) {
synchronized (rfcDateFormat) {
try {
rfcDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return rfcDateFormat.format(val);
}
} | [
"public",
"static",
"String",
"rfcDate",
"(",
"final",
"Date",
"val",
")",
"{",
"synchronized",
"(",
"rfcDateFormat",
")",
"{",
"try",
"{",
"rfcDateFormat",
".",
"setTimeZone",
"(",
"Timezones",
".",
"getDefaultTz",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TimezonesException",
"tze",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"tze",
")",
";",
"}",
"return",
"rfcDateFormat",
".",
"format",
"(",
"val",
")",
";",
"}",
"}"
] | Turn Date into "yyyy-MM-dd"
@param val date
@return String "yyyy-MM-dd" | [
"Turn",
"Date",
"into",
"yyyy",
"-",
"MM",
"-",
"dd"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L138-L147 |
143,543 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.isoDateTime | public static String isoDateTime(final Date val) {
synchronized (isoDateTimeFormat) {
try {
isoDateTimeFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateTimeFormat.format(val);
}
} | java | public static String isoDateTime(final Date val) {
synchronized (isoDateTimeFormat) {
try {
isoDateTimeFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateTimeFormat.format(val);
}
} | [
"public",
"static",
"String",
"isoDateTime",
"(",
"final",
"Date",
"val",
")",
"{",
"synchronized",
"(",
"isoDateTimeFormat",
")",
"{",
"try",
"{",
"isoDateTimeFormat",
".",
"setTimeZone",
"(",
"Timezones",
".",
"getDefaultTz",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TimezonesException",
"tze",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"tze",
")",
";",
"}",
"return",
"isoDateTimeFormat",
".",
"format",
"(",
"val",
")",
";",
"}",
"}"
] | Turn Date into "yyyyMMddTHHmmss"
@param val date
@return String "yyyyMMddTHHmmss" | [
"Turn",
"Date",
"into",
"yyyyMMddTHHmmss"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L163-L172 |
143,544 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.isoDateTime | public static String isoDateTime(final Date val, final TimeZone tz) {
synchronized (isoDateTimeTZFormat) {
isoDateTimeTZFormat.setTimeZone(tz);
return isoDateTimeTZFormat.format(val);
}
} | java | public static String isoDateTime(final Date val, final TimeZone tz) {
synchronized (isoDateTimeTZFormat) {
isoDateTimeTZFormat.setTimeZone(tz);
return isoDateTimeTZFormat.format(val);
}
} | [
"public",
"static",
"String",
"isoDateTime",
"(",
"final",
"Date",
"val",
",",
"final",
"TimeZone",
"tz",
")",
"{",
"synchronized",
"(",
"isoDateTimeTZFormat",
")",
"{",
"isoDateTimeTZFormat",
".",
"setTimeZone",
"(",
"tz",
")",
";",
"return",
"isoDateTimeTZFormat",
".",
"format",
"(",
"val",
")",
";",
"}",
"}"
] | Turn Date into "yyyyMMddTHHmmss" for a given timezone
@param val date
@param tz TimeZone
@return String "yyyyMMddTHHmmss" | [
"Turn",
"Date",
"into",
"yyyyMMddTHHmmss",
"for",
"a",
"given",
"timezone"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L188-L193 |
143,545 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromISODate | public static Date fromISODate(final String val) throws BadDateException {
try {
synchronized (isoDateFormat) {
try {
isoDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromISODate(final String val) throws BadDateException {
try {
synchronized (isoDateFormat) {
try {
isoDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromISODate",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"isoDateFormat",
")",
"{",
"try",
"{",
"isoDateFormat",
".",
"setTimeZone",
"(",
"Timezones",
".",
"getDefaultTz",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TimezonesException",
"tze",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"tze",
")",
";",
"}",
"return",
"isoDateFormat",
".",
"parse",
"(",
"val",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get Date from "yyyyMMdd"
@param val String "yyyyMMdd"
@return Date
@throws BadDateException on format error | [
"Get",
"Date",
"from",
"yyyyMMdd"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L272-L285 |
143,546 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromRfcDate | public static Date fromRfcDate(final String val) throws BadDateException {
try {
synchronized (rfcDateFormat) {
try {
rfcDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return rfcDateFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromRfcDate(final String val) throws BadDateException {
try {
synchronized (rfcDateFormat) {
try {
rfcDateFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return rfcDateFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromRfcDate",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"rfcDateFormat",
")",
"{",
"try",
"{",
"rfcDateFormat",
".",
"setTimeZone",
"(",
"Timezones",
".",
"getDefaultTz",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TimezonesException",
"tze",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"tze",
")",
";",
"}",
"return",
"rfcDateFormat",
".",
"parse",
"(",
"val",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get Date from "yyyy-MM-dd"
@param val String "yyyy-MM-dd"
@return Date
@throws BadDateException on format error | [
"Get",
"Date",
"from",
"yyyy",
"-",
"MM",
"-",
"dd"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L293-L306 |
143,547 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromISODateTime | public static Date fromISODateTime(final String val) throws BadDateException {
try {
synchronized (isoDateTimeFormat) {
try {
isoDateTimeFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateTimeFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromISODateTime(final String val) throws BadDateException {
try {
synchronized (isoDateTimeFormat) {
try {
isoDateTimeFormat.setTimeZone(Timezones.getDefaultTz());
} catch (TimezonesException tze) {
throw new RuntimeException(tze);
}
return isoDateTimeFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromISODateTime",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"isoDateTimeFormat",
")",
"{",
"try",
"{",
"isoDateTimeFormat",
".",
"setTimeZone",
"(",
"Timezones",
".",
"getDefaultTz",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TimezonesException",
"tze",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"tze",
")",
";",
"}",
"return",
"isoDateTimeFormat",
".",
"parse",
"(",
"val",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get Date from "yyyyMMddThhmmss"
@param val String "yyyyMMddThhmmss"
@return Date
@throws BadDateException on format error | [
"Get",
"Date",
"from",
"yyyyMMddThhmmss"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L314-L327 |
143,548 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromISODateTime | public static Date fromISODateTime(final String val,
final TimeZone tz) throws BadDateException {
try {
synchronized (isoDateTimeTZFormat) {
isoDateTimeTZFormat.setTimeZone(tz);
return isoDateTimeTZFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromISODateTime(final String val,
final TimeZone tz) throws BadDateException {
try {
synchronized (isoDateTimeTZFormat) {
isoDateTimeTZFormat.setTimeZone(tz);
return isoDateTimeTZFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromISODateTime",
"(",
"final",
"String",
"val",
",",
"final",
"TimeZone",
"tz",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"isoDateTimeTZFormat",
")",
"{",
"isoDateTimeTZFormat",
".",
"setTimeZone",
"(",
"tz",
")",
";",
"return",
"isoDateTimeTZFormat",
".",
"parse",
"(",
"val",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get Date from "yyyyMMddThhmmss" with timezone
@param val String "yyyyMMddThhmmss"
@param tz TimeZone
@return Date
@throws BadDateException on format error | [
"Get",
"Date",
"from",
"yyyyMMddThhmmss",
"with",
"timezone"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L372-L382 |
143,549 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromISODateTimeUTC | @SuppressWarnings("unused")
public static Date fromISODateTimeUTC(final String val,
final TimeZone tz) throws BadDateException {
try {
synchronized (isoDateTimeUTCTZFormat) {
isoDateTimeUTCTZFormat.setTimeZone(tz);
return isoDateTimeUTCTZFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | @SuppressWarnings("unused")
public static Date fromISODateTimeUTC(final String val,
final TimeZone tz) throws BadDateException {
try {
synchronized (isoDateTimeUTCTZFormat) {
isoDateTimeUTCTZFormat.setTimeZone(tz);
return isoDateTimeUTCTZFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"static",
"Date",
"fromISODateTimeUTC",
"(",
"final",
"String",
"val",
",",
"final",
"TimeZone",
"tz",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"isoDateTimeUTCTZFormat",
")",
"{",
"isoDateTimeUTCTZFormat",
".",
"setTimeZone",
"(",
"tz",
")",
";",
"return",
"isoDateTimeUTCTZFormat",
".",
"parse",
"(",
"val",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get Date from "yyyyMMddThhmmssZ" with timezone
@param val String "yyyyMMddThhmmssZ"
@param tz TimeZone
@return Date
@throws BadDateException on format error | [
"Get",
"Date",
"from",
"yyyyMMddThhmmssZ",
"with",
"timezone"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L391-L402 |
143,550 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromISODateTimeUTC | public static Date fromISODateTimeUTC(final String val) throws BadDateException {
try {
synchronized (isoDateTimeUTCFormat) {
return isoDateTimeUTCFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromISODateTimeUTC(final String val) throws BadDateException {
try {
synchronized (isoDateTimeUTCFormat) {
return isoDateTimeUTCFormat.parse(val);
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromISODateTimeUTC",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"isoDateTimeUTCFormat",
")",
"{",
"return",
"isoDateTimeUTCFormat",
".",
"parse",
"(",
"val",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get Date from "yyyyMMddThhmmssZ"
@param val String "yyyyMMddThhmmssZ"
@return Date
@throws BadDateException on format error | [
"Get",
"Date",
"from",
"yyyyMMddThhmmssZ"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L410-L418 |
143,551 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromISODateTimeUTCtoRfc822 | public static String fromISODateTimeUTCtoRfc822(final String val) throws BadDateException {
try {
synchronized (isoDateTimeUTCFormat) {
return rfc822Date(isoDateTimeUTCFormat.parse(val));
}
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static String fromISODateTimeUTCtoRfc822(final String val) throws BadDateException {
try {
synchronized (isoDateTimeUTCFormat) {
return rfc822Date(isoDateTimeUTCFormat.parse(val));
}
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"String",
"fromISODateTimeUTCtoRfc822",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"synchronized",
"(",
"isoDateTimeUTCFormat",
")",
"{",
"return",
"rfc822Date",
"(",
"isoDateTimeUTCFormat",
".",
"parse",
"(",
"val",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Get RFC822 form from "yyyyMMddThhmmssZ"
@param val String "yyyyMMddThhmmssZ"
@return Date
@throws BadDateException on format error | [
"Get",
"RFC822",
"form",
"from",
"yyyyMMddThhmmssZ"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L442-L450 |
143,552 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.isISODate | public static boolean isISODate(final String val) throws BadDateException {
try {
if (val.length() != 8) {
return false;
}
fromISODate(val);
return true;
} catch (Throwable t) {
return false;
}
} | java | public static boolean isISODate(final String val) throws BadDateException {
try {
if (val.length() != 8) {
return false;
}
fromISODate(val);
return true;
} catch (Throwable t) {
return false;
}
} | [
"public",
"static",
"boolean",
"isISODate",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"if",
"(",
"val",
".",
"length",
"(",
")",
"!=",
"8",
")",
"{",
"return",
"false",
";",
"}",
"fromISODate",
"(",
"val",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Check Date is "yyyyMMdd"
@param val String to check
@return boolean
@throws BadDateException on format error | [
"Check",
"Date",
"is",
"yyyyMMdd"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L458-L468 |
143,553 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.isISODateTimeUTC | public static boolean isISODateTimeUTC(final String val) throws BadDateException {
try {
if (val.length() != 16) {
return false;
}
fromISODateTimeUTC(val);
return true;
} catch (Throwable t) {
return false;
}
} | java | public static boolean isISODateTimeUTC(final String val) throws BadDateException {
try {
if (val.length() != 16) {
return false;
}
fromISODateTimeUTC(val);
return true;
} catch (Throwable t) {
return false;
}
} | [
"public",
"static",
"boolean",
"isISODateTimeUTC",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"if",
"(",
"val",
".",
"length",
"(",
")",
"!=",
"16",
")",
"{",
"return",
"false",
";",
"}",
"fromISODateTimeUTC",
"(",
"val",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Check Date is "yyyyMMddThhmmddZ"
@param val String to check
@return boolean
@throws BadDateException on format error | [
"Check",
"Date",
"is",
"yyyyMMddThhmmddZ"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L476-L486 |
143,554 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.isISODateTime | public static boolean isISODateTime(final String val) throws BadDateException {
try {
if (val.length() != 15) {
return false;
}
fromISODateTime(val);
return true;
} catch (Throwable t) {
return false;
}
} | java | public static boolean isISODateTime(final String val) throws BadDateException {
try {
if (val.length() != 15) {
return false;
}
fromISODateTime(val);
return true;
} catch (Throwable t) {
return false;
}
} | [
"public",
"static",
"boolean",
"isISODateTime",
"(",
"final",
"String",
"val",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"if",
"(",
"val",
".",
"length",
"(",
")",
"!=",
"15",
")",
"{",
"return",
"false",
";",
"}",
"fromISODateTime",
"(",
"val",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Check Date is "yyyyMMddThhmmdd"
@param val String to check
@return boolean
@throws BadDateException on format error | [
"Check",
"Date",
"is",
"yyyyMMddThhmmdd"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L494-L504 |
143,555 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromDate | public static Date fromDate(final String dt) throws BadDateException {
try {
if (dt == null) {
return null;
}
if (dt.indexOf("T") > 0) {
return fromDateTime(dt);
}
if (!dt.contains("-")) {
return fromISODate(dt);
}
return fromRfcDate(dt);
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromDate(final String dt) throws BadDateException {
try {
if (dt == null) {
return null;
}
if (dt.indexOf("T") > 0) {
return fromDateTime(dt);
}
if (!dt.contains("-")) {
return fromISODate(dt);
}
return fromRfcDate(dt);
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromDate",
"(",
"final",
"String",
"dt",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"if",
"(",
"dt",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"dt",
".",
"indexOf",
"(",
"\"T\"",
")",
">",
"0",
")",
"{",
"return",
"fromDateTime",
"(",
"dt",
")",
";",
"}",
"if",
"(",
"!",
"dt",
".",
"contains",
"(",
"\"-\"",
")",
")",
"{",
"return",
"fromISODate",
"(",
"dt",
")",
";",
"}",
"return",
"fromRfcDate",
"(",
"dt",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Return rfc or iso String date or datetime as java Date
@param dt string format date
@return Date
@throws BadDateException on format error | [
"Return",
"rfc",
"or",
"iso",
"String",
"date",
"or",
"datetime",
"as",
"java",
"Date"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L512-L530 |
143,556 | Bedework/bw-util | bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java | DateTimeUtil.fromDateTime | public static Date fromDateTime(final String dt) throws BadDateException {
try {
if (dt == null) {
return null;
}
if (!dt.contains("-")) {
return fromISODateTimeUTC(dt);
}
return fromRfcDateTimeUTC(dt);
} catch (Throwable t) {
throw new BadDateException();
}
} | java | public static Date fromDateTime(final String dt) throws BadDateException {
try {
if (dt == null) {
return null;
}
if (!dt.contains("-")) {
return fromISODateTimeUTC(dt);
}
return fromRfcDateTimeUTC(dt);
} catch (Throwable t) {
throw new BadDateException();
}
} | [
"public",
"static",
"Date",
"fromDateTime",
"(",
"final",
"String",
"dt",
")",
"throws",
"BadDateException",
"{",
"try",
"{",
"if",
"(",
"dt",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"dt",
".",
"contains",
"(",
"\"-\"",
")",
")",
"{",
"return",
"fromISODateTimeUTC",
"(",
"dt",
")",
";",
"}",
"return",
"fromRfcDateTimeUTC",
"(",
"dt",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"BadDateException",
"(",
")",
";",
"}",
"}"
] | Return rfc or iso String datetime as java Date
@param dt string date
@return Date
@throws BadDateException on format error | [
"Return",
"rfc",
"or",
"iso",
"String",
"datetime",
"as",
"java",
"Date"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/DateTimeUtil.java#L538-L552 |
143,557 | sebastiangraf/treetank | coremodules/core/src/main/java/org/treetank/access/conf/ModuleSetter.java | ModuleSetter.createModule | public AbstractModule createModule() {
return new AbstractModule() {
@Override
protected void configure() {
bind(IDataFactory.class).to(mDataFacClass);
bind(IMetaEntryFactory.class).to(mMetaFacClass);
bind(IRevisioning.class).to(mRevisioningClass);
bind(IByteHandlerPipeline.class).toInstance(mByteHandler);
install(new FactoryModuleBuilder().implement(IBackend.class, mBackend).build(
IBackendFactory.class));
install(new FactoryModuleBuilder().build(IResourceConfigurationFactory.class));
bind(Key.class).toInstance(mKey);
install(new FactoryModuleBuilder().build(ISessionConfigurationFactory.class));
}
};
} | java | public AbstractModule createModule() {
return new AbstractModule() {
@Override
protected void configure() {
bind(IDataFactory.class).to(mDataFacClass);
bind(IMetaEntryFactory.class).to(mMetaFacClass);
bind(IRevisioning.class).to(mRevisioningClass);
bind(IByteHandlerPipeline.class).toInstance(mByteHandler);
install(new FactoryModuleBuilder().implement(IBackend.class, mBackend).build(
IBackendFactory.class));
install(new FactoryModuleBuilder().build(IResourceConfigurationFactory.class));
bind(Key.class).toInstance(mKey);
install(new FactoryModuleBuilder().build(ISessionConfigurationFactory.class));
}
};
} | [
"public",
"AbstractModule",
"createModule",
"(",
")",
"{",
"return",
"new",
"AbstractModule",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"configure",
"(",
")",
"{",
"bind",
"(",
"IDataFactory",
".",
"class",
")",
".",
"to",
"(",
"mDataFacClass",
")",
";",
"bind",
"(",
"IMetaEntryFactory",
".",
"class",
")",
".",
"to",
"(",
"mMetaFacClass",
")",
";",
"bind",
"(",
"IRevisioning",
".",
"class",
")",
".",
"to",
"(",
"mRevisioningClass",
")",
";",
"bind",
"(",
"IByteHandlerPipeline",
".",
"class",
")",
".",
"toInstance",
"(",
"mByteHandler",
")",
";",
"install",
"(",
"new",
"FactoryModuleBuilder",
"(",
")",
".",
"implement",
"(",
"IBackend",
".",
"class",
",",
"mBackend",
")",
".",
"build",
"(",
"IBackendFactory",
".",
"class",
")",
")",
";",
"install",
"(",
"new",
"FactoryModuleBuilder",
"(",
")",
".",
"build",
"(",
"IResourceConfigurationFactory",
".",
"class",
")",
")",
";",
"bind",
"(",
"Key",
".",
"class",
")",
".",
"toInstance",
"(",
"mKey",
")",
";",
"install",
"(",
"new",
"FactoryModuleBuilder",
"(",
")",
".",
"build",
"(",
"ISessionConfigurationFactory",
".",
"class",
")",
")",
";",
"}",
"}",
";",
"}"
] | Creating an Guice Module based on the parameters set.
@return the {@link AbstractModule} to be set | [
"Creating",
"an",
"Guice",
"Module",
"based",
"on",
"the",
"parameters",
"set",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/core/src/main/java/org/treetank/access/conf/ModuleSetter.java#L120-L135 |
143,558 | Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java | XmlEmit.setProperty | public void setProperty(final String name, final String val) {
if (props == null) {
props = new Properties();
}
props.setProperty(name, val);
} | java | public void setProperty(final String name, final String val) {
if (props == null) {
props = new Properties();
}
props.setProperty(name, val);
} | [
"public",
"void",
"setProperty",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"val",
")",
"{",
"if",
"(",
"props",
"==",
"null",
")",
"{",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"}",
"props",
".",
"setProperty",
"(",
"name",
",",
"val",
")",
";",
"}"
] | Allows applications to provide parameters to methods using this object class,
<p>For example, a parameter "full" with value "true" might indicate a full
XML dump is required.
@param name
@param val | [
"Allows",
"applications",
"to",
"provide",
"parameters",
"to",
"methods",
"using",
"this",
"object",
"class"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java#L141-L147 |
143,559 | Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java | XmlEmit.startEmit | public void startEmit(final Writer wtr, final String dtd) throws IOException {
this.wtr = wtr;
this.dtd = dtd;
} | java | public void startEmit(final Writer wtr, final String dtd) throws IOException {
this.wtr = wtr;
this.dtd = dtd;
} | [
"public",
"void",
"startEmit",
"(",
"final",
"Writer",
"wtr",
",",
"final",
"String",
"dtd",
")",
"throws",
"IOException",
"{",
"this",
".",
"wtr",
"=",
"wtr",
";",
"this",
".",
"dtd",
"=",
"dtd",
";",
"}"
] | Emit any headers, dtd and namespace declarations
@param wtr
@param dtd
@throws IOException | [
"Emit",
"any",
"headers",
"dtd",
"and",
"namespace",
"declarations"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java#L176-L179 |
143,560 | Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java | XmlEmit.openTag | public void openTag(final QName tag,
final String attrName,
final String attrVal) throws IOException {
blanks();
openTagSameLine(tag, attrName, attrVal);
newline();
indent += 2;
} | java | public void openTag(final QName tag,
final String attrName,
final String attrVal) throws IOException {
blanks();
openTagSameLine(tag, attrName, attrVal);
newline();
indent += 2;
} | [
"public",
"void",
"openTag",
"(",
"final",
"QName",
"tag",
",",
"final",
"String",
"attrName",
",",
"final",
"String",
"attrVal",
")",
"throws",
"IOException",
"{",
"blanks",
"(",
")",
";",
"openTagSameLine",
"(",
"tag",
",",
"attrName",
",",
"attrVal",
")",
";",
"newline",
"(",
")",
";",
"indent",
"+=",
"2",
";",
"}"
] | open with attribute
@param tag
@param attrName
@param attrVal
@throws IOException | [
"open",
"with",
"attribute"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java#L208-L215 |
143,561 | Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java | XmlEmit.openTagSameLine | public void openTagSameLine(final QName tag,
final String attrName,
final String attrVal) throws IOException {
lb();
emitQName(tag);
attribute(attrName, attrVal);
endOpeningTag();
} | java | public void openTagSameLine(final QName tag,
final String attrName,
final String attrVal) throws IOException {
lb();
emitQName(tag);
attribute(attrName, attrVal);
endOpeningTag();
} | [
"public",
"void",
"openTagSameLine",
"(",
"final",
"QName",
"tag",
",",
"final",
"String",
"attrName",
",",
"final",
"String",
"attrVal",
")",
"throws",
"IOException",
"{",
"lb",
"(",
")",
";",
"emitQName",
"(",
"tag",
")",
";",
"attribute",
"(",
"attrName",
",",
"attrVal",
")",
";",
"endOpeningTag",
"(",
")",
";",
"}"
] | Emit an opening tag ready for nested values. No new line
@param tag
@param attrName
@param attrVal
@throws IOException | [
"Emit",
"an",
"opening",
"tag",
"ready",
"for",
"nested",
"values",
".",
"No",
"new",
"line"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java#L258-L265 |
143,562 | Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java | XmlEmit.value | private void value(final String val,
final String quoteChar) throws IOException {
if (val == null) {
return;
}
String q = quoteChar;
if (q == null) {
q = "";
}
if ((val.indexOf('&') >= 0) ||
(val.indexOf('<') >= 0)) {
out("<![CDATA[");
out(q);
out(val);
out(q);
out("]]>");
} else {
out(q);
out(val);
out(q);
}
} | java | private void value(final String val,
final String quoteChar) throws IOException {
if (val == null) {
return;
}
String q = quoteChar;
if (q == null) {
q = "";
}
if ((val.indexOf('&') >= 0) ||
(val.indexOf('<') >= 0)) {
out("<![CDATA[");
out(q);
out(val);
out(q);
out("]]>");
} else {
out(q);
out(val);
out(q);
}
} | [
"private",
"void",
"value",
"(",
"final",
"String",
"val",
",",
"final",
"String",
"quoteChar",
")",
"throws",
"IOException",
"{",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"return",
";",
"}",
"String",
"q",
"=",
"quoteChar",
";",
"if",
"(",
"q",
"==",
"null",
")",
"{",
"q",
"=",
"\"\"",
";",
"}",
"if",
"(",
"(",
"val",
".",
"indexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
"||",
"(",
"val",
".",
"indexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
")",
"{",
"out",
"(",
"\"<![CDATA[\"",
")",
";",
"out",
"(",
"q",
")",
";",
"out",
"(",
"val",
")",
";",
"out",
"(",
"q",
")",
";",
"out",
"(",
"\"]]>\"",
")",
";",
"}",
"else",
"{",
"out",
"(",
"q",
")",
";",
"out",
"(",
"val",
")",
";",
"out",
"(",
"q",
")",
";",
"}",
"}"
] | Write out a value
@param val
@param quoteChar
@throws IOException | [
"Write",
"out",
"a",
"value"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlEmit.java#L545-L568 |
143,563 | Bedework/bw-util | bw-util-options/src/main/java/org/bedework/util/options/Options.java | Options.parseOptions | public OptionElement parseOptions(final InputStream is) throws OptionsException{
Reader rdr = null;
try {
rdr = new InputStreamReader(is);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(rdr));
/* We expect a root element named as specified */
Element root = doc.getDocumentElement();
if (!root.getNodeName().equals(outerTag.getLocalPart())) {
throw new OptionsException("org.bedework.bad.options");
}
OptionElement oel = new OptionElement();
oel.name = "root";
doChildren(oel, root, new Stack<Object>());
return oel;
} catch (OptionsException ce) {
throw ce;
} catch (Throwable t) {
throw new OptionsException(t);
} finally {
if (rdr != null) {
try {
rdr.close();
} catch (Throwable t) {}
}
}
} | java | public OptionElement parseOptions(final InputStream is) throws OptionsException{
Reader rdr = null;
try {
rdr = new InputStreamReader(is);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(rdr));
/* We expect a root element named as specified */
Element root = doc.getDocumentElement();
if (!root.getNodeName().equals(outerTag.getLocalPart())) {
throw new OptionsException("org.bedework.bad.options");
}
OptionElement oel = new OptionElement();
oel.name = "root";
doChildren(oel, root, new Stack<Object>());
return oel;
} catch (OptionsException ce) {
throw ce;
} catch (Throwable t) {
throw new OptionsException(t);
} finally {
if (rdr != null) {
try {
rdr.close();
} catch (Throwable t) {}
}
}
} | [
"public",
"OptionElement",
"parseOptions",
"(",
"final",
"InputStream",
"is",
")",
"throws",
"OptionsException",
"{",
"Reader",
"rdr",
"=",
"null",
";",
"try",
"{",
"rdr",
"=",
"new",
"InputStreamReader",
"(",
"is",
")",
";",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"false",
")",
";",
"DocumentBuilder",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"doc",
"=",
"builder",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"rdr",
")",
")",
";",
"/* We expect a root element named as specified */",
"Element",
"root",
"=",
"doc",
".",
"getDocumentElement",
"(",
")",
";",
"if",
"(",
"!",
"root",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"outerTag",
".",
"getLocalPart",
"(",
")",
")",
")",
"{",
"throw",
"new",
"OptionsException",
"(",
"\"org.bedework.bad.options\"",
")",
";",
"}",
"OptionElement",
"oel",
"=",
"new",
"OptionElement",
"(",
")",
";",
"oel",
".",
"name",
"=",
"\"root\"",
";",
"doChildren",
"(",
"oel",
",",
"root",
",",
"new",
"Stack",
"<",
"Object",
">",
"(",
")",
")",
";",
"return",
"oel",
";",
"}",
"catch",
"(",
"OptionsException",
"ce",
")",
"{",
"throw",
"ce",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"OptionsException",
"(",
"t",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"rdr",
"!=",
"null",
")",
"{",
"try",
"{",
"rdr",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"}",
"}",
"}"
] | Parse the input stream and return the internal representation.
@param is InputStream
@return OptionElement root of parsed options.
@exception OptionsException Some error occurred. | [
"Parse",
"the",
"input",
"stream",
"and",
"return",
"the",
"internal",
"representation",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-options/src/main/java/org/bedework/util/options/Options.java#L156-L194 |
143,564 | Bedework/bw-util | bw-util-options/src/main/java/org/bedework/util/options/Options.java | Options.toXml | public void toXml(final OptionElement root, final OutputStream str) throws OptionsException {
Writer wtr = null;
try {
XmlEmit xml = new XmlEmit(true);
wtr = new OutputStreamWriter(str);
xml.startEmit(wtr);
xml.openTag(outerTag);
for (OptionElement oe: root.getChildren()) {
childToXml(oe, xml);
}
xml.closeTag(outerTag);
} catch (OptionsException ce) {
throw ce;
} catch (Throwable t) {
throw new OptionsException(t);
} finally {
if (wtr != null) {
try {
wtr.close();
} catch (Throwable t) {}
}
}
} | java | public void toXml(final OptionElement root, final OutputStream str) throws OptionsException {
Writer wtr = null;
try {
XmlEmit xml = new XmlEmit(true);
wtr = new OutputStreamWriter(str);
xml.startEmit(wtr);
xml.openTag(outerTag);
for (OptionElement oe: root.getChildren()) {
childToXml(oe, xml);
}
xml.closeTag(outerTag);
} catch (OptionsException ce) {
throw ce;
} catch (Throwable t) {
throw new OptionsException(t);
} finally {
if (wtr != null) {
try {
wtr.close();
} catch (Throwable t) {}
}
}
} | [
"public",
"void",
"toXml",
"(",
"final",
"OptionElement",
"root",
",",
"final",
"OutputStream",
"str",
")",
"throws",
"OptionsException",
"{",
"Writer",
"wtr",
"=",
"null",
";",
"try",
"{",
"XmlEmit",
"xml",
"=",
"new",
"XmlEmit",
"(",
"true",
")",
";",
"wtr",
"=",
"new",
"OutputStreamWriter",
"(",
"str",
")",
";",
"xml",
".",
"startEmit",
"(",
"wtr",
")",
";",
"xml",
".",
"openTag",
"(",
"outerTag",
")",
";",
"for",
"(",
"OptionElement",
"oe",
":",
"root",
".",
"getChildren",
"(",
")",
")",
"{",
"childToXml",
"(",
"oe",
",",
"xml",
")",
";",
"}",
"xml",
".",
"closeTag",
"(",
"outerTag",
")",
";",
"}",
"catch",
"(",
"OptionsException",
"ce",
")",
"{",
"throw",
"ce",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"OptionsException",
"(",
"t",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"wtr",
"!=",
"null",
")",
"{",
"try",
"{",
"wtr",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"}",
"}",
"}"
] | Emit the options as xml.
@param root
@param str
@throws OptionsException | [
"Emit",
"the",
"options",
"as",
"xml",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-options/src/main/java/org/bedework/util/options/Options.java#L202-L229 |
143,565 | Bedework/bw-util | bw-util-options/src/main/java/org/bedework/util/options/Options.java | Options.getProperty | @Override
public Object getProperty(final String name) throws OptionsException {
Object val = getOptProperty(name);
if (val == null) {
throw new OptionsException("Missing property " + name);
}
return val;
} | java | @Override
public Object getProperty(final String name) throws OptionsException {
Object val = getOptProperty(name);
if (val == null) {
throw new OptionsException("Missing property " + name);
}
return val;
} | [
"@",
"Override",
"public",
"Object",
"getProperty",
"(",
"final",
"String",
"name",
")",
"throws",
"OptionsException",
"{",
"Object",
"val",
"=",
"getOptProperty",
"(",
"name",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"throw",
"new",
"OptionsException",
"(",
"\"Missing property \"",
"+",
"name",
")",
";",
"}",
"return",
"val",
";",
"}"
] | Get required property, throw exception if absent
@param name String property name
@return Object value
@throws OptionsException | [
"Get",
"required",
"property",
"throw",
"exception",
"if",
"absent"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-options/src/main/java/org/bedework/util/options/Options.java#L321-L330 |
143,566 | Bedework/bw-util | bw-util-options/src/main/java/org/bedework/util/options/Options.java | Options.getStringProperty | @Override
public String getStringProperty(final String name) throws OptionsException {
Object val = getProperty(name);
if (!(val instanceof String)) {
throw new OptionsException("org.bedework.calenv.bad.option.value");
}
return (String)val;
} | java | @Override
public String getStringProperty(final String name) throws OptionsException {
Object val = getProperty(name);
if (!(val instanceof String)) {
throw new OptionsException("org.bedework.calenv.bad.option.value");
}
return (String)val;
} | [
"@",
"Override",
"public",
"String",
"getStringProperty",
"(",
"final",
"String",
"name",
")",
"throws",
"OptionsException",
"{",
"Object",
"val",
"=",
"getProperty",
"(",
"name",
")",
";",
"if",
"(",
"!",
"(",
"val",
"instanceof",
"String",
")",
")",
"{",
"throw",
"new",
"OptionsException",
"(",
"\"org.bedework.calenv.bad.option.value\"",
")",
";",
"}",
"return",
"(",
"String",
")",
"val",
";",
"}"
] | Return the String value of the named property.
@param name String property name
@return String value of property
@throws OptionsException | [
"Return",
"the",
"String",
"value",
"of",
"the",
"named",
"property",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-options/src/main/java/org/bedework/util/options/Options.java#L353-L362 |
143,567 | Bedework/bw-util | bw-util-options/src/main/java/org/bedework/util/options/Options.java | Options.match | public Collection match(final String name) throws OptionsException {
if (useSystemwideValues) {
return match(optionsRoot, makePathElements(name), -1);
}
return match(localOptionsRoot, makePathElements(name), -1);
} | java | public Collection match(final String name) throws OptionsException {
if (useSystemwideValues) {
return match(optionsRoot, makePathElements(name), -1);
}
return match(localOptionsRoot, makePathElements(name), -1);
} | [
"public",
"Collection",
"match",
"(",
"final",
"String",
"name",
")",
"throws",
"OptionsException",
"{",
"if",
"(",
"useSystemwideValues",
")",
"{",
"return",
"match",
"(",
"optionsRoot",
",",
"makePathElements",
"(",
"name",
")",
",",
"-",
"1",
")",
";",
"}",
"return",
"match",
"(",
"localOptionsRoot",
",",
"makePathElements",
"(",
"name",
")",
",",
"-",
"1",
")",
";",
"}"
] | Match for values.
@param name String property name prefix
@return Collection
@throws OptionsException | [
"Match",
"for",
"values",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-options/src/main/java/org/bedework/util/options/Options.java#L594-L600 |
143,568 | Bedework/bw-util | bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java | StrutsUtil.getProperty | public static String getProperty(final MessageResources msg,
final String pname,
final String def) throws Throwable {
String p = msg.getMessage(pname);
if (p == null) {
return def;
}
return p;
} | java | public static String getProperty(final MessageResources msg,
final String pname,
final String def) throws Throwable {
String p = msg.getMessage(pname);
if (p == null) {
return def;
}
return p;
} | [
"public",
"static",
"String",
"getProperty",
"(",
"final",
"MessageResources",
"msg",
",",
"final",
"String",
"pname",
",",
"final",
"String",
"def",
")",
"throws",
"Throwable",
"{",
"String",
"p",
"=",
"msg",
".",
"getMessage",
"(",
"pname",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"return",
"def",
";",
"}",
"return",
"p",
";",
"}"
] | Return a property value or the default
@param msg MessageResources object
@param pname String name of the property
@param def String default value
@return String property value or default (may be null)
@throws Throwable on error | [
"Return",
"a",
"property",
"value",
"or",
"the",
"default"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java#L54-L63 |
143,569 | Bedework/bw-util | bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java | StrutsUtil.getReqProperty | public static String getReqProperty(final MessageResources msg,
final String pname) throws Throwable {
String p = getProperty(msg, pname, null);
if (p == null) {
logger.error("No definition for property " + pname);
throw new Exception(": No definition for property " + pname);
}
return p;
} | java | public static String getReqProperty(final MessageResources msg,
final String pname) throws Throwable {
String p = getProperty(msg, pname, null);
if (p == null) {
logger.error("No definition for property " + pname);
throw new Exception(": No definition for property " + pname);
}
return p;
} | [
"public",
"static",
"String",
"getReqProperty",
"(",
"final",
"MessageResources",
"msg",
",",
"final",
"String",
"pname",
")",
"throws",
"Throwable",
"{",
"String",
"p",
"=",
"getProperty",
"(",
"msg",
",",
"pname",
",",
"null",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"No definition for property \"",
"+",
"pname",
")",
";",
"throw",
"new",
"Exception",
"(",
"\": No definition for property \"",
"+",
"pname",
")",
";",
"}",
"return",
"p",
";",
"}"
] | Return a required property value
@param msg MessageResources object
@param pname name of the property
@return String property value
@throws Throwable on error | [
"Return",
"a",
"required",
"property",
"value"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java#L72-L82 |
143,570 | Bedework/bw-util | bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java | StrutsUtil.getBoolProperty | public static boolean getBoolProperty(final MessageResources msg,
final String pname,
final boolean def) throws Throwable {
String p = msg.getMessage(pname);
if (p == null) {
return def;
}
return Boolean.valueOf(p);
} | java | public static boolean getBoolProperty(final MessageResources msg,
final String pname,
final boolean def) throws Throwable {
String p = msg.getMessage(pname);
if (p == null) {
return def;
}
return Boolean.valueOf(p);
} | [
"public",
"static",
"boolean",
"getBoolProperty",
"(",
"final",
"MessageResources",
"msg",
",",
"final",
"String",
"pname",
",",
"final",
"boolean",
"def",
")",
"throws",
"Throwable",
"{",
"String",
"p",
"=",
"msg",
".",
"getMessage",
"(",
"pname",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"return",
"def",
";",
"}",
"return",
"Boolean",
".",
"valueOf",
"(",
"p",
")",
";",
"}"
] | Return a boolean property value or the default
@param msg MessageResources object
@param pname String name of the property
@param def boolean default value
@return boolean property value or default
@throws Throwable on error | [
"Return",
"a",
"boolean",
"property",
"value",
"or",
"the",
"default"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java#L92-L101 |
143,571 | Bedework/bw-util | bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java | StrutsUtil.getIntProperty | public static int getIntProperty(final MessageResources msg,
final String pname,
final int def) throws Throwable {
String p = msg.getMessage(pname);
if (p == null) {
return def;
}
return Integer.valueOf(p);
} | java | public static int getIntProperty(final MessageResources msg,
final String pname,
final int def) throws Throwable {
String p = msg.getMessage(pname);
if (p == null) {
return def;
}
return Integer.valueOf(p);
} | [
"public",
"static",
"int",
"getIntProperty",
"(",
"final",
"MessageResources",
"msg",
",",
"final",
"String",
"pname",
",",
"final",
"int",
"def",
")",
"throws",
"Throwable",
"{",
"String",
"p",
"=",
"msg",
".",
"getMessage",
"(",
"pname",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"return",
"def",
";",
"}",
"return",
"Integer",
".",
"valueOf",
"(",
"p",
")",
";",
"}"
] | Return an int property value or the default
@param msg MessageResources object
@param pname String name of the property
@param def int default value
@return int property value or default
@throws Throwable on error | [
"Return",
"an",
"int",
"property",
"value",
"or",
"the",
"default"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java#L111-L120 |
143,572 | Bedework/bw-util | bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java | StrutsUtil.getErrorObj | public static MessageEmit getErrorObj(final HttpServletRequest request,
final String errorObjAttrName) {
if (errorObjAttrName == null) {
// don't set
return null;
}
HttpSession sess = request.getSession(false);
if (sess == null) {
logger.error("No session!!!!!!!");
return null;
}
Object o = sess.getAttribute(errorObjAttrName);
if ((o != null) && (o instanceof MessageEmit)) {
return (MessageEmit)o;
}
return null;
} | java | public static MessageEmit getErrorObj(final HttpServletRequest request,
final String errorObjAttrName) {
if (errorObjAttrName == null) {
// don't set
return null;
}
HttpSession sess = request.getSession(false);
if (sess == null) {
logger.error("No session!!!!!!!");
return null;
}
Object o = sess.getAttribute(errorObjAttrName);
if ((o != null) && (o instanceof MessageEmit)) {
return (MessageEmit)o;
}
return null;
} | [
"public",
"static",
"MessageEmit",
"getErrorObj",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"errorObjAttrName",
")",
"{",
"if",
"(",
"errorObjAttrName",
"==",
"null",
")",
"{",
"// don't set",
"return",
"null",
";",
"}",
"HttpSession",
"sess",
"=",
"request",
".",
"getSession",
"(",
"false",
")",
";",
"if",
"(",
"sess",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"No session!!!!!!!\"",
")",
";",
"return",
"null",
";",
"}",
"Object",
"o",
"=",
"sess",
".",
"getAttribute",
"(",
"errorObjAttrName",
")",
";",
"if",
"(",
"(",
"o",
"!=",
"null",
")",
"&&",
"(",
"o",
"instanceof",
"MessageEmit",
")",
")",
"{",
"return",
"(",
"MessageEmit",
")",
"o",
";",
"}",
"return",
"null",
";",
"}"
] | Get the existing error object from the session or null.
@param request Needed to locate session
@param errorObjAttrName name of session attribute
@return MessageEmit null on none found | [
"Get",
"the",
"existing",
"error",
"object",
"from",
"the",
"session",
"or",
"null",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java#L194-L214 |
143,573 | Bedework/bw-util | bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java | StrutsUtil.getMessageObj | public static MessageEmit getMessageObj(final HttpServletRequest request,
final String messageObjAttrName) {
if (messageObjAttrName == null) {
// don't set
return null;
}
HttpSession sess = request.getSession(false);
if (sess == null) {
logger.error("No session!!!!!!!");
return null;
}
Object o = sess.getAttribute(messageObjAttrName);
if ((o != null) && (o instanceof MessageEmit)) {
return (MessageEmit)o;
}
return null;
} | java | public static MessageEmit getMessageObj(final HttpServletRequest request,
final String messageObjAttrName) {
if (messageObjAttrName == null) {
// don't set
return null;
}
HttpSession sess = request.getSession(false);
if (sess == null) {
logger.error("No session!!!!!!!");
return null;
}
Object o = sess.getAttribute(messageObjAttrName);
if ((o != null) && (o instanceof MessageEmit)) {
return (MessageEmit)o;
}
return null;
} | [
"public",
"static",
"MessageEmit",
"getMessageObj",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"String",
"messageObjAttrName",
")",
"{",
"if",
"(",
"messageObjAttrName",
"==",
"null",
")",
"{",
"// don't set",
"return",
"null",
";",
"}",
"HttpSession",
"sess",
"=",
"request",
".",
"getSession",
"(",
"false",
")",
";",
"if",
"(",
"sess",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"No session!!!!!!!\"",
")",
";",
"return",
"null",
";",
"}",
"Object",
"o",
"=",
"sess",
".",
"getAttribute",
"(",
"messageObjAttrName",
")",
";",
"if",
"(",
"(",
"o",
"!=",
"null",
")",
"&&",
"(",
"o",
"instanceof",
"MessageEmit",
")",
")",
"{",
"return",
"(",
"MessageEmit",
")",
"o",
";",
"}",
"return",
"null",
";",
"}"
] | Get the existing message object from the session or null.
@param request Needed to locate session
@param messageObjAttrName name of session attribute
@return MessageEmit null on none found | [
"Get",
"the",
"existing",
"message",
"object",
"from",
"the",
"session",
"or",
"null",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/StrutsUtil.java#L282-L302 |
143,574 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/Util.java | Util.quickRatio | public static double quickRatio(final String paramFirst, final String paramSecond) {
if (paramFirst == null || paramSecond == null) {
return 1;
}
double matches = 0;
// Use a sparse array to reduce the memory usage
// for unicode characters.
final int x[][] = new int[256][];
for (char c : paramSecond.toCharArray()) {
if (x[c >> 8] == null) {
x[c >> 8] = new int[256];
}
x[c >> 8][c & 0xFF]++;
}
for (char c : paramFirst.toCharArray()) {
final int n = (x[c >> 8] == null) ? 0 : x[c >> 8][c & 0xFF]--;
if (n > 0) {
matches++;
}
}
return 2.0 * matches / (paramFirst.length() + paramSecond.length());
} | java | public static double quickRatio(final String paramFirst, final String paramSecond) {
if (paramFirst == null || paramSecond == null) {
return 1;
}
double matches = 0;
// Use a sparse array to reduce the memory usage
// for unicode characters.
final int x[][] = new int[256][];
for (char c : paramSecond.toCharArray()) {
if (x[c >> 8] == null) {
x[c >> 8] = new int[256];
}
x[c >> 8][c & 0xFF]++;
}
for (char c : paramFirst.toCharArray()) {
final int n = (x[c >> 8] == null) ? 0 : x[c >> 8][c & 0xFF]--;
if (n > 0) {
matches++;
}
}
return 2.0 * matches / (paramFirst.length() + paramSecond.length());
} | [
"public",
"static",
"double",
"quickRatio",
"(",
"final",
"String",
"paramFirst",
",",
"final",
"String",
"paramSecond",
")",
"{",
"if",
"(",
"paramFirst",
"==",
"null",
"||",
"paramSecond",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"double",
"matches",
"=",
"0",
";",
"// Use a sparse array to reduce the memory usage",
"// for unicode characters.",
"final",
"int",
"x",
"[",
"]",
"[",
"]",
"=",
"new",
"int",
"[",
"256",
"]",
"[",
"",
"]",
";",
"for",
"(",
"char",
"c",
":",
"paramSecond",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"x",
"[",
"c",
">>",
"8",
"]",
"==",
"null",
")",
"{",
"x",
"[",
"c",
">>",
"8",
"]",
"=",
"new",
"int",
"[",
"256",
"]",
";",
"}",
"x",
"[",
"c",
">>",
"8",
"]",
"[",
"c",
"&",
"0xFF",
"]",
"++",
";",
"}",
"for",
"(",
"char",
"c",
":",
"paramFirst",
".",
"toCharArray",
"(",
")",
")",
"{",
"final",
"int",
"n",
"=",
"(",
"x",
"[",
"c",
">>",
"8",
"]",
"==",
"null",
")",
"?",
"0",
":",
"x",
"[",
"c",
">>",
"8",
"]",
"[",
"c",
"&",
"0xFF",
"]",
"--",
";",
"if",
"(",
"n",
">",
"0",
")",
"{",
"matches",
"++",
";",
"}",
"}",
"return",
"2.0",
"*",
"matches",
"/",
"(",
"paramFirst",
".",
"length",
"(",
")",
"+",
"paramSecond",
".",
"length",
"(",
")",
")",
";",
"}"
] | Calculates the similarity of two strings. This is done by comparing the
frequency each character occures in both strings.
@param paramFirst
first string
@param paramSecond
second string
@return similarity of a and b, a value in [0, 1] | [
"Calculates",
"the",
"similarity",
"of",
"two",
"strings",
".",
"This",
"is",
"done",
"by",
"comparing",
"the",
"frequency",
"each",
"character",
"occures",
"in",
"both",
"strings",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/Util.java#L119-L143 |
143,575 | Bedework/bw-util | bw-util-jmx/src/main/java/org/bedework/util/jmx/ManagementContext.java | ManagementContext.createCustomComponentMBeanName | public ObjectName createCustomComponentMBeanName(final String type, final String name) {
ObjectName result = null;
String tmp = jmxDomainName + ":" +
"type=" + sanitizeString(type) +
",name=" + sanitizeString(name);
try {
result = new ObjectName(tmp);
} catch (MalformedObjectNameException e) {
error("Couldn't create ObjectName from: " + type + " , " + name);
}
return result;
} | java | public ObjectName createCustomComponentMBeanName(final String type, final String name) {
ObjectName result = null;
String tmp = jmxDomainName + ":" +
"type=" + sanitizeString(type) +
",name=" + sanitizeString(name);
try {
result = new ObjectName(tmp);
} catch (MalformedObjectNameException e) {
error("Couldn't create ObjectName from: " + type + " , " + name);
}
return result;
} | [
"public",
"ObjectName",
"createCustomComponentMBeanName",
"(",
"final",
"String",
"type",
",",
"final",
"String",
"name",
")",
"{",
"ObjectName",
"result",
"=",
"null",
";",
"String",
"tmp",
"=",
"jmxDomainName",
"+",
"\":\"",
"+",
"\"type=\"",
"+",
"sanitizeString",
"(",
"type",
")",
"+",
"\",name=\"",
"+",
"sanitizeString",
"(",
"name",
")",
";",
"try",
"{",
"result",
"=",
"new",
"ObjectName",
"(",
"tmp",
")",
";",
"}",
"catch",
"(",
"MalformedObjectNameException",
"e",
")",
"{",
"error",
"(",
"\"Couldn't create ObjectName from: \"",
"+",
"type",
"+",
"\" , \"",
"+",
"name",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Formulate and return the MBean ObjectName of a custom control MBean
@param type
@param name
@return the JMX ObjectName of the MBean, or <code>null</code> if
<code>customName</code> is invalid. | [
"Formulate",
"and",
"return",
"the",
"MBean",
"ObjectName",
"of",
"a",
"custom",
"control",
"MBean"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jmx/src/main/java/org/bedework/util/jmx/ManagementContext.java#L203-L214 |
143,576 | Bedework/bw-util | bw-util-jmx/src/main/java/org/bedework/util/jmx/ManagementContext.java | ManagementContext.getSystemObjectName | public static ObjectName getSystemObjectName(final String domainName,
final String containerName,
final Class theClass) throws MalformedObjectNameException {
String tmp = domainName + ":" +
"type=" + theClass.getName() +
",name=" + getRelativeName(containerName, theClass);
return new ObjectName(tmp);
} | java | public static ObjectName getSystemObjectName(final String domainName,
final String containerName,
final Class theClass) throws MalformedObjectNameException {
String tmp = domainName + ":" +
"type=" + theClass.getName() +
",name=" + getRelativeName(containerName, theClass);
return new ObjectName(tmp);
} | [
"public",
"static",
"ObjectName",
"getSystemObjectName",
"(",
"final",
"String",
"domainName",
",",
"final",
"String",
"containerName",
",",
"final",
"Class",
"theClass",
")",
"throws",
"MalformedObjectNameException",
"{",
"String",
"tmp",
"=",
"domainName",
"+",
"\":\"",
"+",
"\"type=\"",
"+",
"theClass",
".",
"getName",
"(",
")",
"+",
"\",name=\"",
"+",
"getRelativeName",
"(",
"containerName",
",",
"theClass",
")",
";",
"return",
"new",
"ObjectName",
"(",
"tmp",
")",
";",
"}"
] | Retrieve a System ObjectName
@param domainName
@param containerName
@param theClass
@return the ObjectName
@throws MalformedObjectNameException | [
"Retrieve",
"a",
"System",
"ObjectName"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jmx/src/main/java/org/bedework/util/jmx/ManagementContext.java#L254-L261 |
143,577 | Bedework/bw-util | bw-util-jmx/src/main/java/org/bedework/util/jmx/ManagementContext.java | ManagementContext.unregisterMBean | public void unregisterMBean(final ObjectName name) throws JMException {
if ((beanServer != null) &&
beanServer.isRegistered(name) &&
registeredMBeanNames.remove(name)) {
beanServer.unregisterMBean(name);
}
} | java | public void unregisterMBean(final ObjectName name) throws JMException {
if ((beanServer != null) &&
beanServer.isRegistered(name) &&
registeredMBeanNames.remove(name)) {
beanServer.unregisterMBean(name);
}
} | [
"public",
"void",
"unregisterMBean",
"(",
"final",
"ObjectName",
"name",
")",
"throws",
"JMException",
"{",
"if",
"(",
"(",
"beanServer",
"!=",
"null",
")",
"&&",
"beanServer",
".",
"isRegistered",
"(",
"name",
")",
"&&",
"registeredMBeanNames",
".",
"remove",
"(",
"name",
")",
")",
"{",
"beanServer",
".",
"unregisterMBean",
"(",
"name",
")",
";",
"}",
"}"
] | Unregister an MBean
@param name of mbean
@throws JMException | [
"Unregister",
"an",
"MBean"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jmx/src/main/java/org/bedework/util/jmx/ManagementContext.java#L363-L369 |
143,578 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/ConnectionMap.java | ConnectionMap.set | public void set(final T paramOrigin, final T paramDestination, final boolean paramBool) {
assert paramOrigin != null;
assert paramDestination != null;
if (!mMap.containsKey(paramOrigin)) {
mMap.put(paramOrigin, new IdentityHashMap<T, Boolean>());
}
mMap.get(paramOrigin).put(paramDestination, paramBool);
} | java | public void set(final T paramOrigin, final T paramDestination, final boolean paramBool) {
assert paramOrigin != null;
assert paramDestination != null;
if (!mMap.containsKey(paramOrigin)) {
mMap.put(paramOrigin, new IdentityHashMap<T, Boolean>());
}
mMap.get(paramOrigin).put(paramDestination, paramBool);
} | [
"public",
"void",
"set",
"(",
"final",
"T",
"paramOrigin",
",",
"final",
"T",
"paramDestination",
",",
"final",
"boolean",
"paramBool",
")",
"{",
"assert",
"paramOrigin",
"!=",
"null",
";",
"assert",
"paramDestination",
"!=",
"null",
";",
"if",
"(",
"!",
"mMap",
".",
"containsKey",
"(",
"paramOrigin",
")",
")",
"{",
"mMap",
".",
"put",
"(",
"paramOrigin",
",",
"new",
"IdentityHashMap",
"<",
"T",
",",
"Boolean",
">",
"(",
")",
")",
";",
"}",
"mMap",
".",
"get",
"(",
"paramOrigin",
")",
".",
"put",
"(",
"paramDestination",
",",
"paramBool",
")",
";",
"}"
] | Sets the connection between a and b.
@param paramOrigin
origin object
@param paramDestination
destination object
@param paramBool
if connection is established or not | [
"Sets",
"the",
"connection",
"between",
"a",
"and",
"b",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/ConnectionMap.java#L74-L82 |
143,579 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/ConnectionMap.java | ConnectionMap.get | public boolean get(final T paramOrigin, final T paramDestination) {
assert paramOrigin != null;
assert paramDestination != null;
if (!mMap.containsKey(paramOrigin)) {
return false;
}
final Boolean bool = mMap.get(paramOrigin).get(paramDestination);
return bool != null && bool;
} | java | public boolean get(final T paramOrigin, final T paramDestination) {
assert paramOrigin != null;
assert paramDestination != null;
if (!mMap.containsKey(paramOrigin)) {
return false;
}
final Boolean bool = mMap.get(paramOrigin).get(paramDestination);
return bool != null && bool;
} | [
"public",
"boolean",
"get",
"(",
"final",
"T",
"paramOrigin",
",",
"final",
"T",
"paramDestination",
")",
"{",
"assert",
"paramOrigin",
"!=",
"null",
";",
"assert",
"paramDestination",
"!=",
"null",
";",
"if",
"(",
"!",
"mMap",
".",
"containsKey",
"(",
"paramOrigin",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"Boolean",
"bool",
"=",
"mMap",
".",
"get",
"(",
"paramOrigin",
")",
".",
"get",
"(",
"paramDestination",
")",
";",
"return",
"bool",
"!=",
"null",
"&&",
"bool",
";",
"}"
] | Returns whether there is a connection between a and b. Unknown objects do
never have a connection.
@param paramOrigin
origin object
@param paramDestination
destination object
@return true, iff there is a connection from a to b | [
"Returns",
"whether",
"there",
"is",
"a",
"connection",
"between",
"a",
"and",
"b",
".",
"Unknown",
"objects",
"do",
"never",
"have",
"a",
"connection",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/ConnectionMap.java#L94-L103 |
143,580 | Bedework/bw-util | bw-util-jms/src/main/java/org/bedework/util/jms/events/SysEvent.java | SysEvent.toStringSegment | public void toStringSegment(final ToString ts) {
ts.append("sysCode", String.valueOf(getSysCode()));
ts.append("dtstamp", getDtstamp());
ts.append("sequence", getSequence());
} | java | public void toStringSegment(final ToString ts) {
ts.append("sysCode", String.valueOf(getSysCode()));
ts.append("dtstamp", getDtstamp());
ts.append("sequence", getSequence());
} | [
"public",
"void",
"toStringSegment",
"(",
"final",
"ToString",
"ts",
")",
"{",
"ts",
".",
"append",
"(",
"\"sysCode\"",
",",
"String",
".",
"valueOf",
"(",
"getSysCode",
"(",
")",
")",
")",
";",
"ts",
".",
"append",
"(",
"\"dtstamp\"",
",",
"getDtstamp",
"(",
")",
")",
";",
"ts",
".",
"append",
"(",
"\"sequence\"",
",",
"getSequence",
"(",
")",
")",
";",
"}"
] | Add our stuff to the ToString object
@param ts ToString for result | [
"Add",
"our",
"stuff",
"to",
"the",
"ToString",
"object"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jms/src/main/java/org/bedework/util/jms/events/SysEvent.java#L248-L252 |
143,581 | Bedework/bw-util | bw-util-servlet/src/main/java/org/bedework/util/servlet/io/PooledBufferedOutputStream.java | PooledBufferedOutputStream.toByteArray | public synchronized byte[] toByteArray() {
byte[] outBuff = new byte[count];
int pos = 0;
for (BufferPool.Buffer b: buffers) {
System.arraycopy(b.buf, 0, outBuff, pos, b.pos);
pos += b.pos;
}
return outBuff;
} | java | public synchronized byte[] toByteArray() {
byte[] outBuff = new byte[count];
int pos = 0;
for (BufferPool.Buffer b: buffers) {
System.arraycopy(b.buf, 0, outBuff, pos, b.pos);
pos += b.pos;
}
return outBuff;
} | [
"public",
"synchronized",
"byte",
"[",
"]",
"toByteArray",
"(",
")",
"{",
"byte",
"[",
"]",
"outBuff",
"=",
"new",
"byte",
"[",
"count",
"]",
";",
"int",
"pos",
"=",
"0",
";",
"for",
"(",
"BufferPool",
".",
"Buffer",
"b",
":",
"buffers",
")",
"{",
"System",
".",
"arraycopy",
"(",
"b",
".",
"buf",
",",
"0",
",",
"outBuff",
",",
"pos",
",",
"b",
".",
"pos",
")",
";",
"pos",
"+=",
"b",
".",
"pos",
";",
"}",
"return",
"outBuff",
";",
"}"
] | Creates a newly allocated byte array. Its size is the current
size of this output stream and the valid contents of the buffer
have been copied into it.
@return the current contents of this output stream, as a byte array.
@see java.io.ByteArrayOutputStream#size() | [
"Creates",
"a",
"newly",
"allocated",
"byte",
"array",
".",
"Its",
"size",
"is",
"the",
"current",
"size",
"of",
"this",
"output",
"stream",
"and",
"the",
"valid",
"contents",
"of",
"the",
"buffer",
"have",
"been",
"copied",
"into",
"it",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet/src/main/java/org/bedework/util/servlet/io/PooledBufferedOutputStream.java#L162-L172 |
143,582 | Bedework/bw-util | bw-util-servlet/src/main/java/org/bedework/util/servlet/io/PooledBufferedOutputStream.java | PooledBufferedOutputStream.release | public void release() throws IOException {
for (BufferPool.Buffer b: buffers) {
PooledBuffers.release(b);
}
buffers.clear();
count = 0;
} | java | public void release() throws IOException {
for (BufferPool.Buffer b: buffers) {
PooledBuffers.release(b);
}
buffers.clear();
count = 0;
} | [
"public",
"void",
"release",
"(",
")",
"throws",
"IOException",
"{",
"for",
"(",
"BufferPool",
".",
"Buffer",
"b",
":",
"buffers",
")",
"{",
"PooledBuffers",
".",
"release",
"(",
"b",
")",
";",
"}",
"buffers",
".",
"clear",
"(",
")",
";",
"count",
"=",
"0",
";",
"}"
] | This really release buffers back to the pool. MUST be called to gain the
benefit of pooling.
@throws IOException | [
"This",
"really",
"release",
"buffers",
"back",
"to",
"the",
"pool",
".",
"MUST",
"be",
"called",
"to",
"gain",
"the",
"benefit",
"of",
"pooling",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet/src/main/java/org/bedework/util/servlet/io/PooledBufferedOutputStream.java#L245-L252 |
143,583 | sebastiangraf/treetank | coremodules/core/src/main/java/org/treetank/io/IOUtils.java | IOUtils.createFolderStructure | public static boolean createFolderStructure(final File pFile, IConfigurationPath[] pPaths)
throws TTIOException {
boolean returnVal = true;
pFile.mkdirs();
// creation of folder structure
for (IConfigurationPath paths : pPaths) {
final File toCreate = new File(pFile, paths.getFile().getName());
if (paths.isFolder()) {
returnVal = toCreate.mkdir();
} else {
try {
returnVal = toCreate.createNewFile();
} catch (final IOException exc) {
throw new TTIOException(exc);
}
}
if (!returnVal) {
break;
}
}
return returnVal;
} | java | public static boolean createFolderStructure(final File pFile, IConfigurationPath[] pPaths)
throws TTIOException {
boolean returnVal = true;
pFile.mkdirs();
// creation of folder structure
for (IConfigurationPath paths : pPaths) {
final File toCreate = new File(pFile, paths.getFile().getName());
if (paths.isFolder()) {
returnVal = toCreate.mkdir();
} else {
try {
returnVal = toCreate.createNewFile();
} catch (final IOException exc) {
throw new TTIOException(exc);
}
}
if (!returnVal) {
break;
}
}
return returnVal;
} | [
"public",
"static",
"boolean",
"createFolderStructure",
"(",
"final",
"File",
"pFile",
",",
"IConfigurationPath",
"[",
"]",
"pPaths",
")",
"throws",
"TTIOException",
"{",
"boolean",
"returnVal",
"=",
"true",
";",
"pFile",
".",
"mkdirs",
"(",
")",
";",
"// creation of folder structure",
"for",
"(",
"IConfigurationPath",
"paths",
":",
"pPaths",
")",
"{",
"final",
"File",
"toCreate",
"=",
"new",
"File",
"(",
"pFile",
",",
"paths",
".",
"getFile",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"paths",
".",
"isFolder",
"(",
")",
")",
"{",
"returnVal",
"=",
"toCreate",
".",
"mkdir",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"returnVal",
"=",
"toCreate",
".",
"createNewFile",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"exc",
")",
"{",
"throw",
"new",
"TTIOException",
"(",
"exc",
")",
";",
"}",
"}",
"if",
"(",
"!",
"returnVal",
")",
"{",
"break",
";",
"}",
"}",
"return",
"returnVal",
";",
"}"
] | Creating a folder structure based on a set of paths given as parameter and returning a boolean
determining the success.
@param pFile
the root folder where the configuration should be created to.
@param pPaths
to be created
@return true if creations was successful, false otherwise.
@throws TTIOException | [
"Creating",
"a",
"folder",
"structure",
"based",
"on",
"a",
"set",
"of",
"paths",
"given",
"as",
"parameter",
"and",
"returning",
"a",
"boolean",
"determining",
"the",
"success",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/core/src/main/java/org/treetank/io/IOUtils.java#L32-L53 |
143,584 | sebastiangraf/treetank | coremodules/core/src/main/java/org/treetank/io/IOUtils.java | IOUtils.compareStructure | public static int compareStructure(final File pFile, IConfigurationPath[] pPaths) {
int existing = 0;
for (final IConfigurationPath path : pPaths) {
final File currentFile = new File(pFile, path.getFile().getName());
if (currentFile.exists()) {
existing++;
}
}
return existing - pPaths.length;
} | java | public static int compareStructure(final File pFile, IConfigurationPath[] pPaths) {
int existing = 0;
for (final IConfigurationPath path : pPaths) {
final File currentFile = new File(pFile, path.getFile().getName());
if (currentFile.exists()) {
existing++;
}
}
return existing - pPaths.length;
} | [
"public",
"static",
"int",
"compareStructure",
"(",
"final",
"File",
"pFile",
",",
"IConfigurationPath",
"[",
"]",
"pPaths",
")",
"{",
"int",
"existing",
"=",
"0",
";",
"for",
"(",
"final",
"IConfigurationPath",
"path",
":",
"pPaths",
")",
"{",
"final",
"File",
"currentFile",
"=",
"new",
"File",
"(",
"pFile",
",",
"path",
".",
"getFile",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"currentFile",
".",
"exists",
"(",
")",
")",
"{",
"existing",
"++",
";",
"}",
"}",
"return",
"existing",
"-",
"pPaths",
".",
"length",
";",
"}"
] | Checking a structure in a folder to be equal with the data in this
enum.
@param pFile
to be checked
@param pPaths
containing the elements to be checked against
@return -1 if less folders are there, 0 if the structure is equal to
the one expected, 1 if the structure has more folders | [
"Checking",
"a",
"structure",
"in",
"a",
"folder",
"to",
"be",
"equal",
"with",
"the",
"data",
"in",
"this",
"enum",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/core/src/main/java/org/treetank/io/IOUtils.java#L66-L75 |
143,585 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/DiffFactory.java | DiffFactory.invokeFullDiff | public static synchronized void invokeFullDiff(final Builder paramBuilder) throws TTException {
checkParams(paramBuilder);
DiffKind.FULL.invoke(paramBuilder);
} | java | public static synchronized void invokeFullDiff(final Builder paramBuilder) throws TTException {
checkParams(paramBuilder);
DiffKind.FULL.invoke(paramBuilder);
} | [
"public",
"static",
"synchronized",
"void",
"invokeFullDiff",
"(",
"final",
"Builder",
"paramBuilder",
")",
"throws",
"TTException",
"{",
"checkParams",
"(",
"paramBuilder",
")",
";",
"DiffKind",
".",
"FULL",
".",
"invoke",
"(",
"paramBuilder",
")",
";",
"}"
] | Do a full diff.
@param paramBuilder
{@link Builder} reference
@throws TTException | [
"Do",
"a",
"full",
"diff",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/DiffFactory.java#L186-L189 |
143,586 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/DiffFactory.java | DiffFactory.invokeStructuralDiff | public static synchronized void invokeStructuralDiff(final Builder paramBuilder) throws TTException {
checkParams(paramBuilder);
DiffKind.STRUCTURAL.invoke(paramBuilder);
} | java | public static synchronized void invokeStructuralDiff(final Builder paramBuilder) throws TTException {
checkParams(paramBuilder);
DiffKind.STRUCTURAL.invoke(paramBuilder);
} | [
"public",
"static",
"synchronized",
"void",
"invokeStructuralDiff",
"(",
"final",
"Builder",
"paramBuilder",
")",
"throws",
"TTException",
"{",
"checkParams",
"(",
"paramBuilder",
")",
";",
"DiffKind",
".",
"STRUCTURAL",
".",
"invoke",
"(",
"paramBuilder",
")",
";",
"}"
] | Do a structural diff.
@param paramBuilder
{@link Builder} reference
@throws TTException | [
"Do",
"a",
"structural",
"diff",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/DiffFactory.java#L198-L201 |
143,587 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/DiffFactory.java | DiffFactory.checkParams | private static void checkParams(final Builder paramBuilder) {
checkState(paramBuilder.mSession != null && paramBuilder.mKey >= 0 && paramBuilder.mNewRev >= 0
&& paramBuilder.mOldRev >= 0 && paramBuilder.mObservers != null && paramBuilder.mKind != null,
"No valid arguments specified!");
checkState(
paramBuilder.mNewRev != paramBuilder.mOldRev && paramBuilder.mNewRev >= paramBuilder.mOldRev,
"Revision numbers must not be the same and the new revision must have a greater number than the old revision!");
} | java | private static void checkParams(final Builder paramBuilder) {
checkState(paramBuilder.mSession != null && paramBuilder.mKey >= 0 && paramBuilder.mNewRev >= 0
&& paramBuilder.mOldRev >= 0 && paramBuilder.mObservers != null && paramBuilder.mKind != null,
"No valid arguments specified!");
checkState(
paramBuilder.mNewRev != paramBuilder.mOldRev && paramBuilder.mNewRev >= paramBuilder.mOldRev,
"Revision numbers must not be the same and the new revision must have a greater number than the old revision!");
} | [
"private",
"static",
"void",
"checkParams",
"(",
"final",
"Builder",
"paramBuilder",
")",
"{",
"checkState",
"(",
"paramBuilder",
".",
"mSession",
"!=",
"null",
"&&",
"paramBuilder",
".",
"mKey",
">=",
"0",
"&&",
"paramBuilder",
".",
"mNewRev",
">=",
"0",
"&&",
"paramBuilder",
".",
"mOldRev",
">=",
"0",
"&&",
"paramBuilder",
".",
"mObservers",
"!=",
"null",
"&&",
"paramBuilder",
".",
"mKind",
"!=",
"null",
",",
"\"No valid arguments specified!\"",
")",
";",
"checkState",
"(",
"paramBuilder",
".",
"mNewRev",
"!=",
"paramBuilder",
".",
"mOldRev",
"&&",
"paramBuilder",
".",
"mNewRev",
">=",
"paramBuilder",
".",
"mOldRev",
",",
"\"Revision numbers must not be the same and the new revision must have a greater number than the old revision!\"",
")",
";",
"}"
] | Check parameters for validity and assign global static variables.
@param paramBuilder
{@link Builder} reference | [
"Check",
"parameters",
"for",
"validity",
"and",
"assign",
"global",
"static",
"variables",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/DiffFactory.java#L209-L216 |
143,588 | Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java | DirRecord.equalsAllBut | public boolean equalsAllBut(DirRecord that, String[] attrIDs) throws NamingException {
if (attrIDs == null)
throw new NamingException("DirectoryRecord: null attrID list");
if (!dnEquals(that)) {
return false;
}
int n = attrIDs.length;
if (n == 0) return true;
Attributes thisAttrs = getAttributes();
Attributes thatAttrs = that.getAttributes();
if (thisAttrs == null) {
if (thatAttrs == null) return true;
return false;
}
if (thatAttrs == null) {
return false;
}
/** We need to ensure that all attributes are checked.
We init thatLeft to the number of attributes in the source.
We decrement for each checked attribute.
We then decrement for each ignored attribute present in that
If the result is non-zero, then there are some extra attributes in that
so we return unequal.
*/
int sz = thisAttrs.size();
int thatLeft = sz;
if ((sz == 0) && (thatAttrs.size() == 0)) {
return true;
}
NamingEnumeration ne = thisAttrs.getAll();
if (ne == null) {
return false;
}
while (ne.hasMore()) {
Attribute attr = (Attribute)ne.next();
String id = attr.getID();
boolean present = false;
for (int i = 0; i < attrIDs.length; i++) {
if (id.equalsIgnoreCase(attrIDs[i])) {
present = true;
break;
}
}
if (present) {
// We don't compare
if (thatAttrs.get(id) != null) thatLeft--;
} else {
Attribute thatAttr = thatAttrs.get(id);
if (thatAttr == null) {
return false;
}
if (!thatAttr.contains(attr)) {
return false;
}
thatLeft--;
}
}
return (thatLeft == 0);
} | java | public boolean equalsAllBut(DirRecord that, String[] attrIDs) throws NamingException {
if (attrIDs == null)
throw new NamingException("DirectoryRecord: null attrID list");
if (!dnEquals(that)) {
return false;
}
int n = attrIDs.length;
if (n == 0) return true;
Attributes thisAttrs = getAttributes();
Attributes thatAttrs = that.getAttributes();
if (thisAttrs == null) {
if (thatAttrs == null) return true;
return false;
}
if (thatAttrs == null) {
return false;
}
/** We need to ensure that all attributes are checked.
We init thatLeft to the number of attributes in the source.
We decrement for each checked attribute.
We then decrement for each ignored attribute present in that
If the result is non-zero, then there are some extra attributes in that
so we return unequal.
*/
int sz = thisAttrs.size();
int thatLeft = sz;
if ((sz == 0) && (thatAttrs.size() == 0)) {
return true;
}
NamingEnumeration ne = thisAttrs.getAll();
if (ne == null) {
return false;
}
while (ne.hasMore()) {
Attribute attr = (Attribute)ne.next();
String id = attr.getID();
boolean present = false;
for (int i = 0; i < attrIDs.length; i++) {
if (id.equalsIgnoreCase(attrIDs[i])) {
present = true;
break;
}
}
if (present) {
// We don't compare
if (thatAttrs.get(id) != null) thatLeft--;
} else {
Attribute thatAttr = thatAttrs.get(id);
if (thatAttr == null) {
return false;
}
if (!thatAttr.contains(attr)) {
return false;
}
thatLeft--;
}
}
return (thatLeft == 0);
} | [
"public",
"boolean",
"equalsAllBut",
"(",
"DirRecord",
"that",
",",
"String",
"[",
"]",
"attrIDs",
")",
"throws",
"NamingException",
"{",
"if",
"(",
"attrIDs",
"==",
"null",
")",
"throw",
"new",
"NamingException",
"(",
"\"DirectoryRecord: null attrID list\"",
")",
";",
"if",
"(",
"!",
"dnEquals",
"(",
"that",
")",
")",
"{",
"return",
"false",
";",
"}",
"int",
"n",
"=",
"attrIDs",
".",
"length",
";",
"if",
"(",
"n",
"==",
"0",
")",
"return",
"true",
";",
"Attributes",
"thisAttrs",
"=",
"getAttributes",
"(",
")",
";",
"Attributes",
"thatAttrs",
"=",
"that",
".",
"getAttributes",
"(",
")",
";",
"if",
"(",
"thisAttrs",
"==",
"null",
")",
"{",
"if",
"(",
"thatAttrs",
"==",
"null",
")",
"return",
"true",
";",
"return",
"false",
";",
"}",
"if",
"(",
"thatAttrs",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"/** We need to ensure that all attributes are checked.\n We init thatLeft to the number of attributes in the source.\n We decrement for each checked attribute.\n We then decrement for each ignored attribute present in that\n If the result is non-zero, then there are some extra attributes in that\n so we return unequal.\n */",
"int",
"sz",
"=",
"thisAttrs",
".",
"size",
"(",
")",
";",
"int",
"thatLeft",
"=",
"sz",
";",
"if",
"(",
"(",
"sz",
"==",
"0",
")",
"&&",
"(",
"thatAttrs",
".",
"size",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"NamingEnumeration",
"ne",
"=",
"thisAttrs",
".",
"getAll",
"(",
")",
";",
"if",
"(",
"ne",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"while",
"(",
"ne",
".",
"hasMore",
"(",
")",
")",
"{",
"Attribute",
"attr",
"=",
"(",
"Attribute",
")",
"ne",
".",
"next",
"(",
")",
";",
"String",
"id",
"=",
"attr",
".",
"getID",
"(",
")",
";",
"boolean",
"present",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attrIDs",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"id",
".",
"equalsIgnoreCase",
"(",
"attrIDs",
"[",
"i",
"]",
")",
")",
"{",
"present",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"present",
")",
"{",
"// We don't compare",
"if",
"(",
"thatAttrs",
".",
"get",
"(",
"id",
")",
"!=",
"null",
")",
"thatLeft",
"--",
";",
"}",
"else",
"{",
"Attribute",
"thatAttr",
"=",
"thatAttrs",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"thatAttr",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"thatAttr",
".",
"contains",
"(",
"attr",
")",
")",
"{",
"return",
"false",
";",
"}",
"thatLeft",
"--",
";",
"}",
"}",
"return",
"(",
"thatLeft",
"==",
"0",
")",
";",
"}"
] | This compares all but the named attributes
allbut true => All must be equal except those on the list
@param that
@param attrIDs
@return boolean
@throws NamingException | [
"This",
"compares",
"all",
"but",
"the",
"named",
"attributes",
"allbut",
"true",
"=",
">",
"All",
"must",
"be",
"equal",
"except",
"those",
"on",
"the",
"list"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java#L251-L322 |
143,589 | Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java | DirRecord.dnEquals | public boolean dnEquals(DirRecord that) throws NamingException {
if (that == null) {
throw new NamingException("Null record for dnEquals");
}
String thisDn = getDn();
if (thisDn == null) {
throw new NamingException("No dn for this record");
}
String thatDn = that.getDn();
if (thatDn == null) {
throw new NamingException("That record has no dn");
}
return (thisDn.equals(thatDn));
} | java | public boolean dnEquals(DirRecord that) throws NamingException {
if (that == null) {
throw new NamingException("Null record for dnEquals");
}
String thisDn = getDn();
if (thisDn == null) {
throw new NamingException("No dn for this record");
}
String thatDn = that.getDn();
if (thatDn == null) {
throw new NamingException("That record has no dn");
}
return (thisDn.equals(thatDn));
} | [
"public",
"boolean",
"dnEquals",
"(",
"DirRecord",
"that",
")",
"throws",
"NamingException",
"{",
"if",
"(",
"that",
"==",
"null",
")",
"{",
"throw",
"new",
"NamingException",
"(",
"\"Null record for dnEquals\"",
")",
";",
"}",
"String",
"thisDn",
"=",
"getDn",
"(",
")",
";",
"if",
"(",
"thisDn",
"==",
"null",
")",
"{",
"throw",
"new",
"NamingException",
"(",
"\"No dn for this record\"",
")",
";",
"}",
"String",
"thatDn",
"=",
"that",
".",
"getDn",
"(",
")",
";",
"if",
"(",
"thatDn",
"==",
"null",
")",
"{",
"throw",
"new",
"NamingException",
"(",
"\"That record has no dn\"",
")",
";",
"}",
"return",
"(",
"thisDn",
".",
"equals",
"(",
"thatDn",
")",
")",
";",
"}"
] | Check dns for equality
@param that
@return boolean
@throws NamingException | [
"Check",
"dns",
"for",
"equality"
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java#L454-L470 |
143,590 | Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java | DirRecord.addAttr | public void addAttr(String attr, Object val) throws NamingException {
// System.out.println("addAttr " + attr);
Attribute a = findAttr(attr);
if (a == null) {
setAttr(attr, val);
} else {
a.add(val);
}
} | java | public void addAttr(String attr, Object val) throws NamingException {
// System.out.println("addAttr " + attr);
Attribute a = findAttr(attr);
if (a == null) {
setAttr(attr, val);
} else {
a.add(val);
}
} | [
"public",
"void",
"addAttr",
"(",
"String",
"attr",
",",
"Object",
"val",
")",
"throws",
"NamingException",
"{",
"// System.out.println(\"addAttr \" + attr);",
"Attribute",
"a",
"=",
"findAttr",
"(",
"attr",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"setAttr",
"(",
"attr",
",",
"val",
")",
";",
"}",
"else",
"{",
"a",
".",
"add",
"(",
"val",
")",
";",
"}",
"}"
] | Add the attribute value to the table. If an attribute already exists
add it to the end of its values.
@param attr String attribute name
@param val Object value
@throws NamingException | [
"Add",
"the",
"attribute",
"value",
"to",
"the",
"table",
".",
"If",
"an",
"attribute",
"already",
"exists",
"add",
"it",
"to",
"the",
"end",
"of",
"its",
"values",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java#L479-L489 |
143,591 | Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java | DirRecord.contains | public boolean contains(Attribute attr) throws NamingException {
if (attr == null) {
return false; // protect
}
Attribute recAttr = getAttributes().get(attr.getID());
if (recAttr == null) {
return false;
}
NamingEnumeration ne = attr.getAll();
while (ne.hasMore()) {
if (!recAttr.contains(ne.next())) {
return false;
}
}
return true;
} | java | public boolean contains(Attribute attr) throws NamingException {
if (attr == null) {
return false; // protect
}
Attribute recAttr = getAttributes().get(attr.getID());
if (recAttr == null) {
return false;
}
NamingEnumeration ne = attr.getAll();
while (ne.hasMore()) {
if (!recAttr.contains(ne.next())) {
return false;
}
}
return true;
} | [
"public",
"boolean",
"contains",
"(",
"Attribute",
"attr",
")",
"throws",
"NamingException",
"{",
"if",
"(",
"attr",
"==",
"null",
")",
"{",
"return",
"false",
";",
"// protect",
"}",
"Attribute",
"recAttr",
"=",
"getAttributes",
"(",
")",
".",
"get",
"(",
"attr",
".",
"getID",
"(",
")",
")",
";",
"if",
"(",
"recAttr",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"NamingEnumeration",
"ne",
"=",
"attr",
".",
"getAll",
"(",
")",
";",
"while",
"(",
"ne",
".",
"hasMore",
"(",
")",
")",
"{",
"if",
"(",
"!",
"recAttr",
".",
"contains",
"(",
"ne",
".",
"next",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Return true if the record contains all of the values of the given
attribute.
@param attr Attribute we're looking for
@return boolean true if we found it
@throws NamingException | [
"Return",
"true",
"if",
"the",
"record",
"contains",
"all",
"of",
"the",
"values",
"of",
"the",
"given",
"attribute",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java#L519-L539 |
143,592 | Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java | DirRecord.attrElements | public NamingEnumeration attrElements(String attr) throws NamingException {
Attribute a = findAttr(attr);
if (a == null) {
return null;
}
return a.getAll();
} | java | public NamingEnumeration attrElements(String attr) throws NamingException {
Attribute a = findAttr(attr);
if (a == null) {
return null;
}
return a.getAll();
} | [
"public",
"NamingEnumeration",
"attrElements",
"(",
"String",
"attr",
")",
"throws",
"NamingException",
"{",
"Attribute",
"a",
"=",
"findAttr",
"(",
"attr",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"a",
".",
"getAll",
"(",
")",
";",
"}"
] | Retrieve an enumeration of the named attribute's values.
The behaviour of this enumeration is unspecified
if the the attribute's values are added, changed,
or removed while the enumeration is in progress.
If the attribute values are ordered, the enumeration's items
will be ordered.
Each element of the enumeration is a possibly null Object. The object's
class is the class of the attribute value. The element is null
if the attribute's value is null.
If the attribute has zero values, an empty enumeration
is returned.
@return A non-null enumeration of the attribute's values.
@exception javax.naming.NamingException
If a naming exception was encountered while retrieving
the values. | [
"Retrieve",
"an",
"enumeration",
"of",
"the",
"named",
"attribute",
"s",
"values",
".",
"The",
"behaviour",
"of",
"this",
"enumeration",
"is",
"unspecified",
"if",
"the",
"the",
"attribute",
"s",
"values",
"are",
"added",
"changed",
"or",
"removed",
"while",
"the",
"enumeration",
"is",
"in",
"progress",
".",
"If",
"the",
"attribute",
"values",
"are",
"ordered",
"the",
"enumeration",
"s",
"items",
"will",
"be",
"ordered",
"."
] | f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java#L559-L567 |
143,593 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/StAXSerializer.java | StAXSerializer.emitEndTag | private void emitEndTag() throws TTIOException {
final long nodeKey = mRtx.getNode().getDataKey();
mEvent = mFac.createEndElement(mRtx.getQNameOfCurrentNode(), new NamespaceIterator(mRtx));
mRtx.moveTo(nodeKey);
} | java | private void emitEndTag() throws TTIOException {
final long nodeKey = mRtx.getNode().getDataKey();
mEvent = mFac.createEndElement(mRtx.getQNameOfCurrentNode(), new NamespaceIterator(mRtx));
mRtx.moveTo(nodeKey);
} | [
"private",
"void",
"emitEndTag",
"(",
")",
"throws",
"TTIOException",
"{",
"final",
"long",
"nodeKey",
"=",
"mRtx",
".",
"getNode",
"(",
")",
".",
"getDataKey",
"(",
")",
";",
"mEvent",
"=",
"mFac",
".",
"createEndElement",
"(",
"mRtx",
".",
"getQNameOfCurrentNode",
"(",
")",
",",
"new",
"NamespaceIterator",
"(",
"mRtx",
")",
")",
";",
"mRtx",
".",
"moveTo",
"(",
"nodeKey",
")",
";",
"}"
] | Emit end tag.
@param paramRTX
Treetank reading transaction {@link IReadTransaction}.
@throws TTIOException | [
"Emit",
"end",
"tag",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/StAXSerializer.java#L165-L169 |
143,594 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/StAXSerializer.java | StAXSerializer.emitNode | private void emitNode() throws TTIOException {
switch (mRtx.getNode().getKind()) {
case ROOT:
mEvent = mFac.createStartDocument();
break;
case ELEMENT:
final long key = mRtx.getNode().getDataKey();
final QName qName = mRtx.getQNameOfCurrentNode();
mEvent = mFac.createStartElement(qName, new AttributeIterator(mRtx), new NamespaceIterator(mRtx));
mRtx.moveTo(key);
break;
case TEXT:
mEvent = mFac.createCharacters(mRtx.getValueOfCurrentNode());
break;
default:
throw new IllegalStateException("Kind not known!");
}
} | java | private void emitNode() throws TTIOException {
switch (mRtx.getNode().getKind()) {
case ROOT:
mEvent = mFac.createStartDocument();
break;
case ELEMENT:
final long key = mRtx.getNode().getDataKey();
final QName qName = mRtx.getQNameOfCurrentNode();
mEvent = mFac.createStartElement(qName, new AttributeIterator(mRtx), new NamespaceIterator(mRtx));
mRtx.moveTo(key);
break;
case TEXT:
mEvent = mFac.createCharacters(mRtx.getValueOfCurrentNode());
break;
default:
throw new IllegalStateException("Kind not known!");
}
} | [
"private",
"void",
"emitNode",
"(",
")",
"throws",
"TTIOException",
"{",
"switch",
"(",
"mRtx",
".",
"getNode",
"(",
")",
".",
"getKind",
"(",
")",
")",
"{",
"case",
"ROOT",
":",
"mEvent",
"=",
"mFac",
".",
"createStartDocument",
"(",
")",
";",
"break",
";",
"case",
"ELEMENT",
":",
"final",
"long",
"key",
"=",
"mRtx",
".",
"getNode",
"(",
")",
".",
"getDataKey",
"(",
")",
";",
"final",
"QName",
"qName",
"=",
"mRtx",
".",
"getQNameOfCurrentNode",
"(",
")",
";",
"mEvent",
"=",
"mFac",
".",
"createStartElement",
"(",
"qName",
",",
"new",
"AttributeIterator",
"(",
"mRtx",
")",
",",
"new",
"NamespaceIterator",
"(",
"mRtx",
")",
")",
";",
"mRtx",
".",
"moveTo",
"(",
"key",
")",
";",
"break",
";",
"case",
"TEXT",
":",
"mEvent",
"=",
"mFac",
".",
"createCharacters",
"(",
"mRtx",
".",
"getValueOfCurrentNode",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Kind not known!\"",
")",
";",
"}",
"}"
] | Emit a node.
@param paramRTX
Treetank reading transaction {@link IReadTransaction}.
@throws TTIOException | [
"Emit",
"a",
"node",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/StAXSerializer.java#L178-L195 |
143,595 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/StAXSerializer.java | StAXSerializer.emit | private void emit() throws TTIOException {
// Emit pending end elements.
if (mCloseElements) {
if (!mStack.empty() && mStack.peek() != ((ITreeStructData)mRtx.getNode()).getLeftSiblingKey()) {
mRtx.moveTo(mStack.pop());
emitEndTag();
mRtx.moveTo(mKey);
} else if (!mStack.empty()) {
mRtx.moveTo(mStack.pop());
emitEndTag();
mRtx.moveTo(mKey);
mCloseElements = false;
mCloseElementsEmitted = true;
}
} else {
mCloseElementsEmitted = false;
// Emit node.
emitNode();
final long nodeKey = mRtx.getNode().getDataKey();
mLastKey = nodeKey;
// Push end element to stack if we are a start element.
if (mRtx.getNode().getKind() == ELEMENT) {
mStack.push(nodeKey);
}
// Remember to emit all pending end elements from stack if
// required.
if (!((ITreeStructData)mRtx.getNode()).hasFirstChild()
&& !((ITreeStructData)mRtx.getNode()).hasRightSibling()) {
mGoUp = true;
moveToNextNode();
} else if (mRtx.getNode().getKind() == ELEMENT && !((ElementNode)mRtx.getNode()).hasFirstChild()) {
// Case: Empty elements with right siblings.
mGoBack = true;
moveToNextNode();
}
}
} | java | private void emit() throws TTIOException {
// Emit pending end elements.
if (mCloseElements) {
if (!mStack.empty() && mStack.peek() != ((ITreeStructData)mRtx.getNode()).getLeftSiblingKey()) {
mRtx.moveTo(mStack.pop());
emitEndTag();
mRtx.moveTo(mKey);
} else if (!mStack.empty()) {
mRtx.moveTo(mStack.pop());
emitEndTag();
mRtx.moveTo(mKey);
mCloseElements = false;
mCloseElementsEmitted = true;
}
} else {
mCloseElementsEmitted = false;
// Emit node.
emitNode();
final long nodeKey = mRtx.getNode().getDataKey();
mLastKey = nodeKey;
// Push end element to stack if we are a start element.
if (mRtx.getNode().getKind() == ELEMENT) {
mStack.push(nodeKey);
}
// Remember to emit all pending end elements from stack if
// required.
if (!((ITreeStructData)mRtx.getNode()).hasFirstChild()
&& !((ITreeStructData)mRtx.getNode()).hasRightSibling()) {
mGoUp = true;
moveToNextNode();
} else if (mRtx.getNode().getKind() == ELEMENT && !((ElementNode)mRtx.getNode()).hasFirstChild()) {
// Case: Empty elements with right siblings.
mGoBack = true;
moveToNextNode();
}
}
} | [
"private",
"void",
"emit",
"(",
")",
"throws",
"TTIOException",
"{",
"// Emit pending end elements.",
"if",
"(",
"mCloseElements",
")",
"{",
"if",
"(",
"!",
"mStack",
".",
"empty",
"(",
")",
"&&",
"mStack",
".",
"peek",
"(",
")",
"!=",
"(",
"(",
"ITreeStructData",
")",
"mRtx",
".",
"getNode",
"(",
")",
")",
".",
"getLeftSiblingKey",
"(",
")",
")",
"{",
"mRtx",
".",
"moveTo",
"(",
"mStack",
".",
"pop",
"(",
")",
")",
";",
"emitEndTag",
"(",
")",
";",
"mRtx",
".",
"moveTo",
"(",
"mKey",
")",
";",
"}",
"else",
"if",
"(",
"!",
"mStack",
".",
"empty",
"(",
")",
")",
"{",
"mRtx",
".",
"moveTo",
"(",
"mStack",
".",
"pop",
"(",
")",
")",
";",
"emitEndTag",
"(",
")",
";",
"mRtx",
".",
"moveTo",
"(",
"mKey",
")",
";",
"mCloseElements",
"=",
"false",
";",
"mCloseElementsEmitted",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"mCloseElementsEmitted",
"=",
"false",
";",
"// Emit node.",
"emitNode",
"(",
")",
";",
"final",
"long",
"nodeKey",
"=",
"mRtx",
".",
"getNode",
"(",
")",
".",
"getDataKey",
"(",
")",
";",
"mLastKey",
"=",
"nodeKey",
";",
"// Push end element to stack if we are a start element.",
"if",
"(",
"mRtx",
".",
"getNode",
"(",
")",
".",
"getKind",
"(",
")",
"==",
"ELEMENT",
")",
"{",
"mStack",
".",
"push",
"(",
"nodeKey",
")",
";",
"}",
"// Remember to emit all pending end elements from stack if",
"// required.",
"if",
"(",
"!",
"(",
"(",
"ITreeStructData",
")",
"mRtx",
".",
"getNode",
"(",
")",
")",
".",
"hasFirstChild",
"(",
")",
"&&",
"!",
"(",
"(",
"ITreeStructData",
")",
"mRtx",
".",
"getNode",
"(",
")",
")",
".",
"hasRightSibling",
"(",
")",
")",
"{",
"mGoUp",
"=",
"true",
";",
"moveToNextNode",
"(",
")",
";",
"}",
"else",
"if",
"(",
"mRtx",
".",
"getNode",
"(",
")",
".",
"getKind",
"(",
")",
"==",
"ELEMENT",
"&&",
"!",
"(",
"(",
"ElementNode",
")",
"mRtx",
".",
"getNode",
"(",
")",
")",
".",
"hasFirstChild",
"(",
")",
")",
"{",
"// Case: Empty elements with right siblings.",
"mGoBack",
"=",
"true",
";",
"moveToNextNode",
"(",
")",
";",
"}",
"}",
"}"
] | Move to node and emit it.
@throws IOException
In case of any I/O error. | [
"Move",
"to",
"node",
"and",
"emit",
"it",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/serialize/StAXSerializer.java#L383-L423 |
143,596 | sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/filter/PredicateFilterAxis.java | PredicateFilterAxis.isBooleanFalse | private boolean isBooleanFalse() {
if (getNode().getDataKey() >= 0) {
return false;
} else { // is AtomicValue
if (getNode().getTypeKey() == NamePageHash.generateHashForString("xs:boolean")) {
// atomic value of type boolean
// return true, if atomic values's value is false
return !(Boolean.parseBoolean(new String(((ITreeValData)getNode()).getRawValue())));
} else {
return false;
}
}
} | java | private boolean isBooleanFalse() {
if (getNode().getDataKey() >= 0) {
return false;
} else { // is AtomicValue
if (getNode().getTypeKey() == NamePageHash.generateHashForString("xs:boolean")) {
// atomic value of type boolean
// return true, if atomic values's value is false
return !(Boolean.parseBoolean(new String(((ITreeValData)getNode()).getRawValue())));
} else {
return false;
}
}
} | [
"private",
"boolean",
"isBooleanFalse",
"(",
")",
"{",
"if",
"(",
"getNode",
"(",
")",
".",
"getDataKey",
"(",
")",
">=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"// is AtomicValue",
"if",
"(",
"getNode",
"(",
")",
".",
"getTypeKey",
"(",
")",
"==",
"NamePageHash",
".",
"generateHashForString",
"(",
"\"xs:boolean\"",
")",
")",
"{",
"// atomic value of type boolean",
"// return true, if atomic values's value is false",
"return",
"!",
"(",
"Boolean",
".",
"parseBoolean",
"(",
"new",
"String",
"(",
"(",
"(",
"ITreeValData",
")",
"getNode",
"(",
")",
")",
".",
"getRawValue",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] | Tests whether current Item is an atomic value with boolean value "false".
@return true, if Item is boolean typed atomic value with type "false". | [
"Tests",
"whether",
"current",
"Item",
"is",
"an",
"atomic",
"value",
"with",
"boolean",
"value",
"false",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/filter/PredicateFilterAxis.java#L117-L132 |
143,597 | sebastiangraf/treetank | interfacemodules/saxon/src/main/java/org/treetank/saxon/wrapper/NodeWrapper.java | NodeWrapper.expandString | private String expandString() {
final FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.SMALL);
try {
final INodeReadTrx rtx = createRtxAndMove();
final FilterAxis axis = new FilterAxis(new DescendantAxis(rtx), rtx, new TextFilter(rtx));
while (axis.hasNext()) {
if (rtx.getNode().getKind() == TEXT) {
fsb.append(rtx.getValueOfCurrentNode());
}
axis.next();
}
rtx.close();
} catch (final TTException exc) {
LOGGER.error(exc.toString());
}
return fsb.condense().toString();
} | java | private String expandString() {
final FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.SMALL);
try {
final INodeReadTrx rtx = createRtxAndMove();
final FilterAxis axis = new FilterAxis(new DescendantAxis(rtx), rtx, new TextFilter(rtx));
while (axis.hasNext()) {
if (rtx.getNode().getKind() == TEXT) {
fsb.append(rtx.getValueOfCurrentNode());
}
axis.next();
}
rtx.close();
} catch (final TTException exc) {
LOGGER.error(exc.toString());
}
return fsb.condense().toString();
} | [
"private",
"String",
"expandString",
"(",
")",
"{",
"final",
"FastStringBuffer",
"fsb",
"=",
"new",
"FastStringBuffer",
"(",
"FastStringBuffer",
".",
"SMALL",
")",
";",
"try",
"{",
"final",
"INodeReadTrx",
"rtx",
"=",
"createRtxAndMove",
"(",
")",
";",
"final",
"FilterAxis",
"axis",
"=",
"new",
"FilterAxis",
"(",
"new",
"DescendantAxis",
"(",
"rtx",
")",
",",
"rtx",
",",
"new",
"TextFilter",
"(",
"rtx",
")",
")",
";",
"while",
"(",
"axis",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"rtx",
".",
"getNode",
"(",
")",
".",
"getKind",
"(",
")",
"==",
"TEXT",
")",
"{",
"fsb",
".",
"append",
"(",
"rtx",
".",
"getValueOfCurrentNode",
"(",
")",
")",
";",
"}",
"axis",
".",
"next",
"(",
")",
";",
"}",
"rtx",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"TTException",
"exc",
")",
"{",
"LOGGER",
".",
"error",
"(",
"exc",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"fsb",
".",
"condense",
"(",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Filter text nodes.
@return concatenated String of text treeData values. | [
"Filter",
"text",
"nodes",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/saxon/src/main/java/org/treetank/saxon/wrapper/NodeWrapper.java#L511-L528 |
143,598 | sebastiangraf/treetank | interfacemodules/saxon/src/main/java/org/treetank/saxon/wrapper/NodeWrapper.java | NodeWrapper.getTypeAnnotation | public int getTypeAnnotation() {
int type = 0;
if (nodeKind == ATTRIBUTE) {
type = StandardNames.XS_UNTYPED_ATOMIC;
} else {
type = StandardNames.XS_UNTYPED;
}
return type;
} | java | public int getTypeAnnotation() {
int type = 0;
if (nodeKind == ATTRIBUTE) {
type = StandardNames.XS_UNTYPED_ATOMIC;
} else {
type = StandardNames.XS_UNTYPED;
}
return type;
} | [
"public",
"int",
"getTypeAnnotation",
"(",
")",
"{",
"int",
"type",
"=",
"0",
";",
"if",
"(",
"nodeKind",
"==",
"ATTRIBUTE",
")",
"{",
"type",
"=",
"StandardNames",
".",
"XS_UNTYPED_ATOMIC",
";",
"}",
"else",
"{",
"type",
"=",
"StandardNames",
".",
"XS_UNTYPED",
";",
"}",
"return",
"type",
";",
"}"
] | Get the type annotation.
@return UNTYPED or UNTYPED_ATOMIC. | [
"Get",
"the",
"type",
"annotation",
"."
] | 9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60 | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/saxon/src/main/java/org/treetank/saxon/wrapper/NodeWrapper.java#L543-L551 |
143,599 | centic9/commons-dost | src/main/java/org/dstadler/commons/zip/ZipFileWalker.java | ZipFileWalker.walk | public boolean walk(OutputHandler outputHandler) throws IOException {
try (ZipFile zipFile = new ZipFile(zip)) {
// walk all entries and look for matches
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while(entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
// first check if the file matches the name, if a name-pattern is given
File file = new File(zip, entry.getName());
if(outputHandler.found(file, zipFile.getInputStream(entry))) {
return true;
}
// look for name or content inside zip-files as well, do it recursively to also
// look at content of nested zip-files
if(ZipUtils.isZip(entry.getName())) {
if(walkRecursive(file, zipFile.getInputStream(entry), outputHandler)) {
return true;
}
}
}
return false;
}
} | java | public boolean walk(OutputHandler outputHandler) throws IOException {
try (ZipFile zipFile = new ZipFile(zip)) {
// walk all entries and look for matches
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while(entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
// first check if the file matches the name, if a name-pattern is given
File file = new File(zip, entry.getName());
if(outputHandler.found(file, zipFile.getInputStream(entry))) {
return true;
}
// look for name or content inside zip-files as well, do it recursively to also
// look at content of nested zip-files
if(ZipUtils.isZip(entry.getName())) {
if(walkRecursive(file, zipFile.getInputStream(entry), outputHandler)) {
return true;
}
}
}
return false;
}
} | [
"public",
"boolean",
"walk",
"(",
"OutputHandler",
"outputHandler",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ZipFile",
"zipFile",
"=",
"new",
"ZipFile",
"(",
"zip",
")",
")",
"{",
"// walk all entries and look for matches",
"Enumeration",
"<",
"?",
"extends",
"ZipEntry",
">",
"entries",
"=",
"zipFile",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"ZipEntry",
"entry",
"=",
"entries",
".",
"nextElement",
"(",
")",
";",
"// first check if the file matches the name, if a name-pattern is given",
"File",
"file",
"=",
"new",
"File",
"(",
"zip",
",",
"entry",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"outputHandler",
".",
"found",
"(",
"file",
",",
"zipFile",
".",
"getInputStream",
"(",
"entry",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// look for name or content inside zip-files as well, do it recursively to also",
"// look at content of nested zip-files",
"if",
"(",
"ZipUtils",
".",
"isZip",
"(",
"entry",
".",
"getName",
"(",
")",
")",
")",
"{",
"if",
"(",
"walkRecursive",
"(",
"file",
",",
"zipFile",
".",
"getInputStream",
"(",
"entry",
")",
",",
"outputHandler",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}",
"}"
] | Run the ZipFileWalker using the given OutputHandler
@param outputHandler For every file that is found in the
Zip-file, the method found() in the {@link OutputHandler}
is invoked.
@return true if processing was stopped because of a found file,
false if no file was found or the {@link OutputHandler} did
not return true on the call to found().
@throws IOException Thrown if an error occurs while handling the
Zip-file or while handling the call to found(). | [
"Run",
"the",
"ZipFileWalker",
"using",
"the",
"given",
"OutputHandler"
] | f6fa4e3e0b943ff103f918824319d8abf33d0e0f | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/zip/ZipFileWalker.java#L38-L62 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.