id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
8,600
esmasui/AndroidJUnit4
android-junit4/src/main/java/com/android/internal/util/Predicates.java
Predicates.or
public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) { return new OrPredicate(components); }
java
public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) { return new OrPredicate(components); }
[ "public", "static", "<", "T", ">", "Predicate", "<", "T", ">", "or", "(", "Iterable", "<", "?", "extends", "Predicate", "<", "?", "super", "T", ">", ">", "components", ")", "{", "return", "new", "OrPredicate", "(", "components", ")", ";", "}" ]
Returns a Predicate that evaluates to true iff any one of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as the answer is determined. Does not defensively copy the iterable passed in, so future changes to it will alter the behavior of this Predicate. If components is empty, the returned Predicate will always evaluate to false.
[ "Returns", "a", "Predicate", "that", "evaluates", "to", "true", "iff", "any", "one", "of", "its", "components", "evaluates", "to", "true", ".", "The", "components", "are", "evaluated", "in", "order", "and", "evaluation", "will", "be", "short", "-", "circuited", "as", "soon", "as", "the", "answer", "is", "determined", ".", "Does", "not", "defensively", "copy", "the", "iterable", "passed", "in", "so", "future", "changes", "to", "it", "will", "alter", "the", "behavior", "of", "this", "Predicate", ".", "If", "components", "is", "empty", "the", "returned", "Predicate", "will", "always", "evaluate", "to", "false", "." ]
173b050663844f81ca9da6c9076dd13e1bde6a75
https://github.com/esmasui/AndroidJUnit4/blob/173b050663844f81ca9da6c9076dd13e1bde6a75/android-junit4/src/main/java/com/android/internal/util/Predicates.java#L68-L70
8,601
Bernardo-MG/repository-pattern-java
src/main/java/com/wandrell/pattern/repository/jpa/JpaRepository.java
JpaRepository.applyPagination
private final void applyPagination(final Query query, final PaginationData pagination) { query.setFirstResult( (pagination.getPageNumber() - 1) * pagination.getPageSize()); query.setMaxResults(pagination.getPageSize()); }
java
private final void applyPagination(final Query query, final PaginationData pagination) { query.setFirstResult( (pagination.getPageNumber() - 1) * pagination.getPageSize()); query.setMaxResults(pagination.getPageSize()); }
[ "private", "final", "void", "applyPagination", "(", "final", "Query", "query", ",", "final", "PaginationData", "pagination", ")", "{", "query", ".", "setFirstResult", "(", "(", "pagination", ".", "getPageNumber", "(", ")", "-", "1", ")", "*", "pagination", ".", "getPageSize", "(", ")", ")", ";", "query", ".", "setMaxResults", "(", "pagination", ".", "getPageSize", "(", ")", ")", ";", "}" ]
Applies pagination to the query. @param query query to apply the pagination to @param pagination pagination to apply
[ "Applies", "pagination", "to", "the", "query", "." ]
e94d5bbf9aeeb45acc8485f3686a6e791b082ea8
https://github.com/Bernardo-MG/repository-pattern-java/blob/e94d5bbf9aeeb45acc8485f3686a6e791b082ea8/src/main/java/com/wandrell/pattern/repository/jpa/JpaRepository.java#L309-L314
8,602
chen0040/java-genetic-programming
src/main/java/com/github/chen0040/gp/lgp/gp/Replacement.java
Replacement.compete
public static Program compete(List<Program> programs, Program current, Program candidate, LGP manager, RandEngine randEngine) { if(manager.getReplacementStrategy() == LGPReplacementStrategy.DirectCompetition) { if (CollectionUtils.isBetterThan(candidate, current)) { int index = programs.indexOf(current); programs.set(index, candidate); return current; } else { return candidate; } } else { if(randEngine.uniform() <= manager.getReplacementProbability()){ int index = programs.indexOf(current); programs.set(index, candidate); return current; } else { return candidate; } } }
java
public static Program compete(List<Program> programs, Program current, Program candidate, LGP manager, RandEngine randEngine) { if(manager.getReplacementStrategy() == LGPReplacementStrategy.DirectCompetition) { if (CollectionUtils.isBetterThan(candidate, current)) { int index = programs.indexOf(current); programs.set(index, candidate); return current; } else { return candidate; } } else { if(randEngine.uniform() <= manager.getReplacementProbability()){ int index = programs.indexOf(current); programs.set(index, candidate); return current; } else { return candidate; } } }
[ "public", "static", "Program", "compete", "(", "List", "<", "Program", ">", "programs", ",", "Program", "current", ",", "Program", "candidate", ",", "LGP", "manager", ",", "RandEngine", "randEngine", ")", "{", "if", "(", "manager", ".", "getReplacementStrategy", "(", ")", "==", "LGPReplacementStrategy", ".", "DirectCompetition", ")", "{", "if", "(", "CollectionUtils", ".", "isBetterThan", "(", "candidate", ",", "current", ")", ")", "{", "int", "index", "=", "programs", ".", "indexOf", "(", "current", ")", ";", "programs", ".", "set", "(", "index", ",", "candidate", ")", ";", "return", "current", ";", "}", "else", "{", "return", "candidate", ";", "}", "}", "else", "{", "if", "(", "randEngine", ".", "uniform", "(", ")", "<=", "manager", ".", "getReplacementProbability", "(", ")", ")", "{", "int", "index", "=", "programs", ".", "indexOf", "(", "current", ")", ";", "programs", ".", "set", "(", "index", ",", "candidate", ")", ";", "return", "current", ";", "}", "else", "{", "return", "candidate", ";", "}", "}", "}" ]
this method returns the pointer to the loser in the competition for survival;
[ "this", "method", "returns", "the", "pointer", "to", "the", "loser", "in", "the", "competition", "for", "survival", ";" ]
498fc8f4407ea9d45f2e0ac797a8948da337c74f
https://github.com/chen0040/java-genetic-programming/blob/498fc8f4407ea9d45f2e0ac797a8948da337c74f/src/main/java/com/github/chen0040/gp/lgp/gp/Replacement.java#L19-L38
8,603
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/PositionViewMover.java
PositionViewMover.changeViewPosition
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override void changeViewPosition(float xAxisDelta, float yAxisDelta) { float endLeftBoundPointX = calculateEndLeftBound(xAxisDelta); float endTopBoundPointY = calculateEndTopBound(yAxisDelta); getView().setX(endLeftBoundPointX); getView().setY(endTopBoundPointY); LOGGER.trace("Updated view position: leftX = {}, topY = {}", endLeftBoundPointX, endTopBoundPointY); }
java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override void changeViewPosition(float xAxisDelta, float yAxisDelta) { float endLeftBoundPointX = calculateEndLeftBound(xAxisDelta); float endTopBoundPointY = calculateEndTopBound(yAxisDelta); getView().setX(endLeftBoundPointX); getView().setY(endTopBoundPointY); LOGGER.trace("Updated view position: leftX = {}, topY = {}", endLeftBoundPointX, endTopBoundPointY); }
[ "@", "TargetApi", "(", "Build", ".", "VERSION_CODES", ".", "JELLY_BEAN", ")", "@", "Override", "void", "changeViewPosition", "(", "float", "xAxisDelta", ",", "float", "yAxisDelta", ")", "{", "float", "endLeftBoundPointX", "=", "calculateEndLeftBound", "(", "xAxisDelta", ")", ";", "float", "endTopBoundPointY", "=", "calculateEndTopBound", "(", "yAxisDelta", ")", ";", "getView", "(", ")", ".", "setX", "(", "endLeftBoundPointX", ")", ";", "getView", "(", ")", ".", "setY", "(", "endTopBoundPointY", ")", ";", "LOGGER", ".", "trace", "(", "\"Updated view position: leftX = {}, topY = {}\"", ",", "endLeftBoundPointX", ",", "endTopBoundPointY", ")", ";", "}" ]
Changes the position of the view based on view's visual position within its parent container @param xAxisDelta X-axis delta in actual pixels @param yAxisDelta Y-axis delta in actual pixels
[ "Changes", "the", "position", "of", "the", "view", "based", "on", "view", "s", "visual", "position", "within", "its", "parent", "container" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/PositionViewMover.java#L57-L65
8,604
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/PositionViewMover.java
PositionViewMover.calculateEndLeftBound
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override int calculateEndLeftBound(float xAxisDelta) { return (int) (getView().getX() + xAxisDelta); }
java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override int calculateEndLeftBound(float xAxisDelta) { return (int) (getView().getX() + xAxisDelta); }
[ "@", "TargetApi", "(", "Build", ".", "VERSION_CODES", ".", "JELLY_BEAN", ")", "@", "Override", "int", "calculateEndLeftBound", "(", "float", "xAxisDelta", ")", "{", "return", "(", "int", ")", "(", "getView", "(", ")", ".", "getX", "(", ")", "+", "xAxisDelta", ")", ";", "}" ]
Calculates the resulting X coordinate of the view's left bound based on the X position of the view and the X-axis delta @param xAxisDelta X-axis delta in actual pixels @return resulting X coordinate of the view's left bound
[ "Calculates", "the", "resulting", "X", "coordinate", "of", "the", "view", "s", "left", "bound", "based", "on", "the", "X", "position", "of", "the", "view", "and", "the", "X", "-", "axis", "delta" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/PositionViewMover.java#L74-L78
8,605
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/PositionViewMover.java
PositionViewMover.calculateEndTopBound
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override int calculateEndTopBound(float yAxisDelta) { return (int) (getView().getY() + yAxisDelta); }
java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override int calculateEndTopBound(float yAxisDelta) { return (int) (getView().getY() + yAxisDelta); }
[ "@", "TargetApi", "(", "Build", ".", "VERSION_CODES", ".", "JELLY_BEAN", ")", "@", "Override", "int", "calculateEndTopBound", "(", "float", "yAxisDelta", ")", "{", "return", "(", "int", ")", "(", "getView", "(", ")", ".", "getY", "(", ")", "+", "yAxisDelta", ")", ";", "}" ]
Calculates the resulting Y coordinate of the view's top bound based on the Y position of the view and the Y-axis delta @param yAxisDelta Y-axis delta in actual pixels @return resulting Y coordinate of the view's top bound
[ "Calculates", "the", "resulting", "Y", "coordinate", "of", "the", "view", "s", "top", "bound", "based", "on", "the", "Y", "position", "of", "the", "view", "and", "the", "Y", "-", "axis", "delta" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/PositionViewMover.java#L99-L103
8,606
chen0040/java-genetic-programming
src/main/java/com/github/chen0040/gp/treegp/program/Program.java
Program.compareTo
@Override public int compareTo(Program that) { int cmp = Integer.compare(depth, that.depth); if (cmp == 0) { return Integer.compare(length, that.length); } else { return cmp; } }
java
@Override public int compareTo(Program that) { int cmp = Integer.compare(depth, that.depth); if (cmp == 0) { return Integer.compare(length, that.length); } else { return cmp; } }
[ "@", "Override", "public", "int", "compareTo", "(", "Program", "that", ")", "{", "int", "cmp", "=", "Integer", ".", "compare", "(", "depth", ",", "that", ".", "depth", ")", ";", "if", "(", "cmp", "==", "0", ")", "{", "return", "Integer", ".", "compare", "(", "length", ",", "that", ".", "length", ")", ";", "}", "else", "{", "return", "cmp", ";", "}", "}" ]
The method return -1 if this program is better than that program @param that @return
[ "The", "method", "return", "-", "1", "if", "this", "program", "is", "better", "than", "that", "program" ]
498fc8f4407ea9d45f2e0ac797a8948da337c74f
https://github.com/chen0040/java-genetic-programming/blob/498fc8f4407ea9d45f2e0ac797a8948da337c74f/src/main/java/com/github/chen0040/gp/treegp/program/Program.java#L144-L153
8,607
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/MarginViewMover.java
MarginViewMover.isViewLeftAligned
private boolean isViewLeftAligned(ViewGroup.MarginLayoutParams layoutParams) { final int left = getView().getLeft(); boolean viewLeftAligned = left == 0 || left == layoutParams.leftMargin; LOGGER.trace("View is {} aligned", viewLeftAligned ? "LEFT" : "RIGHT"); return viewLeftAligned; }
java
private boolean isViewLeftAligned(ViewGroup.MarginLayoutParams layoutParams) { final int left = getView().getLeft(); boolean viewLeftAligned = left == 0 || left == layoutParams.leftMargin; LOGGER.trace("View is {} aligned", viewLeftAligned ? "LEFT" : "RIGHT"); return viewLeftAligned; }
[ "private", "boolean", "isViewLeftAligned", "(", "ViewGroup", ".", "MarginLayoutParams", "layoutParams", ")", "{", "final", "int", "left", "=", "getView", "(", ")", ".", "getLeft", "(", ")", ";", "boolean", "viewLeftAligned", "=", "left", "==", "0", "||", "left", "==", "layoutParams", ".", "leftMargin", ";", "LOGGER", ".", "trace", "(", "\"View is {} aligned\"", ",", "viewLeftAligned", "?", "\"LEFT\"", ":", "\"RIGHT\"", ")", ";", "return", "viewLeftAligned", ";", "}" ]
Checks whether view is left aligned @param layoutParams view's layout parameters @return true if the view is left aligned, otherwise false
[ "Checks", "whether", "view", "is", "left", "aligned" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/MarginViewMover.java#L85-L90
8,608
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/MarginViewMover.java
MarginViewMover.isViewTopAligned
private boolean isViewTopAligned(ViewGroup.MarginLayoutParams layoutParams) { final int top = getView().getTop(); boolean viewTopAligned = top == 0 || top == layoutParams.topMargin; LOGGER.trace("View is {} aligned", viewTopAligned ? "TOP" : "BOTTOM"); return viewTopAligned; }
java
private boolean isViewTopAligned(ViewGroup.MarginLayoutParams layoutParams) { final int top = getView().getTop(); boolean viewTopAligned = top == 0 || top == layoutParams.topMargin; LOGGER.trace("View is {} aligned", viewTopAligned ? "TOP" : "BOTTOM"); return viewTopAligned; }
[ "private", "boolean", "isViewTopAligned", "(", "ViewGroup", ".", "MarginLayoutParams", "layoutParams", ")", "{", "final", "int", "top", "=", "getView", "(", ")", ".", "getTop", "(", ")", ";", "boolean", "viewTopAligned", "=", "top", "==", "0", "||", "top", "==", "layoutParams", ".", "topMargin", ";", "LOGGER", ".", "trace", "(", "\"View is {} aligned\"", ",", "viewTopAligned", "?", "\"TOP\"", ":", "\"BOTTOM\"", ")", ";", "return", "viewTopAligned", ";", "}" ]
Checks whether view is top aligned @param layoutParams view's layout parameters @return true if the view is top aligned, otherwise false
[ "Checks", "whether", "view", "is", "top", "aligned" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/MarginViewMover.java#L98-L103
8,609
TomCools/dropwizard-websocket-jee7-bundle
src/main/java/be/tomcools/dropwizard/websocket/registration/EndpointRegistration.java
EndpointRegistration.determineAnnotatedEndpointPath
private String determineAnnotatedEndpointPath(Class<?> endpointClass) { if (endpointClass.isAnnotationPresent(ServerEndpoint.class)) { return endpointClass.getAnnotation(ServerEndpoint.class).value(); } else { throw new IllegalArgumentException(String.format("@ServerEndpoint annotation not found on Websocket-class: '%s'. Either annotate the class or register it as a programmatic endpoint using ServerEndpointConfig.class", endpointClass)); } }
java
private String determineAnnotatedEndpointPath(Class<?> endpointClass) { if (endpointClass.isAnnotationPresent(ServerEndpoint.class)) { return endpointClass.getAnnotation(ServerEndpoint.class).value(); } else { throw new IllegalArgumentException(String.format("@ServerEndpoint annotation not found on Websocket-class: '%s'. Either annotate the class or register it as a programmatic endpoint using ServerEndpointConfig.class", endpointClass)); } }
[ "private", "String", "determineAnnotatedEndpointPath", "(", "Class", "<", "?", ">", "endpointClass", ")", "{", "if", "(", "endpointClass", ".", "isAnnotationPresent", "(", "ServerEndpoint", ".", "class", ")", ")", "{", "return", "endpointClass", ".", "getAnnotation", "(", "ServerEndpoint", ".", "class", ")", ".", "value", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"@ServerEndpoint annotation not found on Websocket-class: '%s'. Either annotate the class or register it as a programmatic endpoint using ServerEndpointConfig.class\"", ",", "endpointClass", ")", ")", ";", "}", "}" ]
move to sort of ruleEngine
[ "move", "to", "sort", "of", "ruleEngine" ]
6a11e79e141ddd9c811a7dfdb526c91fa20c4798
https://github.com/TomCools/dropwizard-websocket-jee7-bundle/blob/6a11e79e141ddd9c811a7dfdb526c91fa20c4798/src/main/java/be/tomcools/dropwizard/websocket/registration/EndpointRegistration.java#L37-L43
8,610
florent37/DaVinci
davinci/src/main/java/com/github/florent37/davinci/DaVinci.java
DaVinci.init
public static DaVinci init(Context context, int size) { if (INSTANCE == null) INSTANCE = new DaVinci(context, size); if (context != null) INSTANCE.mContext = context; return INSTANCE; }
java
public static DaVinci init(Context context, int size) { if (INSTANCE == null) INSTANCE = new DaVinci(context, size); if (context != null) INSTANCE.mContext = context; return INSTANCE; }
[ "public", "static", "DaVinci", "init", "(", "Context", "context", ",", "int", "size", ")", "{", "if", "(", "INSTANCE", "==", "null", ")", "INSTANCE", "=", "new", "DaVinci", "(", "context", ",", "size", ")", ";", "if", "(", "context", "!=", "null", ")", "INSTANCE", ".", "mContext", "=", "context", ";", "return", "INSTANCE", ";", "}" ]
Initialise DaVinci, muse have a googleApiClient to retrieve Bitmaps from Smartphone @param context the application context @param size the number of entry on the cache
[ "Initialise", "DaVinci", "muse", "have", "a", "googleApiClient", "to", "retrieve", "Bitmaps", "from", "Smartphone" ]
9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a
https://github.com/florent37/DaVinci/blob/9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a/davinci/src/main/java/com/github/florent37/davinci/DaVinci.java#L109-L115
8,611
florent37/DaVinci
davinci/src/main/java/com/github/florent37/davinci/DaVinci.java
DaVinci.get
public Drawable get() { final Drawable[] drawables = new Drawable[]{ mPlaceHolder, new BitmapDrawable(mContext.getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)), }; final TransitionDrawable transitionDrawable = new TransitionDrawable(drawables); into(new Callback() { @Override public void onBitmapLoaded(String path, Bitmap bitmap) { Log.d(TAG, "callback " + path + " called"); if (bitmap != null) { Log.d(TAG, "bitmap " + path + " loaded"); Drawable drawable = drawables[1]; if (drawable != null && drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawables[1]; try { Method method = BitmapDrawable.class.getDeclaredMethod("setBitmap", Bitmap.class); method.setAccessible(true); method.invoke(bitmapDrawable, bitmap); Log.d(TAG, "bitmap " + path + " added to transition"); } catch (Exception e) { e.printStackTrace(); } } transitionDrawable.startTransition(500); Log.d(TAG, "image " + path + " transition started"); } } }); return transitionDrawable; }
java
public Drawable get() { final Drawable[] drawables = new Drawable[]{ mPlaceHolder, new BitmapDrawable(mContext.getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)), }; final TransitionDrawable transitionDrawable = new TransitionDrawable(drawables); into(new Callback() { @Override public void onBitmapLoaded(String path, Bitmap bitmap) { Log.d(TAG, "callback " + path + " called"); if (bitmap != null) { Log.d(TAG, "bitmap " + path + " loaded"); Drawable drawable = drawables[1]; if (drawable != null && drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawables[1]; try { Method method = BitmapDrawable.class.getDeclaredMethod("setBitmap", Bitmap.class); method.setAccessible(true); method.invoke(bitmapDrawable, bitmap); Log.d(TAG, "bitmap " + path + " added to transition"); } catch (Exception e) { e.printStackTrace(); } } transitionDrawable.startTransition(500); Log.d(TAG, "image " + path + " transition started"); } } }); return transitionDrawable; }
[ "public", "Drawable", "get", "(", ")", "{", "final", "Drawable", "[", "]", "drawables", "=", "new", "Drawable", "[", "]", "{", "mPlaceHolder", ",", "new", "BitmapDrawable", "(", "mContext", ".", "getResources", "(", ")", ",", "Bitmap", ".", "createBitmap", "(", "1", ",", "1", ",", "Bitmap", ".", "Config", ".", "ARGB_8888", ")", ")", ",", "}", ";", "final", "TransitionDrawable", "transitionDrawable", "=", "new", "TransitionDrawable", "(", "drawables", ")", ";", "into", "(", "new", "Callback", "(", ")", "{", "@", "Override", "public", "void", "onBitmapLoaded", "(", "String", "path", ",", "Bitmap", "bitmap", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"callback \"", "+", "path", "+", "\" called\"", ")", ";", "if", "(", "bitmap", "!=", "null", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"bitmap \"", "+", "path", "+", "\" loaded\"", ")", ";", "Drawable", "drawable", "=", "drawables", "[", "1", "]", ";", "if", "(", "drawable", "!=", "null", "&&", "drawable", "instanceof", "BitmapDrawable", ")", "{", "BitmapDrawable", "bitmapDrawable", "=", "(", "BitmapDrawable", ")", "drawables", "[", "1", "]", ";", "try", "{", "Method", "method", "=", "BitmapDrawable", ".", "class", ".", "getDeclaredMethod", "(", "\"setBitmap\"", ",", "Bitmap", ".", "class", ")", ";", "method", ".", "setAccessible", "(", "true", ")", ";", "method", ".", "invoke", "(", "bitmapDrawable", ",", "bitmap", ")", ";", "Log", ".", "d", "(", "TAG", ",", "\"bitmap \"", "+", "path", "+", "\" added to transition\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "transitionDrawable", ".", "startTransition", "(", "500", ")", ";", "Log", ".", "d", "(", "TAG", ",", "\"image \"", "+", "path", "+", "\" transition started\"", ")", ";", "}", "}", "}", ")", ";", "return", "transitionDrawable", ";", "}" ]
Load the bitmap into a TransitionDrawable Starts the treatment, when loaded, execute a transition
[ "Load", "the", "bitmap", "into", "a", "TransitionDrawable", "Starts", "the", "treatment", "when", "loaded", "execute", "a", "transition" ]
9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a
https://github.com/florent37/DaVinci/blob/9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a/davinci/src/main/java/com/github/florent37/davinci/DaVinci.java#L269-L307
8,612
florent37/DaVinci
davinci/src/main/java/com/github/florent37/davinci/DaVinci.java
DaVinci.loadImage
private Bitmap loadImage(final String path, final Object into, final Transformation transformation) { if (into == null || mImagesCache == null || path == null || path.trim().isEmpty()) return null; Log.d(TAG, "load(" + path + ")"); Bitmap bitmap = null; if (transformation == null) { bitmap = loadFromLruCache(path, true); } else { final String pathTransformed = generatePathFromTransformation(path, transformation); bitmap = loadFromLruCache(pathTransformed, true); if (bitmap == null) { //if bitmap transformed not found in cache bitmap = loadFromLruCache(path, true); //try to get the bitmap without transformation if (bitmap != null) { new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { return transformAndSaveBitmap(path, transformation); } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); if (bitmap != null) { //now its available on cache, can call again loadImage with same parameters loadImage(path, into, transformation); } } }.execute(); return null; } } } Log.d(TAG, "bitmap from cache " + bitmap + " for " + path); if (bitmap != null) { //load directly from cache returnBitmapInto(bitmap, path, into); Log.d(TAG, "image " + path + " available in the cache"); } else { Log.d(TAG, "image " + path + " not available in the cache, trying to download it"); if (isUrlPath(path)) { Log.d(TAG, "loadImage " + path + " send request to smartphone " + path.hashCode()); addIntoWaiting(path, into, transformation); } else { downloadBitmap(path, into, transformation); } } return bitmap; }
java
private Bitmap loadImage(final String path, final Object into, final Transformation transformation) { if (into == null || mImagesCache == null || path == null || path.trim().isEmpty()) return null; Log.d(TAG, "load(" + path + ")"); Bitmap bitmap = null; if (transformation == null) { bitmap = loadFromLruCache(path, true); } else { final String pathTransformed = generatePathFromTransformation(path, transformation); bitmap = loadFromLruCache(pathTransformed, true); if (bitmap == null) { //if bitmap transformed not found in cache bitmap = loadFromLruCache(path, true); //try to get the bitmap without transformation if (bitmap != null) { new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { return transformAndSaveBitmap(path, transformation); } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); if (bitmap != null) { //now its available on cache, can call again loadImage with same parameters loadImage(path, into, transformation); } } }.execute(); return null; } } } Log.d(TAG, "bitmap from cache " + bitmap + " for " + path); if (bitmap != null) { //load directly from cache returnBitmapInto(bitmap, path, into); Log.d(TAG, "image " + path + " available in the cache"); } else { Log.d(TAG, "image " + path + " not available in the cache, trying to download it"); if (isUrlPath(path)) { Log.d(TAG, "loadImage " + path + " send request to smartphone " + path.hashCode()); addIntoWaiting(path, into, transformation); } else { downloadBitmap(path, into, transformation); } } return bitmap; }
[ "private", "Bitmap", "loadImage", "(", "final", "String", "path", ",", "final", "Object", "into", ",", "final", "Transformation", "transformation", ")", "{", "if", "(", "into", "==", "null", "||", "mImagesCache", "==", "null", "||", "path", "==", "null", "||", "path", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "return", "null", ";", "Log", ".", "d", "(", "TAG", ",", "\"load(\"", "+", "path", "+", "\")\"", ")", ";", "Bitmap", "bitmap", "=", "null", ";", "if", "(", "transformation", "==", "null", ")", "{", "bitmap", "=", "loadFromLruCache", "(", "path", ",", "true", ")", ";", "}", "else", "{", "final", "String", "pathTransformed", "=", "generatePathFromTransformation", "(", "path", ",", "transformation", ")", ";", "bitmap", "=", "loadFromLruCache", "(", "pathTransformed", ",", "true", ")", ";", "if", "(", "bitmap", "==", "null", ")", "{", "//if bitmap transformed not found in cache", "bitmap", "=", "loadFromLruCache", "(", "path", ",", "true", ")", ";", "//try to get the bitmap without transformation", "if", "(", "bitmap", "!=", "null", ")", "{", "new", "AsyncTask", "<", "Void", ",", "Void", ",", "Bitmap", ">", "(", ")", "{", "@", "Override", "protected", "Bitmap", "doInBackground", "(", "Void", "...", "params", ")", "{", "return", "transformAndSaveBitmap", "(", "path", ",", "transformation", ")", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "Bitmap", "bitmap", ")", "{", "super", ".", "onPostExecute", "(", "bitmap", ")", ";", "if", "(", "bitmap", "!=", "null", ")", "{", "//now its available on cache, can call again loadImage with same parameters", "loadImage", "(", "path", ",", "into", ",", "transformation", ")", ";", "}", "}", "}", ".", "execute", "(", ")", ";", "return", "null", ";", "}", "}", "}", "Log", ".", "d", "(", "TAG", ",", "\"bitmap from cache \"", "+", "bitmap", "+", "\" for \"", "+", "path", ")", ";", "if", "(", "bitmap", "!=", "null", ")", "{", "//load directly from cache", "returnBitmapInto", "(", "bitmap", ",", "path", ",", "into", ")", ";", "Log", ".", "d", "(", "TAG", ",", "\"image \"", "+", "path", "+", "\" available in the cache\"", ")", ";", "}", "else", "{", "Log", ".", "d", "(", "TAG", ",", "\"image \"", "+", "path", "+", "\" not available in the cache, trying to download it\"", ")", ";", "if", "(", "isUrlPath", "(", "path", ")", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"loadImage \"", "+", "path", "+", "\" send request to smartphone \"", "+", "path", ".", "hashCode", "(", ")", ")", ";", "addIntoWaiting", "(", "path", ",", "into", ",", "transformation", ")", ";", "}", "else", "{", "downloadBitmap", "(", "path", ",", "into", ",", "transformation", ")", ";", "}", "}", "return", "bitmap", ";", "}" ]
Start the loading of an image @param path path of the bitmap Or url of the image @param into element which will display the image @return the image from cache
[ "Start", "the", "loading", "of", "an", "image" ]
9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a
https://github.com/florent37/DaVinci/blob/9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a/davinci/src/main/java/com/github/florent37/davinci/DaVinci.java#L350-L403
8,613
florent37/DaVinci
davinci/src/main/java/com/github/florent37/davinci/DaVinci.java
DaVinci.downloadBitmap
private void downloadBitmap(final String path, final Object into, final Transformation transformation) { //download the bitmap from bluetooth new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = getBitmap(path); Log.d(TAG, "bitmap from bluetooth " + path + " " + bitmap); if (bitmap != null) { Log.d(TAG, "save bitmap " + path + " into cache"); saveBitmap(getKey(path), bitmap); if (transformation != null) { return transformAndSaveBitmap(path, transformation); } } return bitmap; } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); if (into != null) returnBitmapInto(bitmap, path, into); } }.execute(); }
java
private void downloadBitmap(final String path, final Object into, final Transformation transformation) { //download the bitmap from bluetooth new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = getBitmap(path); Log.d(TAG, "bitmap from bluetooth " + path + " " + bitmap); if (bitmap != null) { Log.d(TAG, "save bitmap " + path + " into cache"); saveBitmap(getKey(path), bitmap); if (transformation != null) { return transformAndSaveBitmap(path, transformation); } } return bitmap; } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); if (into != null) returnBitmapInto(bitmap, path, into); } }.execute(); }
[ "private", "void", "downloadBitmap", "(", "final", "String", "path", ",", "final", "Object", "into", ",", "final", "Transformation", "transformation", ")", "{", "//download the bitmap from bluetooth", "new", "AsyncTask", "<", "Void", ",", "Void", ",", "Bitmap", ">", "(", ")", "{", "@", "Override", "protected", "Bitmap", "doInBackground", "(", "Void", "...", "params", ")", "{", "Bitmap", "bitmap", "=", "getBitmap", "(", "path", ")", ";", "Log", ".", "d", "(", "TAG", ",", "\"bitmap from bluetooth \"", "+", "path", "+", "\" \"", "+", "bitmap", ")", ";", "if", "(", "bitmap", "!=", "null", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"save bitmap \"", "+", "path", "+", "\" into cache\"", ")", ";", "saveBitmap", "(", "getKey", "(", "path", ")", ",", "bitmap", ")", ";", "if", "(", "transformation", "!=", "null", ")", "{", "return", "transformAndSaveBitmap", "(", "path", ",", "transformation", ")", ";", "}", "}", "return", "bitmap", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "Bitmap", "bitmap", ")", "{", "super", ".", "onPostExecute", "(", "bitmap", ")", ";", "if", "(", "into", "!=", "null", ")", "returnBitmapInto", "(", "bitmap", ",", "path", ",", "into", ")", ";", "}", "}", ".", "execute", "(", ")", ";", "}" ]
Download bitmap from bluetooth asset and store it into LruCache and LruDiskCache @param path the path or url of the image @param into the destination object
[ "Download", "bitmap", "from", "bluetooth", "asset", "and", "store", "it", "into", "LruCache", "and", "LruDiskCache" ]
9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a
https://github.com/florent37/DaVinci/blob/9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a/davinci/src/main/java/com/github/florent37/davinci/DaVinci.java#L485-L510
8,614
florent37/DaVinci
davinci/src/main/java/com/github/florent37/davinci/DaVinci.java
DaVinci.onDataChanged
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { String path = dataEvent.getDataItem().getUri().getPath(); Log.d(TAG, "onDataChanged(" + path + ")"); if (path.startsWith(DAVINCI_PATH)) { //if it's a davinci path Log.d(TAG, "davinci-onDataChanged " + path); //download the bitmap and add it to cache Asset asset = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap().getAsset(DAVINCI_ASSET_IMAGE); Bitmap bitmap = loadBitmapFromAsset(asset); if (bitmap != null) saveBitmap(getKey(path), bitmap); //callbacks callIntoWaiting(path); } } }
java
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { String path = dataEvent.getDataItem().getUri().getPath(); Log.d(TAG, "onDataChanged(" + path + ")"); if (path.startsWith(DAVINCI_PATH)) { //if it's a davinci path Log.d(TAG, "davinci-onDataChanged " + path); //download the bitmap and add it to cache Asset asset = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap().getAsset(DAVINCI_ASSET_IMAGE); Bitmap bitmap = loadBitmapFromAsset(asset); if (bitmap != null) saveBitmap(getKey(path), bitmap); //callbacks callIntoWaiting(path); } } }
[ "@", "Override", "public", "void", "onDataChanged", "(", "DataEventBuffer", "dataEvents", ")", "{", "for", "(", "DataEvent", "dataEvent", ":", "dataEvents", ")", "{", "String", "path", "=", "dataEvent", ".", "getDataItem", "(", ")", ".", "getUri", "(", ")", ".", "getPath", "(", ")", ";", "Log", ".", "d", "(", "TAG", ",", "\"onDataChanged(\"", "+", "path", "+", "\")\"", ")", ";", "if", "(", "path", ".", "startsWith", "(", "DAVINCI_PATH", ")", ")", "{", "//if it's a davinci path", "Log", ".", "d", "(", "TAG", ",", "\"davinci-onDataChanged \"", "+", "path", ")", ";", "//download the bitmap and add it to cache", "Asset", "asset", "=", "DataMapItem", ".", "fromDataItem", "(", "dataEvent", ".", "getDataItem", "(", ")", ")", ".", "getDataMap", "(", ")", ".", "getAsset", "(", "DAVINCI_ASSET_IMAGE", ")", ";", "Bitmap", "bitmap", "=", "loadBitmapFromAsset", "(", "asset", ")", ";", "if", "(", "bitmap", "!=", "null", ")", "saveBitmap", "(", "getKey", "(", "path", ")", ",", "bitmap", ")", ";", "//callbacks", "callIntoWaiting", "(", "path", ")", ";", "}", "}", "}" ]
When received assets from DataApi @param dataEvents
[ "When", "received", "assets", "from", "DataApi" ]
9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a
https://github.com/florent37/DaVinci/blob/9c6ce4aa2df8e2288cd6ee8b57d9091b1b770a7a/davinci/src/main/java/com/github/florent37/davinci/DaVinci.java#L699-L717
8,615
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/ViewMover.java
ViewMover.isPreviousAnimationCompleted
boolean isPreviousAnimationCompleted() { Animation previousAnimation = view.getAnimation(); boolean previousAnimationCompleted = previousAnimation == null || previousAnimation.hasEnded(); if (!previousAnimationCompleted) { LOGGER.warn("Unable to move the view. View is being currently moving"); } return previousAnimationCompleted; }
java
boolean isPreviousAnimationCompleted() { Animation previousAnimation = view.getAnimation(); boolean previousAnimationCompleted = previousAnimation == null || previousAnimation.hasEnded(); if (!previousAnimationCompleted) { LOGGER.warn("Unable to move the view. View is being currently moving"); } return previousAnimationCompleted; }
[ "boolean", "isPreviousAnimationCompleted", "(", ")", "{", "Animation", "previousAnimation", "=", "view", ".", "getAnimation", "(", ")", ";", "boolean", "previousAnimationCompleted", "=", "previousAnimation", "==", "null", "||", "previousAnimation", ".", "hasEnded", "(", ")", ";", "if", "(", "!", "previousAnimationCompleted", ")", "{", "LOGGER", ".", "warn", "(", "\"Unable to move the view. View is being currently moving\"", ")", ";", "}", "return", "previousAnimationCompleted", ";", "}" ]
Checks whether previous animation on the view completed @return true if previous animation on the view completed, otherwise false
[ "Checks", "whether", "previous", "animation", "on", "the", "view", "completed" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/ViewMover.java#L151-L158
8,616
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/ViewMover.java
ViewMover.updateXAxisDelta
private void updateXAxisDelta(MovingParams details) { if (!hasHorizontalSpaceToMove(details.getXAxisDelta())) { LOGGER.warn("Unable to move the view horizontally. No horizontal space left to move"); details.setXAxisDelta(0.0f); } }
java
private void updateXAxisDelta(MovingParams details) { if (!hasHorizontalSpaceToMove(details.getXAxisDelta())) { LOGGER.warn("Unable to move the view horizontally. No horizontal space left to move"); details.setXAxisDelta(0.0f); } }
[ "private", "void", "updateXAxisDelta", "(", "MovingParams", "details", ")", "{", "if", "(", "!", "hasHorizontalSpaceToMove", "(", "details", ".", "getXAxisDelta", "(", ")", ")", ")", "{", "LOGGER", ".", "warn", "(", "\"Unable to move the view horizontally. No horizontal space left to move\"", ")", ";", "details", ".", "setXAxisDelta", "(", "0.0f", ")", ";", "}", "}" ]
Updates the X-axis delta in moving details based on checking whether there is enough space left to move the view horizontally @param details moving details, which X-axis delta needs to be updated in
[ "Updates", "the", "X", "-", "axis", "delta", "in", "moving", "details", "based", "on", "checking", "whether", "there", "is", "enough", "space", "left", "to", "move", "the", "view", "horizontally" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/ViewMover.java#L199-L204
8,617
Scalified/viewmover
viewmover/src/main/java/com/scalified/viewmover/movers/ViewMover.java
ViewMover.updateYAxisDelta
private void updateYAxisDelta(MovingParams details) { if (!hasVerticalSpaceToMove(details.getYAxisDelta())) { LOGGER.warn("Unable to move the view vertically. No vertical space left to move"); details.setYAxisDelta(0.0f); } }
java
private void updateYAxisDelta(MovingParams details) { if (!hasVerticalSpaceToMove(details.getYAxisDelta())) { LOGGER.warn("Unable to move the view vertically. No vertical space left to move"); details.setYAxisDelta(0.0f); } }
[ "private", "void", "updateYAxisDelta", "(", "MovingParams", "details", ")", "{", "if", "(", "!", "hasVerticalSpaceToMove", "(", "details", ".", "getYAxisDelta", "(", ")", ")", ")", "{", "LOGGER", ".", "warn", "(", "\"Unable to move the view vertically. No vertical space left to move\"", ")", ";", "details", ".", "setYAxisDelta", "(", "0.0f", ")", ";", "}", "}" ]
Updates the Y-axis delta in moving details based on checking whether there is enough space left to move the view vertically @param details moving details, which Y-axis delta needs to be updated in
[ "Updates", "the", "Y", "-", "axis", "delta", "in", "moving", "details", "based", "on", "checking", "whether", "there", "is", "enough", "space", "left", "to", "move", "the", "view", "vertically" ]
e2b35f7d8517a5533afe8b68a4c1ee352d9aec34
https://github.com/Scalified/viewmover/blob/e2b35f7d8517a5533afe8b68a4c1ee352d9aec34/viewmover/src/main/java/com/scalified/viewmover/movers/ViewMover.java#L212-L217
8,618
chen0040/java-genetic-programming
src/main/java/com/github/chen0040/gp/lgp/gp/MacroMutation.java
MacroMutation.apply
public static void apply(Program child, LGP manager, RandEngine randEngine) { double r=randEngine.uniform(); List<Instruction> instructions=child.getInstructions(); if(child.length() < manager.getMacroMutateMaxProgramLength() && ((r < manager.getMacroMutateInsertionRate()) || child.length() == manager.getMacroMutateMinProgramLength())) { Instruction inserted_instruction = new Instruction(); InstructionHelper.initialize(inserted_instruction, child, randEngine); int loc=randEngine.nextInt(child.length()); if(loc==child.length() - 1) { instructions.add(inserted_instruction); } else { instructions.add(loc, inserted_instruction); } if(manager.isEffectiveMutation()) { while(loc < instructions.size() && instructions.get(loc).getOperator().isConditionalConstruct()) { loc++; } if(loc < instructions.size()) { Set<Integer> Reff= new HashSet<>(); child.markStructuralIntrons(loc, Reff, manager); if(Reff.size() > 0) { int iRegisterIndex=-1; for(Integer Reff_value : Reff) { if(iRegisterIndex==-1) { iRegisterIndex=Reff_value; } else if(randEngine.uniform() < 0.5) { iRegisterIndex=Reff_value; } } instructions.get(loc).setTargetOperand(child.getRegisterSet().get(iRegisterIndex)); } } } } else if(child.length() > manager.getMacroMutateMinProgramLength() && ((r > manager.getMacroMutateInsertionRate()) || child.length() == manager.getMacroMutateMaxProgramLength())) { int loc=randEngine.nextInt(instructions.size()); if(manager.isEffectiveMutation()) { for(int i=0; i<10; i++) { loc=randEngine.nextInt(instructions.size()); if(! instructions.get(loc).isStructuralIntron()) { break; } } } instructions.remove(loc); } child.invalidateCost(); }
java
public static void apply(Program child, LGP manager, RandEngine randEngine) { double r=randEngine.uniform(); List<Instruction> instructions=child.getInstructions(); if(child.length() < manager.getMacroMutateMaxProgramLength() && ((r < manager.getMacroMutateInsertionRate()) || child.length() == manager.getMacroMutateMinProgramLength())) { Instruction inserted_instruction = new Instruction(); InstructionHelper.initialize(inserted_instruction, child, randEngine); int loc=randEngine.nextInt(child.length()); if(loc==child.length() - 1) { instructions.add(inserted_instruction); } else { instructions.add(loc, inserted_instruction); } if(manager.isEffectiveMutation()) { while(loc < instructions.size() && instructions.get(loc).getOperator().isConditionalConstruct()) { loc++; } if(loc < instructions.size()) { Set<Integer> Reff= new HashSet<>(); child.markStructuralIntrons(loc, Reff, manager); if(Reff.size() > 0) { int iRegisterIndex=-1; for(Integer Reff_value : Reff) { if(iRegisterIndex==-1) { iRegisterIndex=Reff_value; } else if(randEngine.uniform() < 0.5) { iRegisterIndex=Reff_value; } } instructions.get(loc).setTargetOperand(child.getRegisterSet().get(iRegisterIndex)); } } } } else if(child.length() > manager.getMacroMutateMinProgramLength() && ((r > manager.getMacroMutateInsertionRate()) || child.length() == manager.getMacroMutateMaxProgramLength())) { int loc=randEngine.nextInt(instructions.size()); if(manager.isEffectiveMutation()) { for(int i=0; i<10; i++) { loc=randEngine.nextInt(instructions.size()); if(! instructions.get(loc).isStructuralIntron()) { break; } } } instructions.remove(loc); } child.invalidateCost(); }
[ "public", "static", "void", "apply", "(", "Program", "child", ",", "LGP", "manager", ",", "RandEngine", "randEngine", ")", "{", "double", "r", "=", "randEngine", ".", "uniform", "(", ")", ";", "List", "<", "Instruction", ">", "instructions", "=", "child", ".", "getInstructions", "(", ")", ";", "if", "(", "child", ".", "length", "(", ")", "<", "manager", ".", "getMacroMutateMaxProgramLength", "(", ")", "&&", "(", "(", "r", "<", "manager", ".", "getMacroMutateInsertionRate", "(", ")", ")", "||", "child", ".", "length", "(", ")", "==", "manager", ".", "getMacroMutateMinProgramLength", "(", ")", ")", ")", "{", "Instruction", "inserted_instruction", "=", "new", "Instruction", "(", ")", ";", "InstructionHelper", ".", "initialize", "(", "inserted_instruction", ",", "child", ",", "randEngine", ")", ";", "int", "loc", "=", "randEngine", ".", "nextInt", "(", "child", ".", "length", "(", ")", ")", ";", "if", "(", "loc", "==", "child", ".", "length", "(", ")", "-", "1", ")", "{", "instructions", ".", "add", "(", "inserted_instruction", ")", ";", "}", "else", "{", "instructions", ".", "add", "(", "loc", ",", "inserted_instruction", ")", ";", "}", "if", "(", "manager", ".", "isEffectiveMutation", "(", ")", ")", "{", "while", "(", "loc", "<", "instructions", ".", "size", "(", ")", "&&", "instructions", ".", "get", "(", "loc", ")", ".", "getOperator", "(", ")", ".", "isConditionalConstruct", "(", ")", ")", "{", "loc", "++", ";", "}", "if", "(", "loc", "<", "instructions", ".", "size", "(", ")", ")", "{", "Set", "<", "Integer", ">", "Reff", "=", "new", "HashSet", "<>", "(", ")", ";", "child", ".", "markStructuralIntrons", "(", "loc", ",", "Reff", ",", "manager", ")", ";", "if", "(", "Reff", ".", "size", "(", ")", ">", "0", ")", "{", "int", "iRegisterIndex", "=", "-", "1", ";", "for", "(", "Integer", "Reff_value", ":", "Reff", ")", "{", "if", "(", "iRegisterIndex", "==", "-", "1", ")", "{", "iRegisterIndex", "=", "Reff_value", ";", "}", "else", "if", "(", "randEngine", ".", "uniform", "(", ")", "<", "0.5", ")", "{", "iRegisterIndex", "=", "Reff_value", ";", "}", "}", "instructions", ".", "get", "(", "loc", ")", ".", "setTargetOperand", "(", "child", ".", "getRegisterSet", "(", ")", ".", "get", "(", "iRegisterIndex", ")", ")", ";", "}", "}", "}", "}", "else", "if", "(", "child", ".", "length", "(", ")", ">", "manager", ".", "getMacroMutateMinProgramLength", "(", ")", "&&", "(", "(", "r", ">", "manager", ".", "getMacroMutateInsertionRate", "(", ")", ")", "||", "child", ".", "length", "(", ")", "==", "manager", ".", "getMacroMutateMaxProgramLength", "(", ")", ")", ")", "{", "int", "loc", "=", "randEngine", ".", "nextInt", "(", "instructions", ".", "size", "(", ")", ")", ";", "if", "(", "manager", ".", "isEffectiveMutation", "(", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10", ";", "i", "++", ")", "{", "loc", "=", "randEngine", ".", "nextInt", "(", "instructions", ".", "size", "(", ")", ")", ";", "if", "(", "!", "instructions", ".", "get", "(", "loc", ")", ".", "isStructuralIntron", "(", ")", ")", "{", "break", ";", "}", "}", "}", "instructions", ".", "remove", "(", "loc", ")", ";", "}", "child", ".", "invalidateCost", "(", ")", ";", "}" ]
single instruction would only be exchanged there would be no code growth.
[ "single", "instruction", "would", "only", "be", "exchanged", "there", "would", "be", "no", "code", "growth", "." ]
498fc8f4407ea9d45f2e0ac797a8948da337c74f
https://github.com/chen0040/java-genetic-programming/blob/498fc8f4407ea9d45f2e0ac797a8948da337c74f/src/main/java/com/github/chen0040/gp/lgp/gp/MacroMutation.java#L33-L99
8,619
greenhalolabs/EmailAutoCompleteTextView
emailautocompletetextview/src/main/java/com/greenhalolabs/emailautocompletetextview/util/AccountUtil.java
AccountUtil.getAccountEmails
public static List<String> getAccountEmails(Context context) { final Set<String> emailSet = new HashSet<String>(); final Account[] accounts = AccountManager.get(context).getAccounts(); for (Account account : accounts) { if (isEmail(account.name)) { emailSet.add(account.name); } } return new ArrayList<String>(emailSet); }
java
public static List<String> getAccountEmails(Context context) { final Set<String> emailSet = new HashSet<String>(); final Account[] accounts = AccountManager.get(context).getAccounts(); for (Account account : accounts) { if (isEmail(account.name)) { emailSet.add(account.name); } } return new ArrayList<String>(emailSet); }
[ "public", "static", "List", "<", "String", ">", "getAccountEmails", "(", "Context", "context", ")", "{", "final", "Set", "<", "String", ">", "emailSet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "final", "Account", "[", "]", "accounts", "=", "AccountManager", ".", "get", "(", "context", ")", ".", "getAccounts", "(", ")", ";", "for", "(", "Account", "account", ":", "accounts", ")", "{", "if", "(", "isEmail", "(", "account", ".", "name", ")", ")", "{", "emailSet", ".", "add", "(", "account", ".", "name", ")", ";", "}", "}", "return", "new", "ArrayList", "<", "String", ">", "(", "emailSet", ")", ";", "}" ]
Retrieves a list of e-mails on the device @return A list of emails
[ "Retrieves", "a", "list", "of", "e", "-", "mails", "on", "the", "device" ]
f2be63be328198f763fc0c73a7eeabcb75b571ca
https://github.com/greenhalolabs/EmailAutoCompleteTextView/blob/f2be63be328198f763fc0c73a7eeabcb75b571ca/emailautocompletetextview/src/main/java/com/greenhalolabs/emailautocompletetextview/util/AccountUtil.java#L36-L48
8,620
greenhalolabs/EmailAutoCompleteTextView
emailautocompletetextview/src/main/java/com/greenhalolabs/emailautocompletetextview/util/AccountUtil.java
AccountUtil.isEmail
private static boolean isEmail(String account) { if (TextUtils.isEmpty(account)) { return false; } final Pattern emailPattern = Patterns.EMAIL_ADDRESS; final Matcher matcher = emailPattern.matcher(account); return matcher.matches(); }
java
private static boolean isEmail(String account) { if (TextUtils.isEmpty(account)) { return false; } final Pattern emailPattern = Patterns.EMAIL_ADDRESS; final Matcher matcher = emailPattern.matcher(account); return matcher.matches(); }
[ "private", "static", "boolean", "isEmail", "(", "String", "account", ")", "{", "if", "(", "TextUtils", ".", "isEmpty", "(", "account", ")", ")", "{", "return", "false", ";", "}", "final", "Pattern", "emailPattern", "=", "Patterns", ".", "EMAIL_ADDRESS", ";", "final", "Matcher", "matcher", "=", "emailPattern", ".", "matcher", "(", "account", ")", ";", "return", "matcher", ".", "matches", "(", ")", ";", "}" ]
Returns true if the given string is an email.
[ "Returns", "true", "if", "the", "given", "string", "is", "an", "email", "." ]
f2be63be328198f763fc0c73a7eeabcb75b571ca
https://github.com/greenhalolabs/EmailAutoCompleteTextView/blob/f2be63be328198f763fc0c73a7eeabcb75b571ca/emailautocompletetextview/src/main/java/com/greenhalolabs/emailautocompletetextview/util/AccountUtil.java#L53-L62
8,621
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.createEventAsFuture
public FutureAPIResponse createEventAsFuture(Event event) throws IOException { RequestBuilder builder = new RequestBuilder("POST"); builder.setUrl(apiUrl + "/events.json?accessKey=" + accessKey); String requestJsonString = event.toJsonString(); builder.setBody(requestJsonString); builder.setHeader("Content-Type", "application/json"); builder.setHeader("Content-Length", "" + requestJsonString.length()); return new FutureAPIResponse(client.executeRequest(builder.build(), getHandler())); }
java
public FutureAPIResponse createEventAsFuture(Event event) throws IOException { RequestBuilder builder = new RequestBuilder("POST"); builder.setUrl(apiUrl + "/events.json?accessKey=" + accessKey); String requestJsonString = event.toJsonString(); builder.setBody(requestJsonString); builder.setHeader("Content-Type", "application/json"); builder.setHeader("Content-Length", "" + requestJsonString.length()); return new FutureAPIResponse(client.executeRequest(builder.build(), getHandler())); }
[ "public", "FutureAPIResponse", "createEventAsFuture", "(", "Event", "event", ")", "throws", "IOException", "{", "RequestBuilder", "builder", "=", "new", "RequestBuilder", "(", "\"POST\"", ")", ";", "builder", ".", "setUrl", "(", "apiUrl", "+", "\"/events.json?accessKey=\"", "+", "accessKey", ")", ";", "String", "requestJsonString", "=", "event", ".", "toJsonString", "(", ")", ";", "builder", ".", "setBody", "(", "requestJsonString", ")", ";", "builder", ".", "setHeader", "(", "\"Content-Type\"", ",", "\"application/json\"", ")", ";", "builder", ".", "setHeader", "(", "\"Content-Length\"", ",", "\"\"", "+", "requestJsonString", ".", "length", "(", ")", ")", ";", "return", "new", "FutureAPIResponse", "(", "client", ".", "executeRequest", "(", "builder", ".", "build", "(", ")", ",", "getHandler", "(", ")", ")", ")", ";", "}" ]
Sends an asynchronous create event request to the API. @param event an instance of {@link Event} that will be turned into a request
[ "Sends", "an", "asynchronous", "create", "event", "request", "to", "the", "API", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L124-L132
8,622
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.createEvent
public String createEvent(Event event) throws ExecutionException, InterruptedException, IOException { return createEvent(createEventAsFuture(event)); }
java
public String createEvent(Event event) throws ExecutionException, InterruptedException, IOException { return createEvent(createEventAsFuture(event)); }
[ "public", "String", "createEvent", "(", "Event", "event", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "createEventAsFuture", "(", "event", ")", ")", ";", "}" ]
Sends a synchronous create event request to the API. @param event an instance of {@link Event} that will be turned into a request @return event ID from the server @throws ExecutionException indicates an error in the HTTP backend @throws InterruptedException indicates an interruption during the HTTP operation @throws IOException indicates an error from the API response
[ "Sends", "a", "synchronous", "create", "event", "request", "to", "the", "API", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L143-L146
8,623
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.createEvent
public String createEvent(FutureAPIResponse response) throws ExecutionException, InterruptedException, IOException { int status = response.get().getStatus(); String message = response.get().getMessage(); if (status != HTTP_CREATED) { throw new IOException(status + " " + message); } return ((JsonObject) parser.parse(message)).get("eventId").getAsString(); }
java
public String createEvent(FutureAPIResponse response) throws ExecutionException, InterruptedException, IOException { int status = response.get().getStatus(); String message = response.get().getMessage(); if (status != HTTP_CREATED) { throw new IOException(status + " " + message); } return ((JsonObject) parser.parse(message)).get("eventId").getAsString(); }
[ "public", "String", "createEvent", "(", "FutureAPIResponse", "response", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "int", "status", "=", "response", ".", "get", "(", ")", ".", "getStatus", "(", ")", ";", "String", "message", "=", "response", ".", "get", "(", ")", ".", "getMessage", "(", ")", ";", "if", "(", "status", "!=", "HTTP_CREATED", ")", "{", "throw", "new", "IOException", "(", "status", "+", "\" \"", "+", "message", ")", ";", "}", "return", "(", "(", "JsonObject", ")", "parser", ".", "parse", "(", "message", ")", ")", ".", "get", "(", "\"eventId\"", ")", ".", "getAsString", "(", ")", ";", "}" ]
Synchronize a previously sent asynchronous create event request. @param response an instance of {@link FutureAPIResponse} returned from {@link #createEventAsFuture} @return event ID from the server @throws ExecutionException indicates an error in the HTTP backend @throws InterruptedException indicates an interruption during the HTTP operation @throws IOException indicates an error from the API response
[ "Synchronize", "a", "previously", "sent", "asynchronous", "create", "event", "request", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L158-L167
8,624
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.getEventAsFuture
public FutureAPIResponse getEventAsFuture(String eid) throws IOException { Request request = (new RequestBuilder("GET")) .setUrl(apiUrl + "/events/" + eid + ".json?accessKey=" + accessKey) .build(); return new FutureAPIResponse(client.executeRequest(request, getHandler())); }
java
public FutureAPIResponse getEventAsFuture(String eid) throws IOException { Request request = (new RequestBuilder("GET")) .setUrl(apiUrl + "/events/" + eid + ".json?accessKey=" + accessKey) .build(); return new FutureAPIResponse(client.executeRequest(request, getHandler())); }
[ "public", "FutureAPIResponse", "getEventAsFuture", "(", "String", "eid", ")", "throws", "IOException", "{", "Request", "request", "=", "(", "new", "RequestBuilder", "(", "\"GET\"", ")", ")", ".", "setUrl", "(", "apiUrl", "+", "\"/events/\"", "+", "eid", "+", "\".json?accessKey=\"", "+", "accessKey", ")", ".", "build", "(", ")", ";", "return", "new", "FutureAPIResponse", "(", "client", ".", "executeRequest", "(", "request", ",", "getHandler", "(", ")", ")", ")", ";", "}" ]
Sends an asynchronous get event request to the API. @param eid ID of the event to get
[ "Sends", "an", "asynchronous", "get", "event", "request", "to", "the", "API", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L234-L239
8,625
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.getEvent
public Event getEvent(String eid) throws ExecutionException, InterruptedException, IOException { return getEvent(getEventAsFuture(eid)); }
java
public Event getEvent(String eid) throws ExecutionException, InterruptedException, IOException { return getEvent(getEventAsFuture(eid)); }
[ "public", "Event", "getEvent", "(", "String", "eid", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "getEvent", "(", "getEventAsFuture", "(", "eid", ")", ")", ";", "}" ]
Sends a synchronous get event request to the API. @param eid ID of the event to get @throws ExecutionException indicates an error in the HTTP backend @throws InterruptedException indicates an interruption during the HTTP operation @throws IOException indicates an error from the API response
[ "Sends", "a", "synchronous", "get", "event", "request", "to", "the", "API", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L249-L252
8,626
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.getEvent
public Event getEvent(FutureAPIResponse response) throws ExecutionException, InterruptedException, IOException { int status = response.get().getStatus(); String message = response.get().getMessage(); if (status == HTTP_OK) { // handle DateTime separately GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(DateTime.class, new DateTimeAdapter()); Gson gson = gsonBuilder.create(); return gson.fromJson(message, Event.class); } else { throw new IOException(message); } }
java
public Event getEvent(FutureAPIResponse response) throws ExecutionException, InterruptedException, IOException { int status = response.get().getStatus(); String message = response.get().getMessage(); if (status == HTTP_OK) { // handle DateTime separately GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(DateTime.class, new DateTimeAdapter()); Gson gson = gsonBuilder.create(); return gson.fromJson(message, Event.class); } else { throw new IOException(message); } }
[ "public", "Event", "getEvent", "(", "FutureAPIResponse", "response", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "int", "status", "=", "response", ".", "get", "(", ")", ".", "getStatus", "(", ")", ";", "String", "message", "=", "response", ".", "get", "(", ")", ".", "getMessage", "(", ")", ";", "if", "(", "status", "==", "HTTP_OK", ")", "{", "// handle DateTime separately", "GsonBuilder", "gsonBuilder", "=", "new", "GsonBuilder", "(", ")", ";", "gsonBuilder", ".", "registerTypeAdapter", "(", "DateTime", ".", "class", ",", "new", "DateTimeAdapter", "(", ")", ")", ";", "Gson", "gson", "=", "gsonBuilder", ".", "create", "(", ")", ";", "return", "gson", ".", "fromJson", "(", "message", ",", "Event", ".", "class", ")", ";", "}", "else", "{", "throw", "new", "IOException", "(", "message", ")", ";", "}", "}" ]
Synchronize a previously sent asynchronous get item request. @param response an instance of {@link FutureAPIResponse} returned from {@link #getEventAsFuture} @throws ExecutionException indicates an error in the HTTP backend @throws InterruptedException indicates an interruption during the HTTP operation @throws IOException indicates an error from the API response
[ "Synchronize", "a", "previously", "sent", "asynchronous", "get", "item", "request", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L263-L278
8,627
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.setUserAsFuture
public FutureAPIResponse setUserAsFuture(String uid, Map<String, Object> properties, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$set") .entityType("user") .entityId(uid) .eventTime(eventTime) .properties(properties)); }
java
public FutureAPIResponse setUserAsFuture(String uid, Map<String, Object> properties, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$set") .entityType("user") .entityId(uid) .eventTime(eventTime) .properties(properties)); }
[ "public", "FutureAPIResponse", "setUserAsFuture", "(", "String", "uid", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "return", "createEventAsFuture", "(", "new", "Event", "(", ")", ".", "event", "(", "\"$set\"", ")", ".", "entityType", "(", "\"user\"", ")", ".", "entityId", "(", "uid", ")", ".", "eventTime", "(", "eventTime", ")", ".", "properties", "(", "properties", ")", ")", ";", "}" ]
Sends a set user properties request. Implicitly creates the user if it's not already there. Properties could be empty. @param uid ID of the user @param properties a map of all the properties to be associated with the user, could be empty @param eventTime timestamp of the event @return ID of this event
[ "Sends", "a", "set", "user", "properties", "request", ".", "Implicitly", "creates", "the", "user", "if", "it", "s", "not", "already", "there", ".", "Properties", "could", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L295-L303
8,628
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.setUser
public String setUser(String uid, Map<String, Object> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(setUserAsFuture(uid, properties, eventTime)); }
java
public String setUser(String uid, Map<String, Object> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(setUserAsFuture(uid, properties, eventTime)); }
[ "public", "String", "setUser", "(", "String", "uid", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "setUserAsFuture", "(", "uid", ",", "properties", ",", "eventTime", ")", ")", ";", "}" ]
Sets properties of a user. Implicitly creates the user if it's not already there. Properties could be empty. @param uid ID of the user @param properties a map of all the properties to be associated with the user, could be empty @param eventTime timestamp of the event @return ID of this event
[ "Sets", "properties", "of", "a", "user", ".", "Implicitly", "creates", "the", "user", "if", "it", "s", "not", "already", "there", ".", "Properties", "could", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L324-L327
8,629
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.unsetUser
public String unsetUser(String uid, List<String> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(unsetUserAsFuture(uid, properties, eventTime)); }
java
public String unsetUser(String uid, List<String> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(unsetUserAsFuture(uid, properties, eventTime)); }
[ "public", "String", "unsetUser", "(", "String", "uid", ",", "List", "<", "String", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "unsetUserAsFuture", "(", "uid", ",", "properties", ",", "eventTime", ")", ")", ";", "}" ]
Unsets properties of a user. The list must not be empty. @param uid ID of the user @param properties a list of all the properties to unset @param eventTime timestamp of the event @return ID of this event
[ "Unsets", "properties", "of", "a", "user", ".", "The", "list", "must", "not", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L381-L384
8,630
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.deleteUserAsFuture
public FutureAPIResponse deleteUserAsFuture(String uid, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$delete") .entityType("user") .entityId(uid) .eventTime(eventTime)); }
java
public FutureAPIResponse deleteUserAsFuture(String uid, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$delete") .entityType("user") .entityId(uid) .eventTime(eventTime)); }
[ "public", "FutureAPIResponse", "deleteUserAsFuture", "(", "String", "uid", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "return", "createEventAsFuture", "(", "new", "Event", "(", ")", ".", "event", "(", "\"$delete\"", ")", ".", "entityType", "(", "\"user\"", ")", ".", "entityId", "(", "uid", ")", ".", "eventTime", "(", "eventTime", ")", ")", ";", "}" ]
Sends a delete user request. @param uid ID of the user @param eventTime timestamp of the event
[ "Sends", "a", "delete", "user", "request", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L402-L409
8,631
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.deleteUser
public String deleteUser(String uid) throws ExecutionException, InterruptedException, IOException { return deleteUser(uid, new DateTime()); }
java
public String deleteUser(String uid) throws ExecutionException, InterruptedException, IOException { return deleteUser(uid, new DateTime()); }
[ "public", "String", "deleteUser", "(", "String", "uid", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "deleteUser", "(", "uid", ",", "new", "DateTime", "(", ")", ")", ";", "}" ]
Deletes a user. Event time is recorded as the time when the function is called. @param uid ID of the user @return ID of this event
[ "Deletes", "a", "user", ".", "Event", "time", "is", "recorded", "as", "the", "time", "when", "the", "function", "is", "called", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L439-L442
8,632
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.setItemAsFuture
public FutureAPIResponse setItemAsFuture(String iid, Map<String, Object> properties, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$set") .entityType("item") .entityId(iid) .eventTime(eventTime) .properties(properties)); }
java
public FutureAPIResponse setItemAsFuture(String iid, Map<String, Object> properties, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$set") .entityType("item") .entityId(iid) .eventTime(eventTime) .properties(properties)); }
[ "public", "FutureAPIResponse", "setItemAsFuture", "(", "String", "iid", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "return", "createEventAsFuture", "(", "new", "Event", "(", ")", ".", "event", "(", "\"$set\"", ")", ".", "entityType", "(", "\"item\"", ")", ".", "entityId", "(", "iid", ")", ".", "eventTime", "(", "eventTime", ")", ".", "properties", "(", "properties", ")", ")", ";", "}" ]
Sends a set item properties request. Implicitly creates the item if it's not already there. Properties could be empty. @param iid ID of the item @param properties a map of all the properties to be associated with the item, could be empty @param eventTime timestamp of the event @return ID of this event
[ "Sends", "a", "set", "item", "properties", "request", ".", "Implicitly", "creates", "the", "item", "if", "it", "s", "not", "already", "there", ".", "Properties", "could", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L454-L462
8,633
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.setItem
public String setItem(String iid, Map<String, Object> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(setItemAsFuture(iid, properties, eventTime)); }
java
public String setItem(String iid, Map<String, Object> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(setItemAsFuture(iid, properties, eventTime)); }
[ "public", "String", "setItem", "(", "String", "iid", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "setItemAsFuture", "(", "iid", ",", "properties", ",", "eventTime", ")", ")", ";", "}" ]
Sets properties of a item. Implicitly creates the item if it's not already there. Properties could be empty. @param iid ID of the item @param properties a map of all the properties to be associated with the item, could be empty @param eventTime timestamp of the event @return ID of this event
[ "Sets", "properties", "of", "a", "item", ".", "Implicitly", "creates", "the", "item", "if", "it", "s", "not", "already", "there", ".", "Properties", "could", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L483-L486
8,634
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.unsetItemAsFuture
public FutureAPIResponse unsetItemAsFuture(String iid, List<String> properties, DateTime eventTime) throws IOException { if (properties.isEmpty()) { throw new IllegalStateException("property list cannot be empty"); } // converts the list into a map (to empty string) before creating the event object Map<String, Object> propertiesMap = Maps.newHashMap(); for (String property : properties) { propertiesMap.put(property, ""); } return createEventAsFuture(new Event() .event("$unset") .entityType("item") .entityId(iid) .eventTime(eventTime) .properties(propertiesMap)); }
java
public FutureAPIResponse unsetItemAsFuture(String iid, List<String> properties, DateTime eventTime) throws IOException { if (properties.isEmpty()) { throw new IllegalStateException("property list cannot be empty"); } // converts the list into a map (to empty string) before creating the event object Map<String, Object> propertiesMap = Maps.newHashMap(); for (String property : properties) { propertiesMap.put(property, ""); } return createEventAsFuture(new Event() .event("$unset") .entityType("item") .entityId(iid) .eventTime(eventTime) .properties(propertiesMap)); }
[ "public", "FutureAPIResponse", "unsetItemAsFuture", "(", "String", "iid", ",", "List", "<", "String", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "if", "(", "properties", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"property list cannot be empty\"", ")", ";", "}", "// converts the list into a map (to empty string) before creating the event object", "Map", "<", "String", ",", "Object", ">", "propertiesMap", "=", "Maps", ".", "newHashMap", "(", ")", ";", "for", "(", "String", "property", ":", "properties", ")", "{", "propertiesMap", ".", "put", "(", "property", ",", "\"\"", ")", ";", "}", "return", "createEventAsFuture", "(", "new", "Event", "(", ")", ".", "event", "(", "\"$unset\"", ")", ".", "entityType", "(", "\"item\"", ")", ".", "entityId", "(", "iid", ")", ".", "eventTime", "(", "eventTime", ")", ".", "properties", "(", "propertiesMap", ")", ")", ";", "}" ]
Sends an unset item properties request. The list must not be empty. @param iid ID of the item @param properties a list of all the properties to unset @param eventTime timestamp of the event
[ "Sends", "an", "unset", "item", "properties", "request", ".", "The", "list", "must", "not", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L505-L521
8,635
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.unsetItem
public String unsetItem(String iid, List<String> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(unsetItemAsFuture(iid, properties, eventTime)); }
java
public String unsetItem(String iid, List<String> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(unsetItemAsFuture(iid, properties, eventTime)); }
[ "public", "String", "unsetItem", "(", "String", "iid", ",", "List", "<", "String", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "unsetItemAsFuture", "(", "iid", ",", "properties", ",", "eventTime", ")", ")", ";", "}" ]
Unsets properties of a item. The list must not be empty. @param iid ID of the item @param properties a list of all the properties to unset @param eventTime timestamp of the event @return ID of this event
[ "Unsets", "properties", "of", "a", "item", ".", "The", "list", "must", "not", "be", "empty", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L541-L544
8,636
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.deleteItemAsFuture
public FutureAPIResponse deleteItemAsFuture(String iid, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$delete") .entityType("item") .entityId(iid) .eventTime(eventTime)); }
java
public FutureAPIResponse deleteItemAsFuture(String iid, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event("$delete") .entityType("item") .entityId(iid) .eventTime(eventTime)); }
[ "public", "FutureAPIResponse", "deleteItemAsFuture", "(", "String", "iid", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "return", "createEventAsFuture", "(", "new", "Event", "(", ")", ".", "event", "(", "\"$delete\"", ")", ".", "entityType", "(", "\"item\"", ")", ".", "entityId", "(", "iid", ")", ".", "eventTime", "(", "eventTime", ")", ")", ";", "}" ]
Sends a delete item request. @param iid ID of the item @param eventTime timestamp of the event
[ "Sends", "a", "delete", "item", "request", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L562-L569
8,637
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.deleteItem
public String deleteItem(String iid, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(deleteItemAsFuture(iid, eventTime)); }
java
public String deleteItem(String iid, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(deleteItemAsFuture(iid, eventTime)); }
[ "public", "String", "deleteItem", "(", "String", "iid", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "deleteItemAsFuture", "(", "iid", ",", "eventTime", ")", ")", ";", "}" ]
Deletes a item. @param iid ID of the item @param eventTime timestamp of the event @return ID of this event
[ "Deletes", "a", "item", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L588-L591
8,638
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.deleteItem
public String deleteItem(String iid) throws ExecutionException, InterruptedException, IOException { return deleteItem(iid, new DateTime()); }
java
public String deleteItem(String iid) throws ExecutionException, InterruptedException, IOException { return deleteItem(iid, new DateTime()); }
[ "public", "String", "deleteItem", "(", "String", "iid", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "deleteItem", "(", "iid", ",", "new", "DateTime", "(", ")", ")", ";", "}" ]
Deletes a item. Event time is recorded as the time when the function is called. @param iid ID of the item @return ID of this event
[ "Deletes", "a", "item", ".", "Event", "time", "is", "recorded", "as", "the", "time", "when", "the", "function", "is", "called", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L599-L602
8,639
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.userActionItemAsFuture
public FutureAPIResponse userActionItemAsFuture(String action, String uid, String iid, Map<String, Object> properties, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event(action) .entityType("user") .entityId(uid) .targetEntityType("item") .targetEntityId(iid) .properties(properties) .eventTime(eventTime)); }
java
public FutureAPIResponse userActionItemAsFuture(String action, String uid, String iid, Map<String, Object> properties, DateTime eventTime) throws IOException { return createEventAsFuture(new Event() .event(action) .entityType("user") .entityId(uid) .targetEntityType("item") .targetEntityId(iid) .properties(properties) .eventTime(eventTime)); }
[ "public", "FutureAPIResponse", "userActionItemAsFuture", "(", "String", "action", ",", "String", "uid", ",", "String", "iid", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "return", "createEventAsFuture", "(", "new", "Event", "(", ")", ".", "event", "(", "action", ")", ".", "entityType", "(", "\"user\"", ")", ".", "entityId", "(", "uid", ")", ".", "targetEntityType", "(", "\"item\"", ")", ".", "targetEntityId", "(", "iid", ")", ".", "properties", "(", "properties", ")", ".", "eventTime", "(", "eventTime", ")", ")", ";", "}" ]
Sends a user-action-on-item request. @param action name of the action performed @param uid ID of the user @param iid ID of the item @param properties a map of properties associated with this action @param eventTime timestamp of the event
[ "Sends", "a", "user", "-", "action", "-", "on", "-", "item", "request", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L613-L623
8,640
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java
EventClient.userActionItem
public String userActionItem(String action, String uid, String iid, Map<String, Object> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(userActionItemAsFuture(action, uid, iid, properties, eventTime)); }
java
public String userActionItem(String action, String uid, String iid, Map<String, Object> properties, DateTime eventTime) throws ExecutionException, InterruptedException, IOException { return createEvent(userActionItemAsFuture(action, uid, iid, properties, eventTime)); }
[ "public", "String", "userActionItem", "(", "String", "action", ",", "String", "uid", ",", "String", "iid", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "createEvent", "(", "userActionItemAsFuture", "(", "action", ",", "uid", ",", "iid", ",", "properties", ",", "eventTime", ")", ")", ";", "}" ]
Records a user-action-on-item event. @param action name of the action performed @param uid ID of the user @param iid ID of the item @param properties a map of properties associated with this action @param eventTime timestamp of the event @return ID of this event
[ "Records", "a", "user", "-", "action", "-", "on", "-", "item", "event", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EventClient.java#L646-L650
8,641
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/FileExporter.java
FileExporter.createEvent
public void createEvent(String eventName, String entityType, String entityId, String targetEntityType, String targetEntityId, Map<String, Object> properties, DateTime eventTime) throws IOException { if (eventTime == null) { eventTime = new DateTime(); } Event event = new Event() .event(eventName) .entityType(entityType) .entityId(entityId) .eventTime(eventTime); if (targetEntityType != null) { event.targetEntityType(targetEntityType); } if (targetEntityId != null) { event.targetEntityId(targetEntityId); } if (properties != null) { event.properties(properties); } out.write(event.toJsonString().getBytes("UTF8")); out.write('\n'); }
java
public void createEvent(String eventName, String entityType, String entityId, String targetEntityType, String targetEntityId, Map<String, Object> properties, DateTime eventTime) throws IOException { if (eventTime == null) { eventTime = new DateTime(); } Event event = new Event() .event(eventName) .entityType(entityType) .entityId(entityId) .eventTime(eventTime); if (targetEntityType != null) { event.targetEntityType(targetEntityType); } if (targetEntityId != null) { event.targetEntityId(targetEntityId); } if (properties != null) { event.properties(properties); } out.write(event.toJsonString().getBytes("UTF8")); out.write('\n'); }
[ "public", "void", "createEvent", "(", "String", "eventName", ",", "String", "entityType", ",", "String", "entityId", ",", "String", "targetEntityType", ",", "String", "targetEntityId", ",", "Map", "<", "String", ",", "Object", ">", "properties", ",", "DateTime", "eventTime", ")", "throws", "IOException", "{", "if", "(", "eventTime", "==", "null", ")", "{", "eventTime", "=", "new", "DateTime", "(", ")", ";", "}", "Event", "event", "=", "new", "Event", "(", ")", ".", "event", "(", "eventName", ")", ".", "entityType", "(", "entityType", ")", ".", "entityId", "(", "entityId", ")", ".", "eventTime", "(", "eventTime", ")", ";", "if", "(", "targetEntityType", "!=", "null", ")", "{", "event", ".", "targetEntityType", "(", "targetEntityType", ")", ";", "}", "if", "(", "targetEntityId", "!=", "null", ")", "{", "event", ".", "targetEntityId", "(", "targetEntityId", ")", ";", "}", "if", "(", "properties", "!=", "null", ")", "{", "event", ".", "properties", "(", "properties", ")", ";", "}", "out", ".", "write", "(", "event", ".", "toJsonString", "(", ")", ".", "getBytes", "(", "\"UTF8\"", ")", ")", ";", "out", ".", "write", "(", "'", "'", ")", ";", "}" ]
Create and write a json-encoded event to the underlying file. @param eventName Name of the event. @param entityType The entity type. @param entityId The entity ID. @param targetEntityType The target entity type (optional). @param targetEntityId The target entity ID (optional). @param properties Properties (optional). @param eventTime The time of the event (optional).
[ "Create", "and", "write", "a", "json", "-", "encoded", "event", "to", "the", "underlying", "file", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/FileExporter.java#L46-L74
8,642
Swrve/rate-limited-logger
src/main/java/com/swrve/ratelimitedlogger/LogWithPatternAndLevel.java
LogWithPatternAndLevel.log
public void log(Object... args) { if (!isRateLimited()) { level.log(logger, message, args); } incrementStats(); }
java
public void log(Object... args) { if (!isRateLimited()) { level.log(logger, message, args); } incrementStats(); }
[ "public", "void", "log", "(", "Object", "...", "args", ")", "{", "if", "(", "!", "isRateLimited", "(", ")", ")", "{", "level", ".", "log", "(", "logger", ",", "message", ",", "args", ")", ";", "}", "incrementStats", "(", ")", ";", "}" ]
logging APIs. These can use the SLF4J style of templating to parameterize the Logs. See http://www.slf4j.org/api/org/slf4j/helpers/MessageFormatter.html . <pre> rateLimitedLog.info("Just saw an event of type {}: {}", event.getType(), event); </pre> @param args the varargs list of arguments matching the message template
[ "logging", "APIs", "." ]
9094d3961f35dad0d6114aafade4a34b0b264b0b
https://github.com/Swrve/rate-limited-logger/blob/9094d3961f35dad0d6114aafade4a34b0b264b0b/src/main/java/com/swrve/ratelimitedlogger/LogWithPatternAndLevel.java#L67-L72
8,643
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EngineClient.java
EngineClient.sendQueryAsFuture
public FutureAPIResponse sendQueryAsFuture(Map<String, Object> query) throws ExecutionException, InterruptedException, IOException { RequestBuilder builder = new RequestBuilder("POST"); builder.setUrl(apiUrl + "/queries.json"); // handle DateTime separately GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(DateTime.class, new DateTimeAdapter()); Gson gson = gsonBuilder.create(); String requestJsonString = gson.toJson(query); builder.setBody(requestJsonString); builder.setHeader("Content-Type", "application/json"); builder.setHeader("Content-Length", "" + requestJsonString.length()); return new FutureAPIResponse(client.executeRequest(builder.build(), getHandler())); }
java
public FutureAPIResponse sendQueryAsFuture(Map<String, Object> query) throws ExecutionException, InterruptedException, IOException { RequestBuilder builder = new RequestBuilder("POST"); builder.setUrl(apiUrl + "/queries.json"); // handle DateTime separately GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(DateTime.class, new DateTimeAdapter()); Gson gson = gsonBuilder.create(); String requestJsonString = gson.toJson(query); builder.setBody(requestJsonString); builder.setHeader("Content-Type", "application/json"); builder.setHeader("Content-Length", "" + requestJsonString.length()); return new FutureAPIResponse(client.executeRequest(builder.build(), getHandler())); }
[ "public", "FutureAPIResponse", "sendQueryAsFuture", "(", "Map", "<", "String", ",", "Object", ">", "query", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "RequestBuilder", "builder", "=", "new", "RequestBuilder", "(", "\"POST\"", ")", ";", "builder", ".", "setUrl", "(", "apiUrl", "+", "\"/queries.json\"", ")", ";", "// handle DateTime separately", "GsonBuilder", "gsonBuilder", "=", "new", "GsonBuilder", "(", ")", ";", "gsonBuilder", ".", "registerTypeAdapter", "(", "DateTime", ".", "class", ",", "new", "DateTimeAdapter", "(", ")", ")", ";", "Gson", "gson", "=", "gsonBuilder", ".", "create", "(", ")", ";", "String", "requestJsonString", "=", "gson", ".", "toJson", "(", "query", ")", ";", "builder", ".", "setBody", "(", "requestJsonString", ")", ";", "builder", ".", "setHeader", "(", "\"Content-Type\"", ",", "\"application/json\"", ")", ";", "builder", ".", "setHeader", "(", "\"Content-Length\"", ",", "\"\"", "+", "requestJsonString", ".", "length", "(", ")", ")", ";", "return", "new", "FutureAPIResponse", "(", "client", ".", "executeRequest", "(", "builder", ".", "build", "(", ")", ",", "getHandler", "(", ")", ")", ")", ";", "}" ]
Sends a query asynchronously.
[ "Sends", "a", "query", "asynchronously", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EngineClient.java#L96-L111
8,644
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EngineClient.java
EngineClient.sendQuery
public JsonObject sendQuery(Map<String, Object> query) throws ExecutionException, InterruptedException, IOException { return sendQuery(sendQueryAsFuture(query)); }
java
public JsonObject sendQuery(Map<String, Object> query) throws ExecutionException, InterruptedException, IOException { return sendQuery(sendQueryAsFuture(query)); }
[ "public", "JsonObject", "sendQuery", "(", "Map", "<", "String", ",", "Object", ">", "query", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "sendQuery", "(", "sendQueryAsFuture", "(", "query", ")", ")", ";", "}" ]
Sends a query synchronously.
[ "Sends", "a", "query", "synchronously", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EngineClient.java#L116-L119
8,645
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/EngineClient.java
EngineClient.sendQuery
public JsonObject sendQuery(FutureAPIResponse response) throws ExecutionException, InterruptedException, IOException { int status = response.get().getStatus(); String message = response.get().getMessage(); if (status != HTTP_OK) { throw new IOException(status + " " + message); } return ((JsonObject) parser.parse(message)); }
java
public JsonObject sendQuery(FutureAPIResponse response) throws ExecutionException, InterruptedException, IOException { int status = response.get().getStatus(); String message = response.get().getMessage(); if (status != HTTP_OK) { throw new IOException(status + " " + message); } return ((JsonObject) parser.parse(message)); }
[ "public", "JsonObject", "sendQuery", "(", "FutureAPIResponse", "response", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "int", "status", "=", "response", ".", "get", "(", ")", ".", "getStatus", "(", ")", ";", "String", "message", "=", "response", ".", "get", "(", ")", ".", "getMessage", "(", ")", ";", "if", "(", "status", "!=", "HTTP_OK", ")", "{", "throw", "new", "IOException", "(", "status", "+", "\" \"", "+", "message", ")", ";", "}", "return", "(", "(", "JsonObject", ")", "parser", ".", "parse", "(", "message", ")", ")", ";", "}" ]
Gets query result from a previously sent asynchronous request.
[ "Gets", "query", "result", "from", "a", "previously", "sent", "asynchronous", "request", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/EngineClient.java#L124-L133
8,646
Swrve/rate-limited-logger
src/main/java/com/swrve/ratelimitedlogger/RateLimitedLog.java
RateLimitedLog.withRateLimit
public static RateLimitedLogBuilder.MissingRateAndPeriod withRateLimit(Logger logger) { return new RateLimitedLogBuilder.MissingRateAndPeriod(Objects.requireNonNull(logger)); }
java
public static RateLimitedLogBuilder.MissingRateAndPeriod withRateLimit(Logger logger) { return new RateLimitedLogBuilder.MissingRateAndPeriod(Objects.requireNonNull(logger)); }
[ "public", "static", "RateLimitedLogBuilder", ".", "MissingRateAndPeriod", "withRateLimit", "(", "Logger", "logger", ")", "{", "return", "new", "RateLimitedLogBuilder", ".", "MissingRateAndPeriod", "(", "Objects", ".", "requireNonNull", "(", "logger", ")", ")", ";", "}" ]
Start building a new RateLimitedLog, wrapping the SLF4J logger @param logger.
[ "Start", "building", "a", "new", "RateLimitedLog", "wrapping", "the", "SLF4J", "logger" ]
9094d3961f35dad0d6114aafade4a34b0b264b0b
https://github.com/Swrve/rate-limited-logger/blob/9094d3961f35dad0d6114aafade4a34b0b264b0b/src/main/java/com/swrve/ratelimitedlogger/RateLimitedLog.java#L71-L73
8,647
Swrve/rate-limited-logger
src/main/java/com/swrve/ratelimitedlogger/RateLimitedLog.java
RateLimitedLog.outOfCacheCapacity
private void outOfCacheCapacity() { synchronized (knownPatterns) { if (knownPatterns.size() > MAX_PATTERNS_PER_LOG) { logger.warn("out of capacity in RateLimitedLog registry; accidentally " + "using interpolated strings as patterns?"); registry.flush(); knownPatterns.clear(); } } }
java
private void outOfCacheCapacity() { synchronized (knownPatterns) { if (knownPatterns.size() > MAX_PATTERNS_PER_LOG) { logger.warn("out of capacity in RateLimitedLog registry; accidentally " + "using interpolated strings as patterns?"); registry.flush(); knownPatterns.clear(); } } }
[ "private", "void", "outOfCacheCapacity", "(", ")", "{", "synchronized", "(", "knownPatterns", ")", "{", "if", "(", "knownPatterns", ".", "size", "(", ")", ">", "MAX_PATTERNS_PER_LOG", ")", "{", "logger", ".", "warn", "(", "\"out of capacity in RateLimitedLog registry; accidentally \"", "+", "\"using interpolated strings as patterns?\"", ")", ";", "registry", ".", "flush", "(", ")", ";", "knownPatterns", ".", "clear", "(", ")", ";", "}", "}", "}" ]
We've run out of capacity in our cache of RateLimitedLogWithPattern objects. This probably means that the caller is accidentally calling us with an already-interpolated string, instead of using the pattern as the key and letting us do the interpolation. Don't lose data; instead, fall back to flushing the entire cache but carrying on. The worst-case scenario here is that we flush the logs far more frequently than their requested durations, potentially allowing the logging to impact throughput, but we don't lose any log data.
[ "We", "ve", "run", "out", "of", "capacity", "in", "our", "cache", "of", "RateLimitedLogWithPattern", "objects", ".", "This", "probably", "means", "that", "the", "caller", "is", "accidentally", "calling", "us", "with", "an", "already", "-", "interpolated", "string", "instead", "of", "using", "the", "pattern", "as", "the", "key", "and", "letting", "us", "do", "the", "interpolation", ".", "Don", "t", "lose", "data", ";", "instead", "fall", "back", "to", "flushing", "the", "entire", "cache", "but", "carrying", "on", ".", "The", "worst", "-", "case", "scenario", "here", "is", "that", "we", "flush", "the", "logs", "far", "more", "frequently", "than", "their", "requested", "durations", "potentially", "allowing", "the", "logging", "to", "impact", "throughput", "but", "we", "don", "t", "lose", "any", "log", "data", "." ]
9094d3961f35dad0d6114aafade4a34b0b264b0b
https://github.com/Swrve/rate-limited-logger/blob/9094d3961f35dad0d6114aafade4a34b0b264b0b/src/main/java/com/swrve/ratelimitedlogger/RateLimitedLog.java#L445-L454
8,648
greenhalolabs/EmailAutoCompleteTextView
emailautocompletetextview/src/main/java/com/greenhalolabs/emailautocompletetextview/EmailAutoCompleteTextView.java
EmailAutoCompleteTextView.setClearVisible
public void setClearVisible(boolean visible) { if (mClearButtonEnabled) { final Drawable d = (visible ? mTappableDrawable : null); final Drawable[] drawables = getCompoundDrawables(); if (drawables != null) { setCompoundDrawables(drawables[0], drawables[1], d, drawables[3]); } else { Log.w(TAG, "No clear button is available."); } } }
java
public void setClearVisible(boolean visible) { if (mClearButtonEnabled) { final Drawable d = (visible ? mTappableDrawable : null); final Drawable[] drawables = getCompoundDrawables(); if (drawables != null) { setCompoundDrawables(drawables[0], drawables[1], d, drawables[3]); } else { Log.w(TAG, "No clear button is available."); } } }
[ "public", "void", "setClearVisible", "(", "boolean", "visible", ")", "{", "if", "(", "mClearButtonEnabled", ")", "{", "final", "Drawable", "d", "=", "(", "visible", "?", "mTappableDrawable", ":", "null", ")", ";", "final", "Drawable", "[", "]", "drawables", "=", "getCompoundDrawables", "(", ")", ";", "if", "(", "drawables", "!=", "null", ")", "{", "setCompoundDrawables", "(", "drawables", "[", "0", "]", ",", "drawables", "[", "1", "]", ",", "d", ",", "drawables", "[", "3", "]", ")", ";", "}", "else", "{", "Log", ".", "w", "(", "TAG", ",", "\"No clear button is available.\"", ")", ";", "}", "}", "}" ]
Sets the visibility of the clear button. The clear button must also be enabled for it to be visible. @see {@link #setClearButtonEnabled(boolean)} @param visible true if the clear button should be visible, otherwise, false.
[ "Sets", "the", "visibility", "of", "the", "clear", "button", ".", "The", "clear", "button", "must", "also", "be", "enabled", "for", "it", "to", "be", "visible", "." ]
f2be63be328198f763fc0c73a7eeabcb75b571ca
https://github.com/greenhalolabs/EmailAutoCompleteTextView/blob/f2be63be328198f763fc0c73a7eeabcb75b571ca/emailautocompletetextview/src/main/java/com/greenhalolabs/emailautocompletetextview/EmailAutoCompleteTextView.java#L105-L115
8,649
apache/predictionio-sdk-java
client/src/main/java/org/apache/predictionio/sdk/java/BaseClient.java
BaseClient.getStatus
public String getStatus() throws ExecutionException, InterruptedException, IOException { return (new FutureAPIResponse(client.prepareGet(apiUrl).execute(getHandler()))).get() .getMessage(); }
java
public String getStatus() throws ExecutionException, InterruptedException, IOException { return (new FutureAPIResponse(client.prepareGet(apiUrl).execute(getHandler()))).get() .getMessage(); }
[ "public", "String", "getStatus", "(", ")", "throws", "ExecutionException", ",", "InterruptedException", ",", "IOException", "{", "return", "(", "new", "FutureAPIResponse", "(", "client", ".", "prepareGet", "(", "apiUrl", ")", ".", "execute", "(", "getHandler", "(", ")", ")", ")", ")", ".", "get", "(", ")", ".", "getMessage", "(", ")", ";", "}" ]
Get status of the API. @throws ExecutionException indicates an error in the HTTP backend @throws InterruptedException indicates an interruption during the HTTP operation @throws IOException indicates an error from the API response
[ "Get", "status", "of", "the", "API", "." ]
16052c96b136340c175c3f9c2692e720850df219
https://github.com/apache/predictionio-sdk-java/blob/16052c96b136340c175c3f9c2692e720850df219/client/src/main/java/org/apache/predictionio/sdk/java/BaseClient.java#L146-L149
8,650
wizzardo/tools
modules/tools-security/src/main/java/com/wizzardo/tools/security/AES.java
AES.generateKey
public static SecretKey generateKey(final byte[] key) { return new SecretKey() { private byte[] k; { if (key.length == 16) { k = key; } else { k = new byte[16]; System.arraycopy(key, 0, k, 0, key.length < 16 ? key.length : 16); } } @Override public String getAlgorithm() { return "AES"; } @Override public String getFormat() { return "RAW"; } @Override public byte[] getEncoded() { return k; } }; }
java
public static SecretKey generateKey(final byte[] key) { return new SecretKey() { private byte[] k; { if (key.length == 16) { k = key; } else { k = new byte[16]; System.arraycopy(key, 0, k, 0, key.length < 16 ? key.length : 16); } } @Override public String getAlgorithm() { return "AES"; } @Override public String getFormat() { return "RAW"; } @Override public byte[] getEncoded() { return k; } }; }
[ "public", "static", "SecretKey", "generateKey", "(", "final", "byte", "[", "]", "key", ")", "{", "return", "new", "SecretKey", "(", ")", "{", "private", "byte", "[", "]", "k", ";", "{", "if", "(", "key", ".", "length", "==", "16", ")", "{", "k", "=", "key", ";", "}", "else", "{", "k", "=", "new", "byte", "[", "16", "]", ";", "System", ".", "arraycopy", "(", "key", ",", "0", ",", "k", ",", "0", ",", "key", ".", "length", "<", "16", "?", "key", ".", "length", ":", "16", ")", ";", "}", "}", "@", "Override", "public", "String", "getAlgorithm", "(", ")", "{", "return", "\"AES\"", ";", "}", "@", "Override", "public", "String", "getFormat", "(", ")", "{", "return", "\"RAW\"", ";", "}", "@", "Override", "public", "byte", "[", "]", "getEncoded", "(", ")", "{", "return", "k", ";", "}", "}", ";", "}" ]
16 bytes max, 128-bit encription
[ "16", "bytes", "max", "128", "-", "bit", "encription" ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-security/src/main/java/com/wizzardo/tools/security/AES.java#L48-L77
8,651
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.setAxis
public void setAxis(int axis) { boolean axisChanged = (axis != majorAxis); majorAxis = axis; if (axisChanged) { preferenceChanged(null, true, true); } }
java
public void setAxis(int axis) { boolean axisChanged = (axis != majorAxis); majorAxis = axis; if (axisChanged) { preferenceChanged(null, true, true); } }
[ "public", "void", "setAxis", "(", "int", "axis", ")", "{", "boolean", "axisChanged", "=", "(", "axis", "!=", "majorAxis", ")", ";", "majorAxis", "=", "axis", ";", "if", "(", "axisChanged", ")", "{", "preferenceChanged", "(", "null", ",", "true", ",", "true", ")", ";", "}", "}" ]
Sets the tile axis property. This is the axis along which the child views are tiled. @param axis either <code>View.X_AXIS</code> or <code>View.Y_AXIS</code>
[ "Sets", "the", "tile", "axis", "property", ".", "This", "is", "the", "axis", "along", "which", "the", "child", "views", "are", "tiled", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L179-L187
8,652
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.getCompleteBoxAllocation
private Rectangle getCompleteBoxAllocation(Box b) { Rectangle ret = b.getAbsoluteBounds(); if (b instanceof ElementBox) { ElementBox eb = (ElementBox) b; for (int i = eb.getStartChild(); i < eb.getEndChild(); i++) { Box child = eb.getSubBox(i); if (child.isVisible()) { Rectangle r = getCompleteBoxAllocation(child); ret.add(r); } } } return ret.intersection(b.getClipBlock().getClippedContentBounds()); }
java
private Rectangle getCompleteBoxAllocation(Box b) { Rectangle ret = b.getAbsoluteBounds(); if (b instanceof ElementBox) { ElementBox eb = (ElementBox) b; for (int i = eb.getStartChild(); i < eb.getEndChild(); i++) { Box child = eb.getSubBox(i); if (child.isVisible()) { Rectangle r = getCompleteBoxAllocation(child); ret.add(r); } } } return ret.intersection(b.getClipBlock().getClippedContentBounds()); }
[ "private", "Rectangle", "getCompleteBoxAllocation", "(", "Box", "b", ")", "{", "Rectangle", "ret", "=", "b", ".", "getAbsoluteBounds", "(", ")", ";", "if", "(", "b", "instanceof", "ElementBox", ")", "{", "ElementBox", "eb", "=", "(", "ElementBox", ")", "b", ";", "for", "(", "int", "i", "=", "eb", ".", "getStartChild", "(", ")", ";", "i", "<", "eb", ".", "getEndChild", "(", ")", ";", "i", "++", ")", "{", "Box", "child", "=", "eb", ".", "getSubBox", "(", "i", ")", ";", "if", "(", "child", ".", "isVisible", "(", ")", ")", "{", "Rectangle", "r", "=", "getCompleteBoxAllocation", "(", "child", ")", ";", "ret", ".", "add", "(", "r", ")", ";", "}", "}", "}", "return", "ret", ".", "intersection", "(", "b", ".", "getClipBlock", "(", ")", ".", "getClippedContentBounds", "(", ")", ")", ";", "}" ]
Obtains the allocation of a box together with all its child boxes. @param b the box @return the smallest rectangle containing the box and all its child boxes
[ "Obtains", "the", "allocation", "of", "a", "box", "together", "with", "all", "its", "child", "boxes", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L504-L521
8,653
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.isBefore
@Override protected boolean isBefore(int x, int y, Rectangle innerAlloc) { // System.err.println("isBefore: " + innerAlloc + " my bounds " + // box.getAbsoluteBounds()); // System.err.println("XY: " + x + " : " + y); innerAlloc.setBounds(box.getAbsoluteBounds()); if (majorAxis == View.X_AXIS) { return (x < innerAlloc.x); } else { return (y < innerAlloc.y); } }
java
@Override protected boolean isBefore(int x, int y, Rectangle innerAlloc) { // System.err.println("isBefore: " + innerAlloc + " my bounds " + // box.getAbsoluteBounds()); // System.err.println("XY: " + x + " : " + y); innerAlloc.setBounds(box.getAbsoluteBounds()); if (majorAxis == View.X_AXIS) { return (x < innerAlloc.x); } else { return (y < innerAlloc.y); } }
[ "@", "Override", "protected", "boolean", "isBefore", "(", "int", "x", ",", "int", "y", ",", "Rectangle", "innerAlloc", ")", "{", "// System.err.println(\"isBefore: \" + innerAlloc + \" my bounds \" +", "// box.getAbsoluteBounds());", "// System.err.println(\"XY: \" + x + \" : \" + y);", "innerAlloc", ".", "setBounds", "(", "box", ".", "getAbsoluteBounds", "(", ")", ")", ";", "if", "(", "majorAxis", "==", "View", ".", "X_AXIS", ")", "{", "return", "(", "x", "<", "innerAlloc", ".", "x", ")", ";", "}", "else", "{", "return", "(", "y", "<", "innerAlloc", ".", "y", ")", ";", "}", "}" ]
Determines if a point falls before an allocated region. @param x the X coordinate >= 0 @param y the Y coordinate >= 0 @param innerAlloc the allocated region; this is the area inside of the insets @return true if the point lies before the region else false
[ "Determines", "if", "a", "point", "falls", "before", "an", "allocated", "region", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L595-L610
8,654
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.isAfter
@Override protected boolean isAfter(int x, int y, Rectangle innerAlloc) { // System.err.println("isAfter: " + innerAlloc + " my bounds " + // box.getAbsoluteBounds()); // System.err.println("XY: " + x + " : " + y); innerAlloc.setBounds(box.getAbsoluteBounds()); if (majorAxis == View.X_AXIS) { return (x > (innerAlloc.width + innerAlloc.x)); } else { return (y > (innerAlloc.height + innerAlloc.y)); } }
java
@Override protected boolean isAfter(int x, int y, Rectangle innerAlloc) { // System.err.println("isAfter: " + innerAlloc + " my bounds " + // box.getAbsoluteBounds()); // System.err.println("XY: " + x + " : " + y); innerAlloc.setBounds(box.getAbsoluteBounds()); if (majorAxis == View.X_AXIS) { return (x > (innerAlloc.width + innerAlloc.x)); } else { return (y > (innerAlloc.height + innerAlloc.y)); } }
[ "@", "Override", "protected", "boolean", "isAfter", "(", "int", "x", ",", "int", "y", ",", "Rectangle", "innerAlloc", ")", "{", "// System.err.println(\"isAfter: \" + innerAlloc + \" my bounds \" +", "// box.getAbsoluteBounds());", "// System.err.println(\"XY: \" + x + \" : \" + y);", "innerAlloc", ".", "setBounds", "(", "box", ".", "getAbsoluteBounds", "(", ")", ")", ";", "if", "(", "majorAxis", "==", "View", ".", "X_AXIS", ")", "{", "return", "(", "x", ">", "(", "innerAlloc", ".", "width", "+", "innerAlloc", ".", "x", ")", ")", ";", "}", "else", "{", "return", "(", "y", ">", "(", "innerAlloc", ".", "height", "+", "innerAlloc", ".", "y", ")", ")", ";", "}", "}" ]
Determines if a point falls after an allocated region. @param x the X coordinate >= 0 @param y the Y coordinate >= 0 @param innerAlloc the allocated region; this is the area inside of the insets @return true if the point lies after the region else false
[ "Determines", "if", "a", "point", "falls", "after", "an", "allocated", "region", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L623-L638
8,655
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.validateLayout
protected boolean validateLayout(Dimension dim) { if (majorAxis == X_AXIS) { majorRequest = getRequirements(X_AXIS, majorRequest); minorRequest = getRequirements(Y_AXIS, minorRequest); oldDimension.setSize(majorRequest.preferred, minorRequest.preferred); } else { majorRequest = getRequirements(Y_AXIS, majorRequest); minorRequest = getRequirements(X_AXIS, minorRequest); oldDimension.setSize(minorRequest.preferred, majorRequest.preferred); } majorReqValid = true; minorReqValid = true; majorAllocValid = true; minorAllocValid = true; return false; }
java
protected boolean validateLayout(Dimension dim) { if (majorAxis == X_AXIS) { majorRequest = getRequirements(X_AXIS, majorRequest); minorRequest = getRequirements(Y_AXIS, minorRequest); oldDimension.setSize(majorRequest.preferred, minorRequest.preferred); } else { majorRequest = getRequirements(Y_AXIS, majorRequest); minorRequest = getRequirements(X_AXIS, minorRequest); oldDimension.setSize(minorRequest.preferred, majorRequest.preferred); } majorReqValid = true; minorReqValid = true; majorAllocValid = true; minorAllocValid = true; return false; }
[ "protected", "boolean", "validateLayout", "(", "Dimension", "dim", ")", "{", "if", "(", "majorAxis", "==", "X_AXIS", ")", "{", "majorRequest", "=", "getRequirements", "(", "X_AXIS", ",", "majorRequest", ")", ";", "minorRequest", "=", "getRequirements", "(", "Y_AXIS", ",", "minorRequest", ")", ";", "oldDimension", ".", "setSize", "(", "majorRequest", ".", "preferred", ",", "minorRequest", ".", "preferred", ")", ";", "}", "else", "{", "majorRequest", "=", "getRequirements", "(", "Y_AXIS", ",", "majorRequest", ")", ";", "minorRequest", "=", "getRequirements", "(", "X_AXIS", ",", "minorRequest", ")", ";", "oldDimension", ".", "setSize", "(", "minorRequest", ".", "preferred", ",", "majorRequest", ".", "preferred", ")", ";", "}", "majorReqValid", "=", "true", ";", "minorReqValid", "=", "true", ";", "majorAllocValid", "=", "true", ";", "minorAllocValid", "=", "true", ";", "return", "false", ";", "}" ]
Validates layout. @param dim the new dimension of valid area. Validation run against this @return true, if layout during validation process has been changed.
[ "Validates", "layout", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L757-L777
8,656
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.toRect
public static final Rectangle toRect(Shape a) { return a instanceof Rectangle ? (Rectangle) a : a.getBounds(); }
java
public static final Rectangle toRect(Shape a) { return a instanceof Rectangle ? (Rectangle) a : a.getBounds(); }
[ "public", "static", "final", "Rectangle", "toRect", "(", "Shape", "a", ")", "{", "return", "a", "instanceof", "Rectangle", "?", "(", "Rectangle", ")", "a", ":", "a", ".", "getBounds", "(", ")", ";", "}" ]
Converts an Shape to instance of rectangle @param a the shape @return the rectangle
[ "Converts", "an", "Shape", "to", "instance", "of", "rectangle" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L805-L808
8,657
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.intersection
public static final boolean intersection(Rectangle src1, Rectangle src2, Rectangle dest) { int x1 = Math.max(src1.x, src2.x); int y1 = Math.max(src1.y, src2.y); int x2 = Math.min(src1.x + src1.width, src2.x + src2.width); int y2 = Math.min(src1.y + src1.height, src2.y + src2.height); dest.setBounds(x1, y1, x2 - x1, y2 - y1); if (dest.width <= 0 || dest.height <= 0) return false; return true; // non-empty intersection }
java
public static final boolean intersection(Rectangle src1, Rectangle src2, Rectangle dest) { int x1 = Math.max(src1.x, src2.x); int y1 = Math.max(src1.y, src2.y); int x2 = Math.min(src1.x + src1.width, src2.x + src2.width); int y2 = Math.min(src1.y + src1.height, src2.y + src2.height); dest.setBounds(x1, y1, x2 - x1, y2 - y1); if (dest.width <= 0 || dest.height <= 0) return false; return true; // non-empty intersection }
[ "public", "static", "final", "boolean", "intersection", "(", "Rectangle", "src1", ",", "Rectangle", "src2", ",", "Rectangle", "dest", ")", "{", "int", "x1", "=", "Math", ".", "max", "(", "src1", ".", "x", ",", "src2", ".", "x", ")", ";", "int", "y1", "=", "Math", ".", "max", "(", "src1", ".", "y", ",", "src2", ".", "y", ")", ";", "int", "x2", "=", "Math", ".", "min", "(", "src1", ".", "x", "+", "src1", ".", "width", ",", "src2", ".", "x", "+", "src2", ".", "width", ")", ";", "int", "y2", "=", "Math", ".", "min", "(", "src1", ".", "y", "+", "src1", ".", "height", ",", "src2", ".", "y", "+", "src2", ".", "height", ")", ";", "dest", ".", "setBounds", "(", "x1", ",", "y1", ",", "x2", "-", "x1", ",", "y2", "-", "y1", ")", ";", "if", "(", "dest", ".", "width", "<=", "0", "||", "dest", ".", "height", "<=", "0", ")", "return", "false", ";", "return", "true", ";", "// non-empty intersection", "}" ]
Calculates intersection of two rectangles @param src1 the src1 @param src2 the src2 @param dest the dest @return true, if there is non empty intersection
[ "Calculates", "intersection", "of", "two", "rectangles" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L821-L833
8,658
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.getBox
public static final Box getBox(CSSBoxView v) { try { AttributeSet attr = v.getAttributes(); return (Box) attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE); } catch (Exception e) { throw new IllegalStateException(e); } }
java
public static final Box getBox(CSSBoxView v) { try { AttributeSet attr = v.getAttributes(); return (Box) attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE); } catch (Exception e) { throw new IllegalStateException(e); } }
[ "public", "static", "final", "Box", "getBox", "(", "CSSBoxView", "v", ")", "{", "try", "{", "AttributeSet", "attr", "=", "v", ".", "getAttributes", "(", ")", ";", "return", "(", "Box", ")", "attr", ".", "getAttribute", "(", "Constants", ".", "ATTRIBUTE_BOX_REFERENCE", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Gets the box reference from properties @param v the view, instance of CSSBoxView. @return the box set in properties.
[ "Gets", "the", "box", "reference", "from", "properties" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L842-L853
8,659
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java
ElementBoxView.getBox
public static final Box getBox(View v) { if (v instanceof CSSBoxView) return getBox((CSSBoxView) v); AttributeSet attr = v.getAttributes(); if (attr == null) { throw new NullPointerException("AttributeSet of " + v.getClass().getName() + "@" + Integer.toHexString(v.hashCode()) + " is set to NULL."); } Object obj = attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE); if (obj != null && obj instanceof Box) { return (Box) obj; } else { throw new IllegalArgumentException("Box reference in attributes is not an instance of a Box."); } }
java
public static final Box getBox(View v) { if (v instanceof CSSBoxView) return getBox((CSSBoxView) v); AttributeSet attr = v.getAttributes(); if (attr == null) { throw new NullPointerException("AttributeSet of " + v.getClass().getName() + "@" + Integer.toHexString(v.hashCode()) + " is set to NULL."); } Object obj = attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE); if (obj != null && obj instanceof Box) { return (Box) obj; } else { throw new IllegalArgumentException("Box reference in attributes is not an instance of a Box."); } }
[ "public", "static", "final", "Box", "getBox", "(", "View", "v", ")", "{", "if", "(", "v", "instanceof", "CSSBoxView", ")", "return", "getBox", "(", "(", "CSSBoxView", ")", "v", ")", ";", "AttributeSet", "attr", "=", "v", ".", "getAttributes", "(", ")", ";", "if", "(", "attr", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"AttributeSet of \"", "+", "v", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"@\"", "+", "Integer", ".", "toHexString", "(", "v", ".", "hashCode", "(", ")", ")", "+", "\" is set to NULL.\"", ")", ";", "}", "Object", "obj", "=", "attr", ".", "getAttribute", "(", "Constants", ".", "ATTRIBUTE_BOX_REFERENCE", ")", ";", "if", "(", "obj", "!=", "null", "&&", "obj", "instanceof", "Box", ")", "{", "return", "(", "Box", ")", "obj", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Box reference in attributes is not an instance of a Box.\"", ")", ";", "}", "}" ]
Gets the box reference from properties. @param v just a view. @return the box set in properties, if there is one.
[ "Gets", "the", "box", "reference", "from", "properties", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/ElementBoxView.java#L862-L882
8,660
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/BrowserPane.java
BrowserPane.activateTooltip
public void activateTooltip(boolean show) { if (show) { ToolTipManager.sharedInstance().registerComponent(this); } else { ToolTipManager.sharedInstance().unregisterComponent(this); } ToolTipManager.sharedInstance().setEnabled(show); }
java
public void activateTooltip(boolean show) { if (show) { ToolTipManager.sharedInstance().registerComponent(this); } else { ToolTipManager.sharedInstance().unregisterComponent(this); } ToolTipManager.sharedInstance().setEnabled(show); }
[ "public", "void", "activateTooltip", "(", "boolean", "show", ")", "{", "if", "(", "show", ")", "{", "ToolTipManager", ".", "sharedInstance", "(", ")", ".", "registerComponent", "(", "this", ")", ";", "}", "else", "{", "ToolTipManager", ".", "sharedInstance", "(", ")", ".", "unregisterComponent", "(", "this", ")", ";", "}", "ToolTipManager", ".", "sharedInstance", "(", ")", ".", "setEnabled", "(", "show", ")", ";", "}" ]
Activates tooltips. @param show if true, shows tooltips.
[ "Activates", "tooltips", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/BrowserPane.java#L142-L153
8,661
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/BrowserPane.java
BrowserPane.fireGeneralEvent
public void fireGeneralEvent(GeneralEvent e) { Object[] listeners = listenerList.getListenerList(); // notify those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == GeneralEventListener.class) { ((GeneralEventListener) listeners[i + 1]).generalEventUpdate(e); } } }
java
public void fireGeneralEvent(GeneralEvent e) { Object[] listeners = listenerList.getListenerList(); // notify those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == GeneralEventListener.class) { ((GeneralEventListener) listeners[i + 1]).generalEventUpdate(e); } } }
[ "public", "void", "fireGeneralEvent", "(", "GeneralEvent", "e", ")", "{", "Object", "[", "]", "listeners", "=", "listenerList", ".", "getListenerList", "(", ")", ";", "// notify those that are interested in this event", "for", "(", "int", "i", "=", "listeners", ".", "length", "-", "2", ";", "i", ">=", "0", ";", "i", "-=", "2", ")", "{", "if", "(", "listeners", "[", "i", "]", "==", "GeneralEventListener", ".", "class", ")", "{", "(", "(", "GeneralEventListener", ")", "listeners", "[", "i", "+", "1", "]", ")", ".", "generalEventUpdate", "(", "e", ")", ";", "}", "}", "}" ]
Fires general event. All registered listeners will be notified. @param e the event
[ "Fires", "general", "event", ".", "All", "registered", "listeners", "will", "be", "notified", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/BrowserPane.java#L208-L221
8,662
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/BrowserPane.java
BrowserPane.renderContent
public Graphics2D renderContent() { View view = null; ViewFactory factory = getEditorKit().getViewFactory(); if (factory instanceof SwingBoxViewFactory) { view = ((SwingBoxViewFactory) factory).getViewport(); } if (view != null) { int w = (int) view.getPreferredSpan(View.X_AXIS); int h = (int) view.getPreferredSpan(View.Y_AXIS); Rectangle rec = new Rectangle(w, h); BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = img.createGraphics(); g.setClip(rec); view.paint(g, rec); return g; } return null; }
java
public Graphics2D renderContent() { View view = null; ViewFactory factory = getEditorKit().getViewFactory(); if (factory instanceof SwingBoxViewFactory) { view = ((SwingBoxViewFactory) factory).getViewport(); } if (view != null) { int w = (int) view.getPreferredSpan(View.X_AXIS); int h = (int) view.getPreferredSpan(View.Y_AXIS); Rectangle rec = new Rectangle(w, h); BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = img.createGraphics(); g.setClip(rec); view.paint(g, rec); return g; } return null; }
[ "public", "Graphics2D", "renderContent", "(", ")", "{", "View", "view", "=", "null", ";", "ViewFactory", "factory", "=", "getEditorKit", "(", ")", ".", "getViewFactory", "(", ")", ";", "if", "(", "factory", "instanceof", "SwingBoxViewFactory", ")", "{", "view", "=", "(", "(", "SwingBoxViewFactory", ")", "factory", ")", ".", "getViewport", "(", ")", ";", "}", "if", "(", "view", "!=", "null", ")", "{", "int", "w", "=", "(", "int", ")", "view", ".", "getPreferredSpan", "(", "View", ".", "X_AXIS", ")", ";", "int", "h", "=", "(", "int", ")", "view", ".", "getPreferredSpan", "(", "View", ".", "Y_AXIS", ")", ";", "Rectangle", "rec", "=", "new", "Rectangle", "(", "w", ",", "h", ")", ";", "BufferedImage", "img", "=", "new", "BufferedImage", "(", "w", ",", "h", ",", "BufferedImage", ".", "TYPE_INT_RGB", ")", ";", "Graphics2D", "g", "=", "img", ".", "createGraphics", "(", ")", ";", "g", ".", "setClip", "(", "rec", ")", ";", "view", ".", "paint", "(", "g", ",", "rec", ")", ";", "return", "g", ";", "}", "return", "null", ";", "}" ]
Renders current content to graphic context, which is returned. May return null; @return the Graphics2D context @see Graphics2D
[ "Renders", "current", "content", "to", "graphic", "context", "which", "is", "returned", ".", "May", "return", "null", ";" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/BrowserPane.java#L230-L256
8,663
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/BrowserPane.java
BrowserPane.renderContent
public Graphics2D renderContent(Graphics2D g) { if (g.getClip() == null) throw new NullPointerException( "Clip is not set on graphics context"); ViewFactory factory = getEditorKit().getViewFactory(); if (factory instanceof SwingBoxViewFactory) { View view = ((SwingBoxViewFactory) factory).getViewport(); if (view != null) view.paint(g, g.getClip()); } return g; }
java
public Graphics2D renderContent(Graphics2D g) { if (g.getClip() == null) throw new NullPointerException( "Clip is not set on graphics context"); ViewFactory factory = getEditorKit().getViewFactory(); if (factory instanceof SwingBoxViewFactory) { View view = ((SwingBoxViewFactory) factory).getViewport(); if (view != null) view.paint(g, g.getClip()); } return g; }
[ "public", "Graphics2D", "renderContent", "(", "Graphics2D", "g", ")", "{", "if", "(", "g", ".", "getClip", "(", ")", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Clip is not set on graphics context\"", ")", ";", "ViewFactory", "factory", "=", "getEditorKit", "(", ")", ".", "getViewFactory", "(", ")", ";", "if", "(", "factory", "instanceof", "SwingBoxViewFactory", ")", "{", "View", "view", "=", "(", "(", "SwingBoxViewFactory", ")", "factory", ")", ".", "getViewport", "(", ")", ";", "if", "(", "view", "!=", "null", ")", "view", ".", "paint", "(", "g", ",", "g", ".", "getClip", "(", ")", ")", ";", "}", "return", "g", ";", "}" ]
Renders current content to given graphic context, which is updated and returned. Context must have set the clip, otherwise NullPointerException is thrown. @param g the context to be rendered to. @return the Graphics2D context @see Graphics2D
[ "Renders", "current", "content", "to", "given", "graphic", "context", "which", "is", "updated", "and", "returned", ".", "Context", "must", "have", "set", "the", "clip", "otherwise", "NullPointerException", "is", "thrown", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/BrowserPane.java#L268-L282
8,664
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/BrowserPane.java
BrowserPane.setCSSBoxAnalyzer
public boolean setCSSBoxAnalyzer(CSSBoxAnalyzer cba) { EditorKit kit = getEditorKit(); if (kit instanceof SwingBoxEditorKit) { ((SwingBoxEditorKit) kit).setCSSBoxAnalyzer(cba); return true; } return false; }
java
public boolean setCSSBoxAnalyzer(CSSBoxAnalyzer cba) { EditorKit kit = getEditorKit(); if (kit instanceof SwingBoxEditorKit) { ((SwingBoxEditorKit) kit).setCSSBoxAnalyzer(cba); return true; } return false; }
[ "public", "boolean", "setCSSBoxAnalyzer", "(", "CSSBoxAnalyzer", "cba", ")", "{", "EditorKit", "kit", "=", "getEditorKit", "(", ")", ";", "if", "(", "kit", "instanceof", "SwingBoxEditorKit", ")", "{", "(", "(", "SwingBoxEditorKit", ")", "kit", ")", ".", "setCSSBoxAnalyzer", "(", "cba", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Sets the css box analyzer. @param cba the analyzer to be set @return true, if successful
[ "Sets", "the", "css", "box", "analyzer", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/BrowserPane.java#L307-L317
8,665
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/demo/SwingBrowser.java
SwingBrowser.getMainWindow
public JFrame getMainWindow() { if (mainWindow == null) { mainWindow = new JFrame(); mainWindow.setTitle("Swing Browser"); mainWindow.setVisible(true); mainWindow.setBounds(new Rectangle(0, 0, 583, 251)); mainWindow.setContentPane(getMainPanel()); mainWindow.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { mainWindow.setVisible(false); System.exit(0); } }); } return mainWindow; }
java
public JFrame getMainWindow() { if (mainWindow == null) { mainWindow = new JFrame(); mainWindow.setTitle("Swing Browser"); mainWindow.setVisible(true); mainWindow.setBounds(new Rectangle(0, 0, 583, 251)); mainWindow.setContentPane(getMainPanel()); mainWindow.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { mainWindow.setVisible(false); System.exit(0); } }); } return mainWindow; }
[ "public", "JFrame", "getMainWindow", "(", ")", "{", "if", "(", "mainWindow", "==", "null", ")", "{", "mainWindow", "=", "new", "JFrame", "(", ")", ";", "mainWindow", ".", "setTitle", "(", "\"Swing Browser\"", ")", ";", "mainWindow", ".", "setVisible", "(", "true", ")", ";", "mainWindow", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "583", ",", "251", ")", ")", ";", "mainWindow", ".", "setContentPane", "(", "getMainPanel", "(", ")", ")", ";", "mainWindow", ".", "addWindowListener", "(", "new", "java", ".", "awt", ".", "event", ".", "WindowAdapter", "(", ")", "{", "public", "void", "windowClosing", "(", "java", ".", "awt", ".", "event", ".", "WindowEvent", "e", ")", "{", "mainWindow", ".", "setVisible", "(", "false", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "}", ")", ";", "}", "return", "mainWindow", ";", "}" ]
This method initializes jFrame @return javax.swing.JFrame
[ "This", "method", "initializes", "jFrame" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/demo/SwingBrowser.java#L117-L136
8,666
wizzardo/tools
modules/tools-io/src/main/java/com/wizzardo/tools/io/BoyerMoore.java
BoyerMoore.makeCharTable
private static int[] makeCharTable(byte[] needle) { int[] table = new int[ALPHABET_SIZE]; int l = needle.length; for (int i = 0; i < ALPHABET_SIZE; ++i) { table[i] = l; } l--; for (int i = 0; i < l; ++i) { table[needle[i] & 0xff] = l - i; } return table; }
java
private static int[] makeCharTable(byte[] needle) { int[] table = new int[ALPHABET_SIZE]; int l = needle.length; for (int i = 0; i < ALPHABET_SIZE; ++i) { table[i] = l; } l--; for (int i = 0; i < l; ++i) { table[needle[i] & 0xff] = l - i; } return table; }
[ "private", "static", "int", "[", "]", "makeCharTable", "(", "byte", "[", "]", "needle", ")", "{", "int", "[", "]", "table", "=", "new", "int", "[", "ALPHABET_SIZE", "]", ";", "int", "l", "=", "needle", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ALPHABET_SIZE", ";", "++", "i", ")", "{", "table", "[", "i", "]", "=", "l", ";", "}", "l", "--", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "l", ";", "++", "i", ")", "{", "table", "[", "needle", "[", "i", "]", "&", "0xff", "]", "=", "l", "-", "i", ";", "}", "return", "table", ";", "}" ]
Makes the jump table based on the mismatched character information.
[ "Makes", "the", "jump", "table", "based", "on", "the", "mismatched", "character", "information", "." ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-io/src/main/java/com/wizzardo/tools/io/BoyerMoore.java#L60-L72
8,667
wizzardo/tools
modules/tools-io/src/main/java/com/wizzardo/tools/io/BoyerMoore.java
BoyerMoore.makeOffsetTable
private static int[] makeOffsetTable(byte[] needle) { int l = needle.length; int[] table = new int[l]; int lastPrefixPosition = l; for (int i = l - 1; i >= 0; --i) { if (isPrefix(needle, i + 1)) { lastPrefixPosition = i + 1; } table[l - 1 - i] = lastPrefixPosition - i + l - 1; } for (int i = 0; i < l - 1; ++i) { int slen = suffixLength(needle, i); table[slen] = l - 1 - i + slen; } return table; }
java
private static int[] makeOffsetTable(byte[] needle) { int l = needle.length; int[] table = new int[l]; int lastPrefixPosition = l; for (int i = l - 1; i >= 0; --i) { if (isPrefix(needle, i + 1)) { lastPrefixPosition = i + 1; } table[l - 1 - i] = lastPrefixPosition - i + l - 1; } for (int i = 0; i < l - 1; ++i) { int slen = suffixLength(needle, i); table[slen] = l - 1 - i + slen; } return table; }
[ "private", "static", "int", "[", "]", "makeOffsetTable", "(", "byte", "[", "]", "needle", ")", "{", "int", "l", "=", "needle", ".", "length", ";", "int", "[", "]", "table", "=", "new", "int", "[", "l", "]", ";", "int", "lastPrefixPosition", "=", "l", ";", "for", "(", "int", "i", "=", "l", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "if", "(", "isPrefix", "(", "needle", ",", "i", "+", "1", ")", ")", "{", "lastPrefixPosition", "=", "i", "+", "1", ";", "}", "table", "[", "l", "-", "1", "-", "i", "]", "=", "lastPrefixPosition", "-", "i", "+", "l", "-", "1", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "l", "-", "1", ";", "++", "i", ")", "{", "int", "slen", "=", "suffixLength", "(", "needle", ",", "i", ")", ";", "table", "[", "slen", "]", "=", "l", "-", "1", "-", "i", "+", "slen", ";", "}", "return", "table", ";", "}" ]
Makes the jump table based on the scan offset which mismatch occurs.
[ "Makes", "the", "jump", "table", "based", "on", "the", "scan", "offset", "which", "mismatch", "occurs", "." ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-io/src/main/java/com/wizzardo/tools/io/BoyerMoore.java#L77-L92
8,668
wizzardo/tools
modules/tools-io/src/main/java/com/wizzardo/tools/io/BoyerMoore.java
BoyerMoore.suffixLength
private static int suffixLength(byte[] needle, int p) { int len = 0; for (int i = p, j = needle.length - 1; i >= 0 && needle[i] == needle[j]; --i, --j) { len++; } return len; }
java
private static int suffixLength(byte[] needle, int p) { int len = 0; for (int i = p, j = needle.length - 1; i >= 0 && needle[i] == needle[j]; --i, --j) { len++; } return len; }
[ "private", "static", "int", "suffixLength", "(", "byte", "[", "]", "needle", ",", "int", "p", ")", "{", "int", "len", "=", "0", ";", "for", "(", "int", "i", "=", "p", ",", "j", "=", "needle", ".", "length", "-", "1", ";", "i", ">=", "0", "&&", "needle", "[", "i", "]", "==", "needle", "[", "j", "]", ";", "--", "i", ",", "--", "j", ")", "{", "len", "++", ";", "}", "return", "len", ";", "}" ]
Returns the maximum length of the substring ends at p and is a suffix.
[ "Returns", "the", "maximum", "length", "of", "the", "substring", "ends", "at", "p", "and", "is", "a", "suffix", "." ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-io/src/main/java/com/wizzardo/tools/io/BoyerMoore.java#L110-L116
8,669
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.processPaint
protected void processPaint(Graphics gg, Shape a) { Graphics2D g = (Graphics2D) gg; AffineTransform tmpTransform = g.getTransform(); if (!tmpTransform.equals(transform)) { transform = tmpTransform; invalidateTextLayout(); } Component c = container; int p0 = getStartOffset(); int p1 = getEndOffset(); Color fg = getForeground(); if (c instanceof JTextComponent) { JTextComponent tc = (JTextComponent) c; if (!tc.isEnabled()) { fg = tc.getDisabledTextColor(); } // javax.swing.plaf.basic.BasicTextUI $ BasicHighlighter // >> DefaultHighlighter // >> DefaultHighlightPainter Highlighter highLighter = tc.getHighlighter(); if (highLighter instanceof LayeredHighlighter) { ((LayeredHighlighter) highLighter).paintLayeredHighlights(g, p0, p1, box.getAbsoluteContentBounds(), tc, this); // (g, p0, p1, a, tc, this); } } // nothing is selected if (!box.isEmpty() && !getText().isEmpty()) renderContent(g, a, fg, p0, p1); }
java
protected void processPaint(Graphics gg, Shape a) { Graphics2D g = (Graphics2D) gg; AffineTransform tmpTransform = g.getTransform(); if (!tmpTransform.equals(transform)) { transform = tmpTransform; invalidateTextLayout(); } Component c = container; int p0 = getStartOffset(); int p1 = getEndOffset(); Color fg = getForeground(); if (c instanceof JTextComponent) { JTextComponent tc = (JTextComponent) c; if (!tc.isEnabled()) { fg = tc.getDisabledTextColor(); } // javax.swing.plaf.basic.BasicTextUI $ BasicHighlighter // >> DefaultHighlighter // >> DefaultHighlightPainter Highlighter highLighter = tc.getHighlighter(); if (highLighter instanceof LayeredHighlighter) { ((LayeredHighlighter) highLighter).paintLayeredHighlights(g, p0, p1, box.getAbsoluteContentBounds(), tc, this); // (g, p0, p1, a, tc, this); } } // nothing is selected if (!box.isEmpty() && !getText().isEmpty()) renderContent(g, a, fg, p0, p1); }
[ "protected", "void", "processPaint", "(", "Graphics", "gg", ",", "Shape", "a", ")", "{", "Graphics2D", "g", "=", "(", "Graphics2D", ")", "gg", ";", "AffineTransform", "tmpTransform", "=", "g", ".", "getTransform", "(", ")", ";", "if", "(", "!", "tmpTransform", ".", "equals", "(", "transform", ")", ")", "{", "transform", "=", "tmpTransform", ";", "invalidateTextLayout", "(", ")", ";", "}", "Component", "c", "=", "container", ";", "int", "p0", "=", "getStartOffset", "(", ")", ";", "int", "p1", "=", "getEndOffset", "(", ")", ";", "Color", "fg", "=", "getForeground", "(", ")", ";", "if", "(", "c", "instanceof", "JTextComponent", ")", "{", "JTextComponent", "tc", "=", "(", "JTextComponent", ")", "c", ";", "if", "(", "!", "tc", ".", "isEnabled", "(", ")", ")", "{", "fg", "=", "tc", ".", "getDisabledTextColor", "(", ")", ";", "}", "// javax.swing.plaf.basic.BasicTextUI $ BasicHighlighter", "// >> DefaultHighlighter", "// >> DefaultHighlightPainter", "Highlighter", "highLighter", "=", "tc", ".", "getHighlighter", "(", ")", ";", "if", "(", "highLighter", "instanceof", "LayeredHighlighter", ")", "{", "(", "(", "LayeredHighlighter", ")", "highLighter", ")", ".", "paintLayeredHighlights", "(", "g", ",", "p0", ",", "p1", ",", "box", ".", "getAbsoluteContentBounds", "(", ")", ",", "tc", ",", "this", ")", ";", "// (g, p0, p1, a, tc, this);", "}", "}", "// nothing is selected", "if", "(", "!", "box", ".", "isEmpty", "(", ")", "&&", "!", "getText", "(", ")", ".", "isEmpty", "(", ")", ")", "renderContent", "(", "g", ",", "a", ",", "fg", ",", "p0", ",", "p1", ")", ";", "}" ]
Process paint. @param gg the graphics context @param a the allocation
[ "Process", "paint", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L359-L397
8,670
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.renderContent
protected void renderContent(Graphics2D g, Shape a, Color fg, int p0, int p1) { TextLayout layout = getTextLayout(); Rectangle absoluteBounds = box.getAbsoluteBounds(); Rectangle absoluteContentBounds = box.getAbsoluteContentBounds(); int pStart = getStartOffset(); int pEnd = getEndOffset(); int x = absoluteBounds.x; int y = absoluteBounds.y; Shape oldclip = g.getClip(); BlockBox clipblock = box.getClipBlock(); if (clipblock != null) { Rectangle newclip = clipblock.getClippedContentBounds(); Rectangle clip = toRect(oldclip).intersection(newclip); g.setClip(clip); } g.setFont(getFont()); g.setColor(fg); // -- Draw the string at specified positions -- if (p0 > pStart || p1 < pEnd) { try { // TextLayout can't render only part of it's range, so if a // partial range is required, add a clip region. Shape s = modelToView(p0, Position.Bias.Forward, p1, Position.Bias.Backward, a); absoluteContentBounds = absoluteContentBounds.intersection(toRect(s)); } catch (BadLocationException ignored) { } } // render the text layout.draw(g, x, y + layout.getAscent()); //render the decoration if (underline || strike || overline) { Stroke origStroke = g.getStroke(); int w; if (getFont().isBold()) w = getFont().getSize() / 8; else w = getFont().getSize() / 10; if (w < 1) w = 1; y += w / 2; g.setStroke(new BasicStroke(w)); int xx = absoluteContentBounds.x + absoluteContentBounds.width; if (overline) { g.drawLine(absoluteContentBounds.x, y, xx, y); } if (underline) { int yy = y + absoluteContentBounds.height - (int) layout.getDescent(); g.drawLine(absoluteContentBounds.x, yy, xx, yy); } if (strike) { int yy = y + absoluteContentBounds.height / 2; g.drawLine(absoluteContentBounds.x, yy, xx, yy); } g.setStroke(origStroke); } g.setClip(oldclip); }
java
protected void renderContent(Graphics2D g, Shape a, Color fg, int p0, int p1) { TextLayout layout = getTextLayout(); Rectangle absoluteBounds = box.getAbsoluteBounds(); Rectangle absoluteContentBounds = box.getAbsoluteContentBounds(); int pStart = getStartOffset(); int pEnd = getEndOffset(); int x = absoluteBounds.x; int y = absoluteBounds.y; Shape oldclip = g.getClip(); BlockBox clipblock = box.getClipBlock(); if (clipblock != null) { Rectangle newclip = clipblock.getClippedContentBounds(); Rectangle clip = toRect(oldclip).intersection(newclip); g.setClip(clip); } g.setFont(getFont()); g.setColor(fg); // -- Draw the string at specified positions -- if (p0 > pStart || p1 < pEnd) { try { // TextLayout can't render only part of it's range, so if a // partial range is required, add a clip region. Shape s = modelToView(p0, Position.Bias.Forward, p1, Position.Bias.Backward, a); absoluteContentBounds = absoluteContentBounds.intersection(toRect(s)); } catch (BadLocationException ignored) { } } // render the text layout.draw(g, x, y + layout.getAscent()); //render the decoration if (underline || strike || overline) { Stroke origStroke = g.getStroke(); int w; if (getFont().isBold()) w = getFont().getSize() / 8; else w = getFont().getSize() / 10; if (w < 1) w = 1; y += w / 2; g.setStroke(new BasicStroke(w)); int xx = absoluteContentBounds.x + absoluteContentBounds.width; if (overline) { g.drawLine(absoluteContentBounds.x, y, xx, y); } if (underline) { int yy = y + absoluteContentBounds.height - (int) layout.getDescent(); g.drawLine(absoluteContentBounds.x, yy, xx, yy); } if (strike) { int yy = y + absoluteContentBounds.height / 2; g.drawLine(absoluteContentBounds.x, yy, xx, yy); } g.setStroke(origStroke); } g.setClip(oldclip); }
[ "protected", "void", "renderContent", "(", "Graphics2D", "g", ",", "Shape", "a", ",", "Color", "fg", ",", "int", "p0", ",", "int", "p1", ")", "{", "TextLayout", "layout", "=", "getTextLayout", "(", ")", ";", "Rectangle", "absoluteBounds", "=", "box", ".", "getAbsoluteBounds", "(", ")", ";", "Rectangle", "absoluteContentBounds", "=", "box", ".", "getAbsoluteContentBounds", "(", ")", ";", "int", "pStart", "=", "getStartOffset", "(", ")", ";", "int", "pEnd", "=", "getEndOffset", "(", ")", ";", "int", "x", "=", "absoluteBounds", ".", "x", ";", "int", "y", "=", "absoluteBounds", ".", "y", ";", "Shape", "oldclip", "=", "g", ".", "getClip", "(", ")", ";", "BlockBox", "clipblock", "=", "box", ".", "getClipBlock", "(", ")", ";", "if", "(", "clipblock", "!=", "null", ")", "{", "Rectangle", "newclip", "=", "clipblock", ".", "getClippedContentBounds", "(", ")", ";", "Rectangle", "clip", "=", "toRect", "(", "oldclip", ")", ".", "intersection", "(", "newclip", ")", ";", "g", ".", "setClip", "(", "clip", ")", ";", "}", "g", ".", "setFont", "(", "getFont", "(", ")", ")", ";", "g", ".", "setColor", "(", "fg", ")", ";", "// -- Draw the string at specified positions --", "if", "(", "p0", ">", "pStart", "||", "p1", "<", "pEnd", ")", "{", "try", "{", "// TextLayout can't render only part of it's range, so if a", "// partial range is required, add a clip region.", "Shape", "s", "=", "modelToView", "(", "p0", ",", "Position", ".", "Bias", ".", "Forward", ",", "p1", ",", "Position", ".", "Bias", ".", "Backward", ",", "a", ")", ";", "absoluteContentBounds", "=", "absoluteContentBounds", ".", "intersection", "(", "toRect", "(", "s", ")", ")", ";", "}", "catch", "(", "BadLocationException", "ignored", ")", "{", "}", "}", "// render the text", "layout", ".", "draw", "(", "g", ",", "x", ",", "y", "+", "layout", ".", "getAscent", "(", ")", ")", ";", "//render the decoration", "if", "(", "underline", "||", "strike", "||", "overline", ")", "{", "Stroke", "origStroke", "=", "g", ".", "getStroke", "(", ")", ";", "int", "w", ";", "if", "(", "getFont", "(", ")", ".", "isBold", "(", ")", ")", "w", "=", "getFont", "(", ")", ".", "getSize", "(", ")", "/", "8", ";", "else", "w", "=", "getFont", "(", ")", ".", "getSize", "(", ")", "/", "10", ";", "if", "(", "w", "<", "1", ")", "w", "=", "1", ";", "y", "+=", "w", "/", "2", ";", "g", ".", "setStroke", "(", "new", "BasicStroke", "(", "w", ")", ")", ";", "int", "xx", "=", "absoluteContentBounds", ".", "x", "+", "absoluteContentBounds", ".", "width", ";", "if", "(", "overline", ")", "{", "g", ".", "drawLine", "(", "absoluteContentBounds", ".", "x", ",", "y", ",", "xx", ",", "y", ")", ";", "}", "if", "(", "underline", ")", "{", "int", "yy", "=", "y", "+", "absoluteContentBounds", ".", "height", "-", "(", "int", ")", "layout", ".", "getDescent", "(", ")", ";", "g", ".", "drawLine", "(", "absoluteContentBounds", ".", "x", ",", "yy", ",", "xx", ",", "yy", ")", ";", "}", "if", "(", "strike", ")", "{", "int", "yy", "=", "y", "+", "absoluteContentBounds", ".", "height", "/", "2", ";", "g", ".", "drawLine", "(", "absoluteContentBounds", ".", "x", ",", "yy", ",", "xx", ",", "yy", ")", ";", "}", "g", ".", "setStroke", "(", "origStroke", ")", ";", "}", "g", ".", "setClip", "(", "oldclip", ")", ";", "}" ]
Renders content. @param g the graphics @param a the allocation @param fg the color of foreground @param p0 start position @param p1 end position
[ "Renders", "content", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L413-L489
8,671
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.repaint
protected void repaint(final int ms, final Rectangle bounds) { if (container != null) { container.repaint(ms, bounds.x, bounds.y, bounds.width, bounds.height); } }
java
protected void repaint(final int ms, final Rectangle bounds) { if (container != null) { container.repaint(ms, bounds.x, bounds.y, bounds.width, bounds.height); } }
[ "protected", "void", "repaint", "(", "final", "int", "ms", ",", "final", "Rectangle", "bounds", ")", "{", "if", "(", "container", "!=", "null", ")", "{", "container", ".", "repaint", "(", "ms", ",", "bounds", ".", "x", ",", "bounds", ".", "y", ",", "bounds", ".", "width", ",", "bounds", ".", "height", ")", ";", "}", "}" ]
Repaints the content, used by blink decoration. @param ms time - the upper bound of delay @param bounds the bounds
[ "Repaints", "the", "content", "used", "by", "blink", "decoration", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L499-L505
8,672
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.getStringBounds
protected Rectangle2D getStringBounds(TextLayout tl) { return new Rectangle2D.Float(0, -tl.getAscent(), tl.getAdvance(), tl.getAscent() + tl.getDescent() + tl.getLeading()); }
java
protected Rectangle2D getStringBounds(TextLayout tl) { return new Rectangle2D.Float(0, -tl.getAscent(), tl.getAdvance(), tl.getAscent() + tl.getDescent() + tl.getLeading()); }
[ "protected", "Rectangle2D", "getStringBounds", "(", "TextLayout", "tl", ")", "{", "return", "new", "Rectangle2D", ".", "Float", "(", "0", ",", "-", "tl", ".", "getAscent", "(", ")", ",", "tl", ".", "getAdvance", "(", ")", ",", "tl", ".", "getAscent", "(", ")", "+", "tl", ".", "getDescent", "(", ")", "+", "tl", ".", "getLeading", "(", ")", ")", ";", "}" ]
Gets the string bounds. @param tl textlayout instance @return the string bounds
[ "Gets", "the", "string", "bounds", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L516-L520
8,673
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.getTextEx
protected String getTextEx(int position, int len) { try { return getDocument().getText(position, len); } catch (BadLocationException e) { e.printStackTrace(); return ""; } }
java
protected String getTextEx(int position, int len) { try { return getDocument().getText(position, len); } catch (BadLocationException e) { e.printStackTrace(); return ""; } }
[ "protected", "String", "getTextEx", "(", "int", "position", ",", "int", "len", ")", "{", "try", "{", "return", "getDocument", "(", ")", ".", "getText", "(", "position", ",", "len", ")", ";", "}", "catch", "(", "BadLocationException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "\"\"", ";", "}", "}" ]
Gets the text. @param position the position, where to begin @param len the length of text portion @return the text
[ "Gets", "the", "text", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L555-L563
8,674
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.setPropertiesFromAttributes
protected void setPropertiesFromAttributes(AttributeSet attr) { if (attr != null) { Font newFont = (Font) attr.getAttribute(Constants.ATTRIBUTE_FONT); if (newFont != null) { setFont(newFont); } else { // the font is the most important for us throw new IllegalStateException("Font can not be null !"); } setForeground((Color) attr.getAttribute(Constants.ATTRIBUTE_FOREGROUND)); setFontVariant((String) attr.getAttribute(Constants.ATTRIBUTE_FONT_VARIANT)); @SuppressWarnings("unchecked") List<TextDecoration> attribute = (List<TextDecoration>) attr.getAttribute(Constants.ATTRIBUTE_TEXT_DECORATION); setTextDecoration(attribute); } }
java
protected void setPropertiesFromAttributes(AttributeSet attr) { if (attr != null) { Font newFont = (Font) attr.getAttribute(Constants.ATTRIBUTE_FONT); if (newFont != null) { setFont(newFont); } else { // the font is the most important for us throw new IllegalStateException("Font can not be null !"); } setForeground((Color) attr.getAttribute(Constants.ATTRIBUTE_FOREGROUND)); setFontVariant((String) attr.getAttribute(Constants.ATTRIBUTE_FONT_VARIANT)); @SuppressWarnings("unchecked") List<TextDecoration> attribute = (List<TextDecoration>) attr.getAttribute(Constants.ATTRIBUTE_TEXT_DECORATION); setTextDecoration(attribute); } }
[ "protected", "void", "setPropertiesFromAttributes", "(", "AttributeSet", "attr", ")", "{", "if", "(", "attr", "!=", "null", ")", "{", "Font", "newFont", "=", "(", "Font", ")", "attr", ".", "getAttribute", "(", "Constants", ".", "ATTRIBUTE_FONT", ")", ";", "if", "(", "newFont", "!=", "null", ")", "{", "setFont", "(", "newFont", ")", ";", "}", "else", "{", "// the font is the most important for us", "throw", "new", "IllegalStateException", "(", "\"Font can not be null !\"", ")", ";", "}", "setForeground", "(", "(", "Color", ")", "attr", ".", "getAttribute", "(", "Constants", ".", "ATTRIBUTE_FOREGROUND", ")", ")", ";", "setFontVariant", "(", "(", "String", ")", "attr", ".", "getAttribute", "(", "Constants", ".", "ATTRIBUTE_FONT_VARIANT", ")", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "TextDecoration", ">", "attribute", "=", "(", "List", "<", "TextDecoration", ">", ")", "attr", ".", "getAttribute", "(", "Constants", ".", "ATTRIBUTE_TEXT_DECORATION", ")", ";", "setTextDecoration", "(", "attribute", ")", ";", "}", "}" ]
Sets the properties from the attributes. @param attr the new properties from attributes
[ "Sets", "the", "properties", "from", "the", "attributes", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L571-L593
8,675
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.setFont
protected void setFont(Font newFont) { if (font == null || !font.equals(newFont)) { font = new Font(newFont.getAttributes()); invalidateCache(); invalidateTextLayout(); } }
java
protected void setFont(Font newFont) { if (font == null || !font.equals(newFont)) { font = new Font(newFont.getAttributes()); invalidateCache(); invalidateTextLayout(); } }
[ "protected", "void", "setFont", "(", "Font", "newFont", ")", "{", "if", "(", "font", "==", "null", "||", "!", "font", ".", "equals", "(", "newFont", ")", ")", "{", "font", "=", "new", "Font", "(", "newFont", ".", "getAttributes", "(", ")", ")", ";", "invalidateCache", "(", ")", ";", "invalidateTextLayout", "(", ")", ";", "}", "}" ]
Sets the font. @param newFont the new font
[ "Sets", "the", "font", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L641-L649
8,676
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.setForeground
protected void setForeground(Color newColor) { if (foreground == null || !foreground.equals(newColor)) { foreground = new Color(newColor.getRGB()); invalidateCache(); } }
java
protected void setForeground(Color newColor) { if (foreground == null || !foreground.equals(newColor)) { foreground = new Color(newColor.getRGB()); invalidateCache(); } }
[ "protected", "void", "setForeground", "(", "Color", "newColor", ")", "{", "if", "(", "foreground", "==", "null", "||", "!", "foreground", ".", "equals", "(", "newColor", ")", ")", "{", "foreground", "=", "new", "Color", "(", "newColor", ".", "getRGB", "(", ")", ")", ";", "invalidateCache", "(", ")", ";", "}", "}" ]
Sets the foreground. @param newColor the new foreground
[ "Sets", "the", "foreground", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L657-L664
8,677
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.setFontVariant
protected void setFontVariant(String newFontVariant) { if (fontVariant == null || !fontVariant.equals(newFontVariant)) { FontVariant val[] = FontVariant.values(); for (FontVariant aVal : val) { if (aVal.toString().equals(newFontVariant)) { fontVariant = newFontVariant; invalidateCache(); return; } } } }
java
protected void setFontVariant(String newFontVariant) { if (fontVariant == null || !fontVariant.equals(newFontVariant)) { FontVariant val[] = FontVariant.values(); for (FontVariant aVal : val) { if (aVal.toString().equals(newFontVariant)) { fontVariant = newFontVariant; invalidateCache(); return; } } } }
[ "protected", "void", "setFontVariant", "(", "String", "newFontVariant", ")", "{", "if", "(", "fontVariant", "==", "null", "||", "!", "fontVariant", ".", "equals", "(", "newFontVariant", ")", ")", "{", "FontVariant", "val", "[", "]", "=", "FontVariant", ".", "values", "(", ")", ";", "for", "(", "FontVariant", "aVal", ":", "val", ")", "{", "if", "(", "aVal", ".", "toString", "(", ")", ".", "equals", "(", "newFontVariant", ")", ")", "{", "fontVariant", "=", "newFontVariant", ";", "invalidateCache", "(", ")", ";", "return", ";", "}", "}", "}", "}" ]
Sets the font variant. @param newFontVariant the new font variant
[ "Sets", "the", "font", "variant", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L683-L700
8,678
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.setTextDecoration
protected void setTextDecoration(List<TextDecoration> newTextDecoration) { if (textDecoration == null || !textDecoration.equals(newTextDecoration)) { textDecoration = newTextDecoration; reflectTextDecoration(textDecoration); invalidateCache(); } }
java
protected void setTextDecoration(List<TextDecoration> newTextDecoration) { if (textDecoration == null || !textDecoration.equals(newTextDecoration)) { textDecoration = newTextDecoration; reflectTextDecoration(textDecoration); invalidateCache(); } }
[ "protected", "void", "setTextDecoration", "(", "List", "<", "TextDecoration", ">", "newTextDecoration", ")", "{", "if", "(", "textDecoration", "==", "null", "||", "!", "textDecoration", ".", "equals", "(", "newTextDecoration", ")", ")", "{", "textDecoration", "=", "newTextDecoration", ";", "reflectTextDecoration", "(", "textDecoration", ")", ";", "invalidateCache", "(", ")", ";", "}", "}" ]
Sets the text decoration. @param newTextDecoration the new text decoration
[ "Sets", "the", "text", "decoration", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L708-L717
8,679
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java
TextBoxView.getTextLayout
protected TextLayout getTextLayout() { if (refreshTextLayout) { refreshTextLayout = false; layout = new TextLayout(getText(), getFont(), new FontRenderContext(transform, true, false)); } return layout; }
java
protected TextLayout getTextLayout() { if (refreshTextLayout) { refreshTextLayout = false; layout = new TextLayout(getText(), getFont(), new FontRenderContext(transform, true, false)); } return layout; }
[ "protected", "TextLayout", "getTextLayout", "(", ")", "{", "if", "(", "refreshTextLayout", ")", "{", "refreshTextLayout", "=", "false", ";", "layout", "=", "new", "TextLayout", "(", "getText", "(", ")", ",", "getFont", "(", ")", ",", "new", "FontRenderContext", "(", "transform", ",", "true", ",", "false", ")", ")", ";", "}", "return", "layout", ";", "}" ]
Gets the text layout. @return the text layout
[ "Gets", "the", "text", "layout", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/TextBoxView.java#L747-L756
8,680
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/SwingBoxEditorKit.java
SwingBoxEditorKit.update
public void update(SwingBoxDocument doc, Viewport root, Dimension dim) throws IOException { ContentReader rdr = new ContentReader(); List<ElementSpec> elements = rdr.update(root, dim, getCSSBoxAnalyzer()); ElementSpec elementsArray[] = elements.toArray(new ElementSpec[0]); doc.create(elementsArray); }
java
public void update(SwingBoxDocument doc, Viewport root, Dimension dim) throws IOException { ContentReader rdr = new ContentReader(); List<ElementSpec> elements = rdr.update(root, dim, getCSSBoxAnalyzer()); ElementSpec elementsArray[] = elements.toArray(new ElementSpec[0]); doc.create(elementsArray); }
[ "public", "void", "update", "(", "SwingBoxDocument", "doc", ",", "Viewport", "root", ",", "Dimension", "dim", ")", "throws", "IOException", "{", "ContentReader", "rdr", "=", "new", "ContentReader", "(", ")", ";", "List", "<", "ElementSpec", ">", "elements", "=", "rdr", ".", "update", "(", "root", ",", "dim", ",", "getCSSBoxAnalyzer", "(", ")", ")", ";", "ElementSpec", "elementsArray", "[", "]", "=", "elements", ".", "toArray", "(", "new", "ElementSpec", "[", "0", "]", ")", ";", "doc", ".", "create", "(", "elementsArray", ")", ";", "}" ]
Updates layout, using new dimensions. @param doc the document @param root the root box @param dim new dimension @throws IOException Signals that an I/O exception has occurred.
[ "Updates", "layout", "using", "new", "dimensions", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/SwingBoxEditorKit.java#L270-L277
8,681
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/util/DefaultHyperlinkHandler.java
DefaultHyperlinkHandler.loadPage
protected void loadPage(JEditorPane pane, HyperlinkEvent evt) { // if some security, or other interaction is needed, override this // method try { pane.setPage(evt.getURL()); } catch (IOException e) { System.err.println(e.getLocalizedMessage()); } }
java
protected void loadPage(JEditorPane pane, HyperlinkEvent evt) { // if some security, or other interaction is needed, override this // method try { pane.setPage(evt.getURL()); } catch (IOException e) { System.err.println(e.getLocalizedMessage()); } }
[ "protected", "void", "loadPage", "(", "JEditorPane", "pane", ",", "HyperlinkEvent", "evt", ")", "{", "// if some security, or other interaction is needed, override this", "// method", "try", "{", "pane", ".", "setPage", "(", "evt", ".", "getURL", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "System", ".", "err", ".", "println", "(", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "}" ]
Loads given page as HyperlinkEvent. @param pane the pane @param evt the event
[ "Loads", "given", "page", "as", "HyperlinkEvent", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/util/DefaultHyperlinkHandler.java#L67-L78
8,682
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/util/ContentReader.java
ContentReader.read
public List<ElementSpec> read(DocumentSource docSource, CSSBoxAnalyzer cba, Dimension dim) throws IOException { // ale ked sa pouzije setText() neviem nic o url, nic sa nenastavuje , // moze byt null // (URL) doc.getProperty(Document.StreamDescriptionProperty) if (cba == null) throw new IllegalArgumentException("CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object..."); elements = new Vector<ElementSpec>();// ArrayList<ElementSpec>(1024); elements.add(new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.EndTagType)); order = 0; // System.err.print("used Reader and encoding ? " + // is.getCharacterStream() + " , "); // InputStreamReader r = (InputStreamReader)is.getCharacterStream(); // System.err.println(r.getEncoding()); Viewport vp; try { // System.err.println("analyzing..."); vp = cba.analyze(docSource, dim); // System.err.println("analyzing finished..."); } catch (Exception e) { throw new IOException(e); } //Use this for "drawing" the boxes. This constructs the element list. vp.draw(this); // System.err.println("num. of elements : " + elements.size()); // System.err.println("Root min width : " + root.getMinimalWidth() + // " ,normal width : " + root.getWidth() + " ,maximal width : " + // root.getMaximalWidth()); // TODO po skonceni nacitavania aj nejake info spravit // >> Document.TitleProperty - observer, metainfo return elements; }
java
public List<ElementSpec> read(DocumentSource docSource, CSSBoxAnalyzer cba, Dimension dim) throws IOException { // ale ked sa pouzije setText() neviem nic o url, nic sa nenastavuje , // moze byt null // (URL) doc.getProperty(Document.StreamDescriptionProperty) if (cba == null) throw new IllegalArgumentException("CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object..."); elements = new Vector<ElementSpec>();// ArrayList<ElementSpec>(1024); elements.add(new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.EndTagType)); order = 0; // System.err.print("used Reader and encoding ? " + // is.getCharacterStream() + " , "); // InputStreamReader r = (InputStreamReader)is.getCharacterStream(); // System.err.println(r.getEncoding()); Viewport vp; try { // System.err.println("analyzing..."); vp = cba.analyze(docSource, dim); // System.err.println("analyzing finished..."); } catch (Exception e) { throw new IOException(e); } //Use this for "drawing" the boxes. This constructs the element list. vp.draw(this); // System.err.println("num. of elements : " + elements.size()); // System.err.println("Root min width : " + root.getMinimalWidth() + // " ,normal width : " + root.getWidth() + " ,maximal width : " + // root.getMaximalWidth()); // TODO po skonceni nacitavania aj nejake info spravit // >> Document.TitleProperty - observer, metainfo return elements; }
[ "public", "List", "<", "ElementSpec", ">", "read", "(", "DocumentSource", "docSource", ",", "CSSBoxAnalyzer", "cba", ",", "Dimension", "dim", ")", "throws", "IOException", "{", "// ale ked sa pouzije setText() neviem nic o url, nic sa nenastavuje ,", "// moze byt null", "// (URL) doc.getProperty(Document.StreamDescriptionProperty)", "if", "(", "cba", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"CSSBoxAnalyzer can not be NULL !!!\\nProvide your custom implementation or check instantiation of DefaultAnalyzer object...\"", ")", ";", "elements", "=", "new", "Vector", "<", "ElementSpec", ">", "(", ")", ";", "// ArrayList<ElementSpec>(1024);", "elements", ".", "add", "(", "new", "ElementSpec", "(", "SimpleAttributeSet", ".", "EMPTY", ",", "ElementSpec", ".", "EndTagType", ")", ")", ";", "order", "=", "0", ";", "// System.err.print(\"used Reader and encoding ? \" +", "// is.getCharacterStream() + \" , \");", "// InputStreamReader r = (InputStreamReader)is.getCharacterStream();", "// System.err.println(r.getEncoding());", "Viewport", "vp", ";", "try", "{", "// System.err.println(\"analyzing...\");", "vp", "=", "cba", ".", "analyze", "(", "docSource", ",", "dim", ")", ";", "// System.err.println(\"analyzing finished...\");", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "//Use this for \"drawing\" the boxes. This constructs the element list.", "vp", ".", "draw", "(", "this", ")", ";", "// System.err.println(\"num. of elements : \" + elements.size());", "// System.err.println(\"Root min width : \" + root.getMinimalWidth() +", "// \" ,normal width : \" + root.getWidth() + \" ,maximal width : \" +", "// root.getMaximalWidth());", "// TODO po skonceni nacitavania aj nejake info spravit", "// >> Document.TitleProperty - observer, metainfo", "return", "elements", ";", "}" ]
Reads input data and converts them to "elements" @param docSource the document source @param cba the instance of {@link CSSBoxAnalyzer} @param dim the dimension @return the list of elements. Note that, this method returns instance of LinkedList. @throws IOException Signals that an I/O exception has occurred.
[ "Reads", "input", "data", "and", "converts", "them", "to", "elements" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/util/ContentReader.java#L89-L130
8,683
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/util/ContentReader.java
ContentReader.update
public List<ElementSpec> update(Viewport root, Dimension newDimension, CSSBoxAnalyzer cba) throws IOException { if (cba == null) throw new IllegalArgumentException("CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object..."); elements = new LinkedList<ElementSpec>(); elements.add(new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.EndTagType)); order = 0; Viewport vp; try { vp = cba.update(newDimension); } catch (Exception e) { throw new IOException(e); } vp.draw(this); return elements; }
java
public List<ElementSpec> update(Viewport root, Dimension newDimension, CSSBoxAnalyzer cba) throws IOException { if (cba == null) throw new IllegalArgumentException("CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object..."); elements = new LinkedList<ElementSpec>(); elements.add(new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.EndTagType)); order = 0; Viewport vp; try { vp = cba.update(newDimension); } catch (Exception e) { throw new IOException(e); } vp.draw(this); return elements; }
[ "public", "List", "<", "ElementSpec", ">", "update", "(", "Viewport", "root", ",", "Dimension", "newDimension", ",", "CSSBoxAnalyzer", "cba", ")", "throws", "IOException", "{", "if", "(", "cba", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"CSSBoxAnalyzer can not be NULL !!!\\nProvide your custom implementation or check instantiation of DefaultAnalyzer object...\"", ")", ";", "elements", "=", "new", "LinkedList", "<", "ElementSpec", ">", "(", ")", ";", "elements", ".", "add", "(", "new", "ElementSpec", "(", "SimpleAttributeSet", ".", "EMPTY", ",", "ElementSpec", ".", "EndTagType", ")", ")", ";", "order", "=", "0", ";", "Viewport", "vp", ";", "try", "{", "vp", "=", "cba", ".", "update", "(", "newDimension", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "vp", ".", "draw", "(", "this", ")", ";", "return", "elements", ";", "}" ]
Updates the layout. It is designed to do a re-layout only, not to process input data again. @param root the root @param newDimension the new dimension @param cba the CSSBoxAnalyzer @return the list @throws IOException Signals that an I/O exception has occurred.
[ "Updates", "the", "layout", ".", "It", "is", "designed", "to", "do", "a", "re", "-", "layout", "only", "not", "to", "process", "input", "data", "again", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/util/ContentReader.java#L146-L167
8,684
wizzardo/tools
modules/tools-image/src/main/java/com/wizzardo/tools/image/JpegEncoder.java
Huffman.HuffmanBlockEncoder
void HuffmanBlockEncoder(BufferedOutputStream outStream, int zigzag[], int prec, int DCcode, int ACcode) throws IOException { int temp, temp2, nbits, k, r, i; // The DC portion temp = temp2 = zigzag[0] - prec; if (temp < 0) { temp = -temp; temp2--; } nbits = 0; while (temp != 0) { nbits++; temp >>= 1; } // if (nbits > 11) nbits = 11; bufferIt(outStream, (DC_matrix[DCcode])[nbits][0], (DC_matrix[DCcode])[nbits][1]); // The arguments in bufferIt are code and size. if (nbits != 0) { bufferIt(outStream, temp2, nbits); } // The AC portion r = 0; for (k = 1; k < 64; k++) { if ((temp = zigzag[jpegNaturalOrder[k]]) == 0) { r++; } else { while (r > 15) { bufferIt(outStream, (AC_matrix[ACcode])[0xF0][0], (AC_matrix[ACcode])[0xF0][1]); r -= 16; } temp2 = temp; if (temp < 0) { temp = -temp; temp2--; } nbits = 1; while ((temp >>= 1) != 0) { nbits++; } i = (r << 4) + nbits; bufferIt(outStream, (AC_matrix[ACcode])[i][0], (AC_matrix[ACcode])[i][1]); bufferIt(outStream, temp2, nbits); r = 0; } } if (r > 0) { bufferIt(outStream, (AC_matrix[ACcode])[0][0], (AC_matrix[ACcode])[0][1]); } }
java
void HuffmanBlockEncoder(BufferedOutputStream outStream, int zigzag[], int prec, int DCcode, int ACcode) throws IOException { int temp, temp2, nbits, k, r, i; // The DC portion temp = temp2 = zigzag[0] - prec; if (temp < 0) { temp = -temp; temp2--; } nbits = 0; while (temp != 0) { nbits++; temp >>= 1; } // if (nbits > 11) nbits = 11; bufferIt(outStream, (DC_matrix[DCcode])[nbits][0], (DC_matrix[DCcode])[nbits][1]); // The arguments in bufferIt are code and size. if (nbits != 0) { bufferIt(outStream, temp2, nbits); } // The AC portion r = 0; for (k = 1; k < 64; k++) { if ((temp = zigzag[jpegNaturalOrder[k]]) == 0) { r++; } else { while (r > 15) { bufferIt(outStream, (AC_matrix[ACcode])[0xF0][0], (AC_matrix[ACcode])[0xF0][1]); r -= 16; } temp2 = temp; if (temp < 0) { temp = -temp; temp2--; } nbits = 1; while ((temp >>= 1) != 0) { nbits++; } i = (r << 4) + nbits; bufferIt(outStream, (AC_matrix[ACcode])[i][0], (AC_matrix[ACcode])[i][1]); bufferIt(outStream, temp2, nbits); r = 0; } } if (r > 0) { bufferIt(outStream, (AC_matrix[ACcode])[0][0], (AC_matrix[ACcode])[0][1]); } }
[ "void", "HuffmanBlockEncoder", "(", "BufferedOutputStream", "outStream", ",", "int", "zigzag", "[", "]", ",", "int", "prec", ",", "int", "DCcode", ",", "int", "ACcode", ")", "throws", "IOException", "{", "int", "temp", ",", "temp2", ",", "nbits", ",", "k", ",", "r", ",", "i", ";", "// The DC portion", "temp", "=", "temp2", "=", "zigzag", "[", "0", "]", "-", "prec", ";", "if", "(", "temp", "<", "0", ")", "{", "temp", "=", "-", "temp", ";", "temp2", "--", ";", "}", "nbits", "=", "0", ";", "while", "(", "temp", "!=", "0", ")", "{", "nbits", "++", ";", "temp", ">>=", "1", ";", "}", "// if (nbits > 11) nbits = 11;", "bufferIt", "(", "outStream", ",", "(", "DC_matrix", "[", "DCcode", "]", ")", "[", "nbits", "]", "[", "0", "]", ",", "(", "DC_matrix", "[", "DCcode", "]", ")", "[", "nbits", "]", "[", "1", "]", ")", ";", "// The arguments in bufferIt are code and size.", "if", "(", "nbits", "!=", "0", ")", "{", "bufferIt", "(", "outStream", ",", "temp2", ",", "nbits", ")", ";", "}", "// The AC portion", "r", "=", "0", ";", "for", "(", "k", "=", "1", ";", "k", "<", "64", ";", "k", "++", ")", "{", "if", "(", "(", "temp", "=", "zigzag", "[", "jpegNaturalOrder", "[", "k", "]", "]", ")", "==", "0", ")", "{", "r", "++", ";", "}", "else", "{", "while", "(", "r", ">", "15", ")", "{", "bufferIt", "(", "outStream", ",", "(", "AC_matrix", "[", "ACcode", "]", ")", "[", "0xF0", "]", "[", "0", "]", ",", "(", "AC_matrix", "[", "ACcode", "]", ")", "[", "0xF0", "]", "[", "1", "]", ")", ";", "r", "-=", "16", ";", "}", "temp2", "=", "temp", ";", "if", "(", "temp", "<", "0", ")", "{", "temp", "=", "-", "temp", ";", "temp2", "--", ";", "}", "nbits", "=", "1", ";", "while", "(", "(", "temp", ">>=", "1", ")", "!=", "0", ")", "{", "nbits", "++", ";", "}", "i", "=", "(", "r", "<<", "4", ")", "+", "nbits", ";", "bufferIt", "(", "outStream", ",", "(", "AC_matrix", "[", "ACcode", "]", ")", "[", "i", "]", "[", "0", "]", ",", "(", "AC_matrix", "[", "ACcode", "]", ")", "[", "i", "]", "[", "1", "]", ")", ";", "bufferIt", "(", "outStream", ",", "temp2", ",", "nbits", ")", ";", "r", "=", "0", ";", "}", "}", "if", "(", "r", ">", "0", ")", "{", "bufferIt", "(", "outStream", ",", "(", "AC_matrix", "[", "ACcode", "]", ")", "[", "0", "]", "[", "0", "]", ",", "(", "AC_matrix", "[", "ACcode", "]", ")", "[", "0", "]", "[", "1", "]", ")", ";", "}", "}" ]
HuffmanBlockEncoder run length encodes and Huffman encodes the quantized data.
[ "HuffmanBlockEncoder", "run", "length", "encodes", "and", "Huffman", "encodes", "the", "quantized", "data", "." ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-image/src/main/java/com/wizzardo/tools/image/JpegEncoder.java#L794-L849
8,685
wizzardo/tools
modules/tools-image/src/main/java/com/wizzardo/tools/image/JpegEncoder.java
Huffman.bufferIt
void bufferIt(BufferedOutputStream outStream, int code, int size) throws IOException { int PutBuffer = code; int PutBits = bufferPutBits; PutBuffer &= (1 << size) - 1; PutBits += size; PutBuffer <<= 24 - PutBits; PutBuffer |= bufferPutBuffer; while (PutBits >= 8) { int c = ((PutBuffer >> 16) & 0xFF); outStream.write(c); if (c == 0xFF) { outStream.write(0); } PutBuffer <<= 8; PutBits -= 8; } bufferPutBuffer = PutBuffer; bufferPutBits = PutBits; }
java
void bufferIt(BufferedOutputStream outStream, int code, int size) throws IOException { int PutBuffer = code; int PutBits = bufferPutBits; PutBuffer &= (1 << size) - 1; PutBits += size; PutBuffer <<= 24 - PutBits; PutBuffer |= bufferPutBuffer; while (PutBits >= 8) { int c = ((PutBuffer >> 16) & 0xFF); outStream.write(c); if (c == 0xFF) { outStream.write(0); } PutBuffer <<= 8; PutBits -= 8; } bufferPutBuffer = PutBuffer; bufferPutBits = PutBits; }
[ "void", "bufferIt", "(", "BufferedOutputStream", "outStream", ",", "int", "code", ",", "int", "size", ")", "throws", "IOException", "{", "int", "PutBuffer", "=", "code", ";", "int", "PutBits", "=", "bufferPutBits", ";", "PutBuffer", "&=", "(", "1", "<<", "size", ")", "-", "1", ";", "PutBits", "+=", "size", ";", "PutBuffer", "<<=", "24", "-", "PutBits", ";", "PutBuffer", "|=", "bufferPutBuffer", ";", "while", "(", "PutBits", ">=", "8", ")", "{", "int", "c", "=", "(", "(", "PutBuffer", ">>", "16", ")", "&", "0xFF", ")", ";", "outStream", ".", "write", "(", "c", ")", ";", "if", "(", "c", "==", "0xFF", ")", "{", "outStream", ".", "write", "(", "0", ")", ";", "}", "PutBuffer", "<<=", "8", ";", "PutBits", "-=", "8", ";", "}", "bufferPutBuffer", "=", "PutBuffer", ";", "bufferPutBits", "=", "PutBits", ";", "}" ]
and sends them to outStream by the byte.
[ "and", "sends", "them", "to", "outStream", "by", "the", "byte", "." ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-image/src/main/java/com/wizzardo/tools/image/JpegEncoder.java#L854-L875
8,686
wizzardo/tools
modules/tools-security/src/main/java/com/wizzardo/tools/security/Hash.java
Hash.check
public boolean check(String value, String hashString) { return update(value.getBytes()).asString().equalsIgnoreCase(hashString); }
java
public boolean check(String value, String hashString) { return update(value.getBytes()).asString().equalsIgnoreCase(hashString); }
[ "public", "boolean", "check", "(", "String", "value", ",", "String", "hashString", ")", "{", "return", "update", "(", "value", ".", "getBytes", "(", ")", ")", ".", "asString", "(", ")", ".", "equalsIgnoreCase", "(", "hashString", ")", ";", "}" ]
get hash from given string and check for equals it with hashString
[ "get", "hash", "from", "given", "string", "and", "check", "for", "equals", "it", "with", "hashString" ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-security/src/main/java/com/wizzardo/tools/security/Hash.java#L112-L114
8,687
wizzardo/tools
modules/tools-collections/src/main/java/com/wizzardo/tools/collections/flow/Flow.java
Flow.map
public <T> Flow<T> map(Mapper<? super B, T> mapper) { return then(new FlowMap<B, T>(mapper)); }
java
public <T> Flow<T> map(Mapper<? super B, T> mapper) { return then(new FlowMap<B, T>(mapper)); }
[ "public", "<", "T", ">", "Flow", "<", "T", ">", "map", "(", "Mapper", "<", "?", "super", "B", ",", "T", ">", "mapper", ")", "{", "return", "then", "(", "new", "FlowMap", "<", "B", ",", "T", ">", "(", "mapper", ")", ")", ";", "}" ]
converts B into T with Mapper, ignores null-values
[ "converts", "B", "into", "T", "with", "Mapper", "ignores", "null", "-", "values" ]
d14a3c5706408ff47973d630f039a7ad00953c24
https://github.com/wizzardo/tools/blob/d14a3c5706408ff47973d630f039a7ad00953c24/modules/tools-collections/src/main/java/com/wizzardo/tools/collections/flow/Flow.java#L128-L130
8,688
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/util/Anchor.java
Anchor.findAnchorElement
public static org.w3c.dom.Element findAnchorElement(org.w3c.dom.Element e) { if ("a".equalsIgnoreCase(e.getTagName().trim())) return e; else if (e.getParentNode() != null && e.getParentNode().getNodeType() == Node.ELEMENT_NODE) return findAnchorElement((org.w3c.dom.Element) e.getParentNode()); else return null; }
java
public static org.w3c.dom.Element findAnchorElement(org.w3c.dom.Element e) { if ("a".equalsIgnoreCase(e.getTagName().trim())) return e; else if (e.getParentNode() != null && e.getParentNode().getNodeType() == Node.ELEMENT_NODE) return findAnchorElement((org.w3c.dom.Element) e.getParentNode()); else return null; }
[ "public", "static", "org", ".", "w3c", ".", "dom", ".", "Element", "findAnchorElement", "(", "org", ".", "w3c", ".", "dom", ".", "Element", "e", ")", "{", "if", "(", "\"a\"", ".", "equalsIgnoreCase", "(", "e", ".", "getTagName", "(", ")", ".", "trim", "(", ")", ")", ")", "return", "e", ";", "else", "if", "(", "e", ".", "getParentNode", "(", ")", "!=", "null", "&&", "e", ".", "getParentNode", "(", ")", ".", "getNodeType", "(", ")", "==", "Node", ".", "ELEMENT_NODE", ")", "return", "findAnchorElement", "(", "(", "org", ".", "w3c", ".", "dom", ".", "Element", ")", "e", ".", "getParentNode", "(", ")", ")", ";", "else", "return", "null", ";", "}" ]
Examines the given element and all its parent elements in order to find the "a" element. @param e the child element to start with @return the "a" element found or null if it is not present
[ "Examines", "the", "given", "element", "and", "all", "its", "parent", "elements", "in", "order", "to", "find", "the", "a", "element", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/util/Anchor.java#L118-L126
8,689
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.setParent
@Override public void setParent(View parent) { if (parent == null && view != null) view.setParent(null); this.parent = parent; // if set new parent and has some element, try to load children // this element is a BranchElement ("collection"), // so we should have some LeafElements ("children") if ((parent != null) && (getElement() != null)) { ViewFactory f = getViewFactory(); loadChildren(f); } }
java
@Override public void setParent(View parent) { if (parent == null && view != null) view.setParent(null); this.parent = parent; // if set new parent and has some element, try to load children // this element is a BranchElement ("collection"), // so we should have some LeafElements ("children") if ((parent != null) && (getElement() != null)) { ViewFactory f = getViewFactory(); loadChildren(f); } }
[ "@", "Override", "public", "void", "setParent", "(", "View", "parent", ")", "{", "if", "(", "parent", "==", "null", "&&", "view", "!=", "null", ")", "view", ".", "setParent", "(", "null", ")", ";", "this", ".", "parent", "=", "parent", ";", "// if set new parent and has some element, try to load children", "// this element is a BranchElement (\"collection\"),", "// so we should have some LeafElements (\"children\")", "if", "(", "(", "parent", "!=", "null", ")", "&&", "(", "getElement", "(", ")", "!=", "null", ")", ")", "{", "ViewFactory", "f", "=", "getViewFactory", "(", ")", ";", "loadChildren", "(", "f", ")", ";", "}", "}" ]
Sets the view parent. @param parent the parent view
[ "Sets", "the", "view", "parent", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L68-L83
8,690
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.getDelegateName
public String getDelegateName() { javax.swing.text.Element data = getElement(); if (data instanceof DelegateElement) { return ((DelegateElement) data) .getDelegateName(); } return null; }
java
public String getDelegateName() { javax.swing.text.Element data = getElement(); if (data instanceof DelegateElement) { return ((DelegateElement) data) .getDelegateName(); } return null; }
[ "public", "String", "getDelegateName", "(", ")", "{", "javax", ".", "swing", ".", "text", ".", "Element", "data", "=", "getElement", "(", ")", ";", "if", "(", "data", "instanceof", "DelegateElement", ")", "{", "return", "(", "(", "DelegateElement", ")", "data", ")", ".", "getDelegateName", "(", ")", ";", "}", "return", "null", ";", "}" ]
Gets the name of delegate @return the name. It may not be a name of a Class !
[ "Gets", "the", "name", "of", "delegate" ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L157-L163
8,691
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.getMaximumSpan
@Override public float getMaximumSpan(int axis) { if (view != null) { return view.getMaximumSpan(axis); } return Integer.MAX_VALUE; }
java
@Override public float getMaximumSpan(int axis) { if (view != null) { return view.getMaximumSpan(axis); } return Integer.MAX_VALUE; }
[ "@", "Override", "public", "float", "getMaximumSpan", "(", "int", "axis", ")", "{", "if", "(", "view", "!=", "null", ")", "{", "return", "view", ".", "getMaximumSpan", "(", "axis", ")", ";", "}", "return", "Integer", ".", "MAX_VALUE", ";", "}" ]
Determines the maximum span for this view along an axis. @param axis may be either X_AXIS or Y_AXIS @return the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
[ "Determines", "the", "maximum", "span", "for", "this", "view", "along", "an", "axis", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L220-L225
8,692
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.paint
@Override public void paint(Graphics g, Shape allocation) { if (view != null) { view.paint(g, allocation); } }
java
@Override public void paint(Graphics g, Shape allocation) { if (view != null) { view.paint(g, allocation); } }
[ "@", "Override", "public", "void", "paint", "(", "Graphics", "g", ",", "Shape", "allocation", ")", "{", "if", "(", "view", "!=", "null", ")", "{", "view", ".", "paint", "(", "g", ",", "allocation", ")", ";", "}", "}" ]
Renders the view. @param g the graphics context @param allocation the region to render into
[ "Renders", "the", "view", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L278-L285
8,693
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.getChildAllocation
@Override public Shape getChildAllocation(int index, Shape a) { if (view != null) return view.getChildAllocation(index, a); return a; }
java
@Override public Shape getChildAllocation(int index, Shape a) { if (view != null) return view.getChildAllocation(index, a); return a; }
[ "@", "Override", "public", "Shape", "getChildAllocation", "(", "int", "index", ",", "Shape", "a", ")", "{", "if", "(", "view", "!=", "null", ")", "return", "view", ".", "getChildAllocation", "(", "index", ",", "a", ")", ";", "return", "a", ";", "}" ]
Fetches the allocation for the given child view. This enables finding out where various views are located, without assuming the views store their location. This returns the given allocation since this view simply acts as a gateway between the view hierarchy and the associated component. @param index the index of the child @param a the allocation to this view. @return the allocation to the child
[ "Fetches", "the", "allocation", "for", "the", "given", "child", "view", ".", "This", "enables", "finding", "out", "where", "various", "views", "are", "located", "without", "assuming", "the", "views", "store", "their", "location", ".", "This", "returns", "the", "given", "allocation", "since", "this", "view", "simply", "acts", "as", "a", "gateway", "between", "the", "view", "hierarchy", "and", "the", "associated", "component", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L341-L346
8,694
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.viewToModel
@Override public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) { if (view != null) { int retValue = view.viewToModel(x, y, a, bias); return retValue; } return -1; }
java
@Override public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) { if (view != null) { int retValue = view.viewToModel(x, y, a, bias); return retValue; } return -1; }
[ "@", "Override", "public", "int", "viewToModel", "(", "float", "x", ",", "float", "y", ",", "Shape", "a", ",", "Position", ".", "Bias", "[", "]", "bias", ")", "{", "if", "(", "view", "!=", "null", ")", "{", "int", "retValue", "=", "view", ".", "viewToModel", "(", "x", ",", "y", ",", "a", ",", "bias", ")", ";", "return", "retValue", ";", "}", "return", "-", "1", ";", "}" ]
Provides a mapping from the view coordinate space to the logical coordinate space of the model. @param x x coordinate of the view location to convert @param y y coordinate of the view location to convert @param a the allocated region to render into @return the location within the model that best represents the given point in the view
[ "Provides", "a", "mapping", "from", "the", "view", "coordinate", "space", "to", "the", "logical", "coordinate", "space", "of", "the", "model", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L413-L422
8,695
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.getNextVisualPositionFrom
@Override public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet) throws BadLocationException { if (view != null) { int nextPos = view.getNextVisualPositionFrom(pos, b, a, direction, biasRet); if (nextPos != -1) { pos = nextPos; } else { biasRet[0] = b; } } return pos; }
java
@Override public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet) throws BadLocationException { if (view != null) { int nextPos = view.getNextVisualPositionFrom(pos, b, a, direction, biasRet); if (nextPos != -1) { pos = nextPos; } else { biasRet[0] = b; } } return pos; }
[ "@", "Override", "public", "int", "getNextVisualPositionFrom", "(", "int", "pos", ",", "Position", ".", "Bias", "b", ",", "Shape", "a", ",", "int", "direction", ",", "Position", ".", "Bias", "[", "]", "biasRet", ")", "throws", "BadLocationException", "{", "if", "(", "view", "!=", "null", ")", "{", "int", "nextPos", "=", "view", ".", "getNextVisualPositionFrom", "(", "pos", ",", "b", ",", "a", ",", "direction", ",", "biasRet", ")", ";", "if", "(", "nextPos", "!=", "-", "1", ")", "{", "pos", "=", "nextPos", ";", "}", "else", "{", "biasRet", "[", "0", "]", "=", "b", ";", "}", "}", "return", "pos", ";", "}" ]
Provides a way to determine the next visually represented model location that one might place a caret. Some views may not be visible, they might not be in the same order found in the model, or they just might not allow access to some of the locations in the model. @param pos the position to convert >= 0 @param a the allocated region to render into @param direction the direction from the current position that can be thought of as the arrow keys typically found on a keyboard. This may be SwingConstants.WEST, SwingConstants.EAST, SwingConstants.NORTH, or SwingConstants.SOUTH. @return the location within the model that best represents the next location visual position. @exception BadLocationException @exception IllegalArgumentException for an invalid direction
[ "Provides", "a", "way", "to", "determine", "the", "next", "visually", "represented", "model", "location", "that", "one", "might", "place", "a", "caret", ".", "Some", "views", "may", "not", "be", "visible", "they", "might", "not", "be", "in", "the", "same", "order", "found", "in", "the", "model", "or", "they", "just", "might", "not", "allow", "access", "to", "some", "of", "the", "locations", "in", "the", "model", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L445-L463
8,696
radkovo/SwingBox
src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java
DelegateView.setSize
@Override public void setSize(float width, float height) { if (view != null) { view.setSize(width, height); } }
java
@Override public void setSize(float width, float height) { if (view != null) { view.setSize(width, height); } }
[ "@", "Override", "public", "void", "setSize", "(", "float", "width", ",", "float", "height", ")", "{", "if", "(", "view", "!=", "null", ")", "{", "view", ".", "setSize", "(", "width", ",", "height", ")", ";", "}", "}" ]
Sets the view size. @param width the width @param height the height
[ "Sets", "the", "view", "size", "." ]
ff370f3dc54d248e4c8852c17513618c83c25984
https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L523-L530
8,697
mgodave/barge
barge-core/src/main/java/org/robotninjas/barge/state/Leader.java
Leader.updateCommitted
private void updateCommitted() { List<Long> sorted = newArrayList(); for (ReplicaManager manager : managers.values()) { sorted.add(manager.getMatchIndex()); } sorted.add(getLog().lastLogIndex()); Collections.sort(sorted); int n = sorted.size(); int quorumSize = (n / 2) + 1; final long committed = sorted.get(quorumSize - 1); LOGGER.debug("updating commitIndex to {}; sorted is {}", committed, sorted); getLog().commitIndex(committed); }
java
private void updateCommitted() { List<Long> sorted = newArrayList(); for (ReplicaManager manager : managers.values()) { sorted.add(manager.getMatchIndex()); } sorted.add(getLog().lastLogIndex()); Collections.sort(sorted); int n = sorted.size(); int quorumSize = (n / 2) + 1; final long committed = sorted.get(quorumSize - 1); LOGGER.debug("updating commitIndex to {}; sorted is {}", committed, sorted); getLog().commitIndex(committed); }
[ "private", "void", "updateCommitted", "(", ")", "{", "List", "<", "Long", ">", "sorted", "=", "newArrayList", "(", ")", ";", "for", "(", "ReplicaManager", "manager", ":", "managers", ".", "values", "(", ")", ")", "{", "sorted", ".", "add", "(", "manager", ".", "getMatchIndex", "(", ")", ")", ";", "}", "sorted", ".", "add", "(", "getLog", "(", ")", ".", "lastLogIndex", "(", ")", ")", ";", "Collections", ".", "sort", "(", "sorted", ")", ";", "int", "n", "=", "sorted", ".", "size", "(", ")", ";", "int", "quorumSize", "=", "(", "n", "/", "2", ")", "+", "1", ";", "final", "long", "committed", "=", "sorted", ".", "get", "(", "quorumSize", "-", "1", ")", ";", "LOGGER", ".", "debug", "(", "\"updating commitIndex to {}; sorted is {}\"", ",", "committed", ",", "sorted", ")", ";", "getLog", "(", ")", ".", "commitIndex", "(", "committed", ")", ";", "}" ]
Find the median value of the list of matchIndex, this value is the committedIndex since, by definition, half of the matchIndex values are greater and half are less than this value. So, at least half of the replicas have stored the median value, this is the definition of committed.
[ "Find", "the", "median", "value", "of", "the", "list", "of", "matchIndex", "this", "value", "is", "the", "committedIndex", "since", "by", "definition", "half", "of", "the", "matchIndex", "values", "are", "greater", "and", "half", "are", "less", "than", "this", "value", ".", "So", "at", "least", "half", "of", "the", "replicas", "have", "stored", "the", "median", "value", "this", "is", "the", "definition", "of", "committed", "." ]
d0c951820f105cfda280e9005e19265c6c44ed8f
https://github.com/mgodave/barge/blob/d0c951820f105cfda280e9005e19265c6c44ed8f/barge-core/src/main/java/org/robotninjas/barge/state/Leader.java#L128-L146
8,698
Gant/Gant
src/main/groovy/org/codehaus/gant/GantMetaClass.java
GantMetaClass.invokeMethod
@SuppressWarnings("rawtypes") @Override public Object invokeMethod(final Class sender, final Object receiver, final String methodName, final Object[] arguments, final boolean isCallToSuper, final boolean fromInsideClass) { return invokeMethod(receiver, methodName, arguments); }
java
@SuppressWarnings("rawtypes") @Override public Object invokeMethod(final Class sender, final Object receiver, final String methodName, final Object[] arguments, final boolean isCallToSuper, final boolean fromInsideClass) { return invokeMethod(receiver, methodName, arguments); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "@", "Override", "public", "Object", "invokeMethod", "(", "final", "Class", "sender", ",", "final", "Object", "receiver", ",", "final", "String", "methodName", ",", "final", "Object", "[", "]", "arguments", ",", "final", "boolean", "isCallToSuper", ",", "final", "boolean", "fromInsideClass", ")", "{", "return", "invokeMethod", "(", "receiver", ",", "methodName", ",", "arguments", ")", ";", "}" ]
Invoke a method on the given receiver for the specified arguments. The sender is the class that invoked the method on the object. Attempt to establish the method to invoke based on the name and arguments provided. <p>The {@code isCallToSuper} and {@code fromInsideClass} help the Groovy runtime perform optimizations on the call to go directly to the superclass if necessary.</p> @param sender The {@code java.lang.Class} instance that invoked the method. @param receiver The object which the method was invoked on. @param methodName The name of the method. @param arguments The arguments to the method. @param isCallToSuper Whether the method is a call to a superclass method. @param fromInsideClass Whether the call was invoked from the inside or the outside of the class. @return The return value of the method
[ "Invoke", "a", "method", "on", "the", "given", "receiver", "for", "the", "specified", "arguments", ".", "The", "sender", "is", "the", "class", "that", "invoked", "the", "method", "on", "the", "object", ".", "Attempt", "to", "establish", "the", "method", "to", "invoke", "based", "on", "the", "name", "and", "arguments", "provided", "." ]
8f82b3cd8968d5595dc44e2beae9f7948172868b
https://github.com/Gant/Gant/blob/8f82b3cd8968d5595dc44e2beae9f7948172868b/src/main/groovy/org/codehaus/gant/GantMetaClass.java#L205-L208
8,699
Gant/Gant
src/main/groovy/org/codehaus/gant/ant/Gant.java
Gant.setTarget
public void setTarget(final String t) { final GantTarget gt = new GantTarget(); gt.setValue(t); targets.add(gt); }
java
public void setTarget(final String t) { final GantTarget gt = new GantTarget(); gt.setValue(t); targets.add(gt); }
[ "public", "void", "setTarget", "(", "final", "String", "t", ")", "{", "final", "GantTarget", "gt", "=", "new", "GantTarget", "(", ")", ";", "gt", ".", "setValue", "(", "t", ")", ";", "targets", ".", "add", "(", "gt", ")", ";", "}" ]
Set the target to be achieved. @param t The target to achieve.
[ "Set", "the", "target", "to", "be", "achieved", "." ]
8f82b3cd8968d5595dc44e2beae9f7948172868b
https://github.com/Gant/Gant/blob/8f82b3cd8968d5595dc44e2beae9f7948172868b/src/main/groovy/org/codehaus/gant/ant/Gant.java#L110-L114