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
algermissen/hawkj
src/main/java/net/jalg/hawkj/HawkContext.java
HawkContext.getBaseString
protected String getBaseString() { StringBuilder sb = new StringBuilder(HAWK_HEADER_PREFIX).append(SLF); sb.append(getTs()).append(SLF); sb.append(getNonce()).append(SLF); sb.append(getMethod()).append(SLF); sb.append(getPath()).append(SLF); sb.append(getHost()).append(SLF); sb.append(getPort()).append(SLF); sb.append(hasHash() ? getHash() : "").append(SLF); sb.append(hasExt() ? getExt() : "").append(SLF); // FIXME: escaping of stuff in ext to a single line. // See https://github.com/algermissen/hawkj/issues/1 if(hasApp()) { sb.append(getApp()).append(SLF); sb.append(hasDlg() ? getDlg() : "").append(SLF); } return sb.toString(); // FIXME - code for ext quote escaping // https://github.com/algermissen/hawkj/issues/1 // if (options.ext) { // normalized += options.ext.replace('\\', '\\\\').replace('\n', '\\n'); // } // // normalized += '\n'; // // // escapeHeaderAttribute: function (attribute) { // // return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // }, }
java
protected String getBaseString() { StringBuilder sb = new StringBuilder(HAWK_HEADER_PREFIX).append(SLF); sb.append(getTs()).append(SLF); sb.append(getNonce()).append(SLF); sb.append(getMethod()).append(SLF); sb.append(getPath()).append(SLF); sb.append(getHost()).append(SLF); sb.append(getPort()).append(SLF); sb.append(hasHash() ? getHash() : "").append(SLF); sb.append(hasExt() ? getExt() : "").append(SLF); // FIXME: escaping of stuff in ext to a single line. // See https://github.com/algermissen/hawkj/issues/1 if(hasApp()) { sb.append(getApp()).append(SLF); sb.append(hasDlg() ? getDlg() : "").append(SLF); } return sb.toString(); // FIXME - code for ext quote escaping // https://github.com/algermissen/hawkj/issues/1 // if (options.ext) { // normalized += options.ext.replace('\\', '\\\\').replace('\n', '\\n'); // } // // normalized += '\n'; // // // escapeHeaderAttribute: function (attribute) { // // return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // }, }
[ "protected", "String", "getBaseString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "HAWK_HEADER_PREFIX", ")", ".", "append", "(", "SLF", ")", ";", "sb", ".", "append", "(", "getTs", "(", ")", ")", ".", "append", "(", "SLF", ...
Generate base string for HMAC generation. @return
[ "Generate", "base", "string", "for", "HMAC", "generation", "." ]
f798a20f058474bcfe761f7c5c02afee17326c71
https://github.com/algermissen/hawkj/blob/f798a20f058474bcfe761f7c5c02afee17326c71/src/main/java/net/jalg/hawkj/HawkContext.java#L274-L306
train
algermissen/hawkj
src/main/java/net/jalg/hawkj/HawkContext.java
HawkContext.request
public static HawkContextBuilder_B request(String method, String path, String host, int port) { return new HawkContextBuilder().method(method).path(path).host(host) .port(port); }
java
public static HawkContextBuilder_B request(String method, String path, String host, int port) { return new HawkContextBuilder().method(method).path(path).host(host) .port(port); }
[ "public", "static", "HawkContextBuilder_B", "request", "(", "String", "method", ",", "String", "path", ",", "String", "host", ",", "int", "port", ")", "{", "return", "new", "HawkContextBuilder", "(", ")", ".", "method", "(", "method", ")", ".", "path", "("...
Create a new RequestBuilder_A, initialized with request data. @param method @param path @param host @param port @return
[ "Create", "a", "new", "RequestBuilder_A", "initialized", "with", "request", "data", "." ]
f798a20f058474bcfe761f7c5c02afee17326c71
https://github.com/algermissen/hawkj/blob/f798a20f058474bcfe761f7c5c02afee17326c71/src/main/java/net/jalg/hawkj/HawkContext.java#L369-L373
train
svanoort/rest-compress
demo-app/src/main/java/com/restcompress/demoapp/RestDemoApp.java
RestDemoApp.decompress
@Override public byte[] decompress(InputStream strm) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); LZFInputStream in = new LZFInputStream(strm); byte[] buffer = new byte[8192]; int len = 0; //Decode and copy to output while ((len = in.read(buffer)) != -1) { baos.write(buffer,0,len); } return baos.toByteArray(); } catch (IOException ioe) { throw new RuntimeException("IOException reading input stream",ioe); } }
java
@Override public byte[] decompress(InputStream strm) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); LZFInputStream in = new LZFInputStream(strm); byte[] buffer = new byte[8192]; int len = 0; //Decode and copy to output while ((len = in.read(buffer)) != -1) { baos.write(buffer,0,len); } return baos.toByteArray(); } catch (IOException ioe) { throw new RuntimeException("IOException reading input stream",ioe); } }
[ "@", "Override", "public", "byte", "[", "]", "decompress", "(", "InputStream", "strm", ")", "{", "try", "{", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "LZFInputStream", "in", "=", "new", "LZFInputStream", "(", "strm",...
Attempts to decompress an LZF stream @param strm @return
[ "Attempts", "to", "decompress", "an", "LZF", "stream" ]
4e34fcbe0d1b510962a93509a78b6a8ade234606
https://github.com/svanoort/rest-compress/blob/4e34fcbe0d1b510962a93509a78b6a8ade234606/demo-app/src/main/java/com/restcompress/demoapp/RestDemoApp.java#L119-L136
train
svanoort/rest-compress
demo-app/src/main/java/com/restcompress/demoapp/RestDemoApp.java
RestDemoApp.getRandomDate
public static GregorianCalendar getRandomDate(long seed) { GregorianCalendar gc = new GregorianCalendar(); Random rand = new Random(seed); gc.set(GregorianCalendar.YEAR,1900+rand.nextInt(120)); //Between 1900 & 2020 gc.set(GregorianCalendar.DAY_OF_YEAR,rand.nextInt(364)+1); //Day of year return gc; }
java
public static GregorianCalendar getRandomDate(long seed) { GregorianCalendar gc = new GregorianCalendar(); Random rand = new Random(seed); gc.set(GregorianCalendar.YEAR,1900+rand.nextInt(120)); //Between 1900 & 2020 gc.set(GregorianCalendar.DAY_OF_YEAR,rand.nextInt(364)+1); //Day of year return gc; }
[ "public", "static", "GregorianCalendar", "getRandomDate", "(", "long", "seed", ")", "{", "GregorianCalendar", "gc", "=", "new", "GregorianCalendar", "(", ")", ";", "Random", "rand", "=", "new", "Random", "(", "seed", ")", ";", "gc", ".", "set", "(", "Grego...
Gets a random date in the last 100 years
[ "Gets", "a", "random", "date", "in", "the", "last", "100", "years" ]
4e34fcbe0d1b510962a93509a78b6a8ade234606
https://github.com/svanoort/rest-compress/blob/4e34fcbe0d1b510962a93509a78b6a8ade234606/demo-app/src/main/java/com/restcompress/demoapp/RestDemoApp.java#L179-L185
train
nikkiii/embedhttp
src/main/java/org/nikkii/embedhttp/impl/HttpRequest.java
HttpRequest.setCookies
public void setCookies(List<HttpCookie> cookies) { Map<String, HttpCookie> map = new HashMap<String, HttpCookie>(); for (HttpCookie cookie : cookies) { map.put(cookie.getName(), cookie); } this.cookies = map; }
java
public void setCookies(List<HttpCookie> cookies) { Map<String, HttpCookie> map = new HashMap<String, HttpCookie>(); for (HttpCookie cookie : cookies) { map.put(cookie.getName(), cookie); } this.cookies = map; }
[ "public", "void", "setCookies", "(", "List", "<", "HttpCookie", ">", "cookies", ")", "{", "Map", "<", "String", ",", "HttpCookie", ">", "map", "=", "new", "HashMap", "<", "String", ",", "HttpCookie", ">", "(", ")", ";", "for", "(", "HttpCookie", "cooki...
Set the request's cookies @param cookies The cookie list
[ "Set", "the", "request", "s", "cookies" ]
7c965b6910dc6ee4ea46d7ae188c0751b98c2615
https://github.com/nikkiii/embedhttp/blob/7c965b6910dc6ee4ea46d7ae188c0751b98c2615/src/main/java/org/nikkii/embedhttp/impl/HttpRequest.java#L209-L215
train
canhnt/sne-xacml
sne-xacml/src/main/java/nl/uva/sne/midd/partition/PartitionBuilder.java
PartitionBuilder.combine
private static <T extends Comparable<T>> List<Interval<T>> combine(Partition<T> p1, Partition<T> p2) throws MIDDException { Set<EndPoint<T>> boundSet = new HashSet<EndPoint<T>>(); //collect all bounds and remove duplicated items for (Interval<T> interval : p1.getIntervals()) { boundSet.add(interval.getLowerBound()); boundSet.add(interval.getUpperBound()); } for (Interval<T> interval : p2.getIntervals()) { boundSet.add(interval.getLowerBound()); boundSet.add(interval.getUpperBound()); } //sorting the bounds List<EndPoint<T>> sortedBounds = new ArrayList<EndPoint<T>>(boundSet); Collections.sort(sortedBounds); List<Interval<T>> tempPartition = new ArrayList<Interval<T>>(); // Generate new intervals for (int i = 0; i < sortedBounds.size() - 1; i++) { EndPoint<T> lowBound = sortedBounds.get(i); EndPoint<T> upBound = sortedBounds.get(i + 1); tempPartition.add(new Interval<T>(lowBound)); tempPartition.add(new Interval<T>(lowBound, upBound)); } // add the last end-point if (sortedBounds.size() > 0) { EndPoint<T> lastBound = sortedBounds.get(sortedBounds.size() - 1); tempPartition.add(new Interval<T>(lastBound)); } else { log.warn("empty sortedBound"); } return tempPartition; }
java
private static <T extends Comparable<T>> List<Interval<T>> combine(Partition<T> p1, Partition<T> p2) throws MIDDException { Set<EndPoint<T>> boundSet = new HashSet<EndPoint<T>>(); //collect all bounds and remove duplicated items for (Interval<T> interval : p1.getIntervals()) { boundSet.add(interval.getLowerBound()); boundSet.add(interval.getUpperBound()); } for (Interval<T> interval : p2.getIntervals()) { boundSet.add(interval.getLowerBound()); boundSet.add(interval.getUpperBound()); } //sorting the bounds List<EndPoint<T>> sortedBounds = new ArrayList<EndPoint<T>>(boundSet); Collections.sort(sortedBounds); List<Interval<T>> tempPartition = new ArrayList<Interval<T>>(); // Generate new intervals for (int i = 0; i < sortedBounds.size() - 1; i++) { EndPoint<T> lowBound = sortedBounds.get(i); EndPoint<T> upBound = sortedBounds.get(i + 1); tempPartition.add(new Interval<T>(lowBound)); tempPartition.add(new Interval<T>(lowBound, upBound)); } // add the last end-point if (sortedBounds.size() > 0) { EndPoint<T> lastBound = sortedBounds.get(sortedBounds.size() - 1); tempPartition.add(new Interval<T>(lastBound)); } else { log.warn("empty sortedBound"); } return tempPartition; }
[ "private", "static", "<", "T", "extends", "Comparable", "<", "T", ">", ">", "List", "<", "Interval", "<", "T", ">", ">", "combine", "(", "Partition", "<", "T", ">", "p1", ",", "Partition", "<", "T", ">", "p2", ")", "throws", "MIDDException", "{", "...
Create a list of intervals from two partitions @param p1 @param p2 @return
[ "Create", "a", "list", "of", "intervals", "from", "two", "partitions" ]
7ffca16bf558d2c3ee16181d926f066ab1de75b2
https://github.com/canhnt/sne-xacml/blob/7ffca16bf558d2c3ee16181d926f066ab1de75b2/sne-xacml/src/main/java/nl/uva/sne/midd/partition/PartitionBuilder.java#L209-L245
train
canhnt/sne-xacml
sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java
Interval.complement
public List<Interval<T>> complement(final Interval<T> op) throws MIDDException { final boolean disJoined = (this.lowerBound.compareTo(op.upperBound) >= 0) || (this.upperBound.compareTo(op.lowerBound) <= 0); if (disJoined) { Interval<T> newInterval = new Interval<>(this.lowerBound, this.upperBound); final boolean isLowerClosed; if (this.lowerBound.compareTo(op.upperBound) == 0) { isLowerClosed = this.lowerBoundClosed && !op.upperBoundClosed; } else { isLowerClosed = this.lowerBoundClosed; } newInterval.closeLeft(isLowerClosed); final boolean isUpperClosed; if (this.upperBound.compareTo(op.lowerBound) == 0) { isUpperClosed = this.upperBoundClosed && !op.upperBoundClosed; } else { isUpperClosed = this.upperBoundClosed; } newInterval.closeRight(isUpperClosed); // return empty if new interval is invalid if (!newInterval.validate()) { return ImmutableList.of(); } return ImmutableList.of(newInterval); } else { final Interval<T> interval1 = new Interval<>(this.lowerBound, op.lowerBound); final Interval<T> interval2 = new Interval<>(op.upperBound, this.upperBound); interval1.closeLeft(!interval1.isLowerInfinite() && this.lowerBoundClosed); interval1.closeRight(!interval1.isUpperInfinite() && !op.lowerBoundClosed); interval2.closeLeft(!interval2.isLowerInfinite() && !op.upperBoundClosed); interval2.closeRight(!interval2.isUpperInfinite() && this.upperBoundClosed); final List<Interval<T>> result = new ArrayList<>(); if (interval1.validate()) { result.add(interval1); } if (interval2.validate()) { result.add(interval2); } return ImmutableList.copyOf(result); } }
java
public List<Interval<T>> complement(final Interval<T> op) throws MIDDException { final boolean disJoined = (this.lowerBound.compareTo(op.upperBound) >= 0) || (this.upperBound.compareTo(op.lowerBound) <= 0); if (disJoined) { Interval<T> newInterval = new Interval<>(this.lowerBound, this.upperBound); final boolean isLowerClosed; if (this.lowerBound.compareTo(op.upperBound) == 0) { isLowerClosed = this.lowerBoundClosed && !op.upperBoundClosed; } else { isLowerClosed = this.lowerBoundClosed; } newInterval.closeLeft(isLowerClosed); final boolean isUpperClosed; if (this.upperBound.compareTo(op.lowerBound) == 0) { isUpperClosed = this.upperBoundClosed && !op.upperBoundClosed; } else { isUpperClosed = this.upperBoundClosed; } newInterval.closeRight(isUpperClosed); // return empty if new interval is invalid if (!newInterval.validate()) { return ImmutableList.of(); } return ImmutableList.of(newInterval); } else { final Interval<T> interval1 = new Interval<>(this.lowerBound, op.lowerBound); final Interval<T> interval2 = new Interval<>(op.upperBound, this.upperBound); interval1.closeLeft(!interval1.isLowerInfinite() && this.lowerBoundClosed); interval1.closeRight(!interval1.isUpperInfinite() && !op.lowerBoundClosed); interval2.closeLeft(!interval2.isLowerInfinite() && !op.upperBoundClosed); interval2.closeRight(!interval2.isUpperInfinite() && this.upperBoundClosed); final List<Interval<T>> result = new ArrayList<>(); if (interval1.validate()) { result.add(interval1); } if (interval2.validate()) { result.add(interval2); } return ImmutableList.copyOf(result); } }
[ "public", "List", "<", "Interval", "<", "T", ">", ">", "complement", "(", "final", "Interval", "<", "T", ">", "op", ")", "throws", "MIDDException", "{", "final", "boolean", "disJoined", "=", "(", "this", ".", "lowerBound", ".", "compareTo", "(", "op", ...
Return the complement section of the interval. @param op @return The complemented interval(s), or an empty list if the complement is empty.
[ "Return", "the", "complement", "section", "of", "the", "interval", "." ]
7ffca16bf558d2c3ee16181d926f066ab1de75b2
https://github.com/canhnt/sne-xacml/blob/7ffca16bf558d2c3ee16181d926f066ab1de75b2/sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java#L123-L171
train
canhnt/sne-xacml
sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java
Interval.contains
public boolean contains(final Interval<T> i) { int compareLow, compareUp; compareLow = this.lowerBound.compareTo(i.lowerBound); compareUp = this.upperBound.compareTo(i.upperBound); if (compareLow < 0) { // check the upper bound if (compareUp > 0) { return true; } else if ((compareUp == 0) && (this.upperBoundClosed || !i.upperBoundClosed)) { return true; } } else if (compareLow == 0) { if (this.lowerBoundClosed || !i.lowerBoundClosed) { // lowerbound satisfied { // check upperbound if (compareUp > 0) { return true; } else if ((compareUp == 0) && (this.upperBoundClosed || !i.upperBoundClosed)) { return true; } } } } return false; }
java
public boolean contains(final Interval<T> i) { int compareLow, compareUp; compareLow = this.lowerBound.compareTo(i.lowerBound); compareUp = this.upperBound.compareTo(i.upperBound); if (compareLow < 0) { // check the upper bound if (compareUp > 0) { return true; } else if ((compareUp == 0) && (this.upperBoundClosed || !i.upperBoundClosed)) { return true; } } else if (compareLow == 0) { if (this.lowerBoundClosed || !i.lowerBoundClosed) { // lowerbound satisfied { // check upperbound if (compareUp > 0) { return true; } else if ((compareUp == 0) && (this.upperBoundClosed || !i.upperBoundClosed)) { return true; } } } } return false; }
[ "public", "boolean", "contains", "(", "final", "Interval", "<", "T", ">", "i", ")", "{", "int", "compareLow", ",", "compareUp", ";", "compareLow", "=", "this", ".", "lowerBound", ".", "compareTo", "(", "i", ".", "lowerBound", ")", ";", "compareUp", "=", ...
Return true if interval in the argument is the subset of the current interval. @param i @return
[ "Return", "true", "if", "interval", "in", "the", "argument", "is", "the", "subset", "of", "the", "current", "interval", "." ]
7ffca16bf558d2c3ee16181d926f066ab1de75b2
https://github.com/canhnt/sne-xacml/blob/7ffca16bf558d2c3ee16181d926f066ab1de75b2/sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java#L179-L207
train
canhnt/sne-xacml
sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java
Interval.hasValue
public boolean hasValue(final T value) throws MIDDException { //special processing when missing attribute if (value == null) { return this.isLowerInfinite() || this.isUpperInfinite(); } EndPoint<T> epValue = new EndPoint<>(value); int compareLow = this.lowerBound.compareTo(epValue); int compareUp = this.upperBound.compareTo(epValue); if ((compareLow < 0 || (compareLow == 0 && this.lowerBoundClosed)) && (compareUp > 0 || (compareUp == 0 && this.upperBoundClosed))) { return true; } return false; }
java
public boolean hasValue(final T value) throws MIDDException { //special processing when missing attribute if (value == null) { return this.isLowerInfinite() || this.isUpperInfinite(); } EndPoint<T> epValue = new EndPoint<>(value); int compareLow = this.lowerBound.compareTo(epValue); int compareUp = this.upperBound.compareTo(epValue); if ((compareLow < 0 || (compareLow == 0 && this.lowerBoundClosed)) && (compareUp > 0 || (compareUp == 0 && this.upperBoundClosed))) { return true; } return false; }
[ "public", "boolean", "hasValue", "(", "final", "T", "value", ")", "throws", "MIDDException", "{", "//special processing when missing attribute", "if", "(", "value", "==", "null", ")", "{", "return", "this", ".", "isLowerInfinite", "(", ")", "||", "this", ".", ...
Check if the value is presenting in the interval. @param value @return
[ "Check", "if", "the", "value", "is", "presenting", "in", "the", "interval", "." ]
7ffca16bf558d2c3ee16181d926f066ab1de75b2
https://github.com/canhnt/sne-xacml/blob/7ffca16bf558d2c3ee16181d926f066ab1de75b2/sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java#L271-L290
train
canhnt/sne-xacml
sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java
Interval.of
public static <T extends Comparable<T>> Interval<T> of(final T v) throws MIDDException { return new Interval(v); }
java
public static <T extends Comparable<T>> Interval<T> of(final T v) throws MIDDException { return new Interval(v); }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "T", ">", ">", "Interval", "<", "T", ">", "of", "(", "final", "T", "v", ")", "throws", "MIDDException", "{", "return", "new", "Interval", "(", "v", ")", ";", "}" ]
Create an interval with a single endpoint @param v @param <T> @return @throws MIDDException
[ "Create", "an", "interval", "with", "a", "single", "endpoint" ]
7ffca16bf558d2c3ee16181d926f066ab1de75b2
https://github.com/canhnt/sne-xacml/blob/7ffca16bf558d2c3ee16181d926f066ab1de75b2/sne-xacml/src/main/java/nl/uva/sne/midd/interval/Interval.java#L493-L495
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/CommandLogDispatcher.java
CommandLogDispatcher.logLocalCommands
public void logLocalCommands(final List<Command> commands) { if (singleValue == null) { return; } for (final Command command : commands) { if (command instanceof SetPropertyValue) { singleValue.logLocalCommand((SetPropertyValue) command); } else if (command instanceof ListCommand) { lists.logLocalCommand((ListCommand) command); } } }
java
public void logLocalCommands(final List<Command> commands) { if (singleValue == null) { return; } for (final Command command : commands) { if (command instanceof SetPropertyValue) { singleValue.logLocalCommand((SetPropertyValue) command); } else if (command instanceof ListCommand) { lists.logLocalCommand((ListCommand) command); } } }
[ "public", "void", "logLocalCommands", "(", "final", "List", "<", "Command", ">", "commands", ")", "{", "if", "(", "singleValue", "==", "null", ")", "{", "return", ";", "}", "for", "(", "final", "Command", "command", ":", "commands", ")", "{", "if", "("...
Logs a list of locally generated commands that is sent to the server. @param commands The commands that where send.
[ "Logs", "a", "list", "of", "locally", "generated", "commands", "that", "is", "sent", "to", "the", "server", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/CommandLogDispatcher.java#L72-L83
train
tvbarthel/Cheerleader
sample/src/main/java/fr/tvbarthel/cheerleader/sampleapp/ui/TrackView.java
TrackView.setModel
public void setModel(SoundCloudTrack track) { mModel = track; if (mModel != null) { Picasso.with(getContext()) .load(SoundCloudArtworkHelper.getArtworkUrl(mModel, SoundCloudArtworkHelper.XLARGE)) .placeholder(R.color.grey_light) .fit() .centerInside() .into(mArtwork); mArtist.setText(mModel.getArtist()); mTitle.setText(mModel.getTitle()); long min = mModel.getDurationInMilli() / 60000; long sec = (mModel.getDurationInMilli() % 60000) / 1000; mDuration.setText(String.format(getResources().getString(R.string.duration), min, sec)); } }
java
public void setModel(SoundCloudTrack track) { mModel = track; if (mModel != null) { Picasso.with(getContext()) .load(SoundCloudArtworkHelper.getArtworkUrl(mModel, SoundCloudArtworkHelper.XLARGE)) .placeholder(R.color.grey_light) .fit() .centerInside() .into(mArtwork); mArtist.setText(mModel.getArtist()); mTitle.setText(mModel.getTitle()); long min = mModel.getDurationInMilli() / 60000; long sec = (mModel.getDurationInMilli() % 60000) / 1000; mDuration.setText(String.format(getResources().getString(R.string.duration), min, sec)); } }
[ "public", "void", "setModel", "(", "SoundCloudTrack", "track", ")", "{", "mModel", "=", "track", ";", "if", "(", "mModel", "!=", "null", ")", "{", "Picasso", ".", "with", "(", "getContext", "(", ")", ")", ".", "load", "(", "SoundCloudArtworkHelper", ".",...
Set the track which must be displayed. @param track view model.
[ "Set", "the", "track", "which", "must", "be", "displayed", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/sample/src/main/java/fr/tvbarthel/cheerleader/sampleapp/ui/TrackView.java#L96-L111
train
tvbarthel/Cheerleader
sample/src/main/java/fr/tvbarthel/cheerleader/sampleapp/ui/PlaybackView.java
PlaybackView.setTrack
private void setTrack(SoundCloudTrack track) { if (track == null) { mTitle.setText(""); mArtwork.setImageDrawable(null); mPlayPause.setImageResource(R.drawable.ic_play_white); mSeekBar.setProgress(0); String none = String.format(getResources().getString(R.string.playback_view_time), 0, 0); mCurrentTime.setText(none); mDuration.setText(none); } else { Picasso.with(getContext()) .load(SoundCloudArtworkHelper.getArtworkUrl(track, SoundCloudArtworkHelper.XLARGE)) .fit() .centerCrop() .placeholder(R.color.grey) .into(mArtwork); mTitle.setText(Html.fromHtml(String.format(getResources().getString(R.string.playback_view_title), track.getArtist(), track.getTitle()))); mPlayPause.setImageResource(R.drawable.ic_pause_white); if (getTranslationY() != 0) { this.animate().translationY(0); } mSeekBar.setMax(((int) track.getDurationInMilli())); String none = String.format(getResources().getString(R.string.playback_view_time), 0, 0); int[] secondMinute = getSecondMinutes(track.getDurationInMilli()); String duration = String.format(getResources().getString(R.string.playback_view_time), secondMinute[0], secondMinute[1]); mCurrentTime.setText(none); mDuration.setText(duration); } }
java
private void setTrack(SoundCloudTrack track) { if (track == null) { mTitle.setText(""); mArtwork.setImageDrawable(null); mPlayPause.setImageResource(R.drawable.ic_play_white); mSeekBar.setProgress(0); String none = String.format(getResources().getString(R.string.playback_view_time), 0, 0); mCurrentTime.setText(none); mDuration.setText(none); } else { Picasso.with(getContext()) .load(SoundCloudArtworkHelper.getArtworkUrl(track, SoundCloudArtworkHelper.XLARGE)) .fit() .centerCrop() .placeholder(R.color.grey) .into(mArtwork); mTitle.setText(Html.fromHtml(String.format(getResources().getString(R.string.playback_view_title), track.getArtist(), track.getTitle()))); mPlayPause.setImageResource(R.drawable.ic_pause_white); if (getTranslationY() != 0) { this.animate().translationY(0); } mSeekBar.setMax(((int) track.getDurationInMilli())); String none = String.format(getResources().getString(R.string.playback_view_time), 0, 0); int[] secondMinute = getSecondMinutes(track.getDurationInMilli()); String duration = String.format(getResources().getString(R.string.playback_view_time), secondMinute[0], secondMinute[1]); mCurrentTime.setText(none); mDuration.setText(duration); } }
[ "private", "void", "setTrack", "(", "SoundCloudTrack", "track", ")", "{", "if", "(", "track", "==", "null", ")", "{", "mTitle", ".", "setText", "(", "\"\"", ")", ";", "mArtwork", ".", "setImageDrawable", "(", "null", ")", ";", "mPlayPause", ".", "setImag...
Set the current played track. @param track track which is played.
[ "Set", "the", "current", "played", "track", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/sample/src/main/java/fr/tvbarthel/cheerleader/sampleapp/ui/PlaybackView.java#L229-L259
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/FinalFlags.java
FinalFlags.getFinalReason
public String getFinalReason(Path path) { StringBuilder sb = new StringBuilder(path + " cannot be modified; "); StringBuilder finalPath = new StringBuilder("/"); // Step through the nodes based on the given path. If any intermediate // nodes are marked as final, we can just return true. Node currentNode = root; for (Term t : path.getTerms()) { finalPath.append(t.toString()); Node nextNode = currentNode.getChild(t); if (nextNode == null) { return null; } else if (nextNode.isFinal()) { sb.append(finalPath.toString() + " is marked as final"); return sb.toString(); } finalPath.append("/"); currentNode = nextNode; } // Strip off the last slash. It is not needed. finalPath.deleteCharAt(finalPath.length() - 1); // Either the path itself is final or a descendant. if (currentNode.isFinal()) { sb.append(finalPath.toString() + " is marked as final"); } else if (currentNode.hasChild()) { sb.append(finalPath.toString() + currentNode.getFinalDescendantPath() + " is marked as final"); return sb.toString(); } else { return null; } return null; }
java
public String getFinalReason(Path path) { StringBuilder sb = new StringBuilder(path + " cannot be modified; "); StringBuilder finalPath = new StringBuilder("/"); // Step through the nodes based on the given path. If any intermediate // nodes are marked as final, we can just return true. Node currentNode = root; for (Term t : path.getTerms()) { finalPath.append(t.toString()); Node nextNode = currentNode.getChild(t); if (nextNode == null) { return null; } else if (nextNode.isFinal()) { sb.append(finalPath.toString() + " is marked as final"); return sb.toString(); } finalPath.append("/"); currentNode = nextNode; } // Strip off the last slash. It is not needed. finalPath.deleteCharAt(finalPath.length() - 1); // Either the path itself is final or a descendant. if (currentNode.isFinal()) { sb.append(finalPath.toString() + " is marked as final"); } else if (currentNode.hasChild()) { sb.append(finalPath.toString() + currentNode.getFinalDescendantPath() + " is marked as final"); return sb.toString(); } else { return null; } return null; }
[ "public", "String", "getFinalReason", "(", "Path", "path", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "path", "+", "\" cannot be modified; \"", ")", ";", "StringBuilder", "finalPath", "=", "new", "StringBuilder", "(", "\"/\"", ")", ";", ...
Return a String with a message indicating why the given path is final. @param path Path to check @return String reason why the path is final or null if the path isn't final
[ "Return", "a", "String", "with", "a", "message", "indicating", "why", "the", "given", "path", "is", "final", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/FinalFlags.java#L89-L126
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/FinalFlags.java
FinalFlags.setFinal
public void setFinal(Path path) { // Step through the nodes creating any nodes which don't exist. Node currentNode = root; for (Term t : path.getTerms()) { Node nextNode = currentNode.getChild(t); if (nextNode == null) { nextNode = currentNode.newChild(t); } currentNode = nextNode; } // The current node is now the one corresponding to the last term in the // path. Set this as final. currentNode.setFinal(); }
java
public void setFinal(Path path) { // Step through the nodes creating any nodes which don't exist. Node currentNode = root; for (Term t : path.getTerms()) { Node nextNode = currentNode.getChild(t); if (nextNode == null) { nextNode = currentNode.newChild(t); } currentNode = nextNode; } // The current node is now the one corresponding to the last term in the // path. Set this as final. currentNode.setFinal(); }
[ "public", "void", "setFinal", "(", "Path", "path", ")", "{", "// Step through the nodes creating any nodes which don't exist.", "Node", "currentNode", "=", "root", ";", "for", "(", "Term", "t", ":", "path", ".", "getTerms", "(", ")", ")", "{", "Node", "nextNode"...
Mark the given Path as being final. @param path Path to mark as final
[ "Mark", "the", "given", "Path", "as", "being", "final", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/FinalFlags.java#L134-L149
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/Path.java
Path.toList
public List<String> toList() { List<String> list = new LinkedList<String>(); if (authority != null) { list.add(authority); } for (Term t : terms) { list.add(t.toString()); } return list; }
java
public List<String> toList() { List<String> list = new LinkedList<String>(); if (authority != null) { list.add(authority); } for (Term t : terms) { list.add(t.toString()); } return list; }
[ "public", "List", "<", "String", ">", "toList", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "if", "(", "authority", "!=", "null", ")", "{", "list", ".", "add", "(", "authority", ...
This method returns the Path as an unmodifiable list of the terms comprising the Path.
[ "This", "method", "returns", "the", "Path", "as", "an", "unmodifiable", "list", "of", "the", "terms", "comprising", "the", "Path", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/Path.java#L240-L249
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/Path.java
Path.compareTo
public int compareTo(Path o) { // Sanity check. if (o == null) { throw new NullPointerException(); } // If these are not the same type, do the simple comparison. if (this.type != o.type) { return type.compareTo(o.type); } // Same type of path, so check first the number of terms. If not equal, // then it is easy to decide the order. (Longer paths come before // shorter ones.) int mySize = this.terms.length; int otherSize = o.terms.length; if (mySize != otherSize) { return (mySize < otherSize) ? 1 : -1; } // Ok, the hard case, the two paths are of the same type and have the // same number of terms. for (int i = 0; i < mySize; i++) { Term myTerm = this.terms[i]; Term otherTerm = o.terms[i]; int comparison = myTerm.compareTo(otherTerm); if (comparison != 0) { return comparison; } } // We've gone through all of the checks, so the two paths must be equal; // return zero. return 0; }
java
public int compareTo(Path o) { // Sanity check. if (o == null) { throw new NullPointerException(); } // If these are not the same type, do the simple comparison. if (this.type != o.type) { return type.compareTo(o.type); } // Same type of path, so check first the number of terms. If not equal, // then it is easy to decide the order. (Longer paths come before // shorter ones.) int mySize = this.terms.length; int otherSize = o.terms.length; if (mySize != otherSize) { return (mySize < otherSize) ? 1 : -1; } // Ok, the hard case, the two paths are of the same type and have the // same number of terms. for (int i = 0; i < mySize; i++) { Term myTerm = this.terms[i]; Term otherTerm = o.terms[i]; int comparison = myTerm.compareTo(otherTerm); if (comparison != 0) { return comparison; } } // We've gone through all of the checks, so the two paths must be equal; // return zero. return 0; }
[ "public", "int", "compareTo", "(", "Path", "o", ")", "{", "// Sanity check.", "if", "(", "o", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "// If these are not the same type, do the simple comparison.", "if", "(", "this", "...
The default ordering for paths is such that it will produce a post-traversal ordering. All relative paths will be before absolute paths which are before external paths.
[ "The", "default", "ordering", "for", "paths", "is", "such", "that", "it", "will", "produce", "a", "post", "-", "traversal", "ordering", ".", "All", "relative", "paths", "will", "be", "before", "absolute", "paths", "which", "are", "before", "external", "paths...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/Path.java#L404-L439
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionReceiver.java
MediaSessionReceiver.sendAction
private void sendAction(Context context, String action) { Intent intent = new Intent(context, PlaybackService.class); intent.setAction(action); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }
java
private void sendAction(Context context, String action) { Intent intent = new Intent(context, PlaybackService.class); intent.setAction(action); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }
[ "private", "void", "sendAction", "(", "Context", "context", ",", "String", "action", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "context", ",", "PlaybackService", ".", "class", ")", ";", "intent", ".", "setAction", "(", "action", ")", ";", ...
Propagate lock screen event to the player. @param context context used to start service. @param action action to send.
[ "Propagate", "lock", "screen", "event", "to", "the", "player", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionReceiver.java#L58-L62
train
quattor/pan
panc/src/main/java/org/quattor/pan/CompilerStatistics.java
CompilerStatistics.updateMemoryInfo
public void updateMemoryInfo() { MemoryMXBean meminfo = ManagementFactory.getMemoryMXBean(); MemoryUsage usage = meminfo.getHeapMemoryUsage(); long _heapUsed = usage.getUsed(); updateMaximum(heapUsed, _heapUsed); updateMaximum(heapTotal, usage.getMax()); usage = meminfo.getNonHeapMemoryUsage(); updateMaximum(nonHeapUsed, usage.getUsed()); updateMaximum(nonHeapTotal, usage.getMax()); // Log the memory usage if requested. Check the log level before logging // to minimize object creation overheads during preparation of the call // parameters. if (memoryLogger.isLoggable(Level.INFO)) { memoryLogger.log(Level.INFO, "MEM", new Object[] { _heapUsed }); } }
java
public void updateMemoryInfo() { MemoryMXBean meminfo = ManagementFactory.getMemoryMXBean(); MemoryUsage usage = meminfo.getHeapMemoryUsage(); long _heapUsed = usage.getUsed(); updateMaximum(heapUsed, _heapUsed); updateMaximum(heapTotal, usage.getMax()); usage = meminfo.getNonHeapMemoryUsage(); updateMaximum(nonHeapUsed, usage.getUsed()); updateMaximum(nonHeapTotal, usage.getMax()); // Log the memory usage if requested. Check the log level before logging // to minimize object creation overheads during preparation of the call // parameters. if (memoryLogger.isLoggable(Level.INFO)) { memoryLogger.log(Level.INFO, "MEM", new Object[] { _heapUsed }); } }
[ "public", "void", "updateMemoryInfo", "(", ")", "{", "MemoryMXBean", "meminfo", "=", "ManagementFactory", ".", "getMemoryMXBean", "(", ")", ";", "MemoryUsage", "usage", "=", "meminfo", ".", "getHeapMemoryUsage", "(", ")", ";", "long", "_heapUsed", "=", "usage", ...
Take a snapshot of the current memory usage of the JVM and update the high-water marks.
[ "Take", "a", "snapshot", "of", "the", "current", "memory", "usage", "of", "the", "JVM", "and", "update", "the", "high", "-", "water", "marks", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/CompilerStatistics.java#L122-L141
train
quattor/pan
panc/src/main/java/org/quattor/pan/CompilerStatistics.java
CompilerStatistics.updateMaximum
private static void updateMaximum(AtomicLong counter, long currentValue) { boolean unset = true; long counterValue = counter.get(); while ((currentValue > counterValue) && unset) { unset = !counter.compareAndSet(counterValue, currentValue); counterValue = counter.get(); } }
java
private static void updateMaximum(AtomicLong counter, long currentValue) { boolean unset = true; long counterValue = counter.get(); while ((currentValue > counterValue) && unset) { unset = !counter.compareAndSet(counterValue, currentValue); counterValue = counter.get(); } }
[ "private", "static", "void", "updateMaximum", "(", "AtomicLong", "counter", ",", "long", "currentValue", ")", "{", "boolean", "unset", "=", "true", ";", "long", "counterValue", "=", "counter", ".", "get", "(", ")", ";", "while", "(", "(", "currentValue", "...
Compares the current value against the value of the counter and updates the counter if the current value is greater. This is done in a way to ensure that no updates are lost. @param counter AtomicLong counter to update @param currentValue current value of the counter
[ "Compares", "the", "current", "value", "against", "the", "value", "of", "the", "counter", "and", "updates", "the", "counter", "if", "the", "current", "value", "is", "greater", ".", "This", "is", "done", "in", "a", "way", "to", "ensure", "that", "no", "up...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/CompilerStatistics.java#L153-L160
train
quattor/pan
panc/src/main/java/org/quattor/pan/CompilerStatistics.java
CompilerStatistics.getResults
public String getResults(long totalErrors) { Object[] info = { fileCount, doneTasks.get(COMPILED).get(), startedTasks.get(COMPILED).get(), doneTasks.get(ANNOTATION).get(), startedTasks.get(ANNOTATION).get(), doneTasks.get(XML).get(), startedTasks.get(XML).get(), doneTasks.get(DEP).get(), startedTasks.get(DEP).get(), totalErrors, buildTime, convertToMB(heapUsed.get()), convertToMB(heapTotal.get()), convertToMB(nonHeapUsed.get()), convertToMB(nonHeapTotal.get()) }; return MessageUtils.format(MSG_STATISTICS_TEMPLATE, info); }
java
public String getResults(long totalErrors) { Object[] info = { fileCount, doneTasks.get(COMPILED).get(), startedTasks.get(COMPILED).get(), doneTasks.get(ANNOTATION).get(), startedTasks.get(ANNOTATION).get(), doneTasks.get(XML).get(), startedTasks.get(XML).get(), doneTasks.get(DEP).get(), startedTasks.get(DEP).get(), totalErrors, buildTime, convertToMB(heapUsed.get()), convertToMB(heapTotal.get()), convertToMB(nonHeapUsed.get()), convertToMB(nonHeapTotal.get()) }; return MessageUtils.format(MSG_STATISTICS_TEMPLATE, info); }
[ "public", "String", "getResults", "(", "long", "totalErrors", ")", "{", "Object", "[", "]", "info", "=", "{", "fileCount", ",", "doneTasks", ".", "get", "(", "COMPILED", ")", ".", "get", "(", ")", ",", "startedTasks", ".", "get", "(", "COMPILED", ")", ...
Generates a terse String representation of the statistics. @param totalErrors total number of errors that have occurred @return statistics as a String value
[ "Generates", "a", "terse", "String", "representation", "of", "the", "statistics", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/CompilerStatistics.java#L168-L180
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/DomainModelServer.java
DomainModelServer.onConnect
@Override public void onConnect(final Object newClient) { meta.commandsForDomainModel(new CommandsForDomainModelCallback() { @Override public void commandsReady(final List<Command> commands) { networkLayer.onConnectFinished(newClient); networkLayer.send(commands, newClient); } }); // TODO networkLayer onConnectFinished(); javadoc that networklayer should then enable sendToAll for new // client. }
java
@Override public void onConnect(final Object newClient) { meta.commandsForDomainModel(new CommandsForDomainModelCallback() { @Override public void commandsReady(final List<Command> commands) { networkLayer.onConnectFinished(newClient); networkLayer.send(commands, newClient); } }); // TODO networkLayer onConnectFinished(); javadoc that networklayer should then enable sendToAll for new // client. }
[ "@", "Override", "public", "void", "onConnect", "(", "final", "Object", "newClient", ")", "{", "meta", ".", "commandsForDomainModel", "(", "new", "CommandsForDomainModelCallback", "(", ")", "{", "@", "Override", "public", "void", "commandsReady", "(", "final", "...
Sends the current domain model to a newly connecting client. @param newClient An object that represent the new client that connected. @see IncommingEventHandlerServer#onConnect(Object)
[ "Sends", "the", "current", "domain", "model", "to", "a", "newly", "connecting", "client", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/DomainModelServer.java#L167-L179
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/DomainModelServer.java
DomainModelServer.onClientConnectionError
@Override public void onClientConnectionError(final Object client, final SynchronizeFXException e) { serverCallback.onClientConnectionError(client, e); }
java
@Override public void onClientConnectionError(final Object client, final SynchronizeFXException e) { serverCallback.onClientConnectionError(client, e); }
[ "@", "Override", "public", "void", "onClientConnectionError", "(", "final", "Object", "client", ",", "final", "SynchronizeFXException", "e", ")", "{", "serverCallback", ".", "onClientConnectionError", "(", "client", ",", "e", ")", ";", "}" ]
Logs the unexpected disconnection of an client. Connection errors to single clients are usually non fatal. The server can still work correctly for the other clients. Because of that this type of error is just logged here and not passed to the user. @param client An object that represent the client where the error occurred. @param e an exception that describes the problem. @see NetworkToTopologyCallbackServer#onClientConnectionError(SynchronizeFXException)
[ "Logs", "the", "unexpected", "disconnection", "of", "an", "client", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/DomainModelServer.java#L191-L194
train
quattor/pan
panc/src/main/java/org/quattor/pan/type/RecordType.java
RecordType.removeDefinedFields
private void removeDefinedFields(Context context, List<Term> undefinedFields) throws ValidationException { // Loop through all of the required and optional fields removing each // from the list of undefined fields. for (Term term : reqKeys) { undefinedFields.remove(term); } for (Term term : optKeys) { undefinedFields.remove(term); } // Now we must apply this method to any included types as well. for (String s : includes) { try { // Pull out the type and base type of the included type. // Ensure that the base type is a record definition. FullType fullType = context.getFullType(s); BaseType baseType = fullType.getBaseType(); RecordType recordType = (RecordType) baseType; recordType.removeDefinedFields(context, undefinedFields); } catch (ClassCastException cce) { // Should have been checked when the type was defined. throw CompilerError.create(MSG_NONRECORD_TYPE_REF, s); } catch (NullPointerException npe) { // Should have been checked when the type was defined. throw CompilerError.create(MSG_NONEXISTANT_REFERENCED_TYPE, s); } } }
java
private void removeDefinedFields(Context context, List<Term> undefinedFields) throws ValidationException { // Loop through all of the required and optional fields removing each // from the list of undefined fields. for (Term term : reqKeys) { undefinedFields.remove(term); } for (Term term : optKeys) { undefinedFields.remove(term); } // Now we must apply this method to any included types as well. for (String s : includes) { try { // Pull out the type and base type of the included type. // Ensure that the base type is a record definition. FullType fullType = context.getFullType(s); BaseType baseType = fullType.getBaseType(); RecordType recordType = (RecordType) baseType; recordType.removeDefinedFields(context, undefinedFields); } catch (ClassCastException cce) { // Should have been checked when the type was defined. throw CompilerError.create(MSG_NONRECORD_TYPE_REF, s); } catch (NullPointerException npe) { // Should have been checked when the type was defined. throw CompilerError.create(MSG_NONEXISTANT_REFERENCED_TYPE, s); } } }
[ "private", "void", "removeDefinedFields", "(", "Context", "context", ",", "List", "<", "Term", ">", "undefinedFields", ")", "throws", "ValidationException", "{", "// Loop through all of the required and optional fields removing each", "// from the list of undefined fields.", "for...
This method will loop through all of the fields defined in this record and remove them from the given list. This is used in the validation of the fields. @param context ObjectContext to use to look up included type definitions @param undefinedFields List containing the field names to check; defined fields are removed directly from the list
[ "This", "method", "will", "loop", "through", "all", "of", "the", "fields", "defined", "in", "this", "record", "and", "remove", "them", "from", "the", "given", "list", ".", "This", "is", "used", "in", "the", "validation", "of", "the", "fields", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/type/RecordType.java#L317-L352
train
quattor/pan
panc/src/main/java/org/quattor/pan/CompilerLogging.java
CompilerLogging.activateLoggers
public static void activateLoggers(String loggerList) { // Create an empty set. This will contain the list of all of the loggers // to activate. (Note that NONE may be a logger; in this case, all // logging will be deactivated.) EnumSet<LoggingType> flags = EnumSet.noneOf(LoggingType.class); // Split on commas and remove white space. for (String name : loggerList.split("\\s*,\\s*")) { try { flags.add(LoggingType.valueOf(name.trim().toUpperCase())); } catch (IllegalArgumentException consumed) { } } // Loop over the flags, enabling each one. for (LoggingType type : flags) { type.activate(); } }
java
public static void activateLoggers(String loggerList) { // Create an empty set. This will contain the list of all of the loggers // to activate. (Note that NONE may be a logger; in this case, all // logging will be deactivated.) EnumSet<LoggingType> flags = EnumSet.noneOf(LoggingType.class); // Split on commas and remove white space. for (String name : loggerList.split("\\s*,\\s*")) { try { flags.add(LoggingType.valueOf(name.trim().toUpperCase())); } catch (IllegalArgumentException consumed) { } } // Loop over the flags, enabling each one. for (LoggingType type : flags) { type.activate(); } }
[ "public", "static", "void", "activateLoggers", "(", "String", "loggerList", ")", "{", "// Create an empty set. This will contain the list of all of the loggers", "// to activate. (Note that NONE may be a logger; in this case, all", "// logging will be deactivated.)", "EnumSet", "<", "Log...
Enable the given types of logging. Note that NONE will take precedence over active logging flags and turn all logging off. Illegal logging values will be silently ignored. @param loggerList a comma-separated list of logging types to enable
[ "Enable", "the", "given", "types", "of", "logging", ".", "Note", "that", "NONE", "will", "take", "precedence", "over", "active", "logging", "flags", "and", "turn", "all", "logging", "off", ".", "Illegal", "logging", "values", "will", "be", "silently", "ignor...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/CompilerLogging.java#L134-L154
train
quattor/pan
panc/src/main/java/org/quattor/pan/CompilerLogging.java
CompilerLogging.initializeLogger
private static void initializeLogger(Logger logger) { // Do NOT send any logging information to parent loggers. topLogger.setUseParentHandlers(false); // Remove any existing handlers. for (Handler handler : topLogger.getHandlers()) { try { topLogger.removeHandler(handler); } catch (SecurityException consumed) { System.err .println("WARNING: missing 'LoggingPermission(\"control\")' permission"); } } }
java
private static void initializeLogger(Logger logger) { // Do NOT send any logging information to parent loggers. topLogger.setUseParentHandlers(false); // Remove any existing handlers. for (Handler handler : topLogger.getHandlers()) { try { topLogger.removeHandler(handler); } catch (SecurityException consumed) { System.err .println("WARNING: missing 'LoggingPermission(\"control\")' permission"); } } }
[ "private", "static", "void", "initializeLogger", "(", "Logger", "logger", ")", "{", "// Do NOT send any logging information to parent loggers.", "topLogger", ".", "setUseParentHandlers", "(", "false", ")", ";", "// Remove any existing handlers.", "for", "(", "Handler", "han...
Remove all handlers associated with the given logger.
[ "Remove", "all", "handlers", "associated", "with", "the", "given", "logger", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/CompilerLogging.java#L159-L174
train
quattor/pan
panc/src/main/java/org/quattor/pan/CompilerLogging.java
CompilerLogging.setLogFile
public synchronized static void setLogFile(File logfile) { // Add a file logger that will use the compiler's customized // formatter. This formatter provides a terse representation of the // logging information. try { if (logfile != null) { String absolutePath = logfile.getAbsolutePath(); if (initializedLogFile == null || (!initializedLogFile.equals(absolutePath))) { // Remove any existing handlers. initializeLogger(topLogger); // Set the new handler. FileHandler handler = new FileHandler(absolutePath); handler.setFormatter(new LogFormatter()); topLogger.addHandler(handler); // Make sure we save the name of the log file to avoid // inappropriate reinitialization. initializedLogFile = absolutePath; } } } catch (IOException consumed) { StringBuilder sb = new StringBuilder(); sb.append("WARNING: unable to open logging file handler\n"); sb.append("WARNING: logfile = '" + logfile.getAbsolutePath() + "'"); sb.append("\nWARNING: message = "); sb.append(consumed.getMessage()); System.err.println(sb.toString()); } }
java
public synchronized static void setLogFile(File logfile) { // Add a file logger that will use the compiler's customized // formatter. This formatter provides a terse representation of the // logging information. try { if (logfile != null) { String absolutePath = logfile.getAbsolutePath(); if (initializedLogFile == null || (!initializedLogFile.equals(absolutePath))) { // Remove any existing handlers. initializeLogger(topLogger); // Set the new handler. FileHandler handler = new FileHandler(absolutePath); handler.setFormatter(new LogFormatter()); topLogger.addHandler(handler); // Make sure we save the name of the log file to avoid // inappropriate reinitialization. initializedLogFile = absolutePath; } } } catch (IOException consumed) { StringBuilder sb = new StringBuilder(); sb.append("WARNING: unable to open logging file handler\n"); sb.append("WARNING: logfile = '" + logfile.getAbsolutePath() + "'"); sb.append("\nWARNING: message = "); sb.append(consumed.getMessage()); System.err.println(sb.toString()); } }
[ "public", "synchronized", "static", "void", "setLogFile", "(", "File", "logfile", ")", "{", "// Add a file logger that will use the compiler's customized", "// formatter. This formatter provides a terse representation of the", "// logging information.", "try", "{", "if", "(", "logf...
Define the file that will contain the logging information. If this is called with null, then the log file will be removed. The log file and logging parameters are global to the JVM. Interference is possible between multiple threads. @param logfile File indicating the log file to use
[ "Define", "the", "file", "that", "will", "contain", "the", "logging", "information", ".", "If", "this", "is", "called", "with", "null", "then", "the", "log", "file", "will", "be", "removed", ".", "The", "log", "file", "and", "logging", "parameters", "are",...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/CompilerLogging.java#L184-L218
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/offline/OfflinerQueryHandler.java
OfflinerQueryHandler.put
public void put(String url, String result) { if (TextUtils.isEmpty(url)) { return; } ContentValues contentValues = new ContentValues(); contentValues.put(OfflinerDBHelper.REQUEST_RESULT, result); contentValues.put(OfflinerDBHelper.REQUEST_URL, url); contentValues.put(OfflinerDBHelper.REQUEST_TIMESTAMP, Calendar.getInstance().getTime().getTime()); this.startQuery( TOKEN_CHECK_SAVED_STATUS, contentValues, getUri(OfflinerDBHelper.TABLE_CACHE), OfflinerDBHelper.PARAMS_CACHE, OfflinerDBHelper.REQUEST_URL + " = '" + url + "'", null, null ); }
java
public void put(String url, String result) { if (TextUtils.isEmpty(url)) { return; } ContentValues contentValues = new ContentValues(); contentValues.put(OfflinerDBHelper.REQUEST_RESULT, result); contentValues.put(OfflinerDBHelper.REQUEST_URL, url); contentValues.put(OfflinerDBHelper.REQUEST_TIMESTAMP, Calendar.getInstance().getTime().getTime()); this.startQuery( TOKEN_CHECK_SAVED_STATUS, contentValues, getUri(OfflinerDBHelper.TABLE_CACHE), OfflinerDBHelper.PARAMS_CACHE, OfflinerDBHelper.REQUEST_URL + " = '" + url + "'", null, null ); }
[ "public", "void", "put", "(", "String", "url", ",", "String", "result", ")", "{", "if", "(", "TextUtils", ".", "isEmpty", "(", "url", ")", ")", "{", "return", ";", "}", "ContentValues", "contentValues", "=", "new", "ContentValues", "(", ")", ";", "cont...
Save a result for offline access. @param url key. @param result value.
[ "Save", "a", "result", "for", "offline", "access", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/offline/OfflinerQueryHandler.java#L146-L165
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/offline/OfflinerQueryHandler.java
OfflinerQueryHandler.get
public String get(Context context, String url) { final Cursor cursor = context.getContentResolver().query(getUri(OfflinerDBHelper.TABLE_CACHE), OfflinerDBHelper.PARAMS_CACHE, OfflinerDBHelper.REQUEST_URL + " = '" + url + "'", null, null); String result = null; if (cursor != null) { if (cursor.getCount() != 0) { cursor.moveToFirst(); result = cursor.getString(cursor.getColumnIndex(OfflinerDBHelper.REQUEST_RESULT)); } cursor.close(); } return result; }
java
public String get(Context context, String url) { final Cursor cursor = context.getContentResolver().query(getUri(OfflinerDBHelper.TABLE_CACHE), OfflinerDBHelper.PARAMS_CACHE, OfflinerDBHelper.REQUEST_URL + " = '" + url + "'", null, null); String result = null; if (cursor != null) { if (cursor.getCount() != 0) { cursor.moveToFirst(); result = cursor.getString(cursor.getColumnIndex(OfflinerDBHelper.REQUEST_RESULT)); } cursor.close(); } return result; }
[ "public", "String", "get", "(", "Context", "context", ",", "String", "url", ")", "{", "final", "Cursor", "cursor", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "getUri", "(", "OfflinerDBHelper", ".", "TABLE_CACHE", ")", ",", "Off...
Retrieve a value saved for offline access. @param context context used to retrieve the content resolver. @param url key. @return retrieved value or null if no entry match the given key.
[ "Retrieve", "a", "value", "saved", "for", "offline", "access", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/offline/OfflinerQueryHandler.java#L174-L189
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/offline/OfflinerQueryHandler.java
OfflinerQueryHandler.getUri
private Uri getUri(String string) { return Uri.parse(OfflinerProvider.CONTENT + OfflinerProvider.getAuthority(mPackageName) + OfflinerProvider.SLASH + string); }
java
private Uri getUri(String string) { return Uri.parse(OfflinerProvider.CONTENT + OfflinerProvider.getAuthority(mPackageName) + OfflinerProvider.SLASH + string); }
[ "private", "Uri", "getUri", "(", "String", "string", ")", "{", "return", "Uri", ".", "parse", "(", "OfflinerProvider", ".", "CONTENT", "+", "OfflinerProvider", ".", "getAuthority", "(", "mPackageName", ")", "+", "OfflinerProvider", ".", "SLASH", "+", "string",...
Retrieve the URI with Cache database provider authority. @param string ends of the URI. @return full build URI.
[ "Retrieve", "the", "URI", "with", "Cache", "database", "provider", "authority", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/offline/OfflinerQueryHandler.java#L197-L200
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/remote/RemoteControlClientCompat.java
RemoteControlClientCompat.setPlaybackState
public void setPlaybackState(int state) { if (sHasRemoteControlAPIs) { try { sRCCSetPlayStateMethod.invoke(mActualRemoteControlClient, state); } catch (Exception e) { throw new RuntimeException(e); } } }
java
public void setPlaybackState(int state) { if (sHasRemoteControlAPIs) { try { sRCCSetPlayStateMethod.invoke(mActualRemoteControlClient, state); } catch (Exception e) { throw new RuntimeException(e); } } }
[ "public", "void", "setPlaybackState", "(", "int", "state", ")", "{", "if", "(", "sHasRemoteControlAPIs", ")", "{", "try", "{", "sRCCSetPlayStateMethod", ".", "invoke", "(", "mActualRemoteControlClient", ",", "state", ")", ";", "}", "catch", "(", "Exception", "...
Sets the current playback state. @param state The current playback state, one of the following values: {@link android.media.RemoteControlClient#PLAYSTATE_STOPPED}, {@link android.media.RemoteControlClient#PLAYSTATE_PAUSED}, {@link android.media.RemoteControlClient#PLAYSTATE_PLAYING}, {@link android.media.RemoteControlClient#PLAYSTATE_FAST_FORWARDING} , {@link android.media.RemoteControlClient#PLAYSTATE_REWINDING} , {@link android.media.RemoteControlClient#PLAYSTATE_SKIPPING_FORWARDS} , {@link android.media.RemoteControlClient#PLAYSTATE_SKIPPING_BACKWARDS} , {@link android.media.RemoteControlClient#PLAYSTATE_BUFFERING} , {@link android.media.RemoteControlClient#PLAYSTATE_ERROR}.
[ "Sets", "the", "current", "playback", "state", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/remote/RemoteControlClientCompat.java#L325-L333
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/remote/RemoteControlClientCompat.java
RemoteControlClientCompat.setTransportControlFlags
public void setTransportControlFlags(int transportControlFlags) { if (sHasRemoteControlAPIs) { try { sRCCSetTransportControlFlags.invoke(mActualRemoteControlClient, transportControlFlags); } catch (Exception e) { throw new RuntimeException(e); } } }
java
public void setTransportControlFlags(int transportControlFlags) { if (sHasRemoteControlAPIs) { try { sRCCSetTransportControlFlags.invoke(mActualRemoteControlClient, transportControlFlags); } catch (Exception e) { throw new RuntimeException(e); } } }
[ "public", "void", "setTransportControlFlags", "(", "int", "transportControlFlags", ")", "{", "if", "(", "sHasRemoteControlAPIs", ")", "{", "try", "{", "sRCCSetTransportControlFlags", ".", "invoke", "(", "mActualRemoteControlClient", ",", "transportControlFlags", ")", ";...
Sets the flags for the media transport control buttons that this client supports. @param transportControlFlags A combination of the following flags: {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PREVIOUS} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_REWIND} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PLAY} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PLAY_PAUSE} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PAUSE} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_STOP} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_FAST_FORWARD} , {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_NEXT}
[ "Sets", "the", "flags", "for", "the", "media", "transport", "control", "buttons", "that", "this", "client", "supports", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/remote/RemoteControlClientCompat.java#L348-L357
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.onDestroy
@SuppressWarnings("deprecation") public void onDestroy() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); mAudioManager.unregisterMediaButtonEventReceiver(mMediaButtonReceiverComponent); mLocalBroadcastManager.unregisterReceiver(mLockScreenReceiver); } mMediaSession.release(); }
java
@SuppressWarnings("deprecation") public void onDestroy() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); mAudioManager.unregisterMediaButtonEventReceiver(mMediaButtonReceiverComponent); mLocalBroadcastManager.unregisterReceiver(mLockScreenReceiver); } mMediaSession.release(); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "void", "onDestroy", "(", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP", ")", "{", "mRemoteControlClientCompat", ".", "setPlayba...
Should be called to released the internal component.
[ "Should", "be", "called", "to", "released", "the", "internal", "component", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L149-L157
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.setMetaData
@SuppressWarnings("deprecation") public void setMetaData(SoundCloudTrack track, Bitmap artwork) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // set meta data on the lock screen for pre lollipop. mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); RemoteControlClientCompat.MetadataEditorCompat mediaEditorCompat = mRemoteControlClientCompat.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, track.getTitle()) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, track.getArtist()); if (artwork != null) { mediaEditorCompat.putBitmap( RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, artwork); } mediaEditorCompat.apply(); } // set meta data to the media session. MediaMetadataCompat.Builder metadataCompatBuilder = new MediaMetadataCompat.Builder() .putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.getTitle()) .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, track.getArtist()); if (artwork != null) { metadataCompatBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, artwork); } mMediaSession.setMetadata(metadataCompatBuilder.build()); setMediaSessionCompatPlaybackState(PlaybackStateCompat.STATE_PLAYING); }
java
@SuppressWarnings("deprecation") public void setMetaData(SoundCloudTrack track, Bitmap artwork) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // set meta data on the lock screen for pre lollipop. mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); RemoteControlClientCompat.MetadataEditorCompat mediaEditorCompat = mRemoteControlClientCompat.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, track.getTitle()) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, track.getArtist()); if (artwork != null) { mediaEditorCompat.putBitmap( RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, artwork); } mediaEditorCompat.apply(); } // set meta data to the media session. MediaMetadataCompat.Builder metadataCompatBuilder = new MediaMetadataCompat.Builder() .putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.getTitle()) .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, track.getArtist()); if (artwork != null) { metadataCompatBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, artwork); } mMediaSession.setMetadata(metadataCompatBuilder.build()); setMediaSessionCompatPlaybackState(PlaybackStateCompat.STATE_PLAYING); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "void", "setMetaData", "(", "SoundCloudTrack", "track", ",", "Bitmap", "artwork", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP",...
Update meta data used by the remote control client and the media session. @param track track currently played. @param artwork track artwork.
[ "Update", "meta", "data", "used", "by", "the", "remote", "control", "client", "and", "the", "media", "session", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L208-L234
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.setRemoteControlClientPlaybackState
private void setRemoteControlClientPlaybackState(int state) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mRemoteControlClientCompat.setPlaybackState(state); } }
java
private void setRemoteControlClientPlaybackState(int state) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mRemoteControlClientCompat.setPlaybackState(state); } }
[ "private", "void", "setRemoteControlClientPlaybackState", "(", "int", "state", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP", ")", "{", "mRemoteControlClientCompat", ".", "setPlaybackState", "(", ...
Propagate playback state to the remote control client on the lock screen. @param state playback state.
[ "Propagate", "playback", "state", "to", "the", "remote", "control", "client", "on", "the", "lock", "screen", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L241-L245
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.setMediaSessionCompatPlaybackState
private void setMediaSessionCompatPlaybackState(int state) { mStateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f); mMediaSession.setPlaybackState(mStateBuilder.build()); }
java
private void setMediaSessionCompatPlaybackState(int state) { mStateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f); mMediaSession.setPlaybackState(mStateBuilder.build()); }
[ "private", "void", "setMediaSessionCompatPlaybackState", "(", "int", "state", ")", "{", "mStateBuilder", ".", "setState", "(", "state", ",", "PlaybackStateCompat", ".", "PLAYBACK_POSITION_UNKNOWN", ",", "1.0f", ")", ";", "mMediaSession", ".", "setPlaybackState", "(", ...
Propagate playback state to the media session compat. @param state playback state.
[ "Propagate", "playback", "state", "to", "the", "media", "session", "compat", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L252-L255
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.initPlaybackStateBuilder
private void initPlaybackStateBuilder() { mStateBuilder = new PlaybackStateCompat.Builder(); mStateBuilder.setActions( PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS ); }
java
private void initPlaybackStateBuilder() { mStateBuilder = new PlaybackStateCompat.Builder(); mStateBuilder.setActions( PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS ); }
[ "private", "void", "initPlaybackStateBuilder", "(", ")", "{", "mStateBuilder", "=", "new", "PlaybackStateCompat", ".", "Builder", "(", ")", ";", "mStateBuilder", ".", "setActions", "(", "PlaybackStateCompat", ".", "ACTION_PLAY", "|", "PlaybackStateCompat", ".", "ACT...
Initialize the playback state builder with supported actions.
[ "Initialize", "the", "playback", "state", "builder", "with", "supported", "actions", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L260-L269
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.initLockScreenRemoteControlClient
@SuppressWarnings("deprecation") private void initLockScreenRemoteControlClient(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mMediaButtonReceiverComponent = new ComponentName( mRuntimePackageName, MediaSessionReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent); if (mRemoteControlClientCompat == null) { Intent remoteControlIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); remoteControlIntent.setComponent(mMediaButtonReceiverComponent); mRemoteControlClientCompat = new RemoteControlClientCompat( PendingIntent.getBroadcast(context, 0, remoteControlIntent, 0)); RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat); } mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); mRemoteControlClientCompat.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE); registerLockScreenReceiver(context); } }
java
@SuppressWarnings("deprecation") private void initLockScreenRemoteControlClient(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mMediaButtonReceiverComponent = new ComponentName( mRuntimePackageName, MediaSessionReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent); if (mRemoteControlClientCompat == null) { Intent remoteControlIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); remoteControlIntent.setComponent(mMediaButtonReceiverComponent); mRemoteControlClientCompat = new RemoteControlClientCompat( PendingIntent.getBroadcast(context, 0, remoteControlIntent, 0)); RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat); } mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); mRemoteControlClientCompat.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE); registerLockScreenReceiver(context); } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "private", "void", "initLockScreenRemoteControlClient", "(", "Context", "context", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP", ")", "{", ...
Initialize the remote control client on the lock screen. @param context holding context.
[ "Initialize", "the", "remote", "control", "client", "on", "the", "lock", "screen", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L276-L301
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java
MediaSessionWrapper.registerLockScreenReceiver
private void registerLockScreenReceiver(Context context) { mLockScreenReceiver = new LockScreenReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ACTION_TOGGLE_PLAYBACK); intentFilter.addAction(ACTION_NEXT_TRACK); intentFilter.addAction(ACTION_PREVIOUS_TRACK); mLocalBroadcastManager = LocalBroadcastManager.getInstance(context); mLocalBroadcastManager.registerReceiver(mLockScreenReceiver, intentFilter); }
java
private void registerLockScreenReceiver(Context context) { mLockScreenReceiver = new LockScreenReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ACTION_TOGGLE_PLAYBACK); intentFilter.addAction(ACTION_NEXT_TRACK); intentFilter.addAction(ACTION_PREVIOUS_TRACK); mLocalBroadcastManager = LocalBroadcastManager.getInstance(context); mLocalBroadcastManager.registerReceiver(mLockScreenReceiver, intentFilter); }
[ "private", "void", "registerLockScreenReceiver", "(", "Context", "context", ")", "{", "mLockScreenReceiver", "=", "new", "LockScreenReceiver", "(", ")", ";", "IntentFilter", "intentFilter", "=", "new", "IntentFilter", "(", ")", ";", "intentFilter", ".", "addAction",...
Register the lock screen receiver used to catch lock screen media buttons events. @param context holding context.
[ "Register", "the", "lock", "screen", "receiver", "used", "to", "catch", "lock", "screen", "media", "buttons", "events", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/media/MediaSessionWrapper.java#L308-L316
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ListCommandVersionRepairer.java
ListCommandVersionRepairer.repairLocalCommandsVersion
public void repairLocalCommandsVersion(final Queue<ListCommand> localCommands, final ListCommand originalRemoteCommand) { localCommands.add(repairCommand(localCommands.poll(), originalRemoteCommand.getListVersionChange() .getToVersion(), randomUUID())); final int count = localCommands.size(); for (int i = 1; i < count; i++) { localCommands.add(repairCommand(localCommands.poll(), randomUUID(), randomUUID())); } }
java
public void repairLocalCommandsVersion(final Queue<ListCommand> localCommands, final ListCommand originalRemoteCommand) { localCommands.add(repairCommand(localCommands.poll(), originalRemoteCommand.getListVersionChange() .getToVersion(), randomUUID())); final int count = localCommands.size(); for (int i = 1; i < count; i++) { localCommands.add(repairCommand(localCommands.poll(), randomUUID(), randomUUID())); } }
[ "public", "void", "repairLocalCommandsVersion", "(", "final", "Queue", "<", "ListCommand", ">", "localCommands", ",", "final", "ListCommand", "originalRemoteCommand", ")", "{", "localCommands", ".", "add", "(", "repairCommand", "(", "localCommands", ".", "poll", "("...
Updates the versions of repaired local commands that should be resent to the server so that they are based on the version the original remote command produced. @param localCommands The local commands that should be repaired. <b>WARNING:</b> The repaired commands are added directly to the queue again. @param originalRemoteCommand The remote command that contains the last known version of the list the server has.
[ "Updates", "the", "versions", "of", "repaired", "local", "commands", "that", "should", "be", "resent", "to", "the", "server", "so", "that", "they", "are", "based", "on", "the", "version", "the", "original", "remote", "command", "produced", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ListCommandVersionRepairer.java#L54-L64
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ListCommandVersionRepairer.java
ListCommandVersionRepairer.repairRemoteCommandVersion
public List<? extends ListCommand> repairRemoteCommandVersion( final List<? extends ListCommand> indexRepairedRemoteCommands, final List<ListCommand> versionRepairedLocalCommands) { final int commandCount = indexRepairedRemoteCommands.size(); final ListCommand lastLocalCommand = versionRepairedLocalCommands.get(versionRepairedLocalCommands.size() - 1); if (commandCount == 0) { return asList(new RemoveFromList(lastLocalCommand.getListId(), new ListVersionChange(randomUUID(), lastLocalCommand.getListVersionChange().getToVersion()), 0, 0)); } final List<ListCommand> repaired = new ArrayList<ListCommand>(commandCount); for (int i = 0; i < commandCount - 1; i++) { repaired.add(indexRepairedRemoteCommands.get(i)); } repaired.add(repairCommand(indexRepairedRemoteCommands.get(commandCount - 1), randomUUID(), lastLocalCommand .getListVersionChange().getToVersion())); return repaired; }
java
public List<? extends ListCommand> repairRemoteCommandVersion( final List<? extends ListCommand> indexRepairedRemoteCommands, final List<ListCommand> versionRepairedLocalCommands) { final int commandCount = indexRepairedRemoteCommands.size(); final ListCommand lastLocalCommand = versionRepairedLocalCommands.get(versionRepairedLocalCommands.size() - 1); if (commandCount == 0) { return asList(new RemoveFromList(lastLocalCommand.getListId(), new ListVersionChange(randomUUID(), lastLocalCommand.getListVersionChange().getToVersion()), 0, 0)); } final List<ListCommand> repaired = new ArrayList<ListCommand>(commandCount); for (int i = 0; i < commandCount - 1; i++) { repaired.add(indexRepairedRemoteCommands.get(i)); } repaired.add(repairCommand(indexRepairedRemoteCommands.get(commandCount - 1), randomUUID(), lastLocalCommand .getListVersionChange().getToVersion())); return repaired; }
[ "public", "List", "<", "?", "extends", "ListCommand", ">", "repairRemoteCommandVersion", "(", "final", "List", "<", "?", "extends", "ListCommand", ">", "indexRepairedRemoteCommands", ",", "final", "List", "<", "ListCommand", ">", "versionRepairedLocalCommands", ")", ...
Updates the version of the remote commands that should be executed locally to ensure that the local list version equals the version that is resent to the server when they are executed. @param indexRepairedRemoteCommands The remote commands thats indices where already repaired. This list can be empty. @param versionRepairedLocalCommands The local commands that should be resent to the server thats version was already repaired by this class. This queue must contain at least one element. @return The remote commands with repaired list versions.
[ "Updates", "the", "version", "of", "the", "remote", "commands", "that", "should", "be", "executed", "locally", "to", "ensure", "that", "the", "local", "list", "version", "equals", "the", "version", "that", "is", "resent", "to", "the", "server", "when", "they...
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ListCommandVersionRepairer.java#L77-L97
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/Range.java
Range.checkRangeValues
private void checkRangeValues(long minimum, long maximum) { if (minimum > maximum) { throw EvaluationException.create( MSG_MIN_MUST_BE_LESS_OR_EQUAL_TO_MAX, minimum, maximum); } }
java
private void checkRangeValues(long minimum, long maximum) { if (minimum > maximum) { throw EvaluationException.create( MSG_MIN_MUST_BE_LESS_OR_EQUAL_TO_MAX, minimum, maximum); } }
[ "private", "void", "checkRangeValues", "(", "long", "minimum", ",", "long", "maximum", ")", "{", "if", "(", "minimum", ">", "maximum", ")", "{", "throw", "EvaluationException", ".", "create", "(", "MSG_MIN_MUST_BE_LESS_OR_EQUAL_TO_MAX", ",", "minimum", ",", "max...
Checks whether the range values are valid. Specifically whether the minimum is less than or equal to the maximum. This will throw an EvaluationException if any problems are found. @param minimum @param maximum
[ "Checks", "whether", "the", "range", "values", "are", "valid", ".", "Specifically", "whether", "the", "minimum", "is", "less", "than", "or", "equal", "to", "the", "maximum", ".", "This", "will", "throw", "an", "EvaluationException", "if", "any", "problems", ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/Range.java#L133-L138
train
saxsys/SynchronizeFX
transmitter/tomcat-transmitter/src/main/java/de/saxsys/synchronizefx/tomcat/SynchronizeFXTomcatChannel.java
SynchronizeFXTomcatChannel.shutdown
@Override public void shutdown() { synchronized (connections) { parent.channelCloses(this); for (final MessageInbound connection : connections) { try { connection.getWsOutbound().close(0, null); } catch (final IOException e) { LOG.error("Connection [" + connection.toString() + "] can't be closed.", e); } finally { final ExecutorService executorService = connectionThreads.get(connection); if (executorService != null) { executorService.shutdown(); } connectionThreads.remove(connection); } } connections.clear(); } callback = null; }
java
@Override public void shutdown() { synchronized (connections) { parent.channelCloses(this); for (final MessageInbound connection : connections) { try { connection.getWsOutbound().close(0, null); } catch (final IOException e) { LOG.error("Connection [" + connection.toString() + "] can't be closed.", e); } finally { final ExecutorService executorService = connectionThreads.get(connection); if (executorService != null) { executorService.shutdown(); } connectionThreads.remove(connection); } } connections.clear(); } callback = null; }
[ "@", "Override", "public", "void", "shutdown", "(", ")", "{", "synchronized", "(", "connections", ")", "{", "parent", ".", "channelCloses", "(", "this", ")", ";", "for", "(", "final", "MessageInbound", "connection", ":", "connections", ")", "{", "try", "{"...
Disconnects all clients and makes the servlet refuse new connections.
[ "Disconnects", "all", "clients", "and", "makes", "the", "servlet", "refuse", "new", "connections", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/transmitter/tomcat-transmitter/src/main/java/de/saxsys/synchronizefx/tomcat/SynchronizeFXTomcatChannel.java#L143-L163
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.setPropertyValue
public List<Command> setPropertyValue(final UUID propertyId, final Object value) throws SynchronizeFXException { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { setPropertyValue(propertyId, value, state); } }, true); return state.commands; }
java
public List<Command> setPropertyValue(final UUID propertyId, final Object value) throws SynchronizeFXException { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { setPropertyValue(propertyId, value, state); } }, true); return state.commands; }
[ "public", "List", "<", "Command", ">", "setPropertyValue", "(", "final", "UUID", "propertyId", ",", "final", "Object", "value", ")", "throws", "SynchronizeFXException", "{", "final", "State", "state", "=", "createCommandList", "(", "new", "WithCommandType", "(", ...
Creates the commands necessary to set a new value for a property. @param propertyId The id of the property where the new value should be set. @param value The value that should be set. @throws SynchronizeFXException When creation of the commands failed. @return The commands.
[ "Creates", "the", "commands", "necessary", "to", "set", "a", "new", "value", "for", "a", "property", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L125-L133
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.addToList
public List<Command> addToList(final UUID listId, final int position, final Object value, final int newSize) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { addToList(listId, position, value, newSize, state); } }, true); return state.commands; }
java
public List<Command> addToList(final UUID listId, final int position, final Object value, final int newSize) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { addToList(listId, position, value, newSize, state); } }, true); return state.commands; }
[ "public", "List", "<", "Command", ">", "addToList", "(", "final", "UUID", "listId", ",", "final", "int", "position", ",", "final", "Object", "value", ",", "final", "int", "newSize", ")", "{", "final", "State", "state", "=", "createCommandList", "(", "new",...
Creates the list with commands necessary for an add to list action. @param listId The ID of the list where the element should be added. @param position The position in the list at which the value object should be added. @param value The object that should be added to the list. @param newSize The new size the list has after this command has been executed on it. @return a list with commands necessary to recreate this add to list command.
[ "Creates", "the", "list", "with", "commands", "necessary", "for", "an", "add", "to", "list", "action", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L148-L156
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.addToSet
public List<Command> addToSet(final UUID setId, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { addToSet(setId, value, state); } }, true); return state.commands; }
java
public List<Command> addToSet(final UUID setId, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { addToSet(setId, value, state); } }, true); return state.commands; }
[ "public", "List", "<", "Command", ">", "addToSet", "(", "final", "UUID", "setId", ",", "final", "Object", "value", ")", "{", "final", "State", "state", "=", "createCommandList", "(", "new", "WithCommandType", "(", ")", "{", "@", "Override", "public", "void...
Creates the list with commands necessary for an add to set action. @param setId The ID of the set where the element should be added. @param value The object that should be added to the set. @return a set with commands necessary to recreate this add to set command.
[ "Creates", "the", "list", "with", "commands", "necessary", "for", "an", "add", "to", "set", "action", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L167-L175
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.putToMap
public List<Command> putToMap(final UUID mapId, final Object key, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { putToMap(mapId, key, value, state); } }, true); return state.commands; }
java
public List<Command> putToMap(final UUID mapId, final Object key, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { putToMap(mapId, key, value, state); } }, true); return state.commands; }
[ "public", "List", "<", "Command", ">", "putToMap", "(", "final", "UUID", "mapId", ",", "final", "Object", "key", ",", "final", "Object", "value", ")", "{", "final", "State", "state", "=", "createCommandList", "(", "new", "WithCommandType", "(", ")", "{", ...
Creates the list with commands necessary to put a mapping into a map. @param mapId the id of the map where the mapping should be added. @param key the key of the new mapping. @param value the value of the new mapping. @return the list with the commands.
[ "Creates", "the", "list", "with", "commands", "necessary", "to", "put", "a", "mapping", "into", "a", "map", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L188-L196
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.removeFromList
public List<Command> removeFromList(final UUID listId, final int startPosition, final int removeCount) { final ListVersionChange change = increaseListVersion(listId); final RemoveFromList msg = new RemoveFromList(listId, change, startPosition, removeCount); final List<Command> commands = new ArrayList<>(1); commands.add(msg); return commands; }
java
public List<Command> removeFromList(final UUID listId, final int startPosition, final int removeCount) { final ListVersionChange change = increaseListVersion(listId); final RemoveFromList msg = new RemoveFromList(listId, change, startPosition, removeCount); final List<Command> commands = new ArrayList<>(1); commands.add(msg); return commands; }
[ "public", "List", "<", "Command", ">", "removeFromList", "(", "final", "UUID", "listId", ",", "final", "int", "startPosition", ",", "final", "int", "removeCount", ")", "{", "final", "ListVersionChange", "change", "=", "increaseListVersion", "(", "listId", ")", ...
Creates the list with commands necessary to remove a object from a list. @param listId The ID of the list where an element should be removed. @param startPosition The index of the first element in the list which should be removed. @param removeCount The element count to remove from the list, starting from <code>startPosition</code>. @return The command list.
[ "Creates", "the", "list", "with", "commands", "necessary", "to", "remove", "a", "object", "from", "a", "list", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L209-L215
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.removeFromMap
public List<Command> removeFromMap(final UUID mapId, final Object key) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { createObservableObject(key, state); } }, false); final boolean keyIsObservableObject = state.lastObjectWasObservable; final RemoveFromMap msg = new RemoveFromMap(); msg.setMapId(mapId); msg.setKey(valueMapper.map(key, keyIsObservableObject)); state.commands.add(state.commands.size() - 1, msg); return state.commands; }
java
public List<Command> removeFromMap(final UUID mapId, final Object key) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { createObservableObject(key, state); } }, false); final boolean keyIsObservableObject = state.lastObjectWasObservable; final RemoveFromMap msg = new RemoveFromMap(); msg.setMapId(mapId); msg.setKey(valueMapper.map(key, keyIsObservableObject)); state.commands.add(state.commands.size() - 1, msg); return state.commands; }
[ "public", "List", "<", "Command", ">", "removeFromMap", "(", "final", "UUID", "mapId", ",", "final", "Object", "key", ")", "{", "final", "State", "state", "=", "createCommandList", "(", "new", "WithCommandType", "(", ")", "{", "@", "Override", "public", "v...
Creates the list with command necessary to remove a mapping from a map. @param mapId the map where the mapping should be removed. @param key the key of the mapping that should be removed. @return the list with the commands.
[ "Creates", "the", "list", "with", "command", "necessary", "to", "remove", "a", "mapping", "from", "a", "map", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L226-L242
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.removeFromSet
public List<Command> removeFromSet(final UUID setId, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { createObservableObject(value, state); } }, false); final boolean keyIsObservableObject = state.lastObjectWasObservable; final RemoveFromSet msg = new RemoveFromSet(); msg.setSetId(setId); msg.setValue(valueMapper.map(value, keyIsObservableObject)); state.commands.add(state.commands.size() - 1, msg); return state.commands; }
java
public List<Command> removeFromSet(final UUID setId, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { createObservableObject(value, state); } }, false); final boolean keyIsObservableObject = state.lastObjectWasObservable; final RemoveFromSet msg = new RemoveFromSet(); msg.setSetId(setId); msg.setValue(valueMapper.map(value, keyIsObservableObject)); state.commands.add(state.commands.size() - 1, msg); return state.commands; }
[ "public", "List", "<", "Command", ">", "removeFromSet", "(", "final", "UUID", "setId", ",", "final", "Object", "value", ")", "{", "final", "State", "state", "=", "createCommandList", "(", "new", "WithCommandType", "(", ")", "{", "@", "Override", "public", ...
Creates the list with commands necessary to remove a object from a set. @param setId The ID of the set where an element should be removed. @param value The element that should be removed. @return The command list.
[ "Creates", "the", "list", "with", "commands", "necessary", "to", "remove", "a", "object", "from", "a", "set", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L253-L269
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java
CommandListCreator.replaceInList
public List<Command> replaceInList(final UUID listId, final int position, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { final boolean isObservableObject = createObservableObject(value, state); final ListVersionChange versionChange = increaseListVersion(listId); final ReplaceInList replaceInList = new ReplaceInList(listId, versionChange, valueMapper.map(value, isObservableObject), position); state.commands.add(replaceInList); } }, true); return state.commands; }
java
public List<Command> replaceInList(final UUID listId, final int position, final Object value) { final State state = createCommandList(new WithCommandType() { @Override public void invoke(final State state) { final boolean isObservableObject = createObservableObject(value, state); final ListVersionChange versionChange = increaseListVersion(listId); final ReplaceInList replaceInList = new ReplaceInList(listId, versionChange, valueMapper.map(value, isObservableObject), position); state.commands.add(replaceInList); } }, true); return state.commands; }
[ "public", "List", "<", "Command", ">", "replaceInList", "(", "final", "UUID", "listId", ",", "final", "int", "position", ",", "final", "Object", "value", ")", "{", "final", "State", "state", "=", "createCommandList", "(", "new", "WithCommandType", "(", ")", ...
Creates the list of commands necessary to replace an object in a list. @param listId the ID of the list where the element should be replaced @param position the position of the element that should be replaced @param value the new value @return the command list
[ "Creates", "the", "list", "of", "commands", "necessary", "to", "replace", "an", "object", "in", "a", "list", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandListCreator.java#L282-L296
train
quattor/pan
panc/src/main/java/org/quattor/pan/parser/PanParserUtils.java
PanParserUtils.replaceHeredocStrings
static void replaceHeredocStrings(ASTTemplate tnode, List<StringProperty> strings) { // Only something to do if there were heredoc strings defined. if (strings.size() > 0) { processHeredocStrings(tnode, strings); } }
java
static void replaceHeredocStrings(ASTTemplate tnode, List<StringProperty> strings) { // Only something to do if there were heredoc strings defined. if (strings.size() > 0) { processHeredocStrings(tnode, strings); } }
[ "static", "void", "replaceHeredocStrings", "(", "ASTTemplate", "tnode", ",", "List", "<", "StringProperty", ">", "strings", ")", "{", "// Only something to do if there were heredoc strings defined.", "if", "(", "strings", ".", "size", "(", ")", ">", "0", ")", "{", ...
A utility to replace HEREDOC operations with the associated StringProperty operations. This must be done at the end of the template processing to be sure that all heredoc strings have been captured. @param tnode @param strings
[ "A", "utility", "to", "replace", "HEREDOC", "operations", "with", "the", "associated", "StringProperty", "operations", ".", "This", "must", "be", "done", "at", "the", "end", "of", "the", "template", "processing", "to", "be", "sure", "that", "all", "heredoc", ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/parser/PanParserUtils.java#L52-L59
train
quattor/pan
panc/src/main/java/org/quattor/pan/parser/PanParserUtils.java
PanParserUtils.processSingleQuotedString
static void processSingleQuotedString(StringBuilder sb) { // Sanity checking. Make sure input string has at least two characters // and that the first and last are single quotes. assert (sb.length() >= 2); assert (sb.charAt(0) == '\'' && sb.charAt(sb.length() - 1) == '\''); // Remove the starting and ending quotes. sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(0); // Loop through the string and replace any doubled apostrophes with // a single apostrophe. (Really just delete the second apostrophe.) int i = sb.indexOf("''", 0) + 1; while (i > 0) { sb.deleteCharAt(i); i = sb.indexOf("''", i) + 1; } }
java
static void processSingleQuotedString(StringBuilder sb) { // Sanity checking. Make sure input string has at least two characters // and that the first and last are single quotes. assert (sb.length() >= 2); assert (sb.charAt(0) == '\'' && sb.charAt(sb.length() - 1) == '\''); // Remove the starting and ending quotes. sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(0); // Loop through the string and replace any doubled apostrophes with // a single apostrophe. (Really just delete the second apostrophe.) int i = sb.indexOf("''", 0) + 1; while (i > 0) { sb.deleteCharAt(i); i = sb.indexOf("''", i) + 1; } }
[ "static", "void", "processSingleQuotedString", "(", "StringBuilder", "sb", ")", "{", "// Sanity checking. Make sure input string has at least two characters", "// and that the first and last are single quotes.", "assert", "(", "sb", ".", "length", "(", ")", ">=", "2", ")", ";...
This takes a single-quoted string as identified by the parser and processes it into a standard java string. It removes the surrounding quotes and substitues a single apostrophe or doubled apostrophes. Note: This method modifies the given StringBuilder directly. No copies of the data are made. @param sb StringBuilder containing the single-quoted string
[ "This", "takes", "a", "single", "-", "quoted", "string", "as", "identified", "by", "the", "parser", "and", "processes", "it", "into", "a", "standard", "java", "string", ".", "It", "removes", "the", "surrounding", "quotes", "and", "substitues", "a", "single",...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/parser/PanParserUtils.java#L114-L132
train
quattor/pan
panc/src/main/java/org/quattor/pan/repository/FileSystemSourceRepository.java
FileSystemSourceRepository.retrievePanSource
public SourceFile retrievePanSource(String name, List<String> loadpath) { String cacheKey = name + ((String) " ") + String.join(":", loadpath); SourceFile cachedResult = retrievePanCacheLoadpath.get(cacheKey); if (cachedResult == null) { File file = lookupSource(name, loadpath); cachedResult = createPanSourceFile(name, file); retrievePanCacheLoadpath.put(cacheKey, cachedResult); } return cachedResult; }
java
public SourceFile retrievePanSource(String name, List<String> loadpath) { String cacheKey = name + ((String) " ") + String.join(":", loadpath); SourceFile cachedResult = retrievePanCacheLoadpath.get(cacheKey); if (cachedResult == null) { File file = lookupSource(name, loadpath); cachedResult = createPanSourceFile(name, file); retrievePanCacheLoadpath.put(cacheKey, cachedResult); } return cachedResult; }
[ "public", "SourceFile", "retrievePanSource", "(", "String", "name", ",", "List", "<", "String", ">", "loadpath", ")", "{", "String", "cacheKey", "=", "name", "+", "(", "(", "String", ")", "\" \"", ")", "+", "String", ".", "join", "(", "\":\"", ",", "lo...
Optimised due to lots of calls and slow lookupSource
[ "Optimised", "due", "to", "lots", "of", "calls", "and", "slow", "lookupSource" ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/repository/FileSystemSourceRepository.java#L87-L98
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/IteratorMap.java
IteratorMap.get
public Resource.Iterator get(Resource resource) { Integer key = Integer.valueOf(System.identityHashCode(resource)); return map.get(key); }
java
public Resource.Iterator get(Resource resource) { Integer key = Integer.valueOf(System.identityHashCode(resource)); return map.get(key); }
[ "public", "Resource", ".", "Iterator", "get", "(", "Resource", "resource", ")", "{", "Integer", "key", "=", "Integer", ".", "valueOf", "(", "System", ".", "identityHashCode", "(", "resource", ")", ")", ";", "return", "map", ".", "get", "(", "key", ")", ...
Lookup the iterator associated with the given resource. If there is no iterator, null is returned. @param resource resource to use for lookup @return Resource.Iterator iterator associated with given resource or null if no mapping exists
[ "Lookup", "the", "iterator", "associated", "with", "the", "given", "resource", ".", "If", "there", "is", "no", "iterator", "null", "is", "returned", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/IteratorMap.java#L37-L40
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/IteratorMap.java
IteratorMap.put
public void put(Resource resource, Resource.Iterator iterator) { assert (resource != null); Integer key = Integer.valueOf(System.identityHashCode(resource)); if (iterator != null) { map.put(key, iterator); } else { map.remove(key); } }
java
public void put(Resource resource, Resource.Iterator iterator) { assert (resource != null); Integer key = Integer.valueOf(System.identityHashCode(resource)); if (iterator != null) { map.put(key, iterator); } else { map.remove(key); } }
[ "public", "void", "put", "(", "Resource", "resource", ",", "Resource", ".", "Iterator", "iterator", ")", "{", "assert", "(", "resource", "!=", "null", ")", ";", "Integer", "key", "=", "Integer", ".", "valueOf", "(", "System", ".", "identityHashCode", "(", ...
Associate the iterator to the given resource. If the iterator is null, then the mapping is removed. @param resource resource to associate the iterator to @param iterator iterator to associate to the resource; if null mapping is removed
[ "Associate", "the", "iterator", "to", "the", "given", "resource", ".", "If", "the", "iterator", "is", "null", "then", "the", "mapping", "is", "removed", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/IteratorMap.java#L52-L62
train
quattor/pan
panc/src/main/java/org/quattor/ant/PanCheckSyntaxTask.java
PanCheckSyntaxTask.addFiles
private void addFiles(FileSet fs) { // Get the files included in the fileset. DirectoryScanner ds = fs.getDirectoryScanner(getProject()); // The base directory for all files. File basedir = ds.getBasedir(); // Loop over each file creating a File object. for (String f : ds.getIncludedFiles()) { if (SourceType.hasSourceFileExtension(f)) { sourceFiles.add(new File(basedir, f)); } } }
java
private void addFiles(FileSet fs) { // Get the files included in the fileset. DirectoryScanner ds = fs.getDirectoryScanner(getProject()); // The base directory for all files. File basedir = ds.getBasedir(); // Loop over each file creating a File object. for (String f : ds.getIncludedFiles()) { if (SourceType.hasSourceFileExtension(f)) { sourceFiles.add(new File(basedir, f)); } } }
[ "private", "void", "addFiles", "(", "FileSet", "fs", ")", "{", "// Get the files included in the fileset.", "DirectoryScanner", "ds", "=", "fs", ".", "getDirectoryScanner", "(", "getProject", "(", ")", ")", ";", "// The base directory for all files.", "File", "basedir",...
Utility method that adds all of the files in a fileset to the list of files to be processed. Duplicate files appear only once in the final list. Files not ending with a valid source file extension are ignored. @param fs FileSet from which to get the file names
[ "Utility", "method", "that", "adds", "all", "of", "the", "files", "in", "a", "fileset", "to", "the", "list", "of", "files", "to", "be", "processed", ".", "Duplicate", "files", "appear", "only", "once", "in", "the", "final", "list", ".", "Files", "not", ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/ant/PanCheckSyntaxTask.java#L83-L97
train
quattor/pan
panc/src/main/java/org/quattor/ant/PanCheckSyntaxTask.java
PanCheckSyntaxTask.setWarnings
public void setWarnings(String warnings) { try { deprecationWarnings = CompilerOptions.DeprecationWarnings .fromString(warnings); } catch (IllegalArgumentException e) { throw new BuildException("invalid value for warnings: " + warnings); } }
java
public void setWarnings(String warnings) { try { deprecationWarnings = CompilerOptions.DeprecationWarnings .fromString(warnings); } catch (IllegalArgumentException e) { throw new BuildException("invalid value for warnings: " + warnings); } }
[ "public", "void", "setWarnings", "(", "String", "warnings", ")", "{", "try", "{", "deprecationWarnings", "=", "CompilerOptions", ".", "DeprecationWarnings", ".", "fromString", "(", "warnings", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{...
Determines whether deprecation warnings are emitted and if so, whether to treat them as fatal errors. @param warnings string value of CompilerOptions.DeprecationWarnings
[ "Determines", "whether", "deprecation", "warnings", "are", "emitted", "and", "if", "so", "whether", "to", "treat", "them", "as", "fatal", "errors", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/ant/PanCheckSyntaxTask.java#L116-L123
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java
CompileTimeContext.setObjectAndLoadpath
public void setObjectAndLoadpath() { StringProperty sname = StringProperty.getInstance(objectTemplate.name); setGlobalVariable("OBJECT", sname, true); setGlobalVariable("LOADPATH", new ListResource(), false); }
java
public void setObjectAndLoadpath() { StringProperty sname = StringProperty.getInstance(objectTemplate.name); setGlobalVariable("OBJECT", sname, true); setGlobalVariable("LOADPATH", new ListResource(), false); }
[ "public", "void", "setObjectAndLoadpath", "(", ")", "{", "StringProperty", "sname", "=", "StringProperty", ".", "getInstance", "(", "objectTemplate", ".", "name", ")", ";", "setGlobalVariable", "(", "\"OBJECT\"", ",", "sname", ",", "true", ")", ";", "setGlobalVa...
Set the name of the object template. Define the necessary variables.
[ "Set", "the", "name", "of", "the", "object", "template", ".", "Define", "the", "necessary", "variables", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java#L247-L253
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java
CompileTimeContext.setIterator
public void setIterator(Resource resource, Resource.Iterator iterator) { iteratorMap.put(resource, iterator); }
java
public void setIterator(Resource resource, Resource.Iterator iterator) { iteratorMap.put(resource, iterator); }
[ "public", "void", "setIterator", "(", "Resource", "resource", ",", "Resource", ".", "Iterator", "iterator", ")", "{", "iteratorMap", ".", "put", "(", "resource", ",", "iterator", ")", ";", "}" ]
Register a Resource iterator in the context.
[ "Register", "a", "Resource", "iterator", "in", "the", "context", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java#L414-L416
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java
CompileTimeContext.getVariable
public Element getVariable(String name) { Element result = localVariables.get(name); // If the result is null, then try to look up a global variable. if (result == null) { result = getGlobalVariable(name); } return result; }
java
public Element getVariable(String name) { Element result = localVariables.get(name); // If the result is null, then try to look up a global variable. if (result == null) { result = getGlobalVariable(name); } return result; }
[ "public", "Element", "getVariable", "(", "String", "name", ")", "{", "Element", "result", "=", "localVariables", ".", "get", "(", "name", ")", ";", "// If the result is null, then try to look up a global variable.", "if", "(", "result", "==", "null", ")", "{", "re...
Return the Element which corresponds to the given variable name. It will first check local variables and then global variables. This method will return null if the variable doesn't exist or the argument is null. Note that this will clone the value before returning it, if it came from a global variable. @param name name of the variable to lookup @return Element corresponding to the given variable name or null if it could not be found
[ "Return", "the", "Element", "which", "corresponds", "to", "the", "given", "variable", "name", ".", "It", "will", "first", "check", "local", "variables", "and", "then", "global", "variables", ".", "This", "method", "will", "return", "null", "if", "the", "vari...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java#L685-L695
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java
CompileTimeContext.dereferenceVariable
public Element dereferenceVariable(String name, boolean lookupOnly, Term[] terms) throws InvalidTermException { boolean duplicate = false; Element result = localVariables.get(name); // If the result is null, then try to look up a global variable. if (result == null) { duplicate = true; result = getGlobalVariable(name); } // Now actually dereference the given variable. The caller must deal // with any invalid term exceptions or evaluation exceptions. We just // pass those on. if (result != null) { if (!(result instanceof Undef)) { // FIXME: Determine if the result needs to be protected. result = result.rget(terms, 0, false, lookupOnly); } else { // Trying to dereference an undefined value. Therefore, the // value does not exist; return null to caller. result = null; } } // FIXME: This is inefficient and should be avoided. However, one must // ensure that global variables are protected against changes. // To ensure that global variables are not inadvertently modified via // copies in local variables, duplicate the result. Do this only AFTER // the dereference to limit the amount of potentially unnecessary // cloning. if (duplicate && result != null) { result = result.duplicate(); } return result; }
java
public Element dereferenceVariable(String name, boolean lookupOnly, Term[] terms) throws InvalidTermException { boolean duplicate = false; Element result = localVariables.get(name); // If the result is null, then try to look up a global variable. if (result == null) { duplicate = true; result = getGlobalVariable(name); } // Now actually dereference the given variable. The caller must deal // with any invalid term exceptions or evaluation exceptions. We just // pass those on. if (result != null) { if (!(result instanceof Undef)) { // FIXME: Determine if the result needs to be protected. result = result.rget(terms, 0, false, lookupOnly); } else { // Trying to dereference an undefined value. Therefore, the // value does not exist; return null to caller. result = null; } } // FIXME: This is inefficient and should be avoided. However, one must // ensure that global variables are protected against changes. // To ensure that global variables are not inadvertently modified via // copies in local variables, duplicate the result. Do this only AFTER // the dereference to limit the amount of potentially unnecessary // cloning. if (duplicate && result != null) { result = result.duplicate(); } return result; }
[ "public", "Element", "dereferenceVariable", "(", "String", "name", ",", "boolean", "lookupOnly", ",", "Term", "[", "]", "terms", ")", "throws", "InvalidTermException", "{", "boolean", "duplicate", "=", "false", ";", "Element", "result", "=", "localVariables", "....
Return the Element which corresponds to the given variable name. It will first check local variables and then the parent context. This method will return null if the variable doesn't exist or the argument is null. Note that this will clone the final value, if it originated from a global variable. @param name name of the variable to lookup @param lookupOnly flag indicating if only a lookup should be done @param terms values for dereferencing the given variable @return Element value of the associated dereferenced variable
[ "Return", "the", "Element", "which", "corresponds", "to", "the", "given", "variable", "name", ".", "It", "will", "first", "check", "local", "variables", "and", "then", "the", "parent", "context", ".", "This", "method", "will", "return", "null", "if", "the", ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/CompileTimeContext.java#L713-L751
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/functions/AbstractMatcher.java
AbstractMatcher.convertMatchFlags
protected int convertMatchFlags(Element opts) { int flags = 0; String sopts = ((StringProperty) opts).getValue(); for (int i = 0; i < sopts.length(); i++) { char c = sopts.charAt(i); switch (c) { case 'i': flags |= Pattern.CASE_INSENSITIVE; break; case 's': flags |= Pattern.DOTALL; break; case 'm': flags |= Pattern.MULTILINE; break; case 'u': flags |= Pattern.UNICODE_CASE; break; case 'x': flags |= Pattern.COMMENTS; break; default: throw EvaluationException.create(sourceRange, MSG_INVALID_REGEXP_FLAG, c); } } return flags; }
java
protected int convertMatchFlags(Element opts) { int flags = 0; String sopts = ((StringProperty) opts).getValue(); for (int i = 0; i < sopts.length(); i++) { char c = sopts.charAt(i); switch (c) { case 'i': flags |= Pattern.CASE_INSENSITIVE; break; case 's': flags |= Pattern.DOTALL; break; case 'm': flags |= Pattern.MULTILINE; break; case 'u': flags |= Pattern.UNICODE_CASE; break; case 'x': flags |= Pattern.COMMENTS; break; default: throw EvaluationException.create(sourceRange, MSG_INVALID_REGEXP_FLAG, c); } } return flags; }
[ "protected", "int", "convertMatchFlags", "(", "Element", "opts", ")", "{", "int", "flags", "=", "0", ";", "String", "sopts", "=", "(", "(", "StringProperty", ")", "opts", ")", ".", "getValue", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "...
A utility function to convert a string containing match options to the associated integer with the appropriate bits set. @param opts string containing matching flags @return integer with appropriate bits set
[ "A", "utility", "function", "to", "convert", "a", "string", "containing", "match", "options", "to", "the", "associated", "integer", "with", "the", "appropriate", "bits", "set", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/functions/AbstractMatcher.java#L69-L99
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/functions/AbstractMatcher.java
AbstractMatcher.compilePattern
protected Pattern compilePattern(Element regex, int flags) { Pattern p = null; try { String re = ((StringProperty) regex).getValue(); p = Pattern.compile(re, flags); } catch (PatternSyntaxException pse) { throw EvaluationException.create(sourceRange, MSG_INVALID_REGEXP, pse.getLocalizedMessage()); } return p; }
java
protected Pattern compilePattern(Element regex, int flags) { Pattern p = null; try { String re = ((StringProperty) regex).getValue(); p = Pattern.compile(re, flags); } catch (PatternSyntaxException pse) { throw EvaluationException.create(sourceRange, MSG_INVALID_REGEXP, pse.getLocalizedMessage()); } return p; }
[ "protected", "Pattern", "compilePattern", "(", "Element", "regex", ",", "int", "flags", ")", "{", "Pattern", "p", "=", "null", ";", "try", "{", "String", "re", "=", "(", "(", "StringProperty", ")", "regex", ")", ".", "getValue", "(", ")", ";", "p", "...
Generate a Pattern from the given string and flags. @param regex regular expression to compile @param flags matching flags to use for pattern @return Pattern corresponding to the given regular expression and matching flags
[ "Generate", "a", "Pattern", "from", "the", "given", "string", "and", "flags", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/functions/AbstractMatcher.java#L112-L124
train
quattor/pan
panc/src/main/java/org/quattor/pan/cache/BuildCache.java
BuildCache.setDependency
synchronized public void setDependency(String objectName, String dependencyName) throws EvaluationException { // Determine if adding this dependency will create a cycle. String nextObjectName = dependencies.get(dependencyName); while (nextObjectName != null) { if (objectName.equals(nextObjectName)) { throw EvaluationException.create( MSG_CIRCULAR_OBJECT_DEPENDENCY, getCycle(objectName, dependencyName)); } nextObjectName = dependencies.get(nextObjectName); } // If we get to here, then we reached the end of the chain without // creating a cycle. It is OK to add this to the dependencies. dependencies.put(objectName, dependencyName); // To avoid deadlock, ensure that the number of available threads is // larger than number of entries in the dependencies. compiler.ensureMinimumBuildThreadLimit(dependencies.size() + 1); }
java
synchronized public void setDependency(String objectName, String dependencyName) throws EvaluationException { // Determine if adding this dependency will create a cycle. String nextObjectName = dependencies.get(dependencyName); while (nextObjectName != null) { if (objectName.equals(nextObjectName)) { throw EvaluationException.create( MSG_CIRCULAR_OBJECT_DEPENDENCY, getCycle(objectName, dependencyName)); } nextObjectName = dependencies.get(nextObjectName); } // If we get to here, then we reached the end of the chain without // creating a cycle. It is OK to add this to the dependencies. dependencies.put(objectName, dependencyName); // To avoid deadlock, ensure that the number of available threads is // larger than number of entries in the dependencies. compiler.ensureMinimumBuildThreadLimit(dependencies.size() + 1); }
[ "synchronized", "public", "void", "setDependency", "(", "String", "objectName", ",", "String", "dependencyName", ")", "throws", "EvaluationException", "{", "// Determine if adding this dependency will create a cycle.", "String", "nextObjectName", "=", "dependencies", ".", "ge...
This method will set the given dependency in the map which holds them. This method will throw an exception if the specified dependency would create a cycle in the dependency map. In this case, the dependency will not be inserted. Note: This method MUST be synchronized to ensure that the entire cycle calculation occurs with the dependency map in a consistent state. @param objectName name of the object which has the dependency @param dependencyName name of the object objectName depends on @throws EvaluationException when an error occurs during the evaluation of the dependency
[ "This", "method", "will", "set", "the", "given", "dependency", "in", "the", "map", "which", "holds", "them", ".", "This", "method", "will", "throw", "an", "exception", "if", "the", "specified", "dependency", "would", "create", "a", "cycle", "in", "the", "d...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/cache/BuildCache.java#L98-L119
train
quattor/pan
panc/src/main/java/org/quattor/pan/cache/BuildCache.java
BuildCache.getCycle
synchronized private String getCycle(String objectName, String dependencyName) { // Determine if adding this dependency will create a cycle. StringBuilder sb = new StringBuilder(); sb.append(objectName); sb.append(" -> "); sb.append(dependencyName); String nextObjectName = dependencies.get(dependencyName); while (nextObjectName != null && !objectName.equals(nextObjectName)) { sb.append(" -> "); sb.append(nextObjectName); nextObjectName = dependencies.get(nextObjectName); } sb.append(" -> "); sb.append(objectName); return sb.toString(); }
java
synchronized private String getCycle(String objectName, String dependencyName) { // Determine if adding this dependency will create a cycle. StringBuilder sb = new StringBuilder(); sb.append(objectName); sb.append(" -> "); sb.append(dependencyName); String nextObjectName = dependencies.get(dependencyName); while (nextObjectName != null && !objectName.equals(nextObjectName)) { sb.append(" -> "); sb.append(nextObjectName); nextObjectName = dependencies.get(nextObjectName); } sb.append(" -> "); sb.append(objectName); return sb.toString(); }
[ "synchronized", "private", "String", "getCycle", "(", "String", "objectName", ",", "String", "dependencyName", ")", "{", "// Determine if adding this dependency will create a cycle.", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append"...
This method creates a string describing a cycle which has been detected. It should only be called if a cycle with the specified dependency has actually been detected. @param objectName name of the object which has the dependency @param dependencyName name of the object objectName depends on @return String describing the cyclic dependency
[ "This", "method", "creates", "a", "string", "describing", "a", "cycle", "which", "has", "been", "detected", ".", "It", "should", "only", "be", "called", "if", "a", "cycle", "with", "the", "specified", "dependency", "has", "actually", "been", "detected", "." ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/cache/BuildCache.java#L133-L153
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/operators/Add.java
Add.execute
@Override public Element execute(Context context) { try { Element[] args = calculateArgs(context); Property a = (Property) args[0]; Property b = (Property) args[1]; return execute(sourceRange, a, b); } catch (ClassCastException cce) { throw new EvaluationException(MessageUtils .format(MSG_INVALID_ARGS_ADD), sourceRange); } }
java
@Override public Element execute(Context context) { try { Element[] args = calculateArgs(context); Property a = (Property) args[0]; Property b = (Property) args[1]; return execute(sourceRange, a, b); } catch (ClassCastException cce) { throw new EvaluationException(MessageUtils .format(MSG_INVALID_ARGS_ADD), sourceRange); } }
[ "@", "Override", "public", "Element", "execute", "(", "Context", "context", ")", "{", "try", "{", "Element", "[", "]", "args", "=", "calculateArgs", "(", "context", ")", ";", "Property", "a", "=", "(", "Property", ")", "args", "[", "0", "]", ";", "Pr...
Perform the addition of the two top values on the data stack in the given DMLContext. This method will handle long, double, and string values. Exceptions are thrown if the types of the arguments do not match or they are another type.
[ "Perform", "the", "addition", "of", "the", "two", "top", "values", "on", "the", "data", "stack", "in", "the", "given", "DMLContext", ".", "This", "method", "will", "handle", "long", "double", "and", "string", "values", ".", "Exceptions", "are", "thrown", "...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/operators/Add.java#L107-L119
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/operators/Add.java
Add.execute
private static Element execute(SourceRange sourceRange, Property a, Property b) { assert (a != null); assert (b != null); Element result = null; if ((a instanceof LongProperty) && (b instanceof LongProperty)) { long l1 = ((Long) a.getValue()).longValue(); long l2 = ((Long) b.getValue()).longValue(); result = LongProperty.getInstance(l1 + l2); } else if ((a instanceof NumberProperty) && (b instanceof NumberProperty)) { double d1 = ((NumberProperty) a).doubleValue(); double d2 = ((NumberProperty) b).doubleValue(); result = DoubleProperty.getInstance(d1 + d2); } else if ((a instanceof StringProperty) && (b instanceof StringProperty)) { String s1 = (String) a.getValue(); String s2 = (String) b.getValue(); result = StringProperty.getInstance(s1 + s2); } else { throw new EvaluationException(MessageUtils .format(MSG_MISMATCHED_ARGS_ADD), sourceRange); } return result; }
java
private static Element execute(SourceRange sourceRange, Property a, Property b) { assert (a != null); assert (b != null); Element result = null; if ((a instanceof LongProperty) && (b instanceof LongProperty)) { long l1 = ((Long) a.getValue()).longValue(); long l2 = ((Long) b.getValue()).longValue(); result = LongProperty.getInstance(l1 + l2); } else if ((a instanceof NumberProperty) && (b instanceof NumberProperty)) { double d1 = ((NumberProperty) a).doubleValue(); double d2 = ((NumberProperty) b).doubleValue(); result = DoubleProperty.getInstance(d1 + d2); } else if ((a instanceof StringProperty) && (b instanceof StringProperty)) { String s1 = (String) a.getValue(); String s2 = (String) b.getValue(); result = StringProperty.getInstance(s1 + s2); } else { throw new EvaluationException(MessageUtils .format(MSG_MISMATCHED_ARGS_ADD), sourceRange); } return result; }
[ "private", "static", "Element", "execute", "(", "SourceRange", "sourceRange", ",", "Property", "a", ",", "Property", "b", ")", "{", "assert", "(", "a", "!=", "null", ")", ";", "assert", "(", "b", "!=", "null", ")", ";", "Element", "result", "=", "null"...
Do the actual addition.
[ "Do", "the", "actual", "addition", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/operators/Add.java#L124-L161
train
quattor/pan
panc/src/main/java/org/quattor/ant/PanCompilerTask.java
PanCompilerTask.setIncludeRoot
public void setIncludeRoot(File includeroot) { this.includeroot = includeroot; if (!includeroot.exists()) { throw new BuildException("includeroot doesn't exist: " + includeroot); } if (!includeroot.isDirectory()) { throw new BuildException("includeroot must be a directory: " + includeroot); } }
java
public void setIncludeRoot(File includeroot) { this.includeroot = includeroot; if (!includeroot.exists()) { throw new BuildException("includeroot doesn't exist: " + includeroot); } if (!includeroot.isDirectory()) { throw new BuildException("includeroot must be a directory: " + includeroot); } }
[ "public", "void", "setIncludeRoot", "(", "File", "includeroot", ")", "{", "this", ".", "includeroot", "=", "includeroot", ";", "if", "(", "!", "includeroot", ".", "exists", "(", ")", ")", "{", "throw", "new", "BuildException", "(", "\"includeroot doesn't exist...
Set the directory to use for the include globs. This is required only if the includes parameter is set. @param includeroot File giving the root directory for the include globs
[ "Set", "the", "directory", "to", "use", "for", "the", "include", "globs", ".", "This", "is", "required", "only", "if", "the", "includes", "parameter", "is", "set", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/ant/PanCompilerTask.java#L217-L229
train
quattor/pan
panc/src/main/java/org/quattor/ant/PanCompilerTask.java
PanCompilerTask.setIncludes
public void setIncludes(String includes) { // Split the string into separate file globs. String[] globs = includes.split("[\\s,]+"); // Loop over these globs and create dirsets from them. // Do not set the root directory until the task is // executed. for (String glob : globs) { DirSet dirset = new DirSet(); dirset.setIncludes(glob); this.includes.add(dirset); } }
java
public void setIncludes(String includes) { // Split the string into separate file globs. String[] globs = includes.split("[\\s,]+"); // Loop over these globs and create dirsets from them. // Do not set the root directory until the task is // executed. for (String glob : globs) { DirSet dirset = new DirSet(); dirset.setIncludes(glob); this.includes.add(dirset); } }
[ "public", "void", "setIncludes", "(", "String", "includes", ")", "{", "// Split the string into separate file globs.", "String", "[", "]", "globs", "=", "includes", ".", "split", "(", "\"[\\\\s,]+\"", ")", ";", "// Loop over these globs and create dirsets from them.", "//...
Set the include globs to use for the pan compiler loadpath. @param includes String of comma- or space-separated file globs
[ "Set", "the", "include", "globs", "to", "use", "for", "the", "pan", "compiler", "loadpath", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/ant/PanCompilerTask.java#L237-L250
train
quattor/pan
panc/src/main/java/org/quattor/ant/PanCompilerTask.java
PanCompilerTask.addPaths
private void addPaths(Path p) { for (String d : p.list()) { File dir = new File(d); if (dir.exists() && dir.isDirectory()) { if (!includeDirectories.contains(dir)) includeDirectories.add(dir); } } }
java
private void addPaths(Path p) { for (String d : p.list()) { File dir = new File(d); if (dir.exists() && dir.isDirectory()) { if (!includeDirectories.contains(dir)) includeDirectories.add(dir); } } }
[ "private", "void", "addPaths", "(", "Path", "p", ")", "{", "for", "(", "String", "d", ":", "p", ".", "list", "(", ")", ")", "{", "File", "dir", "=", "new", "File", "(", "d", ")", ";", "if", "(", "dir", ".", "exists", "(", ")", "&&", "dir", ...
Collect all of the directories listed within enclosed path tags. Order of the path elements is preserved. Duplicates are included where first specified. @param p Path containing directories to include in compilation
[ "Collect", "all", "of", "the", "directories", "listed", "within", "enclosed", "path", "tags", ".", "Order", "of", "the", "path", "elements", "is", "preserved", ".", "Duplicates", "are", "included", "where", "first", "specified", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/ant/PanCompilerTask.java#L274-L283
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.restoreRelativeRoot
public HashResource restoreRelativeRoot(HashResource previousValue) { HashResource value = relativeRoot; relativeRoot = previousValue; return value; }
java
public HashResource restoreRelativeRoot(HashResource previousValue) { HashResource value = relativeRoot; relativeRoot = previousValue; return value; }
[ "public", "HashResource", "restoreRelativeRoot", "(", "HashResource", "previousValue", ")", "{", "HashResource", "value", "=", "relativeRoot", ";", "relativeRoot", "=", "previousValue", ";", "return", "value", ";", "}" ]
Retrieve and clear the relative root for this context. @param previousValue previous value of the relative root to restore @return value of the relative root which was replaced
[ "Retrieve", "and", "clear", "the", "relative", "root", "for", "this", "context", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L258-L262
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.getDependencies
public Set<SourceFile> getDependencies() { Set<SourceFile> sourceFiles = new TreeSet<SourceFile>(); // Include all of the standard dependencies. for (Template t : dependencies.values()) { sourceFiles.add(t.sourceFile); } // Add the files that were looked-up but not found as well as the files // included via the file_contents() function. sourceFiles.addAll(otherDependencies); return Collections.unmodifiableSet(sourceFiles); }
java
public Set<SourceFile> getDependencies() { Set<SourceFile> sourceFiles = new TreeSet<SourceFile>(); // Include all of the standard dependencies. for (Template t : dependencies.values()) { sourceFiles.add(t.sourceFile); } // Add the files that were looked-up but not found as well as the files // included via the file_contents() function. sourceFiles.addAll(otherDependencies); return Collections.unmodifiableSet(sourceFiles); }
[ "public", "Set", "<", "SourceFile", ">", "getDependencies", "(", ")", "{", "Set", "<", "SourceFile", ">", "sourceFiles", "=", "new", "TreeSet", "<", "SourceFile", ">", "(", ")", ";", "// Include all of the standard dependencies.", "for", "(", "Template", "t", ...
Returns an unmodifiable copy of the dependencies.
[ "Returns", "an", "unmodifiable", "copy", "of", "the", "dependencies", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L280-L294
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.globalLoad
public Template globalLoad(String name, boolean lookupOnly) { // If this context was created without a Compiler object specified, then // no global lookups can be done. Just return null indicating that the // requested template can't be found. if (compiler == null) { return null; } // Use the full lookup to find the correct template file. This must // always be done on a global load because the actual template file on // disk may be different for different object templates. The raw // (unduplicated) value of LOADPATH can be used because it will not be // changed by the code below. SourceRepository repository = compiler.getSourceRepository(); SourceFile source = repository.retrievePanSource(name, relativeLoadpaths); if (source.isAbsent()) { if (lookupOnly) { // Files that were searched for but not found are still // dependencies. Keep track of these so that they can be // included in the dependency file and checked when trying to // see if profiles are up-to-date. otherDependencies.add(source); return null; } else { // The lookupOnly flag was not set, so it is an error if the // template has not been found. throw EvaluationException.create((SourceRange) null, (BuildContext) this, MSG_CANNOT_LOCATE_TEMPLATE, name); } } // Now actually retrieve the other object's root, waiting if the // result isn't yet available. CompileCache ccache = compiler.getCompileCache(); CompileResult cresult = ccache.waitForResult(source.getPath() .getAbsolutePath()); Template template = null; try { // Extract the compiled template and ensure that the name is // correct. The template must not be null if no exception is thrown. template = cresult.template; template.templateNameVerification(name); // Found the template. Put this into the dependencies only if we're // really going to use it. I.e. if the lookupOnly flag is false. if (!lookupOnly) { dependencies.put(name, template); if (template.type == TemplateType.OBJECT) { objectDependencies.add(template.name); } } } catch (SyntaxException se) { // This can happen if there is a syntax error while including // the given template. If this isn't just a lookup, then convert // this into an evaluation exception // and throw it. if (!lookupOnly) { throw new EvaluationException(se.getMessage()); } else { template = null; } } catch (EvaluationException ee) { // Eat the exception if we're only doing a lookup; otherwise, // rethrow it. if (!lookupOnly) { throw ee; } else { template = null; } } return template; }
java
public Template globalLoad(String name, boolean lookupOnly) { // If this context was created without a Compiler object specified, then // no global lookups can be done. Just return null indicating that the // requested template can't be found. if (compiler == null) { return null; } // Use the full lookup to find the correct template file. This must // always be done on a global load because the actual template file on // disk may be different for different object templates. The raw // (unduplicated) value of LOADPATH can be used because it will not be // changed by the code below. SourceRepository repository = compiler.getSourceRepository(); SourceFile source = repository.retrievePanSource(name, relativeLoadpaths); if (source.isAbsent()) { if (lookupOnly) { // Files that were searched for but not found are still // dependencies. Keep track of these so that they can be // included in the dependency file and checked when trying to // see if profiles are up-to-date. otherDependencies.add(source); return null; } else { // The lookupOnly flag was not set, so it is an error if the // template has not been found. throw EvaluationException.create((SourceRange) null, (BuildContext) this, MSG_CANNOT_LOCATE_TEMPLATE, name); } } // Now actually retrieve the other object's root, waiting if the // result isn't yet available. CompileCache ccache = compiler.getCompileCache(); CompileResult cresult = ccache.waitForResult(source.getPath() .getAbsolutePath()); Template template = null; try { // Extract the compiled template and ensure that the name is // correct. The template must not be null if no exception is thrown. template = cresult.template; template.templateNameVerification(name); // Found the template. Put this into the dependencies only if we're // really going to use it. I.e. if the lookupOnly flag is false. if (!lookupOnly) { dependencies.put(name, template); if (template.type == TemplateType.OBJECT) { objectDependencies.add(template.name); } } } catch (SyntaxException se) { // This can happen if there is a syntax error while including // the given template. If this isn't just a lookup, then convert // this into an evaluation exception // and throw it. if (!lookupOnly) { throw new EvaluationException(se.getMessage()); } else { template = null; } } catch (EvaluationException ee) { // Eat the exception if we're only doing a lookup; otherwise, // rethrow it. if (!lookupOnly) { throw ee; } else { template = null; } } return template; }
[ "public", "Template", "globalLoad", "(", "String", "name", ",", "boolean", "lookupOnly", ")", "{", "// If this context was created without a Compiler object specified, then", "// no global lookups can be done. Just return null indicating that the", "// requested template can't be found.", ...
A method to load a template from the global cache. This may trigger the global cache to compile the template.
[ "A", "method", "to", "load", "a", "template", "from", "the", "global", "cache", ".", "This", "may", "trigger", "the", "global", "cache", "to", "compile", "the", "template", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L339-L422
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.setBinding
public void setBinding(Path path, FullType fullType, Template template, SourceRange sourceRange) { assert (path != null); assert (path.isAbsolute()); assert (fullType != null); // Must make sure that all of the subtypes for the given type are // defined before adding the binding. try { fullType.verifySubtypesDefined(types); } catch (EvaluationException ee) { throw ee.addExceptionInfo(sourceRange, template.source, this.getTraceback(sourceRange)); } // Retrieve or create the list of bindings for this path. List<FullType> list = bindings.get(path); if (list == null) { list = new LinkedList<FullType>(); bindings.put(path, list); } // Add the binding. assert (list != null); list.add(fullType); }
java
public void setBinding(Path path, FullType fullType, Template template, SourceRange sourceRange) { assert (path != null); assert (path.isAbsolute()); assert (fullType != null); // Must make sure that all of the subtypes for the given type are // defined before adding the binding. try { fullType.verifySubtypesDefined(types); } catch (EvaluationException ee) { throw ee.addExceptionInfo(sourceRange, template.source, this.getTraceback(sourceRange)); } // Retrieve or create the list of bindings for this path. List<FullType> list = bindings.get(path); if (list == null) { list = new LinkedList<FullType>(); bindings.put(path, list); } // Add the binding. assert (list != null); list.add(fullType); }
[ "public", "void", "setBinding", "(", "Path", "path", ",", "FullType", "fullType", ",", "Template", "template", ",", "SourceRange", "sourceRange", ")", "{", "assert", "(", "path", "!=", "null", ")", ";", "assert", "(", "path", ".", "isAbsolute", "(", ")", ...
This method associates a type definition to a path. These bindings are checked as part of the validation process. Note that there can be more than one binding per path. @param path absolute path to bind to the type @param fullType data type to use @param template template where the binding was defined (used for error handling) @param sourceRange location in the template where the binding was defined (used for error handling)
[ "This", "method", "associates", "a", "type", "definition", "to", "a", "path", ".", "These", "bindings", "are", "checked", "as", "part", "of", "the", "validation", "process", ".", "Note", "that", "there", "can", "be", "more", "than", "one", "binding", "per"...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L530-L556
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.setGlobalVariable
public void setGlobalVariable(String name, Element value) { assert (name != null); GlobalVariable gvar = globalVariables.get(name); gvar.setValue(value); }
java
public void setGlobalVariable(String name, Element value) { assert (name != null); GlobalVariable gvar = globalVariables.get(name); gvar.setValue(value); }
[ "public", "void", "setGlobalVariable", "(", "String", "name", ",", "Element", "value", ")", "{", "assert", "(", "name", "!=", "null", ")", ";", "GlobalVariable", "gvar", "=", "globalVariables", ".", "get", "(", "name", ")", ";", "gvar", ".", "setValue", ...
Set the variable to the given value, preserving the status of the final flag. This will unconditionally set the value without checking if the value is final; be careful. The value must already exist.
[ "Set", "the", "variable", "to", "the", "given", "value", "preserving", "the", "status", "of", "the", "final", "flag", ".", "This", "will", "unconditionally", "set", "the", "value", "without", "checking", "if", "the", "value", "is", "final", ";", "be", "car...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L598-L604
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.setGlobalVariable
public void setGlobalVariable(String name, GlobalVariable variable) { assert (name != null); if (variable != null) { globalVariables.put(name, variable); } else { globalVariables.remove(name); } }
java
public void setGlobalVariable(String name, GlobalVariable variable) { assert (name != null); if (variable != null) { globalVariables.put(name, variable); } else { globalVariables.remove(name); } }
[ "public", "void", "setGlobalVariable", "(", "String", "name", ",", "GlobalVariable", "variable", ")", "{", "assert", "(", "name", "!=", "null", ")", ";", "if", "(", "variable", "!=", "null", ")", "{", "globalVariables", ".", "put", "(", "name", ",", "var...
Set the variable to the given GlobalVariable. If variable is null, then the global variable definition is removed. @param name global variable name @param variable GlobalVariable to associate with name
[ "Set", "the", "variable", "to", "the", "given", "GlobalVariable", ".", "If", "variable", "is", "null", "then", "the", "global", "variable", "definition", "is", "removed", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L615-L624
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.replaceGlobalVariable
public GlobalVariable replaceGlobalVariable(String name, Element value, boolean finalFlag) { assert (name != null); GlobalVariable oldVariable = globalVariables.get(name); GlobalVariable newVariable = new GlobalVariable(finalFlag, value); globalVariables.put(name, newVariable); return oldVariable; }
java
public GlobalVariable replaceGlobalVariable(String name, Element value, boolean finalFlag) { assert (name != null); GlobalVariable oldVariable = globalVariables.get(name); GlobalVariable newVariable = new GlobalVariable(finalFlag, value); globalVariables.put(name, newVariable); return oldVariable; }
[ "public", "GlobalVariable", "replaceGlobalVariable", "(", "String", "name", ",", "Element", "value", ",", "boolean", "finalFlag", ")", "{", "assert", "(", "name", "!=", "null", ")", ";", "GlobalVariable", "oldVariable", "=", "globalVariables", ".", "get", "(", ...
Replaces the given global variable with the given value. The flag indicates whether or not the variable should be marked as final. Note, however, that this routine does not respect the final flag and replaces the value unconditionally. The function returns the old value of the variable or null if it didn't exist.
[ "Replaces", "the", "given", "global", "variable", "with", "the", "given", "value", ".", "The", "flag", "indicates", "whether", "or", "not", "the", "variable", "should", "be", "marked", "as", "final", ".", "Note", "however", "that", "this", "routine", "does",...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L633-L642
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.setGlobalVariable
public void setGlobalVariable(String name, Element value, boolean finalFlag) { assert (name != null); // Either modify an existing value (with appropriate checks) or add a // new one. if (globalVariables.containsKey(name)) { GlobalVariable gvar = globalVariables.get(name); gvar.setValue(value); gvar.setFinalFlag(finalFlag); } else if (value != null) { GlobalVariable gvar = new GlobalVariable(finalFlag, value); globalVariables.put(name, gvar); } }
java
public void setGlobalVariable(String name, Element value, boolean finalFlag) { assert (name != null); // Either modify an existing value (with appropriate checks) or add a // new one. if (globalVariables.containsKey(name)) { GlobalVariable gvar = globalVariables.get(name); gvar.setValue(value); gvar.setFinalFlag(finalFlag); } else if (value != null) { GlobalVariable gvar = new GlobalVariable(finalFlag, value); globalVariables.put(name, gvar); } }
[ "public", "void", "setGlobalVariable", "(", "String", "name", ",", "Element", "value", ",", "boolean", "finalFlag", ")", "{", "assert", "(", "name", "!=", "null", ")", ";", "// Either modify an existing value (with appropriate checks) or add a", "// new one.", "if", "...
Set the variable to the given value. If the value is null, then the variable will be removed from the context.
[ "Set", "the", "variable", "to", "the", "given", "value", ".", "If", "the", "value", "is", "null", "then", "the", "variable", "will", "be", "removed", "from", "the", "context", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L649-L665
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.getGlobalVariable
public Element getGlobalVariable(String name) { GlobalVariable gvar = globalVariables.get(name); return (gvar != null) ? gvar.getValue() : null; }
java
public Element getGlobalVariable(String name) { GlobalVariable gvar = globalVariables.get(name); return (gvar != null) ? gvar.getValue() : null; }
[ "public", "Element", "getGlobalVariable", "(", "String", "name", ")", "{", "GlobalVariable", "gvar", "=", "globalVariables", ".", "get", "(", "name", ")", ";", "return", "(", "gvar", "!=", "null", ")", "?", "gvar", ".", "getValue", "(", ")", ":", "null",...
Return the Element which corresponds to the given variable name without duplicating the value. This is useful when dealing with SELF or with variables in a context where it is known that the value won't be modified.
[ "Return", "the", "Element", "which", "corresponds", "to", "the", "given", "variable", "name", "without", "duplicating", "the", "value", ".", "This", "is", "useful", "when", "dealing", "with", "SELF", "or", "with", "variables", "in", "a", "context", "where", ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L697-L700
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.getElement
public Element getElement(Path path, boolean errorIfNotFound) throws EvaluationException { // Set the initial node to use. Element node = null; // The initial element to use depends on the type of path. Define the // correct root element. switch (path.getType()) { case ABSOLUTE: // Typical, very easy case. All absolute paths refer to this object. node = root; break; case RELATIVE: // Check to see if we are within a structure template by checking if // relativeRoot is set. If set, then proceed with lookup, otherwise // fail. if (relativeRoot != null) { node = relativeRoot; } else { throw new EvaluationException( "relative path ('" + path + "') cannot be used to retrieve element in configuration"); } break; case EXTERNAL: // This is an external path. Check the authority. String myObject = objectTemplate.name; String externalObject = path.getAuthority(); if (myObject.equals(externalObject)) { // Easy case, this references itself. Just set the initial node // to the root of this object. node = root; } else { // FIXME: Review this code. Much can probably be deleted. // Harder case, we must lookup the other object template, // compiling and building it as necessary. // Try loading the template. This may throw an // EvaluationException if something goes wrong in the load. Template externalTemplate = localAndGlobalLoad(externalObject, !errorIfNotFound); // Check to see if the template was found. if (externalTemplate != null && !errorIfNotFound) { // If we asked for only a lookup of the template, then we // need to ensure that the referenced template is added to // the dependencies. dependencies.put(externalObject, externalTemplate); objectDependencies.add(externalObject); } else if (externalTemplate == null) { // Throw an error or return null as appropriate. if (errorIfNotFound) { throw new EvaluationException("object template " + externalObject + " could not be found", null); } else { return null; } } // Verify that the retrieved template is actually an object // template. if (externalTemplate.type != TemplateType.OBJECT) { throw new EvaluationException(externalObject + " does not refer to an object template"); } // Retrieve the build cache. BuildCache bcache = compiler.getBuildCache(); // Only check the object dependencies if this object is // currently in the "build" phase. If this is being validated, // then circular dependencies will be handled without problems. // If dependencies are checked, check BEFORE waiting for the // external object, otherwise the compilation may deadlock. if (checkObjectDependencies) { bcache.setDependency(myObject, externalObject); } // Wait for the result and set the node to the external object's // root element. BuildResult result = (BuildResult) bcache .waitForResult(externalObject); node = result.getRoot(); } break; } // Now that the root node is defined, recursively descend through the // given terms to retrieve the desired element. assert (node != null); try { node = node.rget(path.getTerms(), 0, node.isProtected(), !errorIfNotFound); } catch (InvalidTermException ite) { throw new EvaluationException(ite.formatMessage(path)); } if (!errorIfNotFound || node != null) { return node; } else { throw new EvaluationException(MessageUtils.format( MSG_NO_VALUE_FOR_PATH, path.toString())); } }
java
public Element getElement(Path path, boolean errorIfNotFound) throws EvaluationException { // Set the initial node to use. Element node = null; // The initial element to use depends on the type of path. Define the // correct root element. switch (path.getType()) { case ABSOLUTE: // Typical, very easy case. All absolute paths refer to this object. node = root; break; case RELATIVE: // Check to see if we are within a structure template by checking if // relativeRoot is set. If set, then proceed with lookup, otherwise // fail. if (relativeRoot != null) { node = relativeRoot; } else { throw new EvaluationException( "relative path ('" + path + "') cannot be used to retrieve element in configuration"); } break; case EXTERNAL: // This is an external path. Check the authority. String myObject = objectTemplate.name; String externalObject = path.getAuthority(); if (myObject.equals(externalObject)) { // Easy case, this references itself. Just set the initial node // to the root of this object. node = root; } else { // FIXME: Review this code. Much can probably be deleted. // Harder case, we must lookup the other object template, // compiling and building it as necessary. // Try loading the template. This may throw an // EvaluationException if something goes wrong in the load. Template externalTemplate = localAndGlobalLoad(externalObject, !errorIfNotFound); // Check to see if the template was found. if (externalTemplate != null && !errorIfNotFound) { // If we asked for only a lookup of the template, then we // need to ensure that the referenced template is added to // the dependencies. dependencies.put(externalObject, externalTemplate); objectDependencies.add(externalObject); } else if (externalTemplate == null) { // Throw an error or return null as appropriate. if (errorIfNotFound) { throw new EvaluationException("object template " + externalObject + " could not be found", null); } else { return null; } } // Verify that the retrieved template is actually an object // template. if (externalTemplate.type != TemplateType.OBJECT) { throw new EvaluationException(externalObject + " does not refer to an object template"); } // Retrieve the build cache. BuildCache bcache = compiler.getBuildCache(); // Only check the object dependencies if this object is // currently in the "build" phase. If this is being validated, // then circular dependencies will be handled without problems. // If dependencies are checked, check BEFORE waiting for the // external object, otherwise the compilation may deadlock. if (checkObjectDependencies) { bcache.setDependency(myObject, externalObject); } // Wait for the result and set the node to the external object's // root element. BuildResult result = (BuildResult) bcache .waitForResult(externalObject); node = result.getRoot(); } break; } // Now that the root node is defined, recursively descend through the // given terms to retrieve the desired element. assert (node != null); try { node = node.rget(path.getTerms(), 0, node.isProtected(), !errorIfNotFound); } catch (InvalidTermException ite) { throw new EvaluationException(ite.formatMessage(path)); } if (!errorIfNotFound || node != null) { return node; } else { throw new EvaluationException(MessageUtils.format( MSG_NO_VALUE_FOR_PATH, path.toString())); } }
[ "public", "Element", "getElement", "(", "Path", "path", ",", "boolean", "errorIfNotFound", ")", "throws", "EvaluationException", "{", "// Set the initial node to use.", "Element", "node", "=", "null", ";", "// The initial element to use depends on the type of path. Define the",...
Pull the value of an element from a configuration tree. This can either be an absolute, relative, or external path. @param path path to lookup @param errorIfNotFound if true an EvaluationException will be thrown if the path can't be found @return Element associated to the given path @throws EvaluationException if the path can't be found and errorIfNotFound is set, or if the path is relative and relativeRoot isn't set
[ "Pull", "the", "value", "of", "an", "element", "from", "a", "configuration", "tree", ".", "This", "can", "either", "be", "an", "absolute", "relative", "or", "external", "path", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L808-L930
train
quattor/pan
panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java
BuildContext.setLocalVariable
public void setLocalVariable(String name, Term[] terms, Element value) throws EvaluationException { assert (name != null); // Only truly local variables can be set via this method. Throw an // exception if a global variable is found which matches the name. if (globalVariables.containsKey(name)) { throw new EvaluationException(MessageUtils.format( MSG_CANNOT_MODIFY_GLOBAL_VARIABLE_FROM_DML, name)); } if (terms == null || terms.length == 0) { // Revert back to the simple case that does not require // dereferencing. setLocalVariable(name, value); } else { // The more complicated case where we need to dereference the // variable. (And also possibly create the parents.) // Retrieve the value of the local variable. Element var = getLocalVariable(name); // If the value is a protected resource, then make a shallow copy // and replace the value of the local variable. if (var != null && var.isProtected()) { var = var.writableCopy(); setLocalVariable(name, var); } // If the value does not exist, create a resource of the correct // type and insert into variable table. if (var == null || var instanceof Undef) { Term term = terms[0]; if (term.isKey()) { var = new HashResource(); } else { var = new ListResource(); } setLocalVariable(name, var); } // Recursively descend to set the value. assert (var != null); try { var.rput(terms, 0, value); } catch (InvalidTermException ite) { throw new EvaluationException(ite.formatVariableMessage(name, terms)); } } }
java
public void setLocalVariable(String name, Term[] terms, Element value) throws EvaluationException { assert (name != null); // Only truly local variables can be set via this method. Throw an // exception if a global variable is found which matches the name. if (globalVariables.containsKey(name)) { throw new EvaluationException(MessageUtils.format( MSG_CANNOT_MODIFY_GLOBAL_VARIABLE_FROM_DML, name)); } if (terms == null || terms.length == 0) { // Revert back to the simple case that does not require // dereferencing. setLocalVariable(name, value); } else { // The more complicated case where we need to dereference the // variable. (And also possibly create the parents.) // Retrieve the value of the local variable. Element var = getLocalVariable(name); // If the value is a protected resource, then make a shallow copy // and replace the value of the local variable. if (var != null && var.isProtected()) { var = var.writableCopy(); setLocalVariable(name, var); } // If the value does not exist, create a resource of the correct // type and insert into variable table. if (var == null || var instanceof Undef) { Term term = terms[0]; if (term.isKey()) { var = new HashResource(); } else { var = new ListResource(); } setLocalVariable(name, var); } // Recursively descend to set the value. assert (var != null); try { var.rput(terms, 0, value); } catch (InvalidTermException ite) { throw new EvaluationException(ite.formatVariableMessage(name, terms)); } } }
[ "public", "void", "setLocalVariable", "(", "String", "name", ",", "Term", "[", "]", "terms", ",", "Element", "value", ")", "throws", "EvaluationException", "{", "assert", "(", "name", "!=", "null", ")", ";", "// Only truly local variables can be set via this method....
Set the local variable to the given value. If the value is null, then the corresponding variable will be removed. If there is a global variable of the same name, then an EvaluationException will be thrown. @param name name of the local variable @param terms terms used to dereference the variable, or null if the variable is to be used directly @param value value to use or null to remove the variable @throws EvaluationException if there is a global variable with the same name as the local variable
[ "Set", "the", "local", "variable", "to", "the", "given", "value", ".", "If", "the", "value", "is", "null", "then", "the", "corresponding", "variable", "will", "be", "removed", ".", "If", "there", "is", "a", "global", "variable", "of", "the", "same", "nam...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/BuildContext.java#L1248-L1304
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/SilentChangeExecutor.java
SilentChangeExecutor.execute
public void execute(final Object observable, final Runnable change) { listeners.disableFor(observable); change.run(); listeners.enableFor(observable); }
java
public void execute(final Object observable, final Runnable change) { listeners.disableFor(observable); change.run(); listeners.enableFor(observable); }
[ "public", "void", "execute", "(", "final", "Object", "observable", ",", "final", "Runnable", "change", ")", "{", "listeners", ".", "disableFor", "(", "observable", ")", ";", "change", ".", "run", "(", ")", ";", "listeners", ".", "enableFor", "(", "observab...
Executes a change to an observable of the users domain model without generating change commands for this change. <p> Any changes done to the users domain model are executed over the model change executor passed in the constructor. </p> @param observable The observable that is changed. @param change The change that is done to the observable.
[ "Executes", "a", "change", "to", "an", "observable", "of", "the", "users", "domain", "model", "without", "generating", "change", "commands", "for", "this", "change", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/SilentChangeExecutor.java#L48-L52
train
quattor/pan
panc/src/main/java/org/quattor/pan/statement/IncludeStatement.java
IncludeStatement.executeWithNamedTemplate
protected void executeWithNamedTemplate(Context context, String name) throws EvaluationException { assert (context != null); assert (name != null); Template template = null; boolean runStatic = false; try { template = context.localLoad(name); if (template == null) { template = context.globalLoad(name); runStatic = true; } } catch (EvaluationException ee) { throw ee.addExceptionInfo(getSourceRange(), context); } // Check that the template was actually loaded. if (template == null) { throw new EvaluationException("failed to load template: " + name, getSourceRange()); } TemplateType includeeType = context.getCurrentTemplate().type; TemplateType includedType = template.type; // Check that the template types are correct for the inclusion. if (!Template.checkValidInclude(includeeType, includedType)) { throw new EvaluationException(includeeType + " template cannot include " + includedType + " template", getSourceRange()); } // Push the template, execute it, then pop it from the stack. // Template loops will be caught by the call depth check when pushing // the template. context.pushTemplate(template, getSourceRange(), Level.INFO, includedType.toString()); template.execute(context, runStatic); context.popTemplate(Level.INFO, includedType.toString()); }
java
protected void executeWithNamedTemplate(Context context, String name) throws EvaluationException { assert (context != null); assert (name != null); Template template = null; boolean runStatic = false; try { template = context.localLoad(name); if (template == null) { template = context.globalLoad(name); runStatic = true; } } catch (EvaluationException ee) { throw ee.addExceptionInfo(getSourceRange(), context); } // Check that the template was actually loaded. if (template == null) { throw new EvaluationException("failed to load template: " + name, getSourceRange()); } TemplateType includeeType = context.getCurrentTemplate().type; TemplateType includedType = template.type; // Check that the template types are correct for the inclusion. if (!Template.checkValidInclude(includeeType, includedType)) { throw new EvaluationException(includeeType + " template cannot include " + includedType + " template", getSourceRange()); } // Push the template, execute it, then pop it from the stack. // Template loops will be caught by the call depth check when pushing // the template. context.pushTemplate(template, getSourceRange(), Level.INFO, includedType.toString()); template.execute(context, runStatic); context.popTemplate(Level.INFO, includedType.toString()); }
[ "protected", "void", "executeWithNamedTemplate", "(", "Context", "context", ",", "String", "name", ")", "throws", "EvaluationException", "{", "assert", "(", "context", "!=", "null", ")", ";", "assert", "(", "name", "!=", "null", ")", ";", "Template", "template...
This is a utility method which performs an include from a fixed template name. The validity of the name should be checked by the subclass; this avoids unnecessary regular expression matching. @param context evaluation context to use @param name fixed template name @throws EvaluationException
[ "This", "is", "a", "utility", "method", "which", "performs", "an", "include", "from", "a", "fixed", "template", "name", ".", "The", "validity", "of", "the", "name", "should", "be", "checked", "by", "the", "subclass", ";", "this", "avoids", "unnecessary", "...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/statement/IncludeStatement.java#L122-L165
train
quattor/pan
panc/src/main/java/org/quattor/pan/statement/IncludeStatement.java
IncludeStatement.runDefaultDml
static private Element runDefaultDml(Operation dml) throws SyntaxException { // If the argument is null, return null as the value immediately. if (dml == null) { return null; } // Create a nearly empty execution context. There are no global // variables by default (including no 'SELF' variable). Only the // standard built-in functions are accessible. Context context = new CompileTimeContext(); Element value = null; // Execute the DML block. The block must evaluate to an Element. Any // error is fatal for the compilation. try { value = context.executeDmlBlock(dml); } catch (EvaluationException consumed) { value = null; } return value; }
java
static private Element runDefaultDml(Operation dml) throws SyntaxException { // If the argument is null, return null as the value immediately. if (dml == null) { return null; } // Create a nearly empty execution context. There are no global // variables by default (including no 'SELF' variable). Only the // standard built-in functions are accessible. Context context = new CompileTimeContext(); Element value = null; // Execute the DML block. The block must evaluate to an Element. Any // error is fatal for the compilation. try { value = context.executeDmlBlock(dml); } catch (EvaluationException consumed) { value = null; } return value; }
[ "static", "private", "Element", "runDefaultDml", "(", "Operation", "dml", ")", "throws", "SyntaxException", "{", "// If the argument is null, return null as the value immediately.", "if", "(", "dml", "==", "null", ")", "{", "return", "null", ";", "}", "// Create a nearl...
can be reused.
[ "can", "be", "reused", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/statement/IncludeStatement.java#L170-L193
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/offline/Offliner.java
Offliner.retrieveFromCache
private String retrieveFromCache(String url) { String savedJson; savedJson = mCacheQueryHandler.get(getContext(), url); log("---------- body found in offline saver : " + savedJson); log("----- NO NETWORK : retrieving ends"); return savedJson; }
java
private String retrieveFromCache(String url) { String savedJson; savedJson = mCacheQueryHandler.get(getContext(), url); log("---------- body found in offline saver : " + savedJson); log("----- NO NETWORK : retrieving ends"); return savedJson; }
[ "private", "String", "retrieveFromCache", "(", "String", "url", ")", "{", "String", "savedJson", ";", "savedJson", "=", "mCacheQueryHandler", ".", "get", "(", "getContext", "(", ")", ",", "url", ")", ";", "log", "(", "\"---------- body found in offline saver : \""...
Get a saved body for a given url. @param url url for which we need to retrieve the response body in offline mode. @return response body as string.
[ "Get", "a", "saved", "body", "for", "a", "given", "url", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/offline/Offliner.java#L156-L163
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/offline/Offliner.java
Offliner.getContext
private Context getContext() { Context context = mContext.get(); if (context == null) { throw new IllegalStateException("Context used by the instance has been destroyed."); } return context; }
java
private Context getContext() { Context context = mContext.get(); if (context == null) { throw new IllegalStateException("Context used by the instance has been destroyed."); } return context; }
[ "private", "Context", "getContext", "(", ")", "{", "Context", "context", "=", "mContext", ".", "get", "(", ")", ";", "if", "(", "context", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Context used by the instance has been destroyed.\"",...
Retrieve the context if not yet garbage collected. @return context.
[ "Retrieve", "the", "context", "if", "not", "yet", "garbage", "collected", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/offline/Offliner.java#L181-L187
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/offline/Offliner.java
Offliner.save
private Response save(Response response) { String jsonBody; String key = response.request().url().toString(); log("----- SAVE FOR OFFLINE : saving starts"); log("---------- for request : " + key); log("---------- trying to parse response body"); //Try to get response body BufferedReader reader; StringBuilder sb = new StringBuilder(); log("---------- trying to parse response body"); InputStream bodyStream = response.body().byteStream(); InputStreamReader bodyReader = new InputStreamReader(bodyStream, Charset.forName("UTF-8")); reader = new BufferedReader(bodyReader); String line; try { while ((line = reader.readLine()) != null) { sb.append(line); } bodyReader.close(); bodyReader.close(); reader.close(); } catch (IOException e) { Log.e(TAG, "IOException : " + e.getMessage()); } jsonBody = sb.toString(); log("---------- trying to save response body for offline"); mCacheQueryHandler.put(key, jsonBody); log("---------- url : " + key); log("---------- body : " + jsonBody); log("----- SAVE FOR OFFLINE : saving ends"); return response.newBuilder().body(ResponseBody.create(response.body().contentType(), jsonBody)).build(); }
java
private Response save(Response response) { String jsonBody; String key = response.request().url().toString(); log("----- SAVE FOR OFFLINE : saving starts"); log("---------- for request : " + key); log("---------- trying to parse response body"); //Try to get response body BufferedReader reader; StringBuilder sb = new StringBuilder(); log("---------- trying to parse response body"); InputStream bodyStream = response.body().byteStream(); InputStreamReader bodyReader = new InputStreamReader(bodyStream, Charset.forName("UTF-8")); reader = new BufferedReader(bodyReader); String line; try { while ((line = reader.readLine()) != null) { sb.append(line); } bodyReader.close(); bodyReader.close(); reader.close(); } catch (IOException e) { Log.e(TAG, "IOException : " + e.getMessage()); } jsonBody = sb.toString(); log("---------- trying to save response body for offline"); mCacheQueryHandler.put(key, jsonBody); log("---------- url : " + key); log("---------- body : " + jsonBody); log("----- SAVE FOR OFFLINE : saving ends"); return response.newBuilder().body(ResponseBody.create(response.body().contentType(), jsonBody)).build(); }
[ "private", "Response", "save", "(", "Response", "response", ")", "{", "String", "jsonBody", ";", "String", "key", "=", "response", ".", "request", "(", ")", ".", "url", "(", ")", ".", "toString", "(", ")", ";", "log", "(", "\"----- SAVE FOR OFFLINE : savin...
Allow to save the Response body for offline usage. @param response response to save
[ "Allow", "to", "save", "the", "Response", "body", "for", "offline", "usage", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/offline/Offliner.java#L194-L234
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java
CheerleaderPlayer.destroy
public void destroy() { if (mIsClosed) { return; } if (mState != STATE_STOPPED) { mDestroyDelayed = true; return; } mIsClosed = true; PlaybackService.unregisterListener(getContext(), mInternalListener); mInternalListener = null; mApplicationContext.clear(); mApplicationContext = null; mClientKey = null; mPlayerPlaylist = null; mCheerleaderPlayerListeners.clear(); }
java
public void destroy() { if (mIsClosed) { return; } if (mState != STATE_STOPPED) { mDestroyDelayed = true; return; } mIsClosed = true; PlaybackService.unregisterListener(getContext(), mInternalListener); mInternalListener = null; mApplicationContext.clear(); mApplicationContext = null; mClientKey = null; mPlayerPlaylist = null; mCheerleaderPlayerListeners.clear(); }
[ "public", "void", "destroy", "(", ")", "{", "if", "(", "mIsClosed", ")", "{", "return", ";", "}", "if", "(", "mState", "!=", "STATE_STOPPED", ")", "{", "mDestroyDelayed", "=", "true", ";", "return", ";", "}", "mIsClosed", "=", "true", ";", "PlaybackSer...
Release resources associated with the player.
[ "Release", "resources", "associated", "with", "the", "player", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java#L141-L160
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java
CheerleaderPlayer.play
public void play(int position) { checkState(); ArrayList<SoundCloudTrack> tracks = mPlayerPlaylist.getPlaylist().getTracks(); if (position >= 0 && position < tracks.size()) { SoundCloudTrack trackToPlay = tracks.get(position); mPlayerPlaylist.setPlayingTrack(position); PlaybackService.play(getContext(), mClientKey, trackToPlay); } }
java
public void play(int position) { checkState(); ArrayList<SoundCloudTrack> tracks = mPlayerPlaylist.getPlaylist().getTracks(); if (position >= 0 && position < tracks.size()) { SoundCloudTrack trackToPlay = tracks.get(position); mPlayerPlaylist.setPlayingTrack(position); PlaybackService.play(getContext(), mClientKey, trackToPlay); } }
[ "public", "void", "play", "(", "int", "position", ")", "{", "checkState", "(", ")", ";", "ArrayList", "<", "SoundCloudTrack", ">", "tracks", "=", "mPlayerPlaylist", ".", "getPlaylist", "(", ")", ".", "getTracks", "(", ")", ";", "if", "(", "position", ">=...
Play a track at a given position in the player playlist. @param position position of the track in the playlist.
[ "Play", "a", "track", "at", "a", "given", "position", "in", "the", "player", "playlist", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java#L187-L196
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java
CheerleaderPlayer.addTrack
public void addTrack(SoundCloudTrack track, boolean playNow) { checkState(); mPlayerPlaylist.add(track); for (CheerleaderPlaylistListener listener : mCheerleaderPlaylistListeners) { listener.onTrackAdded(track); } if (playNow) { play(mPlayerPlaylist.size() - 1); } }
java
public void addTrack(SoundCloudTrack track, boolean playNow) { checkState(); mPlayerPlaylist.add(track); for (CheerleaderPlaylistListener listener : mCheerleaderPlaylistListeners) { listener.onTrackAdded(track); } if (playNow) { play(mPlayerPlaylist.size() - 1); } }
[ "public", "void", "addTrack", "(", "SoundCloudTrack", "track", ",", "boolean", "playNow", ")", "{", "checkState", "(", ")", ";", "mPlayerPlaylist", ".", "add", "(", "track", ")", ";", "for", "(", "CheerleaderPlaylistListener", "listener", ":", "mCheerleaderPlayl...
Add a track to the current SoundCloud player playlist. @param track {@link fr.tvbarthel.cheerleader.library.client.SoundCloudTrack} to be added to the player. @param playNow true to play the track immediately.
[ "Add", "a", "track", "to", "the", "current", "SoundCloud", "player", "playlist", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java#L313-L322
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java
CheerleaderPlayer.addTracks
public void addTracks(List<SoundCloudTrack> tracks) { checkState(); for (SoundCloudTrack track : tracks) { addTrack(track); } }
java
public void addTracks(List<SoundCloudTrack> tracks) { checkState(); for (SoundCloudTrack track : tracks) { addTrack(track); } }
[ "public", "void", "addTracks", "(", "List", "<", "SoundCloudTrack", ">", "tracks", ")", "{", "checkState", "(", ")", ";", "for", "(", "SoundCloudTrack", "track", ":", "tracks", ")", "{", "addTrack", "(", "track", ")", ";", "}", "}" ]
Add a list of track to thr current SoundCloud player playlist. @param tracks list of {@link fr.tvbarthel.cheerleader.library.client.SoundCloudTrack} to be added to the player.
[ "Add", "a", "list", "of", "track", "to", "thr", "current", "SoundCloud", "player", "playlist", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java#L330-L335
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java
CheerleaderPlayer.registerPlayerListener
public void registerPlayerListener(CheerleaderPlayerListener listener) { checkState(); mCheerleaderPlayerListeners.add(listener); if (mState == STATE_PLAYING) { listener.onPlayerPlay(mPlayerPlaylist.getCurrentTrack(), mPlayerPlaylist.getCurrentTrackIndex()); } else if (mState == STATE_PAUSED) { listener.onPlayerPause(); } }
java
public void registerPlayerListener(CheerleaderPlayerListener listener) { checkState(); mCheerleaderPlayerListeners.add(listener); if (mState == STATE_PLAYING) { listener.onPlayerPlay(mPlayerPlaylist.getCurrentTrack(), mPlayerPlaylist.getCurrentTrackIndex()); } else if (mState == STATE_PAUSED) { listener.onPlayerPause(); } }
[ "public", "void", "registerPlayerListener", "(", "CheerleaderPlayerListener", "listener", ")", "{", "checkState", "(", ")", ";", "mCheerleaderPlayerListeners", ".", "add", "(", "listener", ")", ";", "if", "(", "mState", "==", "STATE_PLAYING", ")", "{", "listener",...
Register a listener to catch player events. @param listener listener to register.
[ "Register", "a", "listener", "to", "catch", "player", "events", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java#L403-L411
train
tvbarthel/Cheerleader
library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java
CheerleaderPlayer.initInternalListener
private void initInternalListener(Context context) { mInternalListener = new PlaybackListener() { @Override protected void onPlay(SoundCloudTrack track) { super.onPlay(track); mState = STATE_PLAYING; for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerPlay(track, mPlayerPlaylist.getCurrentTrackIndex()); } } @Override protected void onPause() { super.onPause(); mState = STATE_PAUSED; for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerPause(); } } @Override protected void onPlayerDestroyed() { super.onPlayerDestroyed(); mState = STATE_STOPPED; for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerDestroyed(); } if (mDestroyDelayed) { CheerleaderPlayer.this.destroy(); } } @Override protected void onSeekTo(int milli) { super.onSeekTo(milli); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerSeekTo(milli); } } @Override protected void onBufferingStarted() { super.onBufferingStarted(); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onBufferingStarted(); } } @Override protected void onBufferingEnded() { super.onBufferingEnded(); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onBufferingEnded(); } } @Override protected void onProgressChanged(int milli) { super.onProgressChanged(milli); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onProgressChanged(milli); } } }; PlaybackService.registerListener(context, mInternalListener); }
java
private void initInternalListener(Context context) { mInternalListener = new PlaybackListener() { @Override protected void onPlay(SoundCloudTrack track) { super.onPlay(track); mState = STATE_PLAYING; for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerPlay(track, mPlayerPlaylist.getCurrentTrackIndex()); } } @Override protected void onPause() { super.onPause(); mState = STATE_PAUSED; for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerPause(); } } @Override protected void onPlayerDestroyed() { super.onPlayerDestroyed(); mState = STATE_STOPPED; for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerDestroyed(); } if (mDestroyDelayed) { CheerleaderPlayer.this.destroy(); } } @Override protected void onSeekTo(int milli) { super.onSeekTo(milli); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onPlayerSeekTo(milli); } } @Override protected void onBufferingStarted() { super.onBufferingStarted(); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onBufferingStarted(); } } @Override protected void onBufferingEnded() { super.onBufferingEnded(); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onBufferingEnded(); } } @Override protected void onProgressChanged(int milli) { super.onProgressChanged(milli); for (CheerleaderPlayerListener listener : mCheerleaderPlayerListeners) { listener.onProgressChanged(milli); } } }; PlaybackService.registerListener(context, mInternalListener); }
[ "private", "void", "initInternalListener", "(", "Context", "context", ")", "{", "mInternalListener", "=", "new", "PlaybackListener", "(", ")", "{", "@", "Override", "protected", "void", "onPlay", "(", "SoundCloudTrack", "track", ")", "{", "super", ".", "onPlay",...
Initialize the internal listener. @param context context used to register the internal listener.
[ "Initialize", "the", "internal", "listener", "." ]
f61527e4cc44fcd0ed2e1e98aca285f8c236f24e
https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/CheerleaderPlayer.java#L460-L525
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/MessageUtils.java
MessageUtils.getMessageString
public static String getMessageString(String msgKey) { assert (msgKey != null); try { return bundle.getString(msgKey); } catch (MissingResourceException mre) { throw new CompilerError(mre.getLocalizedMessage()); } catch (ClassCastException cce) { throw new CompilerError("bundle contains non-string object for key '" + msgKey + "'"); } }
java
public static String getMessageString(String msgKey) { assert (msgKey != null); try { return bundle.getString(msgKey); } catch (MissingResourceException mre) { throw new CompilerError(mre.getLocalizedMessage()); } catch (ClassCastException cce) { throw new CompilerError("bundle contains non-string object for key '" + msgKey + "'"); } }
[ "public", "static", "String", "getMessageString", "(", "String", "msgKey", ")", "{", "assert", "(", "msgKey", "!=", "null", ")", ";", "try", "{", "return", "bundle", ".", "getString", "(", "msgKey", ")", ";", "}", "catch", "(", "MissingResourceException", ...
Look up a localized message in the message bundle and return a MessageFormat for it. @param msgKey key that identifies which message to retrieve @return MessageFormat corresponding to the given key
[ "Look", "up", "a", "localized", "message", "in", "the", "message", "bundle", "and", "return", "a", "MessageFormat", "for", "it", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/MessageUtils.java#L529-L542
train
quattor/pan
panc/src/main/java/org/quattor/pan/utils/MessageUtils.java
MessageUtils.format
public static String format(String msgKey, Object... args) { try { return MessageFormat.format(getMessageString(msgKey), args); } catch (IllegalArgumentException iae) { throw new CompilerError( "bundle contains invalid message format for key '" + msgKey + "'\n" + "error: " + iae.getMessage()); } }
java
public static String format(String msgKey, Object... args) { try { return MessageFormat.format(getMessageString(msgKey), args); } catch (IllegalArgumentException iae) { throw new CompilerError( "bundle contains invalid message format for key '" + msgKey + "'\n" + "error: " + iae.getMessage()); } }
[ "public", "static", "String", "format", "(", "String", "msgKey", ",", "Object", "...", "args", ")", "{", "try", "{", "return", "MessageFormat", ".", "format", "(", "getMessageString", "(", "msgKey", ")", ",", "args", ")", ";", "}", "catch", "(", "Illegal...
Format a message corresponding to the given key and using the given arguments. @param msgKey key that identifies which message to retrieve @param args arguments to use to complete the message @return localized String corresponding to the given key and arguments
[ "Format", "a", "message", "corresponding", "to", "the", "given", "key", "and", "using", "the", "given", "arguments", "." ]
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/utils/MessageUtils.java#L551-L563
train
saxsys/SynchronizeFX
synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ReparingListPropertyCommandExecutor.java
ReparingListPropertyCommandExecutor.execute
@SuppressWarnings({ "rawtypes", "unchecked" }) // The alternative would be to change the TopologolyLayerCallback.send() to take List<? extends Command> private void execute(final ListCommand command) { getMetaData(command); final Queue<ListCommand> log = metaData.getUnapprovedCommands(); if (log.isEmpty()) { updateVersion(command); executeCommand(command); } else if (log.peek().getListVersionChange().equals(command.getListVersionChange())) { updateVersion(command); log.remove(); } else { // repair indices List<? extends ListCommand> repairedCommands = indexRepairer.repairCommands( metaData.getUnapprovedCommands(), command); // repair versions if local commands are left after repairing indices. versionRepairer.repairLocalCommandsVersion(metaData.getUnapprovedCommands(), command); repairedCommands = versionRepairer.repairRemoteCommandVersion(repairedCommands, metaData.getUnapprovedCommandsAsList()); // re-send repaired local changes topologyLayerCallback.sendCommands((List) metaData.getUnapprovedCommandsAsList()); // execute repaired commands for (final ListCommand repaired : repairedCommands) { executeCommand(repaired); } updateVersion(command); } }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) // The alternative would be to change the TopologolyLayerCallback.send() to take List<? extends Command> private void execute(final ListCommand command) { getMetaData(command); final Queue<ListCommand> log = metaData.getUnapprovedCommands(); if (log.isEmpty()) { updateVersion(command); executeCommand(command); } else if (log.peek().getListVersionChange().equals(command.getListVersionChange())) { updateVersion(command); log.remove(); } else { // repair indices List<? extends ListCommand> repairedCommands = indexRepairer.repairCommands( metaData.getUnapprovedCommands(), command); // repair versions if local commands are left after repairing indices. versionRepairer.repairLocalCommandsVersion(metaData.getUnapprovedCommands(), command); repairedCommands = versionRepairer.repairRemoteCommandVersion(repairedCommands, metaData.getUnapprovedCommandsAsList()); // re-send repaired local changes topologyLayerCallback.sendCommands((List) metaData.getUnapprovedCommandsAsList()); // execute repaired commands for (final ListCommand repaired : repairedCommands) { executeCommand(repaired); } updateVersion(command); } }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "// The alternative would be to change the TopologolyLayerCallback.send() to take List<? extends Command>", "private", "void", "execute", "(", "final", "ListCommand", "command", ")", "{", "getMet...
Executes a remotely received command, repairs it when necessary and resends repaired versions of local commands that where obsoleted by the received command. @param command The command to execute.
[ "Executes", "a", "remotely", "received", "command", "repairs", "it", "when", "necessary", "and", "resends", "repaired", "versions", "of", "local", "commands", "that", "where", "obsoleted", "by", "the", "received", "command", "." ]
f3683020e4749110b38514eb5bc73a247998b579
https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ReparingListPropertyCommandExecutor.java#L123-L153
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java
AbstractElement.checkValidReplacement
public void checkValidReplacement(Element newValue) throws EvaluationException { // Only need to check if new values is not undef or null. Undef or null // can replace any value. if (!(newValue instanceof Undef) && !(newValue instanceof Null)) { if (!this.getClass().isAssignableFrom(newValue.getClass())) { throw new EvaluationException(MessageUtils.format( MSG_INVALID_REPLACEMENT, this.getTypeAsString(), newValue.getTypeAsString())); } } }
java
public void checkValidReplacement(Element newValue) throws EvaluationException { // Only need to check if new values is not undef or null. Undef or null // can replace any value. if (!(newValue instanceof Undef) && !(newValue instanceof Null)) { if (!this.getClass().isAssignableFrom(newValue.getClass())) { throw new EvaluationException(MessageUtils.format( MSG_INVALID_REPLACEMENT, this.getTypeAsString(), newValue.getTypeAsString())); } } }
[ "public", "void", "checkValidReplacement", "(", "Element", "newValue", ")", "throws", "EvaluationException", "{", "// Only need to check if new values is not undef or null. Undef or null", "// can replace any value.", "if", "(", "!", "(", "newValue", "instanceof", "Undef", ")",...
Check that the newValue is a valid replacement for the this value. This implementation will check if the newValue is assignable from the current value or that the newValue is either undef or null. If not, an evaluation exception will be thrown. This implementation should be overridden if more liberal replacements are allowed. @param newValue the new value for the replacement @throws org.quattor.pan.exceptions.EvaluationException if the new value is not a valid replacement of the existing value
[ "Check", "that", "the", "newValue", "is", "a", "valid", "replacement", "for", "the", "this", "value", ".", "This", "implementation", "will", "check", "if", "the", "newValue", "is", "assignable", "from", "the", "current", "value", "or", "that", "the", "newVal...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java#L170-L185
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java
AbstractElement.rget
public Element rget(Term[] terms, int index, boolean protect, boolean lookupOnly) throws InvalidTermException { if (!lookupOnly) { throw new EvaluationException(MessageUtils.format( MSG_ILLEGAL_DEREFERENCE, this.getTypeAsString())); } return null; }
java
public Element rget(Term[] terms, int index, boolean protect, boolean lookupOnly) throws InvalidTermException { if (!lookupOnly) { throw new EvaluationException(MessageUtils.format( MSG_ILLEGAL_DEREFERENCE, this.getTypeAsString())); } return null; }
[ "public", "Element", "rget", "(", "Term", "[", "]", "terms", ",", "int", "index", ",", "boolean", "protect", ",", "boolean", "lookupOnly", ")", "throws", "InvalidTermException", "{", "if", "(", "!", "lookupOnly", ")", "{", "throw", "new", "EvaluationExceptio...
Dereference the Element to return the value of a child. Any resource should return the value of the given child. The default implementation of this method will throw an EvaluationException indicating that this Element cannot be dereferenced. @param terms list of terms to use for dereference @param index the term to use in the given list of term @param protect flag to indicate that the return value should be a protected (if value is a resource) @param lookupOnly indicates that only a lookup is required, return null if the element doesn't exist @throws org.quattor.pan.exceptions.InvalidTermException thrown if an trying to dereference a list with a key or a hash with an index
[ "Dereference", "the", "Element", "to", "return", "the", "value", "of", "a", "child", ".", "Any", "resource", "should", "return", "the", "value", "of", "the", "given", "child", ".", "The", "default", "implementation", "of", "this", "method", "will", "throw", ...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java#L218-L225
train
quattor/pan
panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java
AbstractElement.rgetList
public ListResource rgetList(Term[] terms, int index) throws InvalidTermException { throw new EvaluationException(MessageUtils.format( MSG_ILLEGAL_DEREFERENCE, this.getTypeAsString())); }
java
public ListResource rgetList(Term[] terms, int index) throws InvalidTermException { throw new EvaluationException(MessageUtils.format( MSG_ILLEGAL_DEREFERENCE, this.getTypeAsString())); }
[ "public", "ListResource", "rgetList", "(", "Term", "[", "]", "terms", ",", "int", "index", ")", "throws", "InvalidTermException", "{", "throw", "new", "EvaluationException", "(", "MessageUtils", ".", "format", "(", "MSG_ILLEGAL_DEREFERENCE", ",", "this", ".", "g...
This is a special lookup function that will retrieve a list from the resource. If the resource does not exist, an empty list will be created. All necessary parent resources are created. The returned list is guaranteed to be a writable resource. @param terms list of terms to use for dereference @param index the term to use in the given list of term @return writable list
[ "This", "is", "a", "special", "lookup", "function", "that", "will", "retrieve", "a", "list", "from", "the", "resource", ".", "If", "the", "resource", "does", "not", "exist", "an", "empty", "list", "will", "be", "created", ".", "All", "necessary", "parent",...
009934a603dd0c08d3fa4bb7d9389c380a916f54
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/dml/data/AbstractElement.java#L240-L244
train