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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/discord/HOTSAXImplementation.java | HOTSAXImplementation.hashToFreqEntries | @Deprecated
private static ArrayList<FrequencyTableEntry> hashToFreqEntries(
HashMap<String, ArrayList<Integer>> hash) {
ArrayList<FrequencyTableEntry> res = new ArrayList<FrequencyTableEntry>();
for (Entry<String, ArrayList<Integer>> e : hash.entrySet()) {
char[] payload = e.getKey().toCharArray();
int frequency = e.getValue().size();
for (Integer i : e.getValue()) {
res.add(new FrequencyTableEntry(i, payload.clone(), frequency));
}
}
return res;
} | java | @Deprecated
private static ArrayList<FrequencyTableEntry> hashToFreqEntries(
HashMap<String, ArrayList<Integer>> hash) {
ArrayList<FrequencyTableEntry> res = new ArrayList<FrequencyTableEntry>();
for (Entry<String, ArrayList<Integer>> e : hash.entrySet()) {
char[] payload = e.getKey().toCharArray();
int frequency = e.getValue().size();
for (Integer i : e.getValue()) {
res.add(new FrequencyTableEntry(i, payload.clone(), frequency));
}
}
return res;
} | [
"@",
"Deprecated",
"private",
"static",
"ArrayList",
"<",
"FrequencyTableEntry",
">",
"hashToFreqEntries",
"(",
"HashMap",
"<",
"String",
",",
"ArrayList",
"<",
"Integer",
">",
">",
"hash",
")",
"{",
"ArrayList",
"<",
"FrequencyTableEntry",
">",
"res",
"=",
"n... | Translates the hash table into sortable array of substrings.
@param hash
@return | [
"Translates",
"the",
"hash",
"table",
"into",
"sortable",
"array",
"of",
"substrings",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/discord/HOTSAXImplementation.java#L651-L663 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/discord/HOTSAXImplementation.java | HOTSAXImplementation.distance | private static double distance(double[] subseries, double[] series, int from, int to,
double nThreshold) throws Exception {
double[] subsequence = tp.znorm(tp.subseriesByCopy(series, from, to), nThreshold);
Double sum = 0D;
for (int i = 0; i < subseries.length; i++) {
double tmp = subseries[i] - subsequence[i];
sum = sum + tmp * tmp;
}
return Math.sqrt(sum);
} | java | private static double distance(double[] subseries, double[] series, int from, int to,
double nThreshold) throws Exception {
double[] subsequence = tp.znorm(tp.subseriesByCopy(series, from, to), nThreshold);
Double sum = 0D;
for (int i = 0; i < subseries.length; i++) {
double tmp = subseries[i] - subsequence[i];
sum = sum + tmp * tmp;
}
return Math.sqrt(sum);
} | [
"private",
"static",
"double",
"distance",
"(",
"double",
"[",
"]",
"subseries",
",",
"double",
"[",
"]",
"series",
",",
"int",
"from",
",",
"int",
"to",
",",
"double",
"nThreshold",
")",
"throws",
"Exception",
"{",
"double",
"[",
"]",
"subsequence",
"="... | Calculates the Euclidean distance between two points. Don't use this unless you need that.
@param subseries The first subsequence -- ASSUMED TO BE Z-normalized.
@param series The second point.
@param from the initial index of the range to be copied, inclusive
@param to the final index of the range to be copied, exclusive. (This index may lie outside the
array.)
@param nThreshold z-Normalization threshold.
@return The Euclidean distance between z-Normalized versions of subsequences. | [
"Calculates",
"the",
"Euclidean",
"distance",
"between",
"two",
"points",
".",
"Don",
"t",
"use",
"this",
"unless",
"you",
"need",
"that",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/discord/HOTSAXImplementation.java#L676-L685 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/bitmap/Shingles.java | Shingles.addShingledSeries | public void addShingledSeries(String key, Map<String, Integer> shingledSeries) {
// allocate the weights array corresponding to the time series
int[] counts = new int[this.indexTable.size()];
// fill in the counts
for (String str : shingledSeries.keySet()) {
Integer idx = this.indexTable.get(str);
if (null == idx) {
throw new IndexOutOfBoundsException("the requested shingle " + str + " doesn't exist!");
}
counts[idx] = shingledSeries.get(str);
}
shingles.put(key, counts);
} | java | public void addShingledSeries(String key, Map<String, Integer> shingledSeries) {
// allocate the weights array corresponding to the time series
int[] counts = new int[this.indexTable.size()];
// fill in the counts
for (String str : shingledSeries.keySet()) {
Integer idx = this.indexTable.get(str);
if (null == idx) {
throw new IndexOutOfBoundsException("the requested shingle " + str + " doesn't exist!");
}
counts[idx] = shingledSeries.get(str);
}
shingles.put(key, counts);
} | [
"public",
"void",
"addShingledSeries",
"(",
"String",
"key",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"shingledSeries",
")",
"{",
"// allocate the weights array corresponding to the time series",
"int",
"[",
"]",
"counts",
"=",
"new",
"int",
"[",
"this",
".... | Adds a shingled series assuring the proper index.
@param key the timeseries key (i.e., label).
@param shingledSeries a shingled timeseries in a map of <shingle, index> entries. | [
"Adds",
"a",
"shingled",
"series",
"assuring",
"the",
"proper",
"index",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/bitmap/Shingles.java#L75-L87 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/tinker/ParallelPerformanceEvaluation.java | ParallelPerformanceEvaluation.main | public static void main(String[] args) throws Exception {
NormalAlphabet na = new NormalAlphabet();
SAXProcessor sp = new SAXProcessor();
String dataFileName = args[0];
System.out.println("data file: " + dataFileName);
double[] ts = TSProcessor.readFileColumn(dataFileName, 0, 0);
System.out.println("data size: " + ts.length);
System.out.println("SAX parameters:\n sliding window sizes: " + Arrays.toString(WINDOWS)
+ "\n PAA sizes: " + Arrays.toString(PAAS) + "\n alphabet sizes: "
+ Arrays.toString(ALPHABETS) + "\n NR strategis: " + Arrays.toString(NRS));
System.out.println(
"Performing " + NRUNS + " SAX conversion runs for each algorithm implementation ... ");
// conventional
//
long tstamp1 = System.currentTimeMillis();
for (int slidingWindowSize : WINDOWS) {
for (int paaSize : PAAS) {
for (int alphabetSize : ALPHABETS) {
for (String nrStrategy : NRS) {
for (int i = 0; i < NRUNS; i++) {
@SuppressWarnings("unused")
SAXRecords sequentialRes = sp.ts2saxViaWindow(ts, slidingWindowSize, paaSize,
na.getCuts(alphabetSize), NumerosityReductionStrategy.fromString(nrStrategy),
N_THRESHOLD);
}
}
}
}
}
long tstamp2 = System.currentTimeMillis();
System.out.println("single thread conversion: " + String.valueOf(tstamp2 - tstamp1) + ", "
+ SAXProcessor.timeToString(tstamp1, tstamp2));
// parallel
for (int threadsNum = MIN_CPUS; threadsNum < MAX_CPUS; threadsNum++) {
tstamp1 = System.currentTimeMillis();
for (int slidingWindowSize : WINDOWS) {
for (int paaSize : PAAS) {
for (int alphabetSize : ALPHABETS) {
for (String nrStrategy : NRS) {
for (int i = 0; i < NRUNS; i++) {
ParallelSAXImplementation ps = new ParallelSAXImplementation();
@SuppressWarnings("unused")
SAXRecords parallelRes = ps.process(ts, threadsNum, slidingWindowSize, paaSize,
alphabetSize, NumerosityReductionStrategy.fromString(nrStrategy), N_THRESHOLD);
}
}
}
}
}
tstamp2 = System.currentTimeMillis();
System.out.println("parallel conversion using " + threadsNum + " threads: "
+ String.valueOf(tstamp2 - tstamp1) + ", " + SAXProcessor.timeToString(tstamp1, tstamp2));
}
} | java | public static void main(String[] args) throws Exception {
NormalAlphabet na = new NormalAlphabet();
SAXProcessor sp = new SAXProcessor();
String dataFileName = args[0];
System.out.println("data file: " + dataFileName);
double[] ts = TSProcessor.readFileColumn(dataFileName, 0, 0);
System.out.println("data size: " + ts.length);
System.out.println("SAX parameters:\n sliding window sizes: " + Arrays.toString(WINDOWS)
+ "\n PAA sizes: " + Arrays.toString(PAAS) + "\n alphabet sizes: "
+ Arrays.toString(ALPHABETS) + "\n NR strategis: " + Arrays.toString(NRS));
System.out.println(
"Performing " + NRUNS + " SAX conversion runs for each algorithm implementation ... ");
// conventional
//
long tstamp1 = System.currentTimeMillis();
for (int slidingWindowSize : WINDOWS) {
for (int paaSize : PAAS) {
for (int alphabetSize : ALPHABETS) {
for (String nrStrategy : NRS) {
for (int i = 0; i < NRUNS; i++) {
@SuppressWarnings("unused")
SAXRecords sequentialRes = sp.ts2saxViaWindow(ts, slidingWindowSize, paaSize,
na.getCuts(alphabetSize), NumerosityReductionStrategy.fromString(nrStrategy),
N_THRESHOLD);
}
}
}
}
}
long tstamp2 = System.currentTimeMillis();
System.out.println("single thread conversion: " + String.valueOf(tstamp2 - tstamp1) + ", "
+ SAXProcessor.timeToString(tstamp1, tstamp2));
// parallel
for (int threadsNum = MIN_CPUS; threadsNum < MAX_CPUS; threadsNum++) {
tstamp1 = System.currentTimeMillis();
for (int slidingWindowSize : WINDOWS) {
for (int paaSize : PAAS) {
for (int alphabetSize : ALPHABETS) {
for (String nrStrategy : NRS) {
for (int i = 0; i < NRUNS; i++) {
ParallelSAXImplementation ps = new ParallelSAXImplementation();
@SuppressWarnings("unused")
SAXRecords parallelRes = ps.process(ts, threadsNum, slidingWindowSize, paaSize,
alphabetSize, NumerosityReductionStrategy.fromString(nrStrategy), N_THRESHOLD);
}
}
}
}
}
tstamp2 = System.currentTimeMillis();
System.out.println("parallel conversion using " + threadsNum + " threads: "
+ String.valueOf(tstamp2 - tstamp1) + ", " + SAXProcessor.timeToString(tstamp1, tstamp2));
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"NormalAlphabet",
"na",
"=",
"new",
"NormalAlphabet",
"(",
")",
";",
"SAXProcessor",
"sp",
"=",
"new",
"SAXProcessor",
"(",
")",
";",
"String",
"dataFileN... | Runs the evaluation.
@param args some accepted, see the code.
@throws Exception thrown if an error occured. | [
"Runs",
"the",
"evaluation",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/tinker/ParallelPerformanceEvaluation.java#L38-L103 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.markVisited | public void markVisited(int loc) {
if (checkBounds(loc)) {
if (ZERO == this.registry[loc]) {
this.unvisitedCount--;
}
this.registry[loc] = ONE;
}
else {
throw new RuntimeException(
"The location " + loc + " out of bounds [0," + (this.registry.length - 1) + "]");
}
} | java | public void markVisited(int loc) {
if (checkBounds(loc)) {
if (ZERO == this.registry[loc]) {
this.unvisitedCount--;
}
this.registry[loc] = ONE;
}
else {
throw new RuntimeException(
"The location " + loc + " out of bounds [0," + (this.registry.length - 1) + "]");
}
} | [
"public",
"void",
"markVisited",
"(",
"int",
"loc",
")",
"{",
"if",
"(",
"checkBounds",
"(",
"loc",
")",
")",
"{",
"if",
"(",
"ZERO",
"==",
"this",
".",
"registry",
"[",
"loc",
"]",
")",
"{",
"this",
".",
"unvisitedCount",
"--",
";",
"}",
"this",
... | Marks location visited. If it was unvisited, counter decremented.
@param loc The location to mark. | [
"Marks",
"location",
"visited",
".",
"If",
"it",
"was",
"unvisited",
"counter",
"decremented",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L48-L59 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.markVisited | public void markVisited(int from, int upTo) {
if (checkBounds(from) && checkBounds(upTo - 1)) {
for (int i = from; i < upTo; i++) {
this.markVisited(i);
}
}
else {
throw new RuntimeException("The location " + from + "," + upTo + " out of bounds [0,"
+ (this.registry.length - 1) + "]");
}
} | java | public void markVisited(int from, int upTo) {
if (checkBounds(from) && checkBounds(upTo - 1)) {
for (int i = from; i < upTo; i++) {
this.markVisited(i);
}
}
else {
throw new RuntimeException("The location " + from + "," + upTo + " out of bounds [0,"
+ (this.registry.length - 1) + "]");
}
} | [
"public",
"void",
"markVisited",
"(",
"int",
"from",
",",
"int",
"upTo",
")",
"{",
"if",
"(",
"checkBounds",
"(",
"from",
")",
"&&",
"checkBounds",
"(",
"upTo",
"-",
"1",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"from",
";",
"i",
"<",
"upTo",
... | Marks as visited a range of locations.
@param from the start of labeling (inclusive).
@param upTo the end of labeling (exclusive). | [
"Marks",
"as",
"visited",
"a",
"range",
"of",
"locations",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L67-L77 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.getNextRandomUnvisitedPosition | public int getNextRandomUnvisitedPosition() {
// if all are visited, return -1
//
if (0 == this.unvisitedCount) {
return -1;
}
// if there is space continue with random sampling
//
int i = this.randomizer.nextInt(this.registry.length);
while (ONE == registry[i]) {
i = this.randomizer.nextInt(this.registry.length);
}
return i;
} | java | public int getNextRandomUnvisitedPosition() {
// if all are visited, return -1
//
if (0 == this.unvisitedCount) {
return -1;
}
// if there is space continue with random sampling
//
int i = this.randomizer.nextInt(this.registry.length);
while (ONE == registry[i]) {
i = this.randomizer.nextInt(this.registry.length);
}
return i;
} | [
"public",
"int",
"getNextRandomUnvisitedPosition",
"(",
")",
"{",
"// if all are visited, return -1",
"//",
"if",
"(",
"0",
"==",
"this",
".",
"unvisitedCount",
")",
"{",
"return",
"-",
"1",
";",
"}",
"// if there is space continue with random sampling",
"//",
"int",
... | Get the next random unvisited position.
@return The next unvisited position. | [
"Get",
"the",
"next",
"random",
"unvisited",
"position",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L84-L99 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.isNotVisited | public boolean isNotVisited(int loc) {
if (checkBounds(loc)) {
return (ZERO == this.registry[loc]);
}
else {
throw new RuntimeException(
"The location " + loc + " out of bounds [0," + (this.registry.length - 1) + "]");
}
} | java | public boolean isNotVisited(int loc) {
if (checkBounds(loc)) {
return (ZERO == this.registry[loc]);
}
else {
throw new RuntimeException(
"The location " + loc + " out of bounds [0," + (this.registry.length - 1) + "]");
}
} | [
"public",
"boolean",
"isNotVisited",
"(",
"int",
"loc",
")",
"{",
"if",
"(",
"checkBounds",
"(",
"loc",
")",
")",
"{",
"return",
"(",
"ZERO",
"==",
"this",
".",
"registry",
"[",
"loc",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeExceptio... | Check if position is not visited.
@param loc The index.
@return true if not visited. | [
"Check",
"if",
"position",
"is",
"not",
"visited",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L107-L115 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.isVisited | public boolean isVisited(int from, int upTo) {
if (checkBounds(from) && checkBounds(upTo - 1)) {
// perform the visit check
//
for (int i = from; i < upTo; i++) {
if (ONE == this.registry[i]) {
return true;
}
}
return false;
}
else {
throw new RuntimeException("The location " + from + "," + upTo + " out of bounds [0,"
+ (this.registry.length - 1) + "]");
}
} | java | public boolean isVisited(int from, int upTo) {
if (checkBounds(from) && checkBounds(upTo - 1)) {
// perform the visit check
//
for (int i = from; i < upTo; i++) {
if (ONE == this.registry[i]) {
return true;
}
}
return false;
}
else {
throw new RuntimeException("The location " + from + "," + upTo + " out of bounds [0,"
+ (this.registry.length - 1) + "]");
}
} | [
"public",
"boolean",
"isVisited",
"(",
"int",
"from",
",",
"int",
"upTo",
")",
"{",
"if",
"(",
"checkBounds",
"(",
"from",
")",
"&&",
"checkBounds",
"(",
"upTo",
"-",
"1",
")",
")",
"{",
"// perform the visit check",
"//",
"for",
"(",
"int",
"i",
"=",
... | Check if the interval and its boundaries were visited.
@param from The interval start (inclusive).
@param upTo The interval end (exclusive).
@return True if visited. | [
"Check",
"if",
"the",
"interval",
"and",
"its",
"boundaries",
"were",
"visited",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L124-L139 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.isVisited | public boolean isVisited(int loc) {
if (checkBounds(loc)) {
return (ONE == this.registry[loc]);
}
else {
throw new RuntimeException(
"The location " + loc + " out of bounds [0," + (this.registry.length - 1) + "]");
}
} | java | public boolean isVisited(int loc) {
if (checkBounds(loc)) {
return (ONE == this.registry[loc]);
}
else {
throw new RuntimeException(
"The location " + loc + " out of bounds [0," + (this.registry.length - 1) + "]");
}
} | [
"public",
"boolean",
"isVisited",
"(",
"int",
"loc",
")",
"{",
"if",
"(",
"checkBounds",
"(",
"loc",
")",
")",
"{",
"return",
"(",
"ONE",
"==",
"this",
".",
"registry",
"[",
"loc",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
... | Check if the location specified is visited.
@param loc the location.
@return true if visited | [
"Check",
"if",
"the",
"location",
"specified",
"is",
"visited",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L147-L156 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.getUnvisited | public ArrayList<Integer> getUnvisited() {
if (0 == this.unvisitedCount) {
return new ArrayList<Integer>();
}
ArrayList<Integer> res = new ArrayList<Integer>(this.unvisitedCount);
for (int i = 0; i < this.registry.length; i++) {
if (ZERO == this.registry[i]) {
res.add(i);
}
}
return res;
} | java | public ArrayList<Integer> getUnvisited() {
if (0 == this.unvisitedCount) {
return new ArrayList<Integer>();
}
ArrayList<Integer> res = new ArrayList<Integer>(this.unvisitedCount);
for (int i = 0; i < this.registry.length; i++) {
if (ZERO == this.registry[i]) {
res.add(i);
}
}
return res;
} | [
"public",
"ArrayList",
"<",
"Integer",
">",
"getUnvisited",
"(",
")",
"{",
"if",
"(",
"0",
"==",
"this",
".",
"unvisitedCount",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"}",
"ArrayList",
"<",
"Integer",
">",
"res",
... | Get the list of unvisited positions.
@return list of unvisited positions. | [
"Get",
"the",
"list",
"of",
"unvisited",
"positions",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L163-L174 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java | VisitRegistry.getVisited | public ArrayList<Integer> getVisited() {
if (0 == (this.registry.length - this.unvisitedCount)) {
return new ArrayList<Integer>();
}
ArrayList<Integer> res = new ArrayList<Integer>(this.registry.length - this.unvisitedCount);
for (int i = 0; i < this.registry.length; i++) {
if (ONE == this.registry[i]) {
res.add(i);
}
}
return res;
} | java | public ArrayList<Integer> getVisited() {
if (0 == (this.registry.length - this.unvisitedCount)) {
return new ArrayList<Integer>();
}
ArrayList<Integer> res = new ArrayList<Integer>(this.registry.length - this.unvisitedCount);
for (int i = 0; i < this.registry.length; i++) {
if (ONE == this.registry[i]) {
res.add(i);
}
}
return res;
} | [
"public",
"ArrayList",
"<",
"Integer",
">",
"getVisited",
"(",
")",
"{",
"if",
"(",
"0",
"==",
"(",
"this",
".",
"registry",
".",
"length",
"-",
"this",
".",
"unvisitedCount",
")",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")"... | Get the list of visited positions. Returns NULL if none are visited.
@return list of visited positions. | [
"Get",
"the",
"list",
"of",
"visited",
"positions",
".",
"Returns",
"NULL",
"if",
"none",
"are",
"visited",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/registry/VisitRegistry.java#L181-L192 | train |
jMotif/SAX | src/main/java/net/seninp/util/UCRUtils.java | UCRUtils.readUCRData | public static Map<String, List<double[]>> readUCRData(String fileName)
throws IOException, NumberFormatException {
Map<String, List<double[]>> res = new HashMap<String, List<double[]>>();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String line = "";
while ((line = br.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
String[] split = line.trim().split("[\\,\\s]+");
String label = split[0];
Double num = parseValue(label);
String seriesType = label;
if (!(Double.isNaN(num))) {
seriesType = String.valueOf(num.intValue());
}
double[] series = new double[split.length - 1];
for (int i = 1; i < split.length; i++) {
series[i - 1] = Double.valueOf(split[i].trim()).doubleValue();
}
if (!res.containsKey(seriesType)) {
res.put(seriesType, new ArrayList<double[]>());
}
res.get(seriesType).add(series);
}
br.close();
return res;
} | java | public static Map<String, List<double[]>> readUCRData(String fileName)
throws IOException, NumberFormatException {
Map<String, List<double[]>> res = new HashMap<String, List<double[]>>();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String line = "";
while ((line = br.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
String[] split = line.trim().split("[\\,\\s]+");
String label = split[0];
Double num = parseValue(label);
String seriesType = label;
if (!(Double.isNaN(num))) {
seriesType = String.valueOf(num.intValue());
}
double[] series = new double[split.length - 1];
for (int i = 1; i < split.length; i++) {
series[i - 1] = Double.valueOf(split[i].trim()).doubleValue();
}
if (!res.containsKey(seriesType)) {
res.put(seriesType, new ArrayList<double[]>());
}
res.get(seriesType).add(series);
}
br.close();
return res;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"List",
"<",
"double",
"[",
"]",
">",
">",
"readUCRData",
"(",
"String",
"fileName",
")",
"throws",
"IOException",
",",
"NumberFormatException",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"double",
"[",
"]... | Reads bunch of series from file. First column treats as a class label. Rest as a real-valued
series.
@param fileName the input filename.
@return time series read.
@throws IOException if error occurs.
@throws NumberFormatException if error occurs. | [
"Reads",
"bunch",
"of",
"series",
"from",
"file",
".",
"First",
"column",
"treats",
"as",
"a",
"class",
"label",
".",
"Rest",
"as",
"a",
"real",
"-",
"valued",
"series",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/UCRUtils.java#L35-L69 | train |
jMotif/SAX | src/main/java/net/seninp/util/UCRUtils.java | UCRUtils.datasetStats | public static String datasetStats(Map<String, List<double[]>> data, String name) {
int globalMinLength = Integer.MAX_VALUE;
int globalMaxLength = Integer.MIN_VALUE;
double globalMinValue = Double.MAX_VALUE;
double globalMaxValue = Double.MIN_VALUE;
for (Entry<String, List<double[]>> e : data.entrySet()) {
for (double[] dataEntry : e.getValue()) {
globalMaxLength = (dataEntry.length > globalMaxLength) ? dataEntry.length : globalMaxLength;
globalMinLength = (dataEntry.length < globalMinLength) ? dataEntry.length : globalMinLength;
for (double value : dataEntry) {
globalMaxValue = (value > globalMaxValue) ? value : globalMaxValue;
globalMinValue = (value < globalMinValue) ? value : globalMinValue;
}
}
}
StringBuffer sb = new StringBuffer();
sb.append(name).append("classes: ").append(data.size());
sb.append(", series length min: ").append(globalMinLength);
sb.append(", max: ").append(globalMaxLength);
sb.append(", min value: ").append(globalMinValue);
sb.append(", max value: ").append(globalMaxValue).append(";");
for (Entry<String, List<double[]>> e : data.entrySet()) {
sb.append(name).append(" class: ").append(e.getKey());
sb.append(" series: ").append(e.getValue().size()).append(";");
}
return sb.delete(sb.length() - 1, sb.length()).toString();
} | java | public static String datasetStats(Map<String, List<double[]>> data, String name) {
int globalMinLength = Integer.MAX_VALUE;
int globalMaxLength = Integer.MIN_VALUE;
double globalMinValue = Double.MAX_VALUE;
double globalMaxValue = Double.MIN_VALUE;
for (Entry<String, List<double[]>> e : data.entrySet()) {
for (double[] dataEntry : e.getValue()) {
globalMaxLength = (dataEntry.length > globalMaxLength) ? dataEntry.length : globalMaxLength;
globalMinLength = (dataEntry.length < globalMinLength) ? dataEntry.length : globalMinLength;
for (double value : dataEntry) {
globalMaxValue = (value > globalMaxValue) ? value : globalMaxValue;
globalMinValue = (value < globalMinValue) ? value : globalMinValue;
}
}
}
StringBuffer sb = new StringBuffer();
sb.append(name).append("classes: ").append(data.size());
sb.append(", series length min: ").append(globalMinLength);
sb.append(", max: ").append(globalMaxLength);
sb.append(", min value: ").append(globalMinValue);
sb.append(", max value: ").append(globalMaxValue).append(";");
for (Entry<String, List<double[]>> e : data.entrySet()) {
sb.append(name).append(" class: ").append(e.getKey());
sb.append(" series: ").append(e.getValue().size()).append(";");
}
return sb.delete(sb.length() - 1, sb.length()).toString();
} | [
"public",
"static",
"String",
"datasetStats",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"double",
"[",
"]",
">",
">",
"data",
",",
"String",
"name",
")",
"{",
"int",
"globalMinLength",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"int",
"globalMaxLength",
"... | Prints the dataset statistics.
@param data the UCRdataset.
@param name the dataset name to use.
@return stats. | [
"Prints",
"the",
"dataset",
"statistics",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/UCRUtils.java#L78-L112 | train |
jMotif/SAX | src/main/java/net/seninp/util/UCRUtils.java | UCRUtils.saveData | public static void saveData(Map<String, List<double[]>> data, File file) throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
for (Entry<String, List<double[]>> classEntry : data.entrySet()) {
String classLabel = classEntry.getKey();
for (double[] arr : classEntry.getValue()) {
String arrStr = Arrays.toString(arr).replaceAll("[\\]\\[\\s]+", "");
bw.write(classLabel + "," + arrStr + CR);
}
}
bw.close();
} | java | public static void saveData(Map<String, List<double[]>> data, File file) throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
for (Entry<String, List<double[]>> classEntry : data.entrySet()) {
String classLabel = classEntry.getKey();
for (double[] arr : classEntry.getValue()) {
String arrStr = Arrays.toString(arr).replaceAll("[\\]\\[\\s]+", "");
bw.write(classLabel + "," + arrStr + CR);
}
}
bw.close();
} | [
"public",
"static",
"void",
"saveData",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"double",
"[",
"]",
">",
">",
"data",
",",
"File",
"file",
")",
"throws",
"IOException",
"{",
"BufferedWriter",
"bw",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWrit... | Saves the dataset.
@param data the dataset.
@param file the file handler.
@throws IOException if error occurs. | [
"Saves",
"the",
"dataset",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/UCRUtils.java#L133-L146 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.readTS | public double[] readTS(String dataFileName, int loadLimit) throws SAXException, IOException {
Path path = Paths.get(dataFileName);
if (!(Files.exists(path))) {
throw new SAXException("unable to load data - data source not found.");
}
BufferedReader reader = Files.newBufferedReader(path, DEFAULT_CHARSET);
return readTS(reader, 0, loadLimit);
} | java | public double[] readTS(String dataFileName, int loadLimit) throws SAXException, IOException {
Path path = Paths.get(dataFileName);
if (!(Files.exists(path))) {
throw new SAXException("unable to load data - data source not found.");
}
BufferedReader reader = Files.newBufferedReader(path, DEFAULT_CHARSET);
return readTS(reader, 0, loadLimit);
} | [
"public",
"double",
"[",
"]",
"readTS",
"(",
"String",
"dataFileName",
",",
"int",
"loadLimit",
")",
"throws",
"SAXException",
",",
"IOException",
"{",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"dataFileName",
")",
";",
"if",
"(",
"!",
"(",
"Files",... | Read at least N elements from the one-column file.
@param dataFileName the file name.
@param loadLimit the load limit.
@return the read data or empty array if nothing to load.
@throws SAXException if error occurs.
@throws IOException if error occurs. | [
"Read",
"at",
"least",
"N",
"elements",
"from",
"the",
"one",
"-",
"column",
"file",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L126-L137 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.max | public double max(double[] series) {
double max = Double.MIN_VALUE;
for (int i = 0; i < series.length; i++) {
if (max < series[i]) {
max = series[i];
}
}
return max;
} | java | public double max(double[] series) {
double max = Double.MIN_VALUE;
for (int i = 0; i < series.length; i++) {
if (max < series[i]) {
max = series[i];
}
}
return max;
} | [
"public",
"double",
"max",
"(",
"double",
"[",
"]",
"series",
")",
"{",
"double",
"max",
"=",
"Double",
".",
"MIN_VALUE",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"series",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"max",... | Finds the maximal value in timeseries.
@param series The timeseries.
@return The max value. | [
"Finds",
"the",
"maximal",
"value",
"in",
"timeseries",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L145-L153 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.min | public double min(double[] series) {
double min = Double.MAX_VALUE;
for (int i = 0; i < series.length; i++) {
if (min > series[i]) {
min = series[i];
}
}
return min;
} | java | public double min(double[] series) {
double min = Double.MAX_VALUE;
for (int i = 0; i < series.length; i++) {
if (min > series[i]) {
min = series[i];
}
}
return min;
} | [
"public",
"double",
"min",
"(",
"double",
"[",
"]",
"series",
")",
"{",
"double",
"min",
"=",
"Double",
".",
"MAX_VALUE",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"series",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"min",... | Finds the minimal value in timeseries.
@param series The timeseries.
@return The min value. | [
"Finds",
"the",
"minimal",
"value",
"in",
"timeseries",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L161-L169 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.mean | public double mean(double[] series) {
double res = 0D;
int count = 0;
for (double tp : series) {
res += tp;
count += 1;
}
if (count > 0) {
return res / ((Integer) count).doubleValue();
}
return Double.NaN;
} | java | public double mean(double[] series) {
double res = 0D;
int count = 0;
for (double tp : series) {
res += tp;
count += 1;
}
if (count > 0) {
return res / ((Integer) count).doubleValue();
}
return Double.NaN;
} | [
"public",
"double",
"mean",
"(",
"double",
"[",
"]",
"series",
")",
"{",
"double",
"res",
"=",
"0D",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"double",
"tp",
":",
"series",
")",
"{",
"res",
"+=",
"tp",
";",
"count",
"+=",
"1",
";",
"}",
... | Computes the mean value of timeseries.
@param series The timeseries.
@return The mean value. | [
"Computes",
"the",
"mean",
"value",
"of",
"timeseries",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L177-L189 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.median | public double median(double[] series) {
double[] clonedSeries = series.clone();
Arrays.sort(clonedSeries);
double median;
if (clonedSeries.length % 2 == 0) {
median = (clonedSeries[clonedSeries.length / 2]
+ (double) clonedSeries[clonedSeries.length / 2 - 1]) / 2;
}
else {
median = clonedSeries[clonedSeries.length / 2];
}
return median;
} | java | public double median(double[] series) {
double[] clonedSeries = series.clone();
Arrays.sort(clonedSeries);
double median;
if (clonedSeries.length % 2 == 0) {
median = (clonedSeries[clonedSeries.length / 2]
+ (double) clonedSeries[clonedSeries.length / 2 - 1]) / 2;
}
else {
median = clonedSeries[clonedSeries.length / 2];
}
return median;
} | [
"public",
"double",
"median",
"(",
"double",
"[",
"]",
"series",
")",
"{",
"double",
"[",
"]",
"clonedSeries",
"=",
"series",
".",
"clone",
"(",
")",
";",
"Arrays",
".",
"sort",
"(",
"clonedSeries",
")",
";",
"double",
"median",
";",
"if",
"(",
"clon... | Computes the median value of timeseries.
@param series The timeseries.
@return The median value. | [
"Computes",
"the",
"median",
"value",
"of",
"timeseries",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L217-L230 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.stDev | public double stDev(double[] series) {
double num0 = 0D;
double sum = 0D;
int count = 0;
for (double tp : series) {
num0 = num0 + tp * tp;
sum = sum + tp;
count += 1;
}
double len = ((Integer) count).doubleValue();
return Math.sqrt((len * num0 - sum * sum) / (len * (len - 1)));
} | java | public double stDev(double[] series) {
double num0 = 0D;
double sum = 0D;
int count = 0;
for (double tp : series) {
num0 = num0 + tp * tp;
sum = sum + tp;
count += 1;
}
double len = ((Integer) count).doubleValue();
return Math.sqrt((len * num0 - sum * sum) / (len * (len - 1)));
} | [
"public",
"double",
"stDev",
"(",
"double",
"[",
"]",
"series",
")",
"{",
"double",
"num0",
"=",
"0D",
";",
"double",
"sum",
"=",
"0D",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"double",
"tp",
":",
"series",
")",
"{",
"num0",
"=",
"num0",
... | Speed-optimized implementation.
@param series The timeseries.
@return the standard deviation. | [
"Speed",
"-",
"optimized",
"implementation",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L258-L269 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.znorm | public double[] znorm(double[] series, double normalizationThreshold) {
double[] res = new double[series.length];
double sd = stDev(series);
if (sd < normalizationThreshold) {
// return series.clone();
// return array of zeros
return res;
}
double mean = mean(series);
for (int i = 0; i < res.length; i++) {
res[i] = (series[i] - mean) / sd;
}
return res;
} | java | public double[] znorm(double[] series, double normalizationThreshold) {
double[] res = new double[series.length];
double sd = stDev(series);
if (sd < normalizationThreshold) {
// return series.clone();
// return array of zeros
return res;
}
double mean = mean(series);
for (int i = 0; i < res.length; i++) {
res[i] = (series[i] - mean) / sd;
}
return res;
} | [
"public",
"double",
"[",
"]",
"znorm",
"(",
"double",
"[",
"]",
"series",
",",
"double",
"normalizationThreshold",
")",
"{",
"double",
"[",
"]",
"res",
"=",
"new",
"double",
"[",
"series",
".",
"length",
"]",
";",
"double",
"sd",
"=",
"stDev",
"(",
"... | Z-Normalize routine.
@param series the input timeseries.
@param normalizationThreshold the zNormalization threshold value.
@return Z-normalized time-series. | [
"Z",
"-",
"Normalize",
"routine",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L278-L291 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.ts2String | public char[] ts2String(double[] vals, double[] cuts) {
char[] res = new char[vals.length];
for (int i = 0; i < vals.length; i++) {
res[i] = num2char(vals[i], cuts);
}
return res;
} | java | public char[] ts2String(double[] vals, double[] cuts) {
char[] res = new char[vals.length];
for (int i = 0; i < vals.length; i++) {
res[i] = num2char(vals[i], cuts);
}
return res;
} | [
"public",
"char",
"[",
"]",
"ts2String",
"(",
"double",
"[",
"]",
"vals",
",",
"double",
"[",
"]",
"cuts",
")",
"{",
"char",
"[",
"]",
"res",
"=",
"new",
"char",
"[",
"vals",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i"... | Converts the timeseries into string using given cuts intervals. Useful for not-normal
distribution cuts.
@param vals The timeseries.
@param cuts The cut intervals.
@return The timeseries SAX representation. | [
"Converts",
"the",
"timeseries",
"into",
"string",
"using",
"given",
"cuts",
"intervals",
".",
"Useful",
"for",
"not",
"-",
"normal",
"distribution",
"cuts",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L363-L369 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.ts2Index | public int[] ts2Index(double[] series, double[] cuts) throws Exception {
int[] res = new int[series.length];
for (int i = 0; i < series.length; i++) {
res[i] = num2index(series[i], cuts);
}
return res;
} | java | public int[] ts2Index(double[] series, double[] cuts) throws Exception {
int[] res = new int[series.length];
for (int i = 0; i < series.length; i++) {
res[i] = num2index(series[i], cuts);
}
return res;
} | [
"public",
"int",
"[",
"]",
"ts2Index",
"(",
"double",
"[",
"]",
"series",
",",
"double",
"[",
"]",
"cuts",
")",
"throws",
"Exception",
"{",
"int",
"[",
"]",
"res",
"=",
"new",
"int",
"[",
"series",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",... | Convert the timeseries into the index using SAX cuts.
@param series The timeseries to convert.
@param cuts The alphabet cuts.
@return SAX cuts indices.
@throws Exception if error occurs. | [
"Convert",
"the",
"timeseries",
"into",
"the",
"index",
"using",
"SAX",
"cuts",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L379-L385 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.num2char | public char num2char(double value, double[] cuts) {
int idx = 0;
if (value >= 0) {
idx = cuts.length;
while ((idx > 0) && (cuts[idx - 1] > value)) {
idx--;
}
}
else {
while ((idx < cuts.length) && (cuts[idx] <= value)) {
idx++;
}
}
return ALPHABET[idx];
} | java | public char num2char(double value, double[] cuts) {
int idx = 0;
if (value >= 0) {
idx = cuts.length;
while ((idx > 0) && (cuts[idx - 1] > value)) {
idx--;
}
}
else {
while ((idx < cuts.length) && (cuts[idx] <= value)) {
idx++;
}
}
return ALPHABET[idx];
} | [
"public",
"char",
"num2char",
"(",
"double",
"value",
",",
"double",
"[",
"]",
"cuts",
")",
"{",
"int",
"idx",
"=",
"0",
";",
"if",
"(",
"value",
">=",
"0",
")",
"{",
"idx",
"=",
"cuts",
".",
"length",
";",
"while",
"(",
"(",
"idx",
">",
"0",
... | Get mapping of a number to char.
@param value the value to map.
@param cuts the array of intervals.
@return character corresponding to numeric value. | [
"Get",
"mapping",
"of",
"a",
"number",
"to",
"char",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L394-L408 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.num2index | public int num2index(double value, double[] cuts) {
int count = 0;
while ((count < cuts.length) && (cuts[count] <= value)) {
count++;
}
return count;
} | java | public int num2index(double value, double[] cuts) {
int count = 0;
while ((count < cuts.length) && (cuts[count] <= value)) {
count++;
}
return count;
} | [
"public",
"int",
"num2index",
"(",
"double",
"value",
",",
"double",
"[",
"]",
"cuts",
")",
"{",
"int",
"count",
"=",
"0",
";",
"while",
"(",
"(",
"count",
"<",
"cuts",
".",
"length",
")",
"&&",
"(",
"cuts",
"[",
"count",
"]",
"<=",
"value",
")",... | Get mapping of number to cut index.
@param value the value to map.
@param cuts the array of intervals.
@return character corresponding to numeric value. | [
"Get",
"mapping",
"of",
"number",
"to",
"cut",
"index",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L427-L433 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.subseriesByCopy | public double[] subseriesByCopy(double[] series, int start, int end)
throws IndexOutOfBoundsException {
if ((start > end) || (start < 0) || (end > series.length)) {
throw new IndexOutOfBoundsException("Unable to extract subseries, series length: "
+ series.length + ", start: " + start + ", end: " + String.valueOf(end - start));
}
return Arrays.copyOfRange(series, start, end);
} | java | public double[] subseriesByCopy(double[] series, int start, int end)
throws IndexOutOfBoundsException {
if ((start > end) || (start < 0) || (end > series.length)) {
throw new IndexOutOfBoundsException("Unable to extract subseries, series length: "
+ series.length + ", start: " + start + ", end: " + String.valueOf(end - start));
}
return Arrays.copyOfRange(series, start, end);
} | [
"public",
"double",
"[",
"]",
"subseriesByCopy",
"(",
"double",
"[",
"]",
"series",
",",
"int",
"start",
",",
"int",
"end",
")",
"throws",
"IndexOutOfBoundsException",
"{",
"if",
"(",
"(",
"start",
">",
"end",
")",
"||",
"(",
"start",
"<",
"0",
")",
... | Extract subseries out of series.
@param series The series array.
@param start the fragment start.
@param end the fragment end.
@return The subseries.
@throws IndexOutOfBoundsException If error occurs. | [
"Extract",
"subseries",
"out",
"of",
"series",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L444-L451 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.seriesToString | public String seriesToString(double[] series, NumberFormat df) {
StringBuffer sb = new StringBuffer();
sb.append('[');
for (double d : series) {
sb.append(df.format(d)).append(',');
}
sb.delete(sb.length() - 2, sb.length() - 1).append("]");
return sb.toString();
} | java | public String seriesToString(double[] series, NumberFormat df) {
StringBuffer sb = new StringBuffer();
sb.append('[');
for (double d : series) {
sb.append(df.format(d)).append(',');
}
sb.delete(sb.length() - 2, sb.length() - 1).append("]");
return sb.toString();
} | [
"public",
"String",
"seriesToString",
"(",
"double",
"[",
"]",
"series",
",",
"NumberFormat",
"df",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"for",
"(",
"double",
"d",
":... | Prettyfies the timeseries for screen output.
@param series the data.
@param df the number format to use.
@return The timeseries formatted for screen output. | [
"Prettyfies",
"the",
"timeseries",
"for",
"screen",
"output",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L461-L469 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/TSProcessor.java | TSProcessor.normOne | public double[] normOne(double[] data) {
double[] res = new double[data.length];
double max = max(data);
for (int i = 0; i < data.length; i++) {
res[i] = data[i] / max;
}
return res;
} | java | public double[] normOne(double[] data) {
double[] res = new double[data.length];
double max = max(data);
for (int i = 0; i < data.length; i++) {
res[i] = data[i] / max;
}
return res;
} | [
"public",
"double",
"[",
"]",
"normOne",
"(",
"double",
"[",
"]",
"data",
")",
"{",
"double",
"[",
"]",
"res",
"=",
"new",
"double",
"[",
"data",
".",
"length",
"]",
";",
"double",
"max",
"=",
"max",
"(",
"data",
")",
";",
"for",
"(",
"int",
"i... | Normalizes data in interval 0-1.
@param data the dataset.
@return normalized dataset. | [
"Normalizes",
"data",
"in",
"interval",
"0",
"-",
"1",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/TSProcessor.java#L477-L484 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/discord/DiscordRecords.java | DiscordRecords.getTopHits | public List<DiscordRecord> getTopHits(Integer num) {
if (num >= this.discords.size()) {
return this.discords;
}
List<DiscordRecord> res = this.discords.subList(this.discords.size() - num,
this.discords.size());
return res;
} | java | public List<DiscordRecord> getTopHits(Integer num) {
if (num >= this.discords.size()) {
return this.discords;
}
List<DiscordRecord> res = this.discords.subList(this.discords.size() - num,
this.discords.size());
return res;
} | [
"public",
"List",
"<",
"DiscordRecord",
">",
"getTopHits",
"(",
"Integer",
"num",
")",
"{",
"if",
"(",
"num",
">=",
"this",
".",
"discords",
".",
"size",
"(",
")",
")",
"{",
"return",
"this",
".",
"discords",
";",
"}",
"List",
"<",
"DiscordRecord",
"... | Returns the number of the top hits.
@param num The number of instances to return. If the number larger than the storage size -
returns the storage as is.
@return the top discord hits. | [
"Returns",
"the",
"number",
"of",
"the",
"top",
"hits",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/discord/DiscordRecords.java#L41-L48 | train |
jMotif/SAX | src/main/java/net/seninp/util/HeatChart.java | HeatChart.setZValues | public void setZValues(double[][] zValues, double low, double high) {
this.zValues = zValues;
this.lowValue = low;
this.highValue = high;
} | java | public void setZValues(double[][] zValues, double low, double high) {
this.zValues = zValues;
this.lowValue = low;
this.highValue = high;
} | [
"public",
"void",
"setZValues",
"(",
"double",
"[",
"]",
"[",
"]",
"zValues",
",",
"double",
"low",
",",
"double",
"high",
")",
"{",
"this",
".",
"zValues",
"=",
"zValues",
";",
"this",
".",
"lowValue",
"=",
"low",
";",
"this",
".",
"highValue",
"=",... | Replaces the z-values array. The number of elements should match the number of y-values, with
each element containing a double array with an equal number of elements that matches the number
of x-values. Use this method where the minimum and maximum values possible are not contained
within the dataset.
@param zValues the array to replace the current array with. The number of elements in each
inner array must be identical.
@param low the minimum possible value, which may or may not appear in the z-values.
@param high the maximum possible value, which may or may not appear in the z-values. | [
"Replaces",
"the",
"z",
"-",
"values",
"array",
".",
"The",
"number",
"of",
"elements",
"should",
"match",
"the",
"number",
"of",
"y",
"-",
"values",
"with",
"each",
"element",
"containing",
"a",
"double",
"array",
"with",
"an",
"equal",
"number",
"of",
... | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/HeatChart.java#L341-L345 | train |
jMotif/SAX | src/main/java/net/seninp/util/HeatChart.java | HeatChart.setBackgroundColour | public void setBackgroundColour(Color backgroundColour) {
if (backgroundColour == null) {
backgroundColour = Color.WHITE;
}
this.backgroundColour = backgroundColour;
} | java | public void setBackgroundColour(Color backgroundColour) {
if (backgroundColour == null) {
backgroundColour = Color.WHITE;
}
this.backgroundColour = backgroundColour;
} | [
"public",
"void",
"setBackgroundColour",
"(",
"Color",
"backgroundColour",
")",
"{",
"if",
"(",
"backgroundColour",
"==",
"null",
")",
"{",
"backgroundColour",
"=",
"Color",
".",
"WHITE",
";",
"}",
"this",
".",
"backgroundColour",
"=",
"backgroundColour",
";",
... | Sets the colour to be used on the background of the chart. A transparent background can be set
by setting a background colour with an alpha value. The transparency will only be effective
when the image is saved as a png or gif.
<p>
Defaults to <code>Color.WHITE</code>.
@param backgroundColour the new colour to be set as the background fill. | [
"Sets",
"the",
"colour",
"to",
"be",
"used",
"on",
"the",
"background",
"of",
"the",
"chart",
".",
"A",
"transparent",
"background",
"can",
"be",
"set",
"by",
"setting",
"a",
"background",
"colour",
"with",
"an",
"alpha",
"value",
".",
"The",
"transparency... | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/HeatChart.java#L736-L742 | train |
jMotif/SAX | src/main/java/net/seninp/util/HeatChart.java | HeatChart.max | public static double max(double[][] values) {
double max = 0;
for (int i = 0; i < values.length; i++) {
for (int j = 0; j < values[i].length; j++) {
max = (values[i][j] > max) ? values[i][j] : max;
}
}
return max;
} | java | public static double max(double[][] values) {
double max = 0;
for (int i = 0; i < values.length; i++) {
for (int j = 0; j < values[i].length; j++) {
max = (values[i][j] > max) ? values[i][j] : max;
}
}
return max;
} | [
"public",
"static",
"double",
"max",
"(",
"double",
"[",
"]",
"[",
"]",
"values",
")",
"{",
"double",
"max",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",... | Finds and returns the maximum value in a 2-dimensional array of doubles.
@param values the data to use.
@return the largest value in the array. | [
"Finds",
"and",
"returns",
"the",
"maximum",
"value",
"in",
"a",
"2",
"-",
"dimensional",
"array",
"of",
"doubles",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/HeatChart.java#L1697-L1705 | train |
jMotif/SAX | src/main/java/net/seninp/util/HeatChart.java | HeatChart.min | public static double min(double[][] values) {
double min = Double.MAX_VALUE;
for (int i = 0; i < values.length; i++) {
for (int j = 0; j < values[i].length; j++) {
min = (values[i][j] < min) ? values[i][j] : min;
}
}
return min;
} | java | public static double min(double[][] values) {
double min = Double.MAX_VALUE;
for (int i = 0; i < values.length; i++) {
for (int j = 0; j < values[i].length; j++) {
min = (values[i][j] < min) ? values[i][j] : min;
}
}
return min;
} | [
"public",
"static",
"double",
"min",
"(",
"double",
"[",
"]",
"[",
"]",
"values",
")",
"{",
"double",
"min",
"=",
"Double",
".",
"MAX_VALUE",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{... | Finds and returns the minimum value in a 2-dimensional array of doubles.
@param values the data to use.
@return the smallest value in the array. | [
"Finds",
"and",
"returns",
"the",
"minimum",
"value",
"in",
"a",
"2",
"-",
"dimensional",
"array",
"of",
"doubles",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/HeatChart.java#L1714-L1722 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/discord/DiscordRecord.java | DiscordRecord.compareTo | @Override
public int compareTo(DiscordRecord other) {
if (null == other) {
throw new NullPointerException("Unable compare to null!");
}
return Double.compare(other.getNNDistance(), this.nnDistance);
} | java | @Override
public int compareTo(DiscordRecord other) {
if (null == other) {
throw new NullPointerException("Unable compare to null!");
}
return Double.compare(other.getNNDistance(), this.nnDistance);
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"DiscordRecord",
"other",
")",
"{",
"if",
"(",
"null",
"==",
"other",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Unable compare to null!\"",
")",
";",
"}",
"return",
"Double",
".",
"compare",
... | The simple comparator based on the distance. Note that discord is "better" if the NN distance
is greater.
@param other The discord record this one is compared to.
@return True if equals. | [
"The",
"simple",
"comparator",
"based",
"on",
"the",
"distance",
".",
"Note",
"that",
"discord",
"is",
"better",
"if",
"the",
"NN",
"distance",
"is",
"greater",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/discord/DiscordRecord.java#L160-L166 | train |
jMotif/SAX | src/main/java/net/seninp/util/StdRandom.java | StdRandom.gaussian | public static double gaussian() {
// use the polar form of the Box-Muller transform
double r, x, y;
do {
x = uniform(-1.0, 1.0);
y = uniform(-1.0, 1.0);
r = x * x + y * y;
}
while (r >= 1 || r == 0);
return x * Math.sqrt(-2 * Math.log(r) / r);
// Remark: y * Math.sqrt(-2 * Math.log(r) / r)
// is an independent random gaussian
} | java | public static double gaussian() {
// use the polar form of the Box-Muller transform
double r, x, y;
do {
x = uniform(-1.0, 1.0);
y = uniform(-1.0, 1.0);
r = x * x + y * y;
}
while (r >= 1 || r == 0);
return x * Math.sqrt(-2 * Math.log(r) / r);
// Remark: y * Math.sqrt(-2 * Math.log(r) / r)
// is an independent random gaussian
} | [
"public",
"static",
"double",
"gaussian",
"(",
")",
"{",
"// use the polar form of the Box-Muller transform",
"double",
"r",
",",
"x",
",",
"y",
";",
"do",
"{",
"x",
"=",
"uniform",
"(",
"-",
"1.0",
",",
"1.0",
")",
";",
"y",
"=",
"uniform",
"(",
"-",
... | Returns a real number with a standard Gaussian distribution.
@return the random value. | [
"Returns",
"a",
"real",
"number",
"with",
"a",
"standard",
"Gaussian",
"distribution",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/StdRandom.java#L192-L205 | train |
jMotif/SAX | src/main/java/net/seninp/util/StdRandom.java | StdRandom.shuffle | public static void shuffle(double[] a) {
int N = a.length;
for (int i = 0; i < N; i++) {
int r = i + uniform(N - i); // between i and N-1
double temp = a[i];
a[i] = a[r];
a[r] = temp;
}
} | java | public static void shuffle(double[] a) {
int N = a.length;
for (int i = 0; i < N; i++) {
int r = i + uniform(N - i); // between i and N-1
double temp = a[i];
a[i] = a[r];
a[r] = temp;
}
} | [
"public",
"static",
"void",
"shuffle",
"(",
"double",
"[",
"]",
"a",
")",
"{",
"int",
"N",
"=",
"a",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"int",
"r",
"=",
"i",
"+",
"uniform",
... | Rearrange the elements of a double array in random order.
@param a the array to shuffle. | [
"Rearrange",
"the",
"elements",
"of",
"a",
"double",
"array",
"in",
"random",
"order",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/util/StdRandom.java#L345-L353 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.dropByIndex | public void dropByIndex(int idx) {
SAXRecord entry = realTSindex.get(idx);
if (null != entry) {
realTSindex.remove(idx);
entry.removeIndex(idx);
if (entry.getIndexes().isEmpty()) {
records.remove(String.valueOf(entry.getPayload()));
}
}
} | java | public void dropByIndex(int idx) {
SAXRecord entry = realTSindex.get(idx);
if (null != entry) {
realTSindex.remove(idx);
entry.removeIndex(idx);
if (entry.getIndexes().isEmpty()) {
records.remove(String.valueOf(entry.getPayload()));
}
}
} | [
"public",
"void",
"dropByIndex",
"(",
"int",
"idx",
")",
"{",
"SAXRecord",
"entry",
"=",
"realTSindex",
".",
"get",
"(",
"idx",
")",
";",
"if",
"(",
"null",
"!=",
"entry",
")",
"{",
"realTSindex",
".",
"remove",
"(",
"idx",
")",
";",
"entry",
".",
... | Drops a single entry.
@param idx the index. | [
"Drops",
"a",
"single",
"entry",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L101-L110 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.add | public void add(char[] str, int idx) {
SAXRecord rr = records.get(String.valueOf(str));
if (null == rr) {
rr = new SAXRecord(str, idx);
this.records.put(String.valueOf(str), rr);
}
else {
rr.addIndex(idx);
}
this.realTSindex.put(idx, rr);
} | java | public void add(char[] str, int idx) {
SAXRecord rr = records.get(String.valueOf(str));
if (null == rr) {
rr = new SAXRecord(str, idx);
this.records.put(String.valueOf(str), rr);
}
else {
rr.addIndex(idx);
}
this.realTSindex.put(idx, rr);
} | [
"public",
"void",
"add",
"(",
"char",
"[",
"]",
"str",
",",
"int",
"idx",
")",
"{",
"SAXRecord",
"rr",
"=",
"records",
".",
"get",
"(",
"String",
".",
"valueOf",
"(",
"str",
")",
")",
";",
"if",
"(",
"null",
"==",
"rr",
")",
"{",
"rr",
"=",
"... | Adds a single string and index entry by creating a SAXRecord.
@param str The string.
@param idx The index. | [
"Adds",
"a",
"single",
"string",
"and",
"index",
"entry",
"by",
"creating",
"a",
"SAXRecord",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L118-L128 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.addAll | public void addAll(SAXRecords records) {
for (SAXRecord record : records) {
char[] payload = record.getPayload();
for (Integer i : record.getIndexes()) {
this.add(payload, i);
}
}
} | java | public void addAll(SAXRecords records) {
for (SAXRecord record : records) {
char[] payload = record.getPayload();
for (Integer i : record.getIndexes()) {
this.add(payload, i);
}
}
} | [
"public",
"void",
"addAll",
"(",
"SAXRecords",
"records",
")",
"{",
"for",
"(",
"SAXRecord",
"record",
":",
"records",
")",
"{",
"char",
"[",
"]",
"payload",
"=",
"record",
".",
"getPayload",
"(",
")",
";",
"for",
"(",
"Integer",
"i",
":",
"record",
... | Adds all entries from the collection.
@param records The collection. | [
"Adds",
"all",
"entries",
"from",
"the",
"collection",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L135-L142 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.addAll | public void addAll(HashMap<Integer, char[]> records) {
for (Entry<Integer, char[]> e : records.entrySet()) {
this.add(e.getValue(), e.getKey());
}
} | java | public void addAll(HashMap<Integer, char[]> records) {
for (Entry<Integer, char[]> e : records.entrySet()) {
this.add(e.getValue(), e.getKey());
}
} | [
"public",
"void",
"addAll",
"(",
"HashMap",
"<",
"Integer",
",",
"char",
"[",
"]",
">",
"records",
")",
"{",
"for",
"(",
"Entry",
"<",
"Integer",
",",
"char",
"[",
"]",
">",
"e",
":",
"records",
".",
"entrySet",
"(",
")",
")",
"{",
"this",
".",
... | This adds all to the internal store. Used by the parallel SAX conversion engine.
@param records the data to add. | [
"This",
"adds",
"all",
"to",
"the",
"internal",
"store",
".",
"Used",
"by",
"the",
"parallel",
"SAX",
"conversion",
"engine",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L149-L153 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.getSAXString | public String getSAXString(String separatorToken) {
StringBuffer sb = new StringBuffer();
ArrayList<Integer> index = new ArrayList<Integer>();
index.addAll(this.realTSindex.keySet());
Collections.sort(index, new Comparator<Integer>() {
public int compare(Integer int1, Integer int2) {
return int1.compareTo(int2);
}
});
for (int i : index) {
sb.append(this.realTSindex.get(i).getPayload()).append(separatorToken);
}
return sb.toString();
} | java | public String getSAXString(String separatorToken) {
StringBuffer sb = new StringBuffer();
ArrayList<Integer> index = new ArrayList<Integer>();
index.addAll(this.realTSindex.keySet());
Collections.sort(index, new Comparator<Integer>() {
public int compare(Integer int1, Integer int2) {
return int1.compareTo(int2);
}
});
for (int i : index) {
sb.append(this.realTSindex.get(i).getPayload()).append(separatorToken);
}
return sb.toString();
} | [
"public",
"String",
"getSAXString",
"(",
"String",
"separatorToken",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"ArrayList",
"<",
"Integer",
">",
"index",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"index",... | Get the SAX string of this whole collection.
@param separatorToken The separator token to use for the string.
@return The whole data as a string. | [
"Get",
"the",
"SAX",
"string",
"of",
"this",
"whole",
"collection",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L198-L211 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.getAllIndices | public ArrayList<Integer> getAllIndices() {
ArrayList<Integer> res = new ArrayList<Integer>(this.realTSindex.size());
res.addAll(this.realTSindex.keySet());
Collections.sort(res);
return res;
} | java | public ArrayList<Integer> getAllIndices() {
ArrayList<Integer> res = new ArrayList<Integer>(this.realTSindex.size());
res.addAll(this.realTSindex.keySet());
Collections.sort(res);
return res;
} | [
"public",
"ArrayList",
"<",
"Integer",
">",
"getAllIndices",
"(",
")",
"{",
"ArrayList",
"<",
"Integer",
">",
"res",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
"this",
".",
"realTSindex",
".",
"size",
"(",
")",
")",
";",
"res",
".",
"addAll",
... | Get all indexes, sorted.
@return all the indexes. | [
"Get",
"all",
"indexes",
"sorted",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L218-L223 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.buildIndex | public void buildIndex() {
this.stringPosToRealPos = new HashMap<Integer, Integer>();
int counter = 0;
for (Integer idx : getAllIndices()) {
this.stringPosToRealPos.put(counter, idx);
counter++;
}
} | java | public void buildIndex() {
this.stringPosToRealPos = new HashMap<Integer, Integer>();
int counter = 0;
for (Integer idx : getAllIndices()) {
this.stringPosToRealPos.put(counter, idx);
counter++;
}
} | [
"public",
"void",
"buildIndex",
"(",
")",
"{",
"this",
".",
"stringPosToRealPos",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"Integer",
">",
"(",
")",
";",
"int",
"counter",
"=",
"0",
";",
"for",
"(",
"Integer",
"idx",
":",
"getAllIndices",
"(",
")",
... | This builds an index that aids in mapping of a SAX word to the real timeseries index. | [
"This",
"builds",
"an",
"index",
"that",
"aids",
"in",
"mapping",
"of",
"a",
"SAX",
"word",
"to",
"the",
"real",
"timeseries",
"index",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L228-L235 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.excludePositions | public void excludePositions(ArrayList<Integer> positions) {
for (Integer p : positions) {
if (realTSindex.containsKey(p)) {
SAXRecord rec = realTSindex.get(p);
rec.removeIndex(p);
if (rec.getIndexes().isEmpty()) {
this.records.remove(String.valueOf(rec.getPayload()));
}
realTSindex.remove(p);
}
}
} | java | public void excludePositions(ArrayList<Integer> positions) {
for (Integer p : positions) {
if (realTSindex.containsKey(p)) {
SAXRecord rec = realTSindex.get(p);
rec.removeIndex(p);
if (rec.getIndexes().isEmpty()) {
this.records.remove(String.valueOf(rec.getPayload()));
}
realTSindex.remove(p);
}
}
} | [
"public",
"void",
"excludePositions",
"(",
"ArrayList",
"<",
"Integer",
">",
"positions",
")",
"{",
"for",
"(",
"Integer",
"p",
":",
"positions",
")",
"{",
"if",
"(",
"realTSindex",
".",
"containsKey",
"(",
"p",
")",
")",
"{",
"SAXRecord",
"rec",
"=",
... | Removes saxRecord occurrences that correspond to these positions.
@param positions The positions to clear. | [
"Removes",
"saxRecord",
"occurrences",
"that",
"correspond",
"to",
"these",
"positions",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L252-L263 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.getSimpleMotifs | public ArrayList<SAXRecord> getSimpleMotifs(int num) {
ArrayList<SAXRecord> res = new ArrayList<SAXRecord>(num);
DoublyLinkedSortedList<Entry<String, SAXRecord>> list = new DoublyLinkedSortedList<Entry<String, SAXRecord>>(
num, new Comparator<Entry<String, SAXRecord>>() {
@Override
public int compare(Entry<String, SAXRecord> o1, Entry<String, SAXRecord> o2) {
int f1 = o1.getValue().getIndexes().size();
int f2 = o2.getValue().getIndexes().size();
return Integer.compare(f1, f2);
}
});
for (Entry<String, SAXRecord> e : this.records.entrySet()) {
list.addElement(e);
}
Iterator<Entry<String, SAXRecord>> i = list.iterator();
while (i.hasNext()) {
res.add(i.next().getValue());
}
return res;
} | java | public ArrayList<SAXRecord> getSimpleMotifs(int num) {
ArrayList<SAXRecord> res = new ArrayList<SAXRecord>(num);
DoublyLinkedSortedList<Entry<String, SAXRecord>> list = new DoublyLinkedSortedList<Entry<String, SAXRecord>>(
num, new Comparator<Entry<String, SAXRecord>>() {
@Override
public int compare(Entry<String, SAXRecord> o1, Entry<String, SAXRecord> o2) {
int f1 = o1.getValue().getIndexes().size();
int f2 = o2.getValue().getIndexes().size();
return Integer.compare(f1, f2);
}
});
for (Entry<String, SAXRecord> e : this.records.entrySet()) {
list.addElement(e);
}
Iterator<Entry<String, SAXRecord>> i = list.iterator();
while (i.hasNext()) {
res.add(i.next().getValue());
}
return res;
} | [
"public",
"ArrayList",
"<",
"SAXRecord",
">",
"getSimpleMotifs",
"(",
"int",
"num",
")",
"{",
"ArrayList",
"<",
"SAXRecord",
">",
"res",
"=",
"new",
"ArrayList",
"<",
"SAXRecord",
">",
"(",
"num",
")",
";",
"DoublyLinkedSortedList",
"<",
"Entry",
"<",
"Str... | Get motifs.
@param num how many motifs to report.
@return the array of motif SAXRecords. | [
"Get",
"motifs",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L271-L290 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/parallel/ParallelSAXImplementation.java | ParallelSAXImplementation.cancel | public void cancel() {
try {
executorService.shutdown();
if (!executorService.awaitTermination(30, TimeUnit.MINUTES)) {
executorService.shutdownNow(); // Cancel currently executing tasks
if (!executorService.awaitTermination(30, TimeUnit.MINUTES)) {
LOGGER.error("Pool did not terminate... FATAL ERROR");
throw new RuntimeException("Parallel SAX pool did not terminate... FATAL ERROR");
}
}
else {
LOGGER.error("Parallel SAX was interrupted by a request");
}
}
catch (InterruptedException ie) {
LOGGER.error("Error while waiting interrupting.", ie);
// (Re-)Cancel if current thread also interrupted
executorService.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
}
} | java | public void cancel() {
try {
executorService.shutdown();
if (!executorService.awaitTermination(30, TimeUnit.MINUTES)) {
executorService.shutdownNow(); // Cancel currently executing tasks
if (!executorService.awaitTermination(30, TimeUnit.MINUTES)) {
LOGGER.error("Pool did not terminate... FATAL ERROR");
throw new RuntimeException("Parallel SAX pool did not terminate... FATAL ERROR");
}
}
else {
LOGGER.error("Parallel SAX was interrupted by a request");
}
}
catch (InterruptedException ie) {
LOGGER.error("Error while waiting interrupting.", ie);
// (Re-)Cancel if current thread also interrupted
executorService.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
}
} | [
"public",
"void",
"cancel",
"(",
")",
"{",
"try",
"{",
"executorService",
".",
"shutdown",
"(",
")",
";",
"if",
"(",
"!",
"executorService",
".",
"awaitTermination",
"(",
"30",
",",
"TimeUnit",
".",
"MINUTES",
")",
")",
"{",
"executorService",
".",
"shut... | Cancels the execution. | [
"Cancels",
"the",
"execution",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/parallel/ParallelSAXImplementation.java#L432-L453 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/tinker/MoviePrinter.java | MoviePrinter.main | public static void main(String[] args) throws Exception {
SAXProcessor sp = new SAXProcessor();
// data
//
double[] dat = TSProcessor.readFileColumn(DAT_FNAME, 1, 0);
// TSProcessor tp = new TSProcessor();
// double[] dat = tp.readTS("src/resources/dataset/asys40.txt", 0);
// double[] dat = TSProcessor.readFileColumn(filename, columnIdx,
// sizeLimit)FileColumn(DAT_FNAME, 1, 0);
LOGGER.info("read {} points from {}", dat.length, DAT_FNAME);
String str = "win_width: " + cPoint + "; SAX: W " + SAX_WINDOW_SIZE + ", P " + SAX_PAA_SIZE
+ ", A " + SAX_ALPHABET_SIZE + ", STR " + SAX_NR_STRATEGY.toString();
int frameCounter = 0;
int startOffset = cPoint;
while (cPoint < dat.length - startOffset - 1) {
if (0 == cPoint % 2) {
BufferedImage tsChart = getChart(dat, cPoint);
// bitmap 1
//
double[] win1 = Arrays.copyOfRange(dat, cPoint - startOffset, cPoint);
Map<String, Integer> shingledData1 = sp.ts2Shingles(win1, SAX_WINDOW_SIZE, SAX_PAA_SIZE,
SAX_ALPHABET_SIZE, SAX_NR_STRATEGY, SAX_NORM_THRESHOLD, SHINGLE_SIZE);
BufferedImage pam1 = getHeatMap(shingledData1, "pre-window");
double[] win2 = Arrays.copyOfRange(dat, cPoint, cPoint + startOffset);
Map<String, Integer> shingledData2 = sp.ts2Shingles(win2, SAX_WINDOW_SIZE, SAX_PAA_SIZE,
SAX_ALPHABET_SIZE, SAX_NR_STRATEGY, SAX_NORM_THRESHOLD, SHINGLE_SIZE);
BufferedImage pam2 = getHeatMap(shingledData2, "post-window");
// the assemble
//
BufferedImage target = new BufferedImage(800, 530, BufferedImage.TYPE_INT_ARGB);
Graphics targetGraphics = target.getGraphics();
targetGraphics.setColor(Color.WHITE);
targetGraphics.fillRect(0, 0, 799, 529);
targetGraphics.drawImage(tsChart, 0, 0, null);
targetGraphics.drawImage(pam1, 10, 410, null);// draws the first image onto it
targetGraphics.drawImage(pam2, 120, 410, null);// draws the first image onto it
targetGraphics.setColor(Color.RED);
targetGraphics.setFont(new Font("monospaced", Font.PLAIN, 16));
targetGraphics.drawString(str, 300, 420);
targetGraphics.setColor(Color.BLUE);
targetGraphics.setFont(new Font("monospaced", Font.PLAIN, 24));
double dist = ed.distance(toVector(shingledData1), toVector(shingledData2));
targetGraphics.drawString("ED=" + df.format(dist), 300, 480);
// String fileName = new SimpleDateFormat("yyyyMMddhhmmssSS'.png'").format(new Date());
File outputfile = new File("dframe" + String.format("%04d", frameCounter) + ".png");
ImageIO.write(target, "png", outputfile);
frameCounter++;
}
cPoint++;
}
} | java | public static void main(String[] args) throws Exception {
SAXProcessor sp = new SAXProcessor();
// data
//
double[] dat = TSProcessor.readFileColumn(DAT_FNAME, 1, 0);
// TSProcessor tp = new TSProcessor();
// double[] dat = tp.readTS("src/resources/dataset/asys40.txt", 0);
// double[] dat = TSProcessor.readFileColumn(filename, columnIdx,
// sizeLimit)FileColumn(DAT_FNAME, 1, 0);
LOGGER.info("read {} points from {}", dat.length, DAT_FNAME);
String str = "win_width: " + cPoint + "; SAX: W " + SAX_WINDOW_SIZE + ", P " + SAX_PAA_SIZE
+ ", A " + SAX_ALPHABET_SIZE + ", STR " + SAX_NR_STRATEGY.toString();
int frameCounter = 0;
int startOffset = cPoint;
while (cPoint < dat.length - startOffset - 1) {
if (0 == cPoint % 2) {
BufferedImage tsChart = getChart(dat, cPoint);
// bitmap 1
//
double[] win1 = Arrays.copyOfRange(dat, cPoint - startOffset, cPoint);
Map<String, Integer> shingledData1 = sp.ts2Shingles(win1, SAX_WINDOW_SIZE, SAX_PAA_SIZE,
SAX_ALPHABET_SIZE, SAX_NR_STRATEGY, SAX_NORM_THRESHOLD, SHINGLE_SIZE);
BufferedImage pam1 = getHeatMap(shingledData1, "pre-window");
double[] win2 = Arrays.copyOfRange(dat, cPoint, cPoint + startOffset);
Map<String, Integer> shingledData2 = sp.ts2Shingles(win2, SAX_WINDOW_SIZE, SAX_PAA_SIZE,
SAX_ALPHABET_SIZE, SAX_NR_STRATEGY, SAX_NORM_THRESHOLD, SHINGLE_SIZE);
BufferedImage pam2 = getHeatMap(shingledData2, "post-window");
// the assemble
//
BufferedImage target = new BufferedImage(800, 530, BufferedImage.TYPE_INT_ARGB);
Graphics targetGraphics = target.getGraphics();
targetGraphics.setColor(Color.WHITE);
targetGraphics.fillRect(0, 0, 799, 529);
targetGraphics.drawImage(tsChart, 0, 0, null);
targetGraphics.drawImage(pam1, 10, 410, null);// draws the first image onto it
targetGraphics.drawImage(pam2, 120, 410, null);// draws the first image onto it
targetGraphics.setColor(Color.RED);
targetGraphics.setFont(new Font("monospaced", Font.PLAIN, 16));
targetGraphics.drawString(str, 300, 420);
targetGraphics.setColor(Color.BLUE);
targetGraphics.setFont(new Font("monospaced", Font.PLAIN, 24));
double dist = ed.distance(toVector(shingledData1), toVector(shingledData2));
targetGraphics.drawString("ED=" + df.format(dist), 300, 480);
// String fileName = new SimpleDateFormat("yyyyMMddhhmmssSS'.png'").format(new Date());
File outputfile = new File("dframe" + String.format("%04d", frameCounter) + ".png");
ImageIO.write(target, "png", outputfile);
frameCounter++;
}
cPoint++;
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"SAXProcessor",
"sp",
"=",
"new",
"SAXProcessor",
"(",
")",
";",
"// data",
"//",
"double",
"[",
"]",
"dat",
"=",
"TSProcessor",
".",
"readFileColumn",
... | -pix_fmt yuv420p daimler_man.mp4 | [
"-",
"pix_fmt",
"yuv420p",
"daimler_man",
".",
"mp4"
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/tinker/MoviePrinter.java#L60-L126 | train |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/bitmap/UCRdataBitmapPrinter.java | UCRdataBitmapPrinter.toDoubleAray | private static double[] toDoubleAray(Integer[] intArray, HashSet<Integer> skipIndex) {
double[] res = new double[intArray.length - skipIndex.size()];
int skip = 0;
for (int i = 0; i < intArray.length; i++) {
if (skipIndex.contains(i)) {
skip++;
continue;
}
res[i - skip] = intArray[i].doubleValue();
}
return res;
} | java | private static double[] toDoubleAray(Integer[] intArray, HashSet<Integer> skipIndex) {
double[] res = new double[intArray.length - skipIndex.size()];
int skip = 0;
for (int i = 0; i < intArray.length; i++) {
if (skipIndex.contains(i)) {
skip++;
continue;
}
res[i - skip] = intArray[i].doubleValue();
}
return res;
} | [
"private",
"static",
"double",
"[",
"]",
"toDoubleAray",
"(",
"Integer",
"[",
"]",
"intArray",
",",
"HashSet",
"<",
"Integer",
">",
"skipIndex",
")",
"{",
"double",
"[",
"]",
"res",
"=",
"new",
"double",
"[",
"intArray",
".",
"length",
"-",
"skipIndex",
... | Converts an array into array of doubles skipping specified indeces.
@param intArray the input array.
@param skipIndex skip index list.
@return array of doubles. | [
"Converts",
"an",
"array",
"into",
"array",
"of",
"doubles",
"skipping",
"specified",
"indeces",
"."
] | 39ee07a69facaa330def5130b8790aeda85f1061 | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/bitmap/UCRdataBitmapPrinter.java#L264-L275 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFileAssembly.java | VirtualFileAssembly.getFile | public VirtualFile getFile(VirtualFile mountPoint, VirtualFile target) {
final String path = target.getPathNameRelativeTo(mountPoint);
return rootNode.getFile(new Path(path), mountPoint);
} | java | public VirtualFile getFile(VirtualFile mountPoint, VirtualFile target) {
final String path = target.getPathNameRelativeTo(mountPoint);
return rootNode.getFile(new Path(path), mountPoint);
} | [
"public",
"VirtualFile",
"getFile",
"(",
"VirtualFile",
"mountPoint",
",",
"VirtualFile",
"target",
")",
"{",
"final",
"String",
"path",
"=",
"target",
".",
"getPathNameRelativeTo",
"(",
"mountPoint",
")",
";",
"return",
"rootNode",
".",
"getFile",
"(",
"new",
... | Get the VirtualFile from the assembly. This will traverse VirtualFiles in assembly
to find children if needed.
@param mountPoint
@param target
@return
@throws IOException | [
"Get",
"the",
"VirtualFile",
"from",
"the",
"assembly",
".",
"This",
"will",
"traverse",
"VirtualFiles",
"in",
"assembly",
"to",
"find",
"children",
"if",
"needed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFileAssembly.java#L95-L98 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFileAssembly.java | VirtualFileAssembly.getChildNames | public List<String> getChildNames(VirtualFile mountPoint, VirtualFile target) {
List<String> names = new LinkedList<String>();
AssemblyNode targetNode = null;
if (mountPoint.equals(target)) {
targetNode = rootNode;
} else {
targetNode = rootNode.find(target.getPathNameRelativeTo(mountPoint));
}
if (targetNode != null) {
for (AssemblyNode childNode : targetNode.children.values()) {
names.add(childNode.realName);
}
}
return names;
} | java | public List<String> getChildNames(VirtualFile mountPoint, VirtualFile target) {
List<String> names = new LinkedList<String>();
AssemblyNode targetNode = null;
if (mountPoint.equals(target)) {
targetNode = rootNode;
} else {
targetNode = rootNode.find(target.getPathNameRelativeTo(mountPoint));
}
if (targetNode != null) {
for (AssemblyNode childNode : targetNode.children.values()) {
names.add(childNode.realName);
}
}
return names;
} | [
"public",
"List",
"<",
"String",
">",
"getChildNames",
"(",
"VirtualFile",
"mountPoint",
",",
"VirtualFile",
"target",
")",
"{",
"List",
"<",
"String",
">",
"names",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"AssemblyNode",
"targetNode",
... | Returns a list of all the names of the children in the assembly.
@return | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"names",
"of",
"the",
"children",
"in",
"the",
"assembly",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFileAssembly.java#L105-L119 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/TempDir.java | TempDir.createFile | public File createFile(String relativePath, InputStream sourceData) throws IOException {
final File tempFile = getFile(relativePath);
boolean ok = false;
try {
final FileOutputStream fos = new FileOutputStream(tempFile);
try {
VFSUtils.copyStream(sourceData, fos);
fos.close();
sourceData.close();
ok = true;
return tempFile;
} finally {
VFSUtils.safeClose(fos);
}
} finally {
VFSUtils.safeClose(sourceData);
if (!ok) {
tempFile.delete();
}
}
} | java | public File createFile(String relativePath, InputStream sourceData) throws IOException {
final File tempFile = getFile(relativePath);
boolean ok = false;
try {
final FileOutputStream fos = new FileOutputStream(tempFile);
try {
VFSUtils.copyStream(sourceData, fos);
fos.close();
sourceData.close();
ok = true;
return tempFile;
} finally {
VFSUtils.safeClose(fos);
}
} finally {
VFSUtils.safeClose(sourceData);
if (!ok) {
tempFile.delete();
}
}
} | [
"public",
"File",
"createFile",
"(",
"String",
"relativePath",
",",
"InputStream",
"sourceData",
")",
"throws",
"IOException",
"{",
"final",
"File",
"tempFile",
"=",
"getFile",
"(",
"relativePath",
")",
";",
"boolean",
"ok",
"=",
"false",
";",
"try",
"{",
"f... | Create a file within this temporary directory, prepopulating the file from the given input stream.
@param relativePath the relative path name
@param sourceData the source input stream to use
@return the file
@throws IOException if the directory was closed at the time of this invocation or an error occurs | [
"Create",
"a",
"file",
"within",
"this",
"temporary",
"directory",
"prepopulating",
"the",
"file",
"from",
"the",
"given",
"input",
"stream",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/TempDir.java#L80-L100 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.init | private static void init() {
String pkgs = System.getProperty("java.protocol.handler.pkgs");
if (pkgs == null || pkgs.trim().length() == 0) {
pkgs = "org.jboss.net.protocol|org.jboss.vfs.protocol";
System.setProperty("java.protocol.handler.pkgs", pkgs);
} else if (pkgs.contains("org.jboss.vfs.protocol") == false) {
if (pkgs.contains("org.jboss.net.protocol") == false) { pkgs += "|org.jboss.net.protocol"; }
pkgs += "|org.jboss.vfs.protocol";
System.setProperty("java.protocol.handler.pkgs", pkgs);
}
} | java | private static void init() {
String pkgs = System.getProperty("java.protocol.handler.pkgs");
if (pkgs == null || pkgs.trim().length() == 0) {
pkgs = "org.jboss.net.protocol|org.jboss.vfs.protocol";
System.setProperty("java.protocol.handler.pkgs", pkgs);
} else if (pkgs.contains("org.jboss.vfs.protocol") == false) {
if (pkgs.contains("org.jboss.net.protocol") == false) { pkgs += "|org.jboss.net.protocol"; }
pkgs += "|org.jboss.vfs.protocol";
System.setProperty("java.protocol.handler.pkgs", pkgs);
}
} | [
"private",
"static",
"void",
"init",
"(",
")",
"{",
"String",
"pkgs",
"=",
"System",
".",
"getProperty",
"(",
"\"java.protocol.handler.pkgs\"",
")",
";",
"if",
"(",
"pkgs",
"==",
"null",
"||",
"pkgs",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==... | Initialize VFS protocol handlers package property. | [
"Initialize",
"VFS",
"protocol",
"handlers",
"package",
"property",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L77-L87 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.mount | public static Closeable mount(VirtualFile mountPoint, FileSystem fileSystem) throws IOException {
final VirtualFile parent = mountPoint.getParent();
if (parent == null) {
throw VFSMessages.MESSAGES.rootFileSystemAlreadyMounted();
}
final String name = mountPoint.getName();
final Mount mount = new Mount(fileSystem, mountPoint);
final ConcurrentMap<VirtualFile, Map<String, Mount>> mounts = VFS.mounts;
for (; ; ) {
Map<String, Mount> childMountMap = mounts.get(parent);
Map<String, Mount> newMap;
if (childMountMap == null) {
childMountMap = mounts.putIfAbsent(parent, Collections.singletonMap(name, mount));
if (childMountMap == null) {
return mount;
}
}
newMap = new HashMap<String, Mount>(childMountMap);
if (newMap.put(name, mount) != null) {
throw VFSMessages.MESSAGES.fileSystemAlreadyMountedAtMountPoint(mountPoint);
}
if (mounts.replace(parent, childMountMap, newMap)) {
VFSLogger.ROOT_LOGGER.tracef("Mounted filesystem %s on mount point %s", fileSystem, mountPoint);
return mount;
}
}
} | java | public static Closeable mount(VirtualFile mountPoint, FileSystem fileSystem) throws IOException {
final VirtualFile parent = mountPoint.getParent();
if (parent == null) {
throw VFSMessages.MESSAGES.rootFileSystemAlreadyMounted();
}
final String name = mountPoint.getName();
final Mount mount = new Mount(fileSystem, mountPoint);
final ConcurrentMap<VirtualFile, Map<String, Mount>> mounts = VFS.mounts;
for (; ; ) {
Map<String, Mount> childMountMap = mounts.get(parent);
Map<String, Mount> newMap;
if (childMountMap == null) {
childMountMap = mounts.putIfAbsent(parent, Collections.singletonMap(name, mount));
if (childMountMap == null) {
return mount;
}
}
newMap = new HashMap<String, Mount>(childMountMap);
if (newMap.put(name, mount) != null) {
throw VFSMessages.MESSAGES.fileSystemAlreadyMountedAtMountPoint(mountPoint);
}
if (mounts.replace(parent, childMountMap, newMap)) {
VFSLogger.ROOT_LOGGER.tracef("Mounted filesystem %s on mount point %s", fileSystem, mountPoint);
return mount;
}
}
} | [
"public",
"static",
"Closeable",
"mount",
"(",
"VirtualFile",
"mountPoint",
",",
"FileSystem",
"fileSystem",
")",
"throws",
"IOException",
"{",
"final",
"VirtualFile",
"parent",
"=",
"mountPoint",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"nu... | Mount a filesystem on a mount point in the VFS. The mount point is any valid file name, existent or non-existent.
If a relative path is given, it will be treated as relative to the VFS root.
@param mountPoint the mount point
@param fileSystem the file system to mount
@return a handle which can be used to unmount the filesystem
@throws IOException if an I/O error occurs, such as a filesystem already being mounted at the given mount point | [
"Mount",
"a",
"filesystem",
"on",
"a",
"mount",
"point",
"in",
"the",
"VFS",
".",
"The",
"mount",
"point",
"is",
"any",
"valid",
"file",
"name",
"existent",
"or",
"non",
"-",
"existent",
".",
"If",
"a",
"relative",
"path",
"is",
"given",
"it",
"will",
... | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L98-L124 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.visit | protected static void visit(VirtualFile file, VirtualFileVisitor visitor) throws IOException {
if (file == null) {
throw VFSMessages.MESSAGES.nullArgument("file");
}
visitor.visit(file);
} | java | protected static void visit(VirtualFile file, VirtualFileVisitor visitor) throws IOException {
if (file == null) {
throw VFSMessages.MESSAGES.nullArgument("file");
}
visitor.visit(file);
} | [
"protected",
"static",
"void",
"visit",
"(",
"VirtualFile",
"file",
",",
"VirtualFileVisitor",
"visitor",
")",
"throws",
"IOException",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"VFSMessages",
".",
"MESSAGES",
".",
"nullArgument",
"(",
"\"file\"... | Visit the virtual file system
@param file the file
@param visitor the visitor
@throws IOException for any problem accessing the VFS
@throws IllegalArgumentException if the file or visitor is null | [
"Visit",
"the",
"virtual",
"file",
"system"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L248-L253 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.getSubmounts | static Set<String> getSubmounts(VirtualFile virtualFile) {
final ConcurrentMap<VirtualFile, Map<String, Mount>> mounts = VFS.mounts;
final Map<String, Mount> mountMap = mounts.get(virtualFile);
if (mountMap == null) {
return emptyRemovableSet();
}
return new HashSet<String>(mountMap.keySet());
} | java | static Set<String> getSubmounts(VirtualFile virtualFile) {
final ConcurrentMap<VirtualFile, Map<String, Mount>> mounts = VFS.mounts;
final Map<String, Mount> mountMap = mounts.get(virtualFile);
if (mountMap == null) {
return emptyRemovableSet();
}
return new HashSet<String>(mountMap.keySet());
} | [
"static",
"Set",
"<",
"String",
">",
"getSubmounts",
"(",
"VirtualFile",
"virtualFile",
")",
"{",
"final",
"ConcurrentMap",
"<",
"VirtualFile",
",",
"Map",
"<",
"String",
",",
"Mount",
">",
">",
"mounts",
"=",
"VFS",
".",
"mounts",
";",
"final",
"Map",
"... | Get all immediate submounts for a path.
@param virtualFile the path
@return the collection of present mount (simple) names | [
"Get",
"all",
"immediate",
"submounts",
"for",
"a",
"path",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L282-L289 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.mountReal | public static Closeable mountReal(File realRoot, VirtualFile mountPoint) throws IOException {
return doMount(new RealFileSystem(realRoot), mountPoint);
} | java | public static Closeable mountReal(File realRoot, VirtualFile mountPoint) throws IOException {
return doMount(new RealFileSystem(realRoot), mountPoint);
} | [
"public",
"static",
"Closeable",
"mountReal",
"(",
"File",
"realRoot",
",",
"VirtualFile",
"mountPoint",
")",
"throws",
"IOException",
"{",
"return",
"doMount",
"(",
"new",
"RealFileSystem",
"(",
"realRoot",
")",
",",
"mountPoint",
")",
";",
"}"
] | Create and mount a real file system, returning a single handle which will unmount and close the filesystem when
closed.
@param realRoot the real filesystem root
@param mountPoint the point at which the filesystem should be mounted
@return a handle
@throws IOException if an error occurs | [
"Create",
"and",
"mount",
"a",
"real",
"file",
"system",
"returning",
"a",
"single",
"handle",
"which",
"will",
"unmount",
"and",
"close",
"the",
"filesystem",
"when",
"closed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L380-L382 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.mountTemp | public static Closeable mountTemp(VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException {
boolean ok = false;
final TempDir tempDir = tempFileProvider.createTempDir("tmpfs");
try {
final MountHandle handle = doMount(new RealFileSystem(tempDir.getRoot()), mountPoint, tempDir);
ok = true;
return handle;
} finally {
if (!ok) {
VFSUtils.safeClose(tempDir);
}
}
} | java | public static Closeable mountTemp(VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException {
boolean ok = false;
final TempDir tempDir = tempFileProvider.createTempDir("tmpfs");
try {
final MountHandle handle = doMount(new RealFileSystem(tempDir.getRoot()), mountPoint, tempDir);
ok = true;
return handle;
} finally {
if (!ok) {
VFSUtils.safeClose(tempDir);
}
}
} | [
"public",
"static",
"Closeable",
"mountTemp",
"(",
"VirtualFile",
"mountPoint",
",",
"TempFileProvider",
"tempFileProvider",
")",
"throws",
"IOException",
"{",
"boolean",
"ok",
"=",
"false",
";",
"final",
"TempDir",
"tempDir",
"=",
"tempFileProvider",
".",
"createTe... | Create and mount a temporary file system, returning a single handle which will unmount and close the filesystem
when closed.
@param mountPoint the point at which the filesystem should be mounted
@param tempFileProvider the temporary file provider
@return a handle
@throws IOException if an error occurs | [
"Create",
"and",
"mount",
"a",
"temporary",
"file",
"system",
"returning",
"a",
"single",
"handle",
"which",
"will",
"unmount",
"and",
"close",
"the",
"filesystem",
"when",
"closed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L393-L405 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.mountZipExpanded | public static Closeable mountZipExpanded(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException {
boolean ok = false;
final TempDir tempDir = tempFileProvider.createTempDir(zipFile.getName());
try {
final File rootFile = tempDir.getRoot();
VFSUtils.unzip(zipFile, rootFile);
final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir);
ok = true;
return handle;
} finally {
if (!ok) {
VFSUtils.safeClose(tempDir);
}
}
} | java | public static Closeable mountZipExpanded(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException {
boolean ok = false;
final TempDir tempDir = tempFileProvider.createTempDir(zipFile.getName());
try {
final File rootFile = tempDir.getRoot();
VFSUtils.unzip(zipFile, rootFile);
final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir);
ok = true;
return handle;
} finally {
if (!ok) {
VFSUtils.safeClose(tempDir);
}
}
} | [
"public",
"static",
"Closeable",
"mountZipExpanded",
"(",
"File",
"zipFile",
",",
"VirtualFile",
"mountPoint",
",",
"TempFileProvider",
"tempFileProvider",
")",
"throws",
"IOException",
"{",
"boolean",
"ok",
"=",
"false",
";",
"final",
"TempDir",
"tempDir",
"=",
"... | Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and
close the filesystem when closed.
@param zipFile the zip file to mount
@param mountPoint the point at which the filesystem should be mounted
@param tempFileProvider the temporary file provider
@return a handle
@throws IOException if an error occurs | [
"Create",
"and",
"mount",
"an",
"expanded",
"zip",
"file",
"in",
"a",
"temporary",
"file",
"system",
"returning",
"a",
"single",
"handle",
"which",
"will",
"unmount",
"and",
"close",
"the",
"filesystem",
"when",
"closed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L417-L431 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.mountZipExpanded | public static Closeable mountZipExpanded(InputStream zipData, String zipName, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException {
try {
boolean ok = false;
final TempDir tempDir = tempFileProvider.createTempDir(zipName);
try {
final File zipFile = File.createTempFile(zipName + "-", ".tmp", tempDir.getRoot());
try {
final FileOutputStream os = new FileOutputStream(zipFile);
try {
// allow an error on close to terminate the unzip
VFSUtils.copyStream(zipData, os);
zipData.close();
os.close();
} finally {
VFSUtils.safeClose(zipData);
VFSUtils.safeClose(os);
}
final File rootFile = tempDir.getRoot();
VFSUtils.unzip(zipFile, rootFile);
final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir);
ok = true;
return handle;
} finally {
//noinspection ResultOfMethodCallIgnored
zipFile.delete();
}
} finally {
if (!ok) {
VFSUtils.safeClose(tempDir);
}
}
} finally {
VFSUtils.safeClose(zipData);
}
} | java | public static Closeable mountZipExpanded(InputStream zipData, String zipName, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException {
try {
boolean ok = false;
final TempDir tempDir = tempFileProvider.createTempDir(zipName);
try {
final File zipFile = File.createTempFile(zipName + "-", ".tmp", tempDir.getRoot());
try {
final FileOutputStream os = new FileOutputStream(zipFile);
try {
// allow an error on close to terminate the unzip
VFSUtils.copyStream(zipData, os);
zipData.close();
os.close();
} finally {
VFSUtils.safeClose(zipData);
VFSUtils.safeClose(os);
}
final File rootFile = tempDir.getRoot();
VFSUtils.unzip(zipFile, rootFile);
final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir);
ok = true;
return handle;
} finally {
//noinspection ResultOfMethodCallIgnored
zipFile.delete();
}
} finally {
if (!ok) {
VFSUtils.safeClose(tempDir);
}
}
} finally {
VFSUtils.safeClose(zipData);
}
} | [
"public",
"static",
"Closeable",
"mountZipExpanded",
"(",
"InputStream",
"zipData",
",",
"String",
"zipName",
",",
"VirtualFile",
"mountPoint",
",",
"TempFileProvider",
"tempFileProvider",
")",
"throws",
"IOException",
"{",
"try",
"{",
"boolean",
"ok",
"=",
"false",... | Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and
close the filesystem when closed. The given zip data stream is closed.
@param zipData an input stream containing the zip data
@param zipName the name of the archive
@param mountPoint the point at which the filesystem should be mounted
@param tempFileProvider the temporary file provider
@return a handle
@throws IOException if an error occurs | [
"Create",
"and",
"mount",
"an",
"expanded",
"zip",
"file",
"in",
"a",
"temporary",
"file",
"system",
"returning",
"a",
"single",
"handle",
"which",
"will",
"unmount",
"and",
"close",
"the",
"filesystem",
"when",
"closed",
".",
"The",
"given",
"zip",
"data",
... | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L444-L478 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFS.java | VFS.mountAssembly | public static Closeable mountAssembly(VirtualFileAssembly assembly, VirtualFile mountPoint) throws IOException {
return doMount(new AssemblyFileSystem(assembly), mountPoint);
} | java | public static Closeable mountAssembly(VirtualFileAssembly assembly, VirtualFile mountPoint) throws IOException {
return doMount(new AssemblyFileSystem(assembly), mountPoint);
} | [
"public",
"static",
"Closeable",
"mountAssembly",
"(",
"VirtualFileAssembly",
"assembly",
",",
"VirtualFile",
"mountPoint",
")",
"throws",
"IOException",
"{",
"return",
"doMount",
"(",
"new",
"AssemblyFileSystem",
"(",
"assembly",
")",
",",
"mountPoint",
")",
";",
... | Create and mount an assembly file system, returning a single handle which will unmount and
close the filesystem when closed.
@param assembly an {@link VirtualFileAssembly} to mount in the VFS
@param mountPoint the point at which the filesystem should be mounted
@return a handle
@throws IOException if an error occurs | [
"Create",
"and",
"mount",
"an",
"assembly",
"file",
"system",
"returning",
"a",
"single",
"handle",
"which",
"will",
"unmount",
"and",
"close",
"the",
"filesystem",
"when",
"closed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFS.java#L503-L505 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java | VirtualJarFileInputStream.closeCurrent | private void closeCurrent() throws IOException {
virtualJarInputStream.closeEntry();
currentEntry.crc = crc.getValue();
crc.reset();
} | java | private void closeCurrent() throws IOException {
virtualJarInputStream.closeEntry();
currentEntry.crc = crc.getValue();
crc.reset();
} | [
"private",
"void",
"closeCurrent",
"(",
")",
"throws",
"IOException",
"{",
"virtualJarInputStream",
".",
"closeEntry",
"(",
")",
";",
"currentEntry",
".",
"crc",
"=",
"crc",
".",
"getValue",
"(",
")",
";",
"crc",
".",
"reset",
"(",
")",
";",
"}"
] | Close the current entry, and calculate the crc value.
@throws IOException if any problems occur | [
"Close",
"the",
"current",
"entry",
"and",
"calculate",
"the",
"crc",
"value",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java#L108-L112 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java | VirtualJarFileInputStream.bufferLocalFileHeader | private boolean bufferLocalFileHeader() throws IOException {
buffer.reset();
JarEntry jarEntry = virtualJarInputStream.getNextJarEntry();
if (jarEntry == null) { return false; }
currentEntry = new ProcessedEntry(jarEntry, totalRead);
processedEntries.add(currentEntry);
bufferInt(ZipEntry.LOCSIG); // Local file header signature
bufferShort(10); // Extraction version
bufferShort(0); // Flags
bufferShort(ZipEntry.STORED); // Compression type
bufferInt(jarEntry.getTime()); // Entry time
bufferInt(0); // CRC
bufferInt(0); // Compressed size
bufferInt(0); // Uncompressed size
byte[] nameBytes = jarEntry.getName().getBytes("UTF8");
bufferShort(nameBytes.length); // Entry name length
bufferShort(0); // Extra length
buffer(nameBytes);
return true;
} | java | private boolean bufferLocalFileHeader() throws IOException {
buffer.reset();
JarEntry jarEntry = virtualJarInputStream.getNextJarEntry();
if (jarEntry == null) { return false; }
currentEntry = new ProcessedEntry(jarEntry, totalRead);
processedEntries.add(currentEntry);
bufferInt(ZipEntry.LOCSIG); // Local file header signature
bufferShort(10); // Extraction version
bufferShort(0); // Flags
bufferShort(ZipEntry.STORED); // Compression type
bufferInt(jarEntry.getTime()); // Entry time
bufferInt(0); // CRC
bufferInt(0); // Compressed size
bufferInt(0); // Uncompressed size
byte[] nameBytes = jarEntry.getName().getBytes("UTF8");
bufferShort(nameBytes.length); // Entry name length
bufferShort(0); // Extra length
buffer(nameBytes);
return true;
} | [
"private",
"boolean",
"bufferLocalFileHeader",
"(",
")",
"throws",
"IOException",
"{",
"buffer",
".",
"reset",
"(",
")",
";",
"JarEntry",
"jarEntry",
"=",
"virtualJarInputStream",
".",
"getNextJarEntry",
"(",
")",
";",
"if",
"(",
"jarEntry",
"==",
"null",
")",... | Buffer the content of the local file header for a single entry.
@return true if the next local file header was buffered
@throws IOException if any problems occur | [
"Buffer",
"the",
"content",
"of",
"the",
"local",
"file",
"header",
"for",
"a",
"single",
"entry",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java#L120-L143 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java | VirtualJarFileInputStream.bufferNextCentralFileHeader | private boolean bufferNextCentralFileHeader() throws IOException {
buffer.reset();
if (currentCentralEntryIdx == processedEntries.size()) { return false; }
ProcessedEntry entry = processedEntries.get(currentCentralEntryIdx++);
JarEntry jarEntry = entry.jarEntry;
bufferInt(ZipEntry.CENSIG); // Central file header signature
bufferShort(10); // Version made by
bufferShort(10); // Extraction version
bufferShort(0); // Flags
bufferShort(ZipEntry.STORED); // Compression type
bufferInt(jarEntry.getTime()); // Entry time
bufferInt(entry.crc); // CRC
bufferInt(jarEntry.getSize()); // Compressed size
bufferInt(jarEntry.getSize()); // Uncompressed size
byte[] nameBytes = jarEntry.getName().getBytes("UTF8");
bufferShort(nameBytes.length); // Entry name length
bufferShort(0); // Extra field length
bufferShort(0); // File comment length
bufferShort(0); // Disk number start
bufferShort(0); // Internal file attributes
bufferInt(0); // External file attributes
bufferInt(entry.offset); // Relative offset of local header
buffer(nameBytes);
return true;
} | java | private boolean bufferNextCentralFileHeader() throws IOException {
buffer.reset();
if (currentCentralEntryIdx == processedEntries.size()) { return false; }
ProcessedEntry entry = processedEntries.get(currentCentralEntryIdx++);
JarEntry jarEntry = entry.jarEntry;
bufferInt(ZipEntry.CENSIG); // Central file header signature
bufferShort(10); // Version made by
bufferShort(10); // Extraction version
bufferShort(0); // Flags
bufferShort(ZipEntry.STORED); // Compression type
bufferInt(jarEntry.getTime()); // Entry time
bufferInt(entry.crc); // CRC
bufferInt(jarEntry.getSize()); // Compressed size
bufferInt(jarEntry.getSize()); // Uncompressed size
byte[] nameBytes = jarEntry.getName().getBytes("UTF8");
bufferShort(nameBytes.length); // Entry name length
bufferShort(0); // Extra field length
bufferShort(0); // File comment length
bufferShort(0); // Disk number start
bufferShort(0); // Internal file attributes
bufferInt(0); // External file attributes
bufferInt(entry.offset); // Relative offset of local header
buffer(nameBytes);
return true;
} | [
"private",
"boolean",
"bufferNextCentralFileHeader",
"(",
")",
"throws",
"IOException",
"{",
"buffer",
".",
"reset",
"(",
")",
";",
"if",
"(",
"currentCentralEntryIdx",
"==",
"processedEntries",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"... | Buffer the central file header record for a single entry.
@return true if the next central file header was buffered
@throws IOException if any problems occur | [
"Buffer",
"the",
"central",
"file",
"header",
"record",
"for",
"a",
"single",
"entry",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java#L151-L178 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java | VirtualJarFileInputStream.bufferCentralDirectoryEnd | private void bufferCentralDirectoryEnd() throws IOException {
buffer.reset();
long lengthOfCentral = totalRead - centralOffset;
int count = processedEntries.size();
bufferInt(JarEntry.ENDSIG); // End of central directory signature
bufferShort(0); // Number of this disk
bufferShort(0); // Start of central directory disk
bufferShort(count); // Number of processedEntries on disk
bufferShort(count); // Total number of processedEntries
bufferInt(lengthOfCentral); // Size of central directory
bufferInt(centralOffset); // Offset of start of central directory
bufferShort(0); // Comment Length
} | java | private void bufferCentralDirectoryEnd() throws IOException {
buffer.reset();
long lengthOfCentral = totalRead - centralOffset;
int count = processedEntries.size();
bufferInt(JarEntry.ENDSIG); // End of central directory signature
bufferShort(0); // Number of this disk
bufferShort(0); // Start of central directory disk
bufferShort(count); // Number of processedEntries on disk
bufferShort(count); // Total number of processedEntries
bufferInt(lengthOfCentral); // Size of central directory
bufferInt(centralOffset); // Offset of start of central directory
bufferShort(0); // Comment Length
} | [
"private",
"void",
"bufferCentralDirectoryEnd",
"(",
")",
"throws",
"IOException",
"{",
"buffer",
".",
"reset",
"(",
")",
";",
"long",
"lengthOfCentral",
"=",
"totalRead",
"-",
"centralOffset",
";",
"int",
"count",
"=",
"processedEntries",
".",
"size",
"(",
")... | Write the central file header records. This is repeated
until all entries have been added to the central file header.
@throws IOException if any problem occur | [
"Write",
"the",
"central",
"file",
"header",
"records",
".",
"This",
"is",
"repeated",
"until",
"all",
"entries",
"have",
"been",
"added",
"to",
"the",
"central",
"file",
"header",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java#L186-L199 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java | VirtualJarFileInputStream.bufferInt | private void bufferInt(long i) {
buffer((byte) (i & 0xff));
buffer((byte) ((i >>> 8) & 0xff));
buffer((byte) ((i >>> 16) & 0xff));
buffer((byte) ((i >>> 24) & 0xff));
} | java | private void bufferInt(long i) {
buffer((byte) (i & 0xff));
buffer((byte) ((i >>> 8) & 0xff));
buffer((byte) ((i >>> 16) & 0xff));
buffer((byte) ((i >>> 24) & 0xff));
} | [
"private",
"void",
"bufferInt",
"(",
"long",
"i",
")",
"{",
"buffer",
"(",
"(",
"byte",
")",
"(",
"i",
"&",
"0xff",
")",
")",
";",
"buffer",
"(",
"(",
"byte",
")",
"(",
"(",
"i",
">>>",
"8",
")",
"&",
"0xff",
")",
")",
";",
"buffer",
"(",
"... | Buffer a 32-bit integer in little-endian
@param i A long representation of a 32 bit int | [
"Buffer",
"a",
"32",
"-",
"bit",
"integer",
"in",
"little",
"-",
"endian"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java#L206-L211 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java | VirtualJarFileInputStream.buffer | private void buffer(byte b) {
if (buffer.hasCapacity()) {
buffer.put(b);
} else {
throw VFSMessages.MESSAGES.bufferDoesntHaveEnoughCapacity();
}
} | java | private void buffer(byte b) {
if (buffer.hasCapacity()) {
buffer.put(b);
} else {
throw VFSMessages.MESSAGES.bufferDoesntHaveEnoughCapacity();
}
} | [
"private",
"void",
"buffer",
"(",
"byte",
"b",
")",
"{",
"if",
"(",
"buffer",
".",
"hasCapacity",
"(",
")",
")",
"{",
"buffer",
".",
"put",
"(",
"b",
")",
";",
"}",
"else",
"{",
"throw",
"VFSMessages",
".",
"MESSAGES",
".",
"bufferDoesntHaveEnoughCapac... | Buffer a single byte
@param b The byte | [
"Buffer",
"a",
"single",
"byte"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarFileInputStream.java#L228-L234 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.getPathName | String getPathName(boolean url) {
if (pathName == null || pathName.isEmpty()) {
VirtualFile[] path = getParentFiles();
final StringBuilder builder = new StringBuilder(path.length * 30 + 50);
for (int i = path.length - 1; i > -1; i--) {
final VirtualFile parent = path[i].parent;
if (parent == null) {
builder.append(path[i].name);
} else {
if (parent.parent != null) {
builder.append('/');
}
builder.append(path[i].name);
}
}
pathName = builder.toString();
}
// Perhaps this should be cached to avoid the fs stat call?
return (url && isDirectory()) ? pathName.concat("/") : pathName;
} | java | String getPathName(boolean url) {
if (pathName == null || pathName.isEmpty()) {
VirtualFile[] path = getParentFiles();
final StringBuilder builder = new StringBuilder(path.length * 30 + 50);
for (int i = path.length - 1; i > -1; i--) {
final VirtualFile parent = path[i].parent;
if (parent == null) {
builder.append(path[i].name);
} else {
if (parent.parent != null) {
builder.append('/');
}
builder.append(path[i].name);
}
}
pathName = builder.toString();
}
// Perhaps this should be cached to avoid the fs stat call?
return (url && isDirectory()) ? pathName.concat("/") : pathName;
} | [
"String",
"getPathName",
"(",
"boolean",
"url",
")",
"{",
"if",
"(",
"pathName",
"==",
"null",
"||",
"pathName",
".",
"isEmpty",
"(",
")",
")",
"{",
"VirtualFile",
"[",
"]",
"path",
"=",
"getParentFiles",
"(",
")",
";",
"final",
"StringBuilder",
"builder... | Get the absolute VFS full path name. If this is a URL then directory entries will have a trailing slash.
@param url whether or not this path is being used for a URL
@return the VFS full path name | [
"Get",
"the",
"absolute",
"VFS",
"full",
"path",
"name",
".",
"If",
"this",
"is",
"a",
"URL",
"then",
"directory",
"entries",
"will",
"have",
"a",
"trailing",
"slash",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L136-L155 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.getLastModified | public long getLastModified() {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new VirtualFilePermission(getPathName(), "read"));
}
final VFS.Mount mount = VFS.getMount(this);
if (sm != null) {
return AccessController.doPrivileged(
(PrivilegedAction<Long>) () -> mount.getFileSystem().getLastModified(mount.getMountPoint(), this)
);
}
return mount.getFileSystem().getLastModified(mount.getMountPoint(), this);
} | java | public long getLastModified() {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new VirtualFilePermission(getPathName(), "read"));
}
final VFS.Mount mount = VFS.getMount(this);
if (sm != null) {
return AccessController.doPrivileged(
(PrivilegedAction<Long>) () -> mount.getFileSystem().getLastModified(mount.getMountPoint(), this)
);
}
return mount.getFileSystem().getLastModified(mount.getMountPoint(), this);
} | [
"public",
"long",
"getLastModified",
"(",
")",
"{",
"final",
"SecurityManager",
"sm",
"=",
"System",
".",
"getSecurityManager",
"(",
")",
";",
"if",
"(",
"sm",
"!=",
"null",
")",
"{",
"sm",
".",
"checkPermission",
"(",
"new",
"VirtualFilePermission",
"(",
... | When the file was last modified
@return the last modified time | [
"When",
"the",
"file",
"was",
"last",
"modified"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L162-L174 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.openStream | public InputStream openStream() throws IOException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new VirtualFilePermission(getPathName(), "read"));
}
if (isDirectory()) {
return new VirtualJarInputStream(this);
}
final VFS.Mount mount = VFS.getMount(this);
if (sm != null) {
return doIoPrivileged(() -> mount.getFileSystem().openInputStream(mount.getMountPoint(), this));
}
return mount.getFileSystem().openInputStream(mount.getMountPoint(), this);
} | java | public InputStream openStream() throws IOException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new VirtualFilePermission(getPathName(), "read"));
}
if (isDirectory()) {
return new VirtualJarInputStream(this);
}
final VFS.Mount mount = VFS.getMount(this);
if (sm != null) {
return doIoPrivileged(() -> mount.getFileSystem().openInputStream(mount.getMountPoint(), this));
}
return mount.getFileSystem().openInputStream(mount.getMountPoint(), this);
} | [
"public",
"InputStream",
"openStream",
"(",
")",
"throws",
"IOException",
"{",
"final",
"SecurityManager",
"sm",
"=",
"System",
".",
"getSecurityManager",
"(",
")",
";",
"if",
"(",
"sm",
"!=",
"null",
")",
"{",
"sm",
".",
"checkPermission",
"(",
"new",
"Vi... | Access the file contents.
@return an InputStream for the file contents.
@throws IOException for any error accessing the file system | [
"Access",
"the",
"file",
"contents",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L280-L293 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.getPhysicalFile | public File getPhysicalFile() throws IOException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new VirtualFilePermission(getPathName(), "getfile"));
}
final VFS.Mount mount = VFS.getMount(this);
if (sm != null) {
return doIoPrivileged(() -> mount.getFileSystem().getFile(mount.getMountPoint(), this));
}
return mount.getFileSystem().getFile(mount.getMountPoint(), this);
} | java | public File getPhysicalFile() throws IOException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new VirtualFilePermission(getPathName(), "getfile"));
}
final VFS.Mount mount = VFS.getMount(this);
if (sm != null) {
return doIoPrivileged(() -> mount.getFileSystem().getFile(mount.getMountPoint(), this));
}
return mount.getFileSystem().getFile(mount.getMountPoint(), this);
} | [
"public",
"File",
"getPhysicalFile",
"(",
")",
"throws",
"IOException",
"{",
"final",
"SecurityManager",
"sm",
"=",
"System",
".",
"getSecurityManager",
"(",
")",
";",
"if",
"(",
"sm",
"!=",
"null",
")",
"{",
"sm",
".",
"checkPermission",
"(",
"new",
"Virt... | Get a physical file for this virtual file. Depending on the underlying file system type, this may simply return
an already-existing file; it may create a copy of a file; or it may reuse a preexisting copy of the file.
Furthermore, the returned file may or may not have any relationship to other files from the same or any other
virtual directory.
@return the physical file
@throws IOException if an I/O error occurs while producing the physical file | [
"Get",
"a",
"physical",
"file",
"for",
"this",
"virtual",
"file",
".",
"Depending",
"on",
"the",
"underlying",
"file",
"system",
"type",
"this",
"may",
"simply",
"return",
"an",
"already",
"-",
"existing",
"file",
";",
"it",
"may",
"create",
"a",
"copy",
... | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L323-L333 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.getChildren | public List<VirtualFile> getChildren() {
// isDirectory does the read security check
if (!isDirectory()) { return Collections.emptyList(); }
final VFS.Mount mount = VFS.getMount(this);
final Set<String> submounts = VFS.getSubmounts(this);
final List<String> names = mount.getFileSystem().getDirectoryEntries(mount.getMountPoint(), this);
final List<VirtualFile> virtualFiles = new ArrayList<VirtualFile>(names.size() + submounts.size());
for (String name : names) {
final VirtualFile child = new VirtualFile(name, this);
virtualFiles.add(child);
submounts.remove(name);
}
for (String name : submounts) {
final VirtualFile child = new VirtualFile(name, this);
virtualFiles.add(child);
}
return virtualFiles;
} | java | public List<VirtualFile> getChildren() {
// isDirectory does the read security check
if (!isDirectory()) { return Collections.emptyList(); }
final VFS.Mount mount = VFS.getMount(this);
final Set<String> submounts = VFS.getSubmounts(this);
final List<String> names = mount.getFileSystem().getDirectoryEntries(mount.getMountPoint(), this);
final List<VirtualFile> virtualFiles = new ArrayList<VirtualFile>(names.size() + submounts.size());
for (String name : names) {
final VirtualFile child = new VirtualFile(name, this);
virtualFiles.add(child);
submounts.remove(name);
}
for (String name : submounts) {
final VirtualFile child = new VirtualFile(name, this);
virtualFiles.add(child);
}
return virtualFiles;
} | [
"public",
"List",
"<",
"VirtualFile",
">",
"getChildren",
"(",
")",
"{",
"// isDirectory does the read security check",
"if",
"(",
"!",
"isDirectory",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"final",
"VFS",
".",
"Mo... | Get the children. This is the combined list of real children within this directory, as well as virtual children
created by submounts.
@return the children | [
"Get",
"the",
"children",
".",
"This",
"is",
"the",
"combined",
"list",
"of",
"real",
"children",
"within",
"this",
"directory",
"as",
"well",
"as",
"virtual",
"children",
"created",
"by",
"submounts",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L395-L412 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.getChildren | public List<VirtualFile> getChildren(VirtualFileFilter filter) throws IOException {
// isDirectory does the read security check
if (!isDirectory()) { return Collections.emptyList(); }
if (filter == null) { filter = MatchAllVirtualFileFilter.INSTANCE; }
FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, null);
visit(visitor);
return visitor.getMatched();
} | java | public List<VirtualFile> getChildren(VirtualFileFilter filter) throws IOException {
// isDirectory does the read security check
if (!isDirectory()) { return Collections.emptyList(); }
if (filter == null) { filter = MatchAllVirtualFileFilter.INSTANCE; }
FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, null);
visit(visitor);
return visitor.getMatched();
} | [
"public",
"List",
"<",
"VirtualFile",
">",
"getChildren",
"(",
"VirtualFileFilter",
"filter",
")",
"throws",
"IOException",
"{",
"// isDirectory does the read security check",
"if",
"(",
"!",
"isDirectory",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyLis... | Get the children
@param filter to filter the children
@return the children
@throws IOException for any problem accessing the virtual file system
@throws IllegalStateException if the file is closed or it is a leaf node | [
"Get",
"the",
"children"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L422-L429 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualFile.java | VirtualFile.getChild | public VirtualFile getChild(String path) {
if (path == null) {
throw VFSMessages.MESSAGES.nullArgument("path");
}
final List<String> pathParts = PathTokenizer.getTokens(path);
VirtualFile current = this;
for (String part : pathParts) {
if (PathTokenizer.isReverseToken(part)) {
final VirtualFile parent = current.parent;
current = parent == null ? current : parent;
} else if (PathTokenizer.isCurrentToken(part) == false) {
current = new VirtualFile(part, current);
}
}
return current;
} | java | public VirtualFile getChild(String path) {
if (path == null) {
throw VFSMessages.MESSAGES.nullArgument("path");
}
final List<String> pathParts = PathTokenizer.getTokens(path);
VirtualFile current = this;
for (String part : pathParts) {
if (PathTokenizer.isReverseToken(part)) {
final VirtualFile parent = current.parent;
current = parent == null ? current : parent;
} else if (PathTokenizer.isCurrentToken(part) == false) {
current = new VirtualFile(part, current);
}
}
return current;
} | [
"public",
"VirtualFile",
"getChild",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"VFSMessages",
".",
"MESSAGES",
".",
"nullArgument",
"(",
"\"path\"",
")",
";",
"}",
"final",
"List",
"<",
"String",
">",
"pathParts... | Get a child virtual file. The child may or may not exist in the virtual filesystem.
@param path the path
@return the child
@throws IllegalArgumentException if the path is null | [
"Get",
"a",
"child",
"virtual",
"file",
".",
"The",
"child",
"may",
"or",
"may",
"not",
"exist",
"in",
"the",
"virtual",
"filesystem",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualFile.java#L494-L509 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/PathTokenizer.java | PathTokenizer.getTokens | public static List<String> getTokens(String path) {
if (path == null) {
throw MESSAGES.nullArgument("path");
}
List<String> list = new ArrayList<String>();
getTokens(list, path);
return list;
} | java | public static List<String> getTokens(String path) {
if (path == null) {
throw MESSAGES.nullArgument("path");
}
List<String> list = new ArrayList<String>();
getTokens(list, path);
return list;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getTokens",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"path\"",
")",
";",
"}",
"List",
"<",
"String",
">",
"list",
"="... | Get the tokens that comprise this path.
@param path the path
@return the tokens or null if the path is empty
@throws IllegalArgumentException if the path is null | [
"Get",
"the",
"tokens",
"that",
"comprise",
"this",
"path",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/PathTokenizer.java#L93-L100 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/PathTokenizer.java | PathTokenizer.getTokens | public static void getTokens(List<String> list, String path) {
int start = -1, length = path.length(), state = STATE_INITIAL;
char ch;
for (int index = 0; index < length; index++) {
ch = path.charAt(index);
switch (ch) {
case '/':
case '\\': {
switch (state) {
case STATE_INITIAL: {
// skip extra leading /
continue;
}
case STATE_MAYBE_CURRENT_PATH: {
// it's '.'
list.add(CURRENT_PATH);
state = STATE_INITIAL;
continue;
}
case STATE_MAYBE_REVERSE_PATH: {
// it's '..'
list.add(REVERSE_PATH);
state = STATE_INITIAL;
continue;
}
case STATE_NORMAL: {
// it's just a normal path segment
list.add(path.substring(start, index));
state = STATE_INITIAL;
continue;
}
}
continue;
}
case '.': {
switch (state) {
case STATE_INITIAL: {
// . is the first char; might be a special token
state = STATE_MAYBE_CURRENT_PATH;
start = index;
continue;
}
case STATE_MAYBE_CURRENT_PATH: {
// the second . in a row...
state = STATE_MAYBE_REVERSE_PATH;
continue;
}
case STATE_MAYBE_REVERSE_PATH: {
// the third . in a row, guess it's just a weird path name
state = STATE_NORMAL;
continue;
}
}
continue;
}
default: {
switch (state) {
case STATE_INITIAL: {
state = STATE_NORMAL;
start = index;
continue;
}
case STATE_MAYBE_CURRENT_PATH:
case STATE_MAYBE_REVERSE_PATH: {
state = STATE_NORMAL;
}
}
}
}
}
// handle the last token
switch (state) {
case STATE_INITIAL: {
// trailing /
break;
}
case STATE_MAYBE_CURRENT_PATH: {
list.add(CURRENT_PATH);
break;
}
case STATE_MAYBE_REVERSE_PATH: {
list.add(REVERSE_PATH);
break;
}
case STATE_NORMAL: {
list.add(path.substring(start));
break;
}
}
return;
} | java | public static void getTokens(List<String> list, String path) {
int start = -1, length = path.length(), state = STATE_INITIAL;
char ch;
for (int index = 0; index < length; index++) {
ch = path.charAt(index);
switch (ch) {
case '/':
case '\\': {
switch (state) {
case STATE_INITIAL: {
// skip extra leading /
continue;
}
case STATE_MAYBE_CURRENT_PATH: {
// it's '.'
list.add(CURRENT_PATH);
state = STATE_INITIAL;
continue;
}
case STATE_MAYBE_REVERSE_PATH: {
// it's '..'
list.add(REVERSE_PATH);
state = STATE_INITIAL;
continue;
}
case STATE_NORMAL: {
// it's just a normal path segment
list.add(path.substring(start, index));
state = STATE_INITIAL;
continue;
}
}
continue;
}
case '.': {
switch (state) {
case STATE_INITIAL: {
// . is the first char; might be a special token
state = STATE_MAYBE_CURRENT_PATH;
start = index;
continue;
}
case STATE_MAYBE_CURRENT_PATH: {
// the second . in a row...
state = STATE_MAYBE_REVERSE_PATH;
continue;
}
case STATE_MAYBE_REVERSE_PATH: {
// the third . in a row, guess it's just a weird path name
state = STATE_NORMAL;
continue;
}
}
continue;
}
default: {
switch (state) {
case STATE_INITIAL: {
state = STATE_NORMAL;
start = index;
continue;
}
case STATE_MAYBE_CURRENT_PATH:
case STATE_MAYBE_REVERSE_PATH: {
state = STATE_NORMAL;
}
}
}
}
}
// handle the last token
switch (state) {
case STATE_INITIAL: {
// trailing /
break;
}
case STATE_MAYBE_CURRENT_PATH: {
list.add(CURRENT_PATH);
break;
}
case STATE_MAYBE_REVERSE_PATH: {
list.add(REVERSE_PATH);
break;
}
case STATE_NORMAL: {
list.add(path.substring(start));
break;
}
}
return;
} | [
"public",
"static",
"void",
"getTokens",
"(",
"List",
"<",
"String",
">",
"list",
",",
"String",
"path",
")",
"{",
"int",
"start",
"=",
"-",
"1",
",",
"length",
"=",
"path",
".",
"length",
"(",
")",
",",
"state",
"=",
"STATE_INITIAL",
";",
"char",
... | Get the tokens that comprise this path and append them to the list.
@param path the path
@return the tokens or null if the path is empty
@throws IllegalArgumentException if the path is null | [
"Get",
"the",
"tokens",
"that",
"comprise",
"this",
"path",
"and",
"append",
"them",
"to",
"the",
"list",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/PathTokenizer.java#L109-L199 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/PathTokenizer.java | PathTokenizer.applySpecialPaths | public static String applySpecialPaths(String path) throws IllegalArgumentException {
List<String> tokens = getTokens(path);
if (tokens == null) { return null; }
int i = 0;
for (int j = 0; j < tokens.size(); j++) {
String token = tokens.get(j);
if (isCurrentToken(token)) { continue; } else if (isReverseToken(token)) { i--; } else { tokens.set(i++, token); }
if (i < 0) {
throw VFSMessages.MESSAGES.onRootPath();
}
}
return getRemainingPath(tokens, 0, i);
} | java | public static String applySpecialPaths(String path) throws IllegalArgumentException {
List<String> tokens = getTokens(path);
if (tokens == null) { return null; }
int i = 0;
for (int j = 0; j < tokens.size(); j++) {
String token = tokens.get(j);
if (isCurrentToken(token)) { continue; } else if (isReverseToken(token)) { i--; } else { tokens.set(i++, token); }
if (i < 0) {
throw VFSMessages.MESSAGES.onRootPath();
}
}
return getRemainingPath(tokens, 0, i);
} | [
"public",
"static",
"String",
"applySpecialPaths",
"(",
"String",
"path",
")",
"throws",
"IllegalArgumentException",
"{",
"List",
"<",
"String",
">",
"tokens",
"=",
"getTokens",
"(",
"path",
")",
";",
"if",
"(",
"tokens",
"==",
"null",
")",
"{",
"return",
... | Apply any . or .. paths in the path param.
@param path the path
@return simple path, containing no . or .. paths | [
"Apply",
"any",
".",
"or",
"..",
"paths",
"in",
"the",
"path",
"param",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/PathTokenizer.java#L222-L234 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/PathTokenizer.java | PathTokenizer.applySpecialPaths | public static List<String> applySpecialPaths(List<String> pathTokens) throws IllegalArgumentException {
final ArrayList<String> newTokens = new ArrayList<String>();
for (String pathToken : pathTokens) {
if (isCurrentToken(pathToken)) { continue; } else if (isReverseToken(pathToken)) {
final int size = newTokens.size();
if (size == 0) {
throw VFSMessages.MESSAGES.onRootPath();
}
newTokens.remove(size - 1);
} else { newTokens.add(pathToken); }
}
return newTokens;
} | java | public static List<String> applySpecialPaths(List<String> pathTokens) throws IllegalArgumentException {
final ArrayList<String> newTokens = new ArrayList<String>();
for (String pathToken : pathTokens) {
if (isCurrentToken(pathToken)) { continue; } else if (isReverseToken(pathToken)) {
final int size = newTokens.size();
if (size == 0) {
throw VFSMessages.MESSAGES.onRootPath();
}
newTokens.remove(size - 1);
} else { newTokens.add(pathToken); }
}
return newTokens;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"applySpecialPaths",
"(",
"List",
"<",
"String",
">",
"pathTokens",
")",
"throws",
"IllegalArgumentException",
"{",
"final",
"ArrayList",
"<",
"String",
">",
"newTokens",
"=",
"new",
"ArrayList",
"<",
"String",
"... | Apply any . or .. paths in the pathTokens parameter, returning the minimal token list.
@param pathTokens the path tokens
@return the simple path tokens
@throws IllegalArgumentException if reverse path goes over the top path | [
"Apply",
"any",
".",
"or",
"..",
"paths",
"in",
"the",
"pathTokens",
"parameter",
"returning",
"the",
"minimal",
"token",
"list",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/PathTokenizer.java#L243-L255 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.getPathsString | public static String getPathsString(Collection<VirtualFile> paths) {
if (paths == null) {
throw MESSAGES.nullArgument("paths");
}
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (VirtualFile path : paths) {
if (path == null) { throw new IllegalArgumentException("Null path in " + paths); }
if (first == false) {
buffer.append(':');
} else {
first = false;
}
buffer.append(path.getPathName());
}
if (first == true) {
buffer.append("<empty>");
}
return buffer.toString();
} | java | public static String getPathsString(Collection<VirtualFile> paths) {
if (paths == null) {
throw MESSAGES.nullArgument("paths");
}
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (VirtualFile path : paths) {
if (path == null) { throw new IllegalArgumentException("Null path in " + paths); }
if (first == false) {
buffer.append(':');
} else {
first = false;
}
buffer.append(path.getPathName());
}
if (first == true) {
buffer.append("<empty>");
}
return buffer.toString();
} | [
"public",
"static",
"String",
"getPathsString",
"(",
"Collection",
"<",
"VirtualFile",
">",
"paths",
")",
"{",
"if",
"(",
"paths",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"paths\"",
")",
";",
"}",
"StringBuilder",
"buffer",
... | Get the paths string for a collection of virtual files
@param paths the paths
@return the string
@throws IllegalArgumentException for null paths | [
"Get",
"the",
"paths",
"string",
"for",
"a",
"collection",
"of",
"virtual",
"files"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L129-L148 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.addManifestLocations | public static void addManifestLocations(VirtualFile file, List<VirtualFile> paths) throws IOException {
if (file == null) {
throw MESSAGES.nullArgument("file");
}
if (paths == null) {
throw MESSAGES.nullArgument("paths");
}
boolean trace = VFSLogger.ROOT_LOGGER.isTraceEnabled();
Manifest manifest = getManifest(file);
if (manifest == null) { return; }
Attributes mainAttributes = manifest.getMainAttributes();
String classPath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
if (classPath == null) {
if (trace) {
VFSLogger.ROOT_LOGGER.tracef("Manifest has no Class-Path for %s", file.getPathName());
}
return;
}
VirtualFile parent = file.getParent();
if (parent == null) {
VFSLogger.ROOT_LOGGER.debugf("%s has no parent.", file);
return;
}
if (trace) {
VFSLogger.ROOT_LOGGER.tracef("Parsing Class-Path: %s for %s parent=%s", classPath, file.getName(), parent.getName());
}
StringTokenizer tokenizer = new StringTokenizer(classPath);
while (tokenizer.hasMoreTokens()) {
String path = tokenizer.nextToken();
try {
VirtualFile vf = parent.getChild(path);
if (vf.exists()) {
if (paths.contains(vf) == false) {
paths.add(vf);
// Recursively process the jar
Automounter.mount(file, vf);
addManifestLocations(vf, paths);
} else if (trace) {
VFSLogger.ROOT_LOGGER.tracef("%s from manifest is already in the classpath %s", vf.getName(), paths);
}
} else if (trace) {
VFSLogger.ROOT_LOGGER.trace("Unable to find " + path + " from " + parent.getName());
}
} catch (IOException e) {
VFSLogger.ROOT_LOGGER.debugf("Manifest Class-Path entry %s ignored for %s reason= %s", path, file.getPathName(), e);
}
}
} | java | public static void addManifestLocations(VirtualFile file, List<VirtualFile> paths) throws IOException {
if (file == null) {
throw MESSAGES.nullArgument("file");
}
if (paths == null) {
throw MESSAGES.nullArgument("paths");
}
boolean trace = VFSLogger.ROOT_LOGGER.isTraceEnabled();
Manifest manifest = getManifest(file);
if (manifest == null) { return; }
Attributes mainAttributes = manifest.getMainAttributes();
String classPath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
if (classPath == null) {
if (trace) {
VFSLogger.ROOT_LOGGER.tracef("Manifest has no Class-Path for %s", file.getPathName());
}
return;
}
VirtualFile parent = file.getParent();
if (parent == null) {
VFSLogger.ROOT_LOGGER.debugf("%s has no parent.", file);
return;
}
if (trace) {
VFSLogger.ROOT_LOGGER.tracef("Parsing Class-Path: %s for %s parent=%s", classPath, file.getName(), parent.getName());
}
StringTokenizer tokenizer = new StringTokenizer(classPath);
while (tokenizer.hasMoreTokens()) {
String path = tokenizer.nextToken();
try {
VirtualFile vf = parent.getChild(path);
if (vf.exists()) {
if (paths.contains(vf) == false) {
paths.add(vf);
// Recursively process the jar
Automounter.mount(file, vf);
addManifestLocations(vf, paths);
} else if (trace) {
VFSLogger.ROOT_LOGGER.tracef("%s from manifest is already in the classpath %s", vf.getName(), paths);
}
} else if (trace) {
VFSLogger.ROOT_LOGGER.trace("Unable to find " + path + " from " + parent.getName());
}
} catch (IOException e) {
VFSLogger.ROOT_LOGGER.debugf("Manifest Class-Path entry %s ignored for %s reason= %s", path, file.getPathName(), e);
}
}
} | [
"public",
"static",
"void",
"addManifestLocations",
"(",
"VirtualFile",
"file",
",",
"List",
"<",
"VirtualFile",
">",
"paths",
")",
"throws",
"IOException",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"fil... | Add manifest paths
@param file the file
@param paths the paths to add to
@throws IOException if there is an error reading the manifest or the virtual file is closed
@throws IllegalStateException if the file has no parent
@throws IllegalArgumentException for a null file or paths | [
"Add",
"manifest",
"paths"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L159-L206 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.getManifest | public static Manifest getManifest(VirtualFile archive) throws IOException {
if (archive == null) {
throw MESSAGES.nullArgument("archive");
}
VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME);
if (manifest == null || !manifest.exists()) {
if (VFSLogger.ROOT_LOGGER.isTraceEnabled()) {
VFSLogger.ROOT_LOGGER.tracef("Can't find manifest for %s", archive.getPathName());
}
return null;
}
return readManifest(manifest);
} | java | public static Manifest getManifest(VirtualFile archive) throws IOException {
if (archive == null) {
throw MESSAGES.nullArgument("archive");
}
VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME);
if (manifest == null || !manifest.exists()) {
if (VFSLogger.ROOT_LOGGER.isTraceEnabled()) {
VFSLogger.ROOT_LOGGER.tracef("Can't find manifest for %s", archive.getPathName());
}
return null;
}
return readManifest(manifest);
} | [
"public",
"static",
"Manifest",
"getManifest",
"(",
"VirtualFile",
"archive",
")",
"throws",
"IOException",
"{",
"if",
"(",
"archive",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"archive\"",
")",
";",
"}",
"VirtualFile",
"manifest... | Get a manifest from a virtual file, assuming the virtual file is the root of an archive
@param archive the root the archive
@return the manifest or null if not found
@throws IOException if there is an error reading the manifest or the virtual file is closed
@throws IllegalArgumentException for a null archive | [
"Get",
"a",
"manifest",
"from",
"a",
"virtual",
"file",
"assuming",
"the",
"virtual",
"file",
"is",
"the",
"root",
"of",
"an",
"archive"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L216-L228 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.readManifest | public static Manifest readManifest(VirtualFile manifest) throws IOException {
if (manifest == null) {
throw MESSAGES.nullArgument("manifest file");
}
InputStream stream = new PaddedManifestStream(manifest.openStream());
try {
return new Manifest(stream);
} finally {
safeClose(stream);
}
} | java | public static Manifest readManifest(VirtualFile manifest) throws IOException {
if (manifest == null) {
throw MESSAGES.nullArgument("manifest file");
}
InputStream stream = new PaddedManifestStream(manifest.openStream());
try {
return new Manifest(stream);
} finally {
safeClose(stream);
}
} | [
"public",
"static",
"Manifest",
"readManifest",
"(",
"VirtualFile",
"manifest",
")",
"throws",
"IOException",
"{",
"if",
"(",
"manifest",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"manifest file\"",
")",
";",
"}",
"InputStream",
... | Read the manifest from given manifest VirtualFile.
@param manifest the VF to read from
@return JAR's manifest
@throws IOException if problems while opening VF stream occur | [
"Read",
"the",
"manifest",
"from",
"given",
"manifest",
"VirtualFile",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L237-L247 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.decode | public static String decode(String path, String encoding) {
try {
return URLDecoder.decode(path, encoding);
} catch (UnsupportedEncodingException e) {
throw MESSAGES.cannotDecode(path,encoding,e);
}
} | java | public static String decode(String path, String encoding) {
try {
return URLDecoder.decode(path, encoding);
} catch (UnsupportedEncodingException e) {
throw MESSAGES.cannotDecode(path,encoding,e);
}
} | [
"public",
"static",
"String",
"decode",
"(",
"String",
"path",
",",
"String",
"encoding",
")",
"{",
"try",
"{",
"return",
"URLDecoder",
".",
"decode",
"(",
"path",
",",
"encoding",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",... | Decode the path.
@param path the path to decode
@param encoding the encoding
@return decoded path | [
"Decode",
"the",
"path",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L283-L289 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.getName | public static String getName(URI uri) {
if (uri == null) {
throw MESSAGES.nullArgument("uri");
}
String name = uri.getPath();
if (name != null) {
// TODO: Not correct for certain uris like jar:...!/
int lastSlash = name.lastIndexOf('/');
if (lastSlash > 0) { name = name.substring(lastSlash + 1); }
}
return name;
} | java | public static String getName(URI uri) {
if (uri == null) {
throw MESSAGES.nullArgument("uri");
}
String name = uri.getPath();
if (name != null) {
// TODO: Not correct for certain uris like jar:...!/
int lastSlash = name.lastIndexOf('/');
if (lastSlash > 0) { name = name.substring(lastSlash + 1); }
}
return name;
} | [
"public",
"static",
"String",
"getName",
"(",
"URI",
"uri",
")",
"{",
"if",
"(",
"uri",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"uri\"",
")",
";",
"}",
"String",
"name",
"=",
"uri",
".",
"getPath",
"(",
")",
";",
"i... | Get the name.
@param uri the uri
@return name from uri's path | [
"Get",
"the",
"name",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L297-L308 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.toURI | public static URI toURI(URL url) throws URISyntaxException {
if (url == null) {
throw MESSAGES.nullArgument("url");
}
try {
return url.toURI();
} catch (URISyntaxException e) {
String urispec = url.toExternalForm();
// Escape percent sign and spaces
urispec = urispec.replaceAll("%", "%25");
urispec = urispec.replaceAll(" ", "%20");
return new URI(urispec);
}
} | java | public static URI toURI(URL url) throws URISyntaxException {
if (url == null) {
throw MESSAGES.nullArgument("url");
}
try {
return url.toURI();
} catch (URISyntaxException e) {
String urispec = url.toExternalForm();
// Escape percent sign and spaces
urispec = urispec.replaceAll("%", "%25");
urispec = urispec.replaceAll(" ", "%20");
return new URI(urispec);
}
} | [
"public",
"static",
"URI",
"toURI",
"(",
"URL",
"url",
")",
"throws",
"URISyntaxException",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"url\"",
")",
";",
"}",
"try",
"{",
"return",
"url",
".",
"toURI... | Deal with urls that may include spaces.
@param url the url
@return uri the uri
@throws URISyntaxException for any error | [
"Deal",
"with",
"urls",
"that",
"may",
"include",
"spaces",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L318-L331 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.safeClose | public static void safeClose(final Iterable<? extends Closeable> ci) {
if (ci != null) {
for (Closeable closeable : ci) {
safeClose(closeable);
}
}
} | java | public static void safeClose(final Iterable<? extends Closeable> ci) {
if (ci != null) {
for (Closeable closeable : ci) {
safeClose(closeable);
}
}
} | [
"public",
"static",
"void",
"safeClose",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"Closeable",
">",
"ci",
")",
"{",
"if",
"(",
"ci",
"!=",
"null",
")",
"{",
"for",
"(",
"Closeable",
"closeable",
":",
"ci",
")",
"{",
"safeClose",
"(",
"closeable",... | Safely close some resources without throwing an exception. Any exception will be logged at TRACE level.
@param ci the resources | [
"Safely",
"close",
"some",
"resources",
"without",
"throwing",
"an",
"exception",
".",
"Any",
"exception",
"will",
"be",
"logged",
"at",
"TRACE",
"level",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L616-L622 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.exists | public static boolean exists(File file) {
try {
boolean fileExists = file.exists();
if(!forceCaseSensitive || !fileExists) {
return fileExists;
}
String absPath = canonicalize(file.getAbsolutePath());
String canPath = canonicalize(file.getCanonicalPath());
return fileExists && absPath.equals(canPath);
} catch(IOException io) {
return false;
}
} | java | public static boolean exists(File file) {
try {
boolean fileExists = file.exists();
if(!forceCaseSensitive || !fileExists) {
return fileExists;
}
String absPath = canonicalize(file.getAbsolutePath());
String canPath = canonicalize(file.getCanonicalPath());
return fileExists && absPath.equals(canPath);
} catch(IOException io) {
return false;
}
} | [
"public",
"static",
"boolean",
"exists",
"(",
"File",
"file",
")",
"{",
"try",
"{",
"boolean",
"fileExists",
"=",
"file",
".",
"exists",
"(",
")",
";",
"if",
"(",
"!",
"forceCaseSensitive",
"||",
"!",
"fileExists",
")",
"{",
"return",
"fileExists",
";",
... | In case the file system is not case sensitive we compare the canonical path with
the absolute path of the file after normalized.
@param file
@return | [
"In",
"case",
"the",
"file",
"system",
"is",
"not",
"case",
"sensitive",
"we",
"compare",
"the",
"canonical",
"path",
"with",
"the",
"absolute",
"path",
"of",
"the",
"file",
"after",
"normalized",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L649-L662 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.recursiveDelete | public static boolean recursiveDelete(VirtualFile root) {
boolean ok = true;
if (root.isDirectory()) {
final List<VirtualFile> files = root.getChildren();
for (VirtualFile file : files) {
ok &= recursiveDelete(file);
}
return ok && (root.delete() || !root.exists());
} else {
ok &= root.delete() || !root.exists();
}
return ok;
} | java | public static boolean recursiveDelete(VirtualFile root) {
boolean ok = true;
if (root.isDirectory()) {
final List<VirtualFile> files = root.getChildren();
for (VirtualFile file : files) {
ok &= recursiveDelete(file);
}
return ok && (root.delete() || !root.exists());
} else {
ok &= root.delete() || !root.exists();
}
return ok;
} | [
"public",
"static",
"boolean",
"recursiveDelete",
"(",
"VirtualFile",
"root",
")",
"{",
"boolean",
"ok",
"=",
"true",
";",
"if",
"(",
"root",
".",
"isDirectory",
"(",
")",
")",
"{",
"final",
"List",
"<",
"VirtualFile",
">",
"files",
"=",
"root",
".",
"... | Attempt to recursively delete a virtual file.
@param root the virtual file to delete
@return {@code true} if the file was deleted | [
"Attempt",
"to",
"recursively",
"delete",
"a",
"virtual",
"file",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L692-L704 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.recursiveCopy | public static void recursiveCopy(File original, File destDir) throws IOException {
final String name = original.getName();
final File destFile = new File(destDir, name);
if (original.isDirectory()) {
destFile.mkdir();
for (File file : original.listFiles()) {
recursiveCopy(file, destFile);
}
} else {
final OutputStream os = new FileOutputStream(destFile);
try {
final InputStream is = new FileInputStream(original);
copyStreamAndClose(is, os);
} finally {
// in case the input stream open fails
safeClose(os);
}
}
} | java | public static void recursiveCopy(File original, File destDir) throws IOException {
final String name = original.getName();
final File destFile = new File(destDir, name);
if (original.isDirectory()) {
destFile.mkdir();
for (File file : original.listFiles()) {
recursiveCopy(file, destFile);
}
} else {
final OutputStream os = new FileOutputStream(destFile);
try {
final InputStream is = new FileInputStream(original);
copyStreamAndClose(is, os);
} finally {
// in case the input stream open fails
safeClose(os);
}
}
} | [
"public",
"static",
"void",
"recursiveCopy",
"(",
"File",
"original",
",",
"File",
"destDir",
")",
"throws",
"IOException",
"{",
"final",
"String",
"name",
"=",
"original",
".",
"getName",
"(",
")",
";",
"final",
"File",
"destFile",
"=",
"new",
"File",
"("... | Recursively copy a file or directory from one location to another.
@param original the original file or directory
@param destDir the destination directory
@throws IOException if an I/O error occurs before the copy is complete | [
"Recursively",
"copy",
"a",
"file",
"or",
"directory",
"from",
"one",
"location",
"to",
"another",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L713-L731 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.unzip | public static void unzip(File zipFile, File destDir) throws IOException {
final ZipFile zip = new ZipFile(zipFile);
try {
final Set<File> createdDirs = new HashSet<File>();
final Enumeration<? extends ZipEntry> entries = zip.entries();
FILES_LOOP:
while (entries.hasMoreElements()) {
final ZipEntry zipEntry = entries.nextElement();
final String name = zipEntry.getName();
final List<String> tokens = PathTokenizer.getTokens(name);
final Iterator<String> it = tokens.iterator();
File current = destDir;
while (it.hasNext()) {
String token = it.next();
if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
// invalid file; skip it!
continue FILES_LOOP;
}
current = new File(current, token);
if ((it.hasNext() || zipEntry.isDirectory()) && createdDirs.add(current)) {
current.mkdir();
}
}
if (!zipEntry.isDirectory()) {
final InputStream is = zip.getInputStream(zipEntry);
try {
final FileOutputStream os = new FileOutputStream(current);
try {
VFSUtils.copyStream(is, os);
// allow an error on close to terminate the unzip
is.close();
os.close();
} finally {
VFSUtils.safeClose(os);
}
} finally {
VFSUtils.safeClose(is);
}
// exclude jsp files last modified time change. jasper jsp compiler Compiler.java depends on last modified time-stamp to re-compile jsp files
if (!current.getName().endsWith(".jsp"))
current.setLastModified(zipEntry.getTime());
}
}
} finally {
VFSUtils.safeClose(zip);
}
} | java | public static void unzip(File zipFile, File destDir) throws IOException {
final ZipFile zip = new ZipFile(zipFile);
try {
final Set<File> createdDirs = new HashSet<File>();
final Enumeration<? extends ZipEntry> entries = zip.entries();
FILES_LOOP:
while (entries.hasMoreElements()) {
final ZipEntry zipEntry = entries.nextElement();
final String name = zipEntry.getName();
final List<String> tokens = PathTokenizer.getTokens(name);
final Iterator<String> it = tokens.iterator();
File current = destDir;
while (it.hasNext()) {
String token = it.next();
if (PathTokenizer.isCurrentToken(token) || PathTokenizer.isReverseToken(token)) {
// invalid file; skip it!
continue FILES_LOOP;
}
current = new File(current, token);
if ((it.hasNext() || zipEntry.isDirectory()) && createdDirs.add(current)) {
current.mkdir();
}
}
if (!zipEntry.isDirectory()) {
final InputStream is = zip.getInputStream(zipEntry);
try {
final FileOutputStream os = new FileOutputStream(current);
try {
VFSUtils.copyStream(is, os);
// allow an error on close to terminate the unzip
is.close();
os.close();
} finally {
VFSUtils.safeClose(os);
}
} finally {
VFSUtils.safeClose(is);
}
// exclude jsp files last modified time change. jasper jsp compiler Compiler.java depends on last modified time-stamp to re-compile jsp files
if (!current.getName().endsWith(".jsp"))
current.setLastModified(zipEntry.getTime());
}
}
} finally {
VFSUtils.safeClose(zip);
}
} | [
"public",
"static",
"void",
"unzip",
"(",
"File",
"zipFile",
",",
"File",
"destDir",
")",
"throws",
"IOException",
"{",
"final",
"ZipFile",
"zip",
"=",
"new",
"ZipFile",
"(",
"zipFile",
")",
";",
"try",
"{",
"final",
"Set",
"<",
"File",
">",
"createdDirs... | Expand a zip file to a destination directory. The directory must exist. If an error occurs, the destination
directory may contain a partially-extracted archive, so cleanup is up to the caller.
@param zipFile the zip file
@param destDir the destination directory
@throws IOException if an error occurs | [
"Expand",
"a",
"zip",
"file",
"to",
"a",
"destination",
"directory",
".",
"The",
"directory",
"must",
"exist",
".",
"If",
"an",
"error",
"occurs",
"the",
"destination",
"directory",
"may",
"contain",
"a",
"partially",
"-",
"extracted",
"archive",
"so",
"clea... | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L873-L919 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VFSUtils.java | VFSUtils.getMountSource | public static File getMountSource(Closeable handle) {
if (handle instanceof MountHandle) { return MountHandle.class.cast(handle).getMountSource(); }
return null;
} | java | public static File getMountSource(Closeable handle) {
if (handle instanceof MountHandle) { return MountHandle.class.cast(handle).getMountSource(); }
return null;
} | [
"public",
"static",
"File",
"getMountSource",
"(",
"Closeable",
"handle",
")",
"{",
"if",
"(",
"handle",
"instanceof",
"MountHandle",
")",
"{",
"return",
"MountHandle",
".",
"class",
".",
"cast",
"(",
"handle",
")",
".",
"getMountSource",
"(",
")",
";",
"}... | Return the mount source File for a given mount handle.
@param handle The handle to get the source for
@return The mount source file or null if the handle does not have a source, or is not a MountHandle | [
"Return",
"the",
"mount",
"source",
"File",
"for",
"a",
"given",
"mount",
"handle",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VFSUtils.java#L927-L930 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/FilterVirtualFileVisitor.java | FilterVirtualFileVisitor.checkAttributes | private static VisitorAttributes checkAttributes(VirtualFileFilter filter, VisitorAttributes attributes) {
if (filter == null) {
throw MESSAGES.nullArgument("filter");
}
// Specified
if (attributes != null) { return attributes; }
// From the filter
if (filter instanceof VirtualFileFilterWithAttributes) { return ((VirtualFileFilterWithAttributes) filter).getAttributes(); }
// It will use the default
return null;
} | java | private static VisitorAttributes checkAttributes(VirtualFileFilter filter, VisitorAttributes attributes) {
if (filter == null) {
throw MESSAGES.nullArgument("filter");
}
// Specified
if (attributes != null) { return attributes; }
// From the filter
if (filter instanceof VirtualFileFilterWithAttributes) { return ((VirtualFileFilterWithAttributes) filter).getAttributes(); }
// It will use the default
return null;
} | [
"private",
"static",
"VisitorAttributes",
"checkAttributes",
"(",
"VirtualFileFilter",
"filter",
",",
"VisitorAttributes",
"attributes",
")",
"{",
"if",
"(",
"filter",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"filter\"",
")",
";",
... | Check the attributes
@param filter the filter
@param attributes the attributes
@return the attributes
@throws IllegalArgumentException for a null filter | [
"Check",
"the",
"attributes"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/FilterVirtualFileVisitor.java#L57-L67 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/FileNameVirtualFileFilter.java | FileNameVirtualFileFilter.getPathName | protected String getPathName(VirtualFile file) {
try {
// prefer the URI, as the pathName might
// return an empty string for temp virtual files
return file.toURI().toString();
} catch (Exception e) {
return file.getPathName();
}
} | java | protected String getPathName(VirtualFile file) {
try {
// prefer the URI, as the pathName might
// return an empty string for temp virtual files
return file.toURI().toString();
} catch (Exception e) {
return file.getPathName();
}
} | [
"protected",
"String",
"getPathName",
"(",
"VirtualFile",
"file",
")",
"{",
"try",
"{",
"// prefer the URI, as the pathName might\r",
"// return an empty string for temp virtual files\r",
"return",
"file",
".",
"toURI",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"... | Get the path name for the VirtualFile.
@param file the virtual file
@return the path name | [
"Get",
"the",
"path",
"name",
"for",
"the",
"VirtualFile",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/FileNameVirtualFileFilter.java#L78-L86 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/automount/Automounter.java | Automounter.getMountConfig | private static MountConfig getMountConfig(MountOption[] mountOptions) {
final MountConfig config = new MountConfig();
for (MountOption option : mountOptions) {
option.applyTo(config);
}
return config;
} | java | private static MountConfig getMountConfig(MountOption[] mountOptions) {
final MountConfig config = new MountConfig();
for (MountOption option : mountOptions) {
option.applyTo(config);
}
return config;
} | [
"private",
"static",
"MountConfig",
"getMountConfig",
"(",
"MountOption",
"[",
"]",
"mountOptions",
")",
"{",
"final",
"MountConfig",
"config",
"=",
"new",
"MountConfig",
"(",
")",
";",
"for",
"(",
"MountOption",
"option",
":",
"mountOptions",
")",
"{",
"optio... | Creates a MountConfig and applies the provided mount options
@param mountOptions options to use for mounting
@return a MountConfig | [
"Creates",
"a",
"MountConfig",
"and",
"applies",
"the",
"provided",
"mount",
"options"
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/automount/Automounter.java#L119-L125 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/automount/Automounter.java | Automounter.addHandle | public static boolean addHandle(VirtualFile owner, Closeable handle) {
RegistryEntry entry = getEntry(owner);
return entry.handles.add(handle);
} | java | public static boolean addHandle(VirtualFile owner, Closeable handle) {
RegistryEntry entry = getEntry(owner);
return entry.handles.add(handle);
} | [
"public",
"static",
"boolean",
"addHandle",
"(",
"VirtualFile",
"owner",
",",
"Closeable",
"handle",
")",
"{",
"RegistryEntry",
"entry",
"=",
"getEntry",
"(",
"owner",
")",
";",
"return",
"entry",
".",
"handles",
".",
"add",
"(",
"handle",
")",
";",
"}"
] | Add handle to owner, to be auto closed.
@param owner the handle owner
@param handle the handle
@return add result | [
"Add",
"handle",
"to",
"owner",
"to",
"be",
"auto",
"closed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/automount/Automounter.java#L134-L137 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/automount/Automounter.java | Automounter.removeHandle | public static boolean removeHandle(VirtualFile owner, Closeable handle) {
RegistryEntry entry = getEntry(owner);
return entry.handles.remove(handle);
} | java | public static boolean removeHandle(VirtualFile owner, Closeable handle) {
RegistryEntry entry = getEntry(owner);
return entry.handles.remove(handle);
} | [
"public",
"static",
"boolean",
"removeHandle",
"(",
"VirtualFile",
"owner",
",",
"Closeable",
"handle",
")",
"{",
"RegistryEntry",
"entry",
"=",
"getEntry",
"(",
"owner",
")",
";",
"return",
"entry",
".",
"handles",
".",
"remove",
"(",
"handle",
")",
";",
... | Remove handle from owner.
@param owner the handle owner
@param handle the handle
@return remove result | [
"Remove",
"handle",
"from",
"owner",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/automount/Automounter.java#L146-L149 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/automount/Automounter.java | Automounter.getEntry | static RegistryEntry getEntry(VirtualFile virtualFile) {
if (virtualFile == null) {
throw MESSAGES.nullArgument("VirutalFile");
}
return rootEntry.find(virtualFile);
} | java | static RegistryEntry getEntry(VirtualFile virtualFile) {
if (virtualFile == null) {
throw MESSAGES.nullArgument("VirutalFile");
}
return rootEntry.find(virtualFile);
} | [
"static",
"RegistryEntry",
"getEntry",
"(",
"VirtualFile",
"virtualFile",
")",
"{",
"if",
"(",
"virtualFile",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"VirutalFile\"",
")",
";",
"}",
"return",
"rootEntry",
".",
"find",
"(",
"v... | Get the entry from the tree creating the entry if not present.
@param virtualFile entry's owner file
@return registry entry | [
"Get",
"the",
"entry",
"from",
"the",
"tree",
"creating",
"the",
"entry",
"if",
"not",
"present",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/automount/Automounter.java#L200-L205 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/TempFileProvider.java | TempFileProvider.create | public static TempFileProvider create(final String providerType, final ScheduledExecutorService executor, final boolean cleanExisting) throws IOException {
if (cleanExisting) {
try {
// The "clean existing" logic is as follows:
// 1) Rename the root directory "foo" corresponding to the provider type to "bar"
// 2) Submit a task to delete "bar" and its contents, in a background thread, to the the passed executor.
// 3) Create a "foo" root directory for the provider type and return that TempFileProvider (while at the same time the background task is in progress)
// This ensures that the "foo" root directory for the providerType is empty and the older content is being cleaned up in the background (without affecting the current processing),
// thus simulating a "cleanup existing content"
final File possiblyExistingProviderRoot = new File(TMP_ROOT, providerType);
if (possiblyExistingProviderRoot.exists()) {
// rename it so that it can be deleted as a separate (background) task
final File toBeDeletedProviderRoot = new File(TMP_ROOT, createTempName(providerType + "-to-be-deleted-", ""));
final boolean renamed = possiblyExistingProviderRoot.renameTo(toBeDeletedProviderRoot);
if (!renamed) {
throw new IOException("Failed to rename " + possiblyExistingProviderRoot.getAbsolutePath() + " to " + toBeDeletedProviderRoot.getAbsolutePath());
} else {
// delete in the background
executor.submit(new DeleteTask(toBeDeletedProviderRoot, executor));
}
}
} catch (Throwable t) {
// just log a message if existing contents couldn't be deleted
VFSLogger.ROOT_LOGGER.failedToCleanExistingContentForTempFileProvider(providerType);
// log the cause of the failure
VFSLogger.ROOT_LOGGER.debug("Failed to clean existing content for temp file provider of type " + providerType, t);
}
}
// now create and return the TempFileProvider for the providerType
final File providerRoot = new File(TMP_ROOT, providerType);
return new TempFileProvider(createTempDir(providerType, "", providerRoot), executor);
} | java | public static TempFileProvider create(final String providerType, final ScheduledExecutorService executor, final boolean cleanExisting) throws IOException {
if (cleanExisting) {
try {
// The "clean existing" logic is as follows:
// 1) Rename the root directory "foo" corresponding to the provider type to "bar"
// 2) Submit a task to delete "bar" and its contents, in a background thread, to the the passed executor.
// 3) Create a "foo" root directory for the provider type and return that TempFileProvider (while at the same time the background task is in progress)
// This ensures that the "foo" root directory for the providerType is empty and the older content is being cleaned up in the background (without affecting the current processing),
// thus simulating a "cleanup existing content"
final File possiblyExistingProviderRoot = new File(TMP_ROOT, providerType);
if (possiblyExistingProviderRoot.exists()) {
// rename it so that it can be deleted as a separate (background) task
final File toBeDeletedProviderRoot = new File(TMP_ROOT, createTempName(providerType + "-to-be-deleted-", ""));
final boolean renamed = possiblyExistingProviderRoot.renameTo(toBeDeletedProviderRoot);
if (!renamed) {
throw new IOException("Failed to rename " + possiblyExistingProviderRoot.getAbsolutePath() + " to " + toBeDeletedProviderRoot.getAbsolutePath());
} else {
// delete in the background
executor.submit(new DeleteTask(toBeDeletedProviderRoot, executor));
}
}
} catch (Throwable t) {
// just log a message if existing contents couldn't be deleted
VFSLogger.ROOT_LOGGER.failedToCleanExistingContentForTempFileProvider(providerType);
// log the cause of the failure
VFSLogger.ROOT_LOGGER.debug("Failed to clean existing content for temp file provider of type " + providerType, t);
}
}
// now create and return the TempFileProvider for the providerType
final File providerRoot = new File(TMP_ROOT, providerType);
return new TempFileProvider(createTempDir(providerType, "", providerRoot), executor);
} | [
"public",
"static",
"TempFileProvider",
"create",
"(",
"final",
"String",
"providerType",
",",
"final",
"ScheduledExecutorService",
"executor",
",",
"final",
"boolean",
"cleanExisting",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cleanExisting",
")",
"{",
"try",
... | Create a temporary file provider for a given type.
@param providerType The provider type string (used as a prefix in the temp file dir name)
@param executor Executor which will be used to manage temp file provider tasks (like cleaning up/deleting the temp files when needed)
@param cleanExisting If this is true, then this method will *try* to delete the existing temp content (if any) for the <code>providerType</code>. The attempt to delete the existing content (if any)
will be done in the background and this method will not wait for the deletion to complete. The method will immediately return back with a usable {@link TempFileProvider}. Note that the
<code>cleanExisting</code> will just act as a hint for this method to trigger the deletion of existing content. The method may not always be able to delete the existing contents.
@return The new provider
@throws IOException if an I/O error occurs | [
"Create",
"a",
"temporary",
"file",
"provider",
"for",
"a",
"given",
"type",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/TempFileProvider.java#L79-L110 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/TempFileProvider.java | TempFileProvider.createTempDir | public TempDir createTempDir(String originalName) throws IOException {
if (!open.get()) {
throw VFSMessages.MESSAGES.tempFileProviderClosed();
}
final String name = createTempName(originalName + "-", "");
final File f = new File(providerRoot, name);
for (int i = 0; i < RETRIES; i++) {
if (f.mkdirs()) {
return new TempDir(this, f);
}
}
throw VFSMessages.MESSAGES.couldNotCreateDirectory(originalName,RETRIES);
} | java | public TempDir createTempDir(String originalName) throws IOException {
if (!open.get()) {
throw VFSMessages.MESSAGES.tempFileProviderClosed();
}
final String name = createTempName(originalName + "-", "");
final File f = new File(providerRoot, name);
for (int i = 0; i < RETRIES; i++) {
if (f.mkdirs()) {
return new TempDir(this, f);
}
}
throw VFSMessages.MESSAGES.couldNotCreateDirectory(originalName,RETRIES);
} | [
"public",
"TempDir",
"createTempDir",
"(",
"String",
"originalName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"open",
".",
"get",
"(",
")",
")",
"{",
"throw",
"VFSMessages",
".",
"MESSAGES",
".",
"tempFileProviderClosed",
"(",
")",
";",
"}",
"fin... | Create a temp directory, into which temporary files may be placed.
@param originalName the original file name
@return the temp directory
@throws IOException for any error | [
"Create",
"a",
"temp",
"directory",
"into",
"which",
"temporary",
"files",
"may",
"be",
"placed",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/TempFileProvider.java#L131-L143 | train |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/VirtualJarInputStream.java | VirtualJarInputStream.openCurrent | private void openCurrent(VirtualFile current) throws IOException {
if (current.isDirectory()) {
currentEntryStream = VFSUtils.emptyStream();
} else {
currentEntryStream = current.openStream();
}
} | java | private void openCurrent(VirtualFile current) throws IOException {
if (current.isDirectory()) {
currentEntryStream = VFSUtils.emptyStream();
} else {
currentEntryStream = current.openStream();
}
} | [
"private",
"void",
"openCurrent",
"(",
"VirtualFile",
"current",
")",
"throws",
"IOException",
"{",
"if",
"(",
"current",
".",
"isDirectory",
"(",
")",
")",
"{",
"currentEntryStream",
"=",
"VFSUtils",
".",
"emptyStream",
"(",
")",
";",
"}",
"else",
"{",
"c... | Open the current virtual file as the current JarEntry stream.
@param current
@throws IOException | [
"Open",
"the",
"current",
"virtual",
"file",
"as",
"the",
"current",
"JarEntry",
"stream",
"."
] | 420f4b896d6178ee5f6758f3421e9f350d2b8ab5 | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/VirtualJarInputStream.java#L219-L225 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.