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
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
1,800 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/geom/Transform.java | Transform.createRotateTransform | public static Transform createRotateTransform(float angle, float x, float y) {
Transform temp = Transform.createRotateTransform(angle);
float sinAngle = temp.matrixPosition[3];
float oneMinusCosAngle = 1.0f - temp.matrixPosition[4];
temp.matrixPosition[2] = x * oneMinusCosAngle + y * sinAngle;
temp.matrixPosition[5] = y * oneMinusCosAngle - x * sinAngle;
return temp;
} | java | public static Transform createRotateTransform(float angle, float x, float y) {
Transform temp = Transform.createRotateTransform(angle);
float sinAngle = temp.matrixPosition[3];
float oneMinusCosAngle = 1.0f - temp.matrixPosition[4];
temp.matrixPosition[2] = x * oneMinusCosAngle + y * sinAngle;
temp.matrixPosition[5] = y * oneMinusCosAngle - x * sinAngle;
return temp;
} | [
"public",
"static",
"Transform",
"createRotateTransform",
"(",
"float",
"angle",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Transform",
"temp",
"=",
"Transform",
".",
"createRotateTransform",
"(",
"angle",
")",
";",
"float",
"sinAngle",
"=",
"temp",
".",
"matrixPosition",
"[",
"3",
"]",
";",
"float",
"oneMinusCosAngle",
"=",
"1.0f",
"-",
"temp",
".",
"matrixPosition",
"[",
"4",
"]",
";",
"temp",
".",
"matrixPosition",
"[",
"2",
"]",
"=",
"x",
"*",
"oneMinusCosAngle",
"+",
"y",
"*",
"sinAngle",
";",
"temp",
".",
"matrixPosition",
"[",
"5",
"]",
"=",
"y",
"*",
"oneMinusCosAngle",
"-",
"x",
"*",
"sinAngle",
";",
"return",
"temp",
";",
"}"
] | Create a new rotation Transform around the specified point
@param angle The angle in radians to set the transform.
@param x The x coordinate around which to rotate.
@param y The y coordinate around which to rotate.
@return The resulting Transform | [
"Create",
"a",
"new",
"rotation",
"Transform",
"around",
"the",
"specified",
"point"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Transform.java#L184-L192 |
1,801 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/geom/Transform.java | Transform.transform | public Vector2f transform(Vector2f pt) {
float[] in = new float[] {pt.x, pt.y};
float[] out = new float[2];
transform(in, 0, out, 0, 1);
return new Vector2f(out[0], out[1]);
} | java | public Vector2f transform(Vector2f pt) {
float[] in = new float[] {pt.x, pt.y};
float[] out = new float[2];
transform(in, 0, out, 0, 1);
return new Vector2f(out[0], out[1]);
} | [
"public",
"Vector2f",
"transform",
"(",
"Vector2f",
"pt",
")",
"{",
"float",
"[",
"]",
"in",
"=",
"new",
"float",
"[",
"]",
"{",
"pt",
".",
"x",
",",
"pt",
".",
"y",
"}",
";",
"float",
"[",
"]",
"out",
"=",
"new",
"float",
"[",
"2",
"]",
";",
"transform",
"(",
"in",
",",
"0",
",",
"out",
",",
"0",
",",
"1",
")",
";",
"return",
"new",
"Vector2f",
"(",
"out",
"[",
"0",
"]",
",",
"out",
"[",
"1",
"]",
")",
";",
"}"
] | Transform the vector2f based on the matrix defined in this transform
@param pt The point to be transformed
@return The resulting point transformed by this matrix | [
"Transform",
"the",
"vector2f",
"based",
"on",
"the",
"matrix",
"defined",
"in",
"this",
"transform"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/geom/Transform.java#L222-L229 |
1,802 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java | InputProvider.getUniqueCommands | public List getUniqueCommands() {
List uniqueCommands = new ArrayList();
for (Iterator it = commands.values().iterator(); it.hasNext();) {
Command command = (Command) it.next();
if (!uniqueCommands.contains(command)) {
uniqueCommands.add(command);
}
}
return uniqueCommands;
} | java | public List getUniqueCommands() {
List uniqueCommands = new ArrayList();
for (Iterator it = commands.values().iterator(); it.hasNext();) {
Command command = (Command) it.next();
if (!uniqueCommands.contains(command)) {
uniqueCommands.add(command);
}
}
return uniqueCommands;
} | [
"public",
"List",
"getUniqueCommands",
"(",
")",
"{",
"List",
"uniqueCommands",
"=",
"new",
"ArrayList",
"(",
")",
";",
"for",
"(",
"Iterator",
"it",
"=",
"commands",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Command",
"command",
"=",
"(",
"Command",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"uniqueCommands",
".",
"contains",
"(",
"command",
")",
")",
"{",
"uniqueCommands",
".",
"add",
"(",
"command",
")",
";",
"}",
"}",
"return",
"uniqueCommands",
";",
"}"
] | Get the list of commands that have been registered with the provider,
i.e. the commands that can be issued to the listeners
@return The list of commands (@see Command) that can be issued from this
provider | [
"Get",
"the",
"list",
"of",
"commands",
"that",
"have",
"been",
"registered",
"with",
"the",
"provider",
"i",
".",
"e",
".",
"the",
"commands",
"that",
"can",
"be",
"issued",
"to",
"the",
"listeners"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java#L57-L69 |
1,803 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java | InputProvider.bindCommand | public void bindCommand(Control control, Command command) {
commands.put(control, command);
if (commandState.get(command) == null) {
commandState.put(command, new CommandState());
}
} | java | public void bindCommand(Control control, Command command) {
commands.put(control, command);
if (commandState.get(command) == null) {
commandState.put(command, new CommandState());
}
} | [
"public",
"void",
"bindCommand",
"(",
"Control",
"control",
",",
"Command",
"command",
")",
"{",
"commands",
".",
"put",
"(",
"control",
",",
"command",
")",
";",
"if",
"(",
"commandState",
".",
"get",
"(",
"command",
")",
"==",
"null",
")",
"{",
"commandState",
".",
"put",
"(",
"command",
",",
"new",
"CommandState",
"(",
")",
")",
";",
"}",
"}"
] | Bind an command to a control.
@param command
The command to bind to
@param control
The control that is pressed/released to represent the command | [
"Bind",
"an",
"command",
"to",
"a",
"control",
"."
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java#L143-L149 |
1,804 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java | InputProvider.clearCommand | public void clearCommand(Command command) {
List controls = getControlsFor(command);
for (int i=0;i<controls.size();i++) {
unbindCommand((Control) controls.get(i));
}
} | java | public void clearCommand(Command command) {
List controls = getControlsFor(command);
for (int i=0;i<controls.size();i++) {
unbindCommand((Control) controls.get(i));
}
} | [
"public",
"void",
"clearCommand",
"(",
"Command",
"command",
")",
"{",
"List",
"controls",
"=",
"getControlsFor",
"(",
"command",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"controls",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"unbindCommand",
"(",
"(",
"Control",
")",
"controls",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"}"
] | Clear all the controls that have been configured for a given command
@param command The command whose controls should be unbound | [
"Clear",
"all",
"the",
"controls",
"that",
"have",
"been",
"configured",
"for",
"a",
"given",
"command"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java#L156-L162 |
1,805 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java | InputProvider.unbindCommand | public void unbindCommand(Control control) {
Command command = (Command) commands.remove(control);
if (command != null) {
if (!commands.keySet().contains(command)) {
commandState.remove(command);
}
}
} | java | public void unbindCommand(Control control) {
Command command = (Command) commands.remove(control);
if (command != null) {
if (!commands.keySet().contains(command)) {
commandState.remove(command);
}
}
} | [
"public",
"void",
"unbindCommand",
"(",
"Control",
"control",
")",
"{",
"Command",
"command",
"=",
"(",
"Command",
")",
"commands",
".",
"remove",
"(",
"control",
")",
";",
"if",
"(",
"command",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"commands",
".",
"keySet",
"(",
")",
".",
"contains",
"(",
"command",
")",
")",
"{",
"commandState",
".",
"remove",
"(",
"command",
")",
";",
"}",
"}",
"}"
] | Unbinds the command associated with this control
@param control
The control to remove | [
"Unbinds",
"the",
"command",
"associated",
"with",
"this",
"control"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java#L170-L177 |
1,806 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java | InputProvider.firePressed | protected void firePressed(Command command) {
getState(command).down = true;
getState(command).pressed = true;
if (!isActive()) {
return;
}
for (int i = 0; i < listeners.size(); i++) {
((InputProviderListener) listeners.get(i)).controlPressed(command);
}
} | java | protected void firePressed(Command command) {
getState(command).down = true;
getState(command).pressed = true;
if (!isActive()) {
return;
}
for (int i = 0; i < listeners.size(); i++) {
((InputProviderListener) listeners.get(i)).controlPressed(command);
}
} | [
"protected",
"void",
"firePressed",
"(",
"Command",
"command",
")",
"{",
"getState",
"(",
"command",
")",
".",
"down",
"=",
"true",
";",
"getState",
"(",
"command",
")",
".",
"pressed",
"=",
"true",
";",
"if",
"(",
"!",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"listeners",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"(",
"(",
"InputProviderListener",
")",
"listeners",
".",
"get",
"(",
"i",
")",
")",
".",
"controlPressed",
"(",
"command",
")",
";",
"}",
"}"
] | Fire notification to any interested listeners that a control has been
pressed indication an particular command
@param command
The command that has been pressed | [
"Fire",
"notification",
"to",
"any",
"interested",
"listeners",
"that",
"a",
"control",
"has",
"been",
"pressed",
"indication",
"an",
"particular",
"command"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java#L221-L232 |
1,807 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java | InputProvider.fireReleased | protected void fireReleased(Command command) {
getState(command).down = false;
if (!isActive()) {
return;
}
for (int i = 0; i < listeners.size(); i++) {
((InputProviderListener) listeners.get(i)).controlReleased(command);
}
} | java | protected void fireReleased(Command command) {
getState(command).down = false;
if (!isActive()) {
return;
}
for (int i = 0; i < listeners.size(); i++) {
((InputProviderListener) listeners.get(i)).controlReleased(command);
}
} | [
"protected",
"void",
"fireReleased",
"(",
"Command",
"command",
")",
"{",
"getState",
"(",
"command",
")",
".",
"down",
"=",
"false",
";",
"if",
"(",
"!",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"listeners",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"(",
"(",
"InputProviderListener",
")",
"listeners",
".",
"get",
"(",
"i",
")",
")",
".",
"controlReleased",
"(",
"command",
")",
";",
"}",
"}"
] | Fire notification to any interested listeners that a control has been
released indication an particular command should be stopped
@param command
The command that has been pressed | [
"Fire",
"notification",
"to",
"any",
"interested",
"listeners",
"that",
"a",
"control",
"has",
"been",
"released",
"indication",
"an",
"particular",
"command",
"should",
"be",
"stopped"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/command/InputProvider.java#L241-L251 |
1,808 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java | SVGMorph.addStep | public void addStep(Diagram diagram) {
if (diagram.getFigureCount() != figures.size()) {
throw new RuntimeException("Mismatched diagrams, missing ids");
}
for (int i=0;i<diagram.getFigureCount();i++) {
Figure figure = diagram.getFigure(i);
String id = figure.getData().getMetaData();
for (int j=0;j<figures.size();j++) {
Figure existing = (Figure) figures.get(j);
if (existing.getData().getMetaData().equals(id)) {
MorphShape morph = (MorphShape) existing.getShape();
morph.addShape(figure.getShape());
break;
}
}
}
} | java | public void addStep(Diagram diagram) {
if (diagram.getFigureCount() != figures.size()) {
throw new RuntimeException("Mismatched diagrams, missing ids");
}
for (int i=0;i<diagram.getFigureCount();i++) {
Figure figure = diagram.getFigure(i);
String id = figure.getData().getMetaData();
for (int j=0;j<figures.size();j++) {
Figure existing = (Figure) figures.get(j);
if (existing.getData().getMetaData().equals(id)) {
MorphShape morph = (MorphShape) existing.getShape();
morph.addShape(figure.getShape());
break;
}
}
}
} | [
"public",
"void",
"addStep",
"(",
"Diagram",
"diagram",
")",
"{",
"if",
"(",
"diagram",
".",
"getFigureCount",
"(",
")",
"!=",
"figures",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Mismatched diagrams, missing ids\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"diagram",
".",
"getFigureCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Figure",
"figure",
"=",
"diagram",
".",
"getFigure",
"(",
"i",
")",
";",
"String",
"id",
"=",
"figure",
".",
"getData",
"(",
")",
".",
"getMetaData",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"figures",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"Figure",
"existing",
"=",
"(",
"Figure",
")",
"figures",
".",
"get",
"(",
"j",
")",
";",
"if",
"(",
"existing",
".",
"getData",
"(",
")",
".",
"getMetaData",
"(",
")",
".",
"equals",
"(",
"id",
")",
")",
"{",
"MorphShape",
"morph",
"=",
"(",
"MorphShape",
")",
"existing",
".",
"getShape",
"(",
")",
";",
"morph",
".",
"addShape",
"(",
"figure",
".",
"getShape",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | Add a subsquent step to the morphing
@param diagram The diagram to add as the next step in the morph | [
"Add",
"a",
"subsquent",
"step",
"to",
"the",
"morphing"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java#L37-L54 |
1,809 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java | SVGMorph.updateMorphTime | public void updateMorphTime(float delta) {
for (int i=0;i<figures.size();i++) {
Figure figure = (Figure) figures.get(i);
MorphShape shape = (MorphShape) figure.getShape();
shape.updateMorphTime(delta);
}
} | java | public void updateMorphTime(float delta) {
for (int i=0;i<figures.size();i++) {
Figure figure = (Figure) figures.get(i);
MorphShape shape = (MorphShape) figure.getShape();
shape.updateMorphTime(delta);
}
} | [
"public",
"void",
"updateMorphTime",
"(",
"float",
"delta",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"figures",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Figure",
"figure",
"=",
"(",
"Figure",
")",
"figures",
".",
"get",
"(",
"i",
")",
";",
"MorphShape",
"shape",
"=",
"(",
"MorphShape",
")",
"figure",
".",
"getShape",
"(",
")",
";",
"shape",
".",
"updateMorphTime",
"(",
"delta",
")",
";",
"}",
"}"
] | Update the morph time index by the amount specified
@param delta The amount to update the morph by | [
"Update",
"the",
"morph",
"time",
"index",
"by",
"the",
"amount",
"specified"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java#L83-L89 |
1,810 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java | SVGMorph.setMorphTime | public void setMorphTime(float time) {
for (int i=0;i<figures.size();i++) {
Figure figure = (Figure) figures.get(i);
MorphShape shape = (MorphShape) figure.getShape();
shape.setMorphTime(time);
}
} | java | public void setMorphTime(float time) {
for (int i=0;i<figures.size();i++) {
Figure figure = (Figure) figures.get(i);
MorphShape shape = (MorphShape) figure.getShape();
shape.setMorphTime(time);
}
} | [
"public",
"void",
"setMorphTime",
"(",
"float",
"time",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"figures",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Figure",
"figure",
"=",
"(",
"Figure",
")",
"figures",
".",
"get",
"(",
"i",
")",
";",
"MorphShape",
"shape",
"=",
"(",
"MorphShape",
")",
"figure",
".",
"getShape",
"(",
")",
";",
"shape",
".",
"setMorphTime",
"(",
"time",
")",
";",
"}",
"}"
] | Set the "time" index for this morph. This is given in terms of diagrams, so
0.5f would give you the position half way between the first and second diagrams.
@param time The time index to represent on this diagrams | [
"Set",
"the",
"time",
"index",
"for",
"this",
"morph",
".",
"This",
"is",
"given",
"in",
"terms",
"of",
"diagrams",
"so",
"0",
".",
"5f",
"would",
"give",
"you",
"the",
"position",
"half",
"way",
"between",
"the",
"first",
"and",
"second",
"diagrams",
"."
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/svg/SVGMorph.java#L97-L103 |
1,811 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/CachedRender.java | CachedRender.build | private void build() {
if (list == -1) {
list = GL.glGenLists(1);
SlickCallable.enterSafeBlock();
GL.glNewList(list, SGL.GL_COMPILE);
runnable.run();
GL.glEndList();
SlickCallable.leaveSafeBlock();
} else {
throw new RuntimeException("Attempt to build the display list more than once in CachedRender");
}
} | java | private void build() {
if (list == -1) {
list = GL.glGenLists(1);
SlickCallable.enterSafeBlock();
GL.glNewList(list, SGL.GL_COMPILE);
runnable.run();
GL.glEndList();
SlickCallable.leaveSafeBlock();
} else {
throw new RuntimeException("Attempt to build the display list more than once in CachedRender");
}
} | [
"private",
"void",
"build",
"(",
")",
"{",
"if",
"(",
"list",
"==",
"-",
"1",
")",
"{",
"list",
"=",
"GL",
".",
"glGenLists",
"(",
"1",
")",
";",
"SlickCallable",
".",
"enterSafeBlock",
"(",
")",
";",
"GL",
".",
"glNewList",
"(",
"list",
",",
"SGL",
".",
"GL_COMPILE",
")",
";",
"runnable",
".",
"run",
"(",
")",
";",
"GL",
".",
"glEndList",
"(",
")",
";",
"SlickCallable",
".",
"leaveSafeBlock",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Attempt to build the display list more than once in CachedRender\"",
")",
";",
"}",
"}"
] | Build the display list | [
"Build",
"the",
"display",
"list"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/CachedRender.java#L41-L53 |
1,812 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/CachedRender.java | CachedRender.render | public void render() {
if (list == -1) {
throw new RuntimeException("Attempt to render cached operations that have been destroyed");
}
SlickCallable.enterSafeBlock();
GL.glCallList(list);
SlickCallable.leaveSafeBlock();
} | java | public void render() {
if (list == -1) {
throw new RuntimeException("Attempt to render cached operations that have been destroyed");
}
SlickCallable.enterSafeBlock();
GL.glCallList(list);
SlickCallable.leaveSafeBlock();
} | [
"public",
"void",
"render",
"(",
")",
"{",
"if",
"(",
"list",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Attempt to render cached operations that have been destroyed\"",
")",
";",
"}",
"SlickCallable",
".",
"enterSafeBlock",
"(",
")",
";",
"GL",
".",
"glCallList",
"(",
"list",
")",
";",
"SlickCallable",
".",
"leaveSafeBlock",
"(",
")",
";",
"}"
] | Render the cached operations. Note that this doesn't call the operations, but
rather calls the cached version | [
"Render",
"the",
"cached",
"operations",
".",
"Note",
"that",
"this",
"doesn",
"t",
"call",
"the",
"operations",
"but",
"rather",
"calls",
"the",
"cached",
"version"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/CachedRender.java#L59-L67 |
1,813 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/imageout/ImageWriterFactory.java | ImageWriterFactory.getWriterForFormat | public static ImageWriter getWriterForFormat(String format) throws SlickException
{
ImageWriter writer = (ImageWriter) writers.get(format);
if (writer != null) {
return writer;
}
writer = (ImageWriter) writers.get(format.toLowerCase());
if (writer != null) {
return writer;
}
writer = (ImageWriter) writers.get(format.toUpperCase());
if (writer != null) {
return writer;
}
throw new SlickException("No image writer available for: "+format);
} | java | public static ImageWriter getWriterForFormat(String format) throws SlickException
{
ImageWriter writer = (ImageWriter) writers.get(format);
if (writer != null) {
return writer;
}
writer = (ImageWriter) writers.get(format.toLowerCase());
if (writer != null) {
return writer;
}
writer = (ImageWriter) writers.get(format.toUpperCase());
if (writer != null) {
return writer;
}
throw new SlickException("No image writer available for: "+format);
} | [
"public",
"static",
"ImageWriter",
"getWriterForFormat",
"(",
"String",
"format",
")",
"throws",
"SlickException",
"{",
"ImageWriter",
"writer",
"=",
"(",
"ImageWriter",
")",
"writers",
".",
"get",
"(",
"format",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"return",
"writer",
";",
"}",
"writer",
"=",
"(",
"ImageWriter",
")",
"writers",
".",
"get",
"(",
"format",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"return",
"writer",
";",
"}",
"writer",
"=",
"(",
"ImageWriter",
")",
"writers",
".",
"get",
"(",
"format",
".",
"toUpperCase",
"(",
")",
")",
";",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"return",
"writer",
";",
"}",
"throw",
"new",
"SlickException",
"(",
"\"No image writer available for: \"",
"+",
"format",
")",
";",
"}"
] | Get a Slick image writer for the given format
@param format The format of the image to write
@return The image write to use to produce these images
@throws SlickException | [
"Get",
"a",
"Slick",
"image",
"writer",
"for",
"the",
"given",
"format"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/imageout/ImageWriterFactory.java#L57-L75 |
1,814 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/SavedState.java | SavedState.getNumber | public double getNumber(String nameOfField, double defaultValue) {
Double value = ((Double)numericData.get(nameOfField));
if (value == null) {
return defaultValue;
}
return value.doubleValue();
} | java | public double getNumber(String nameOfField, double defaultValue) {
Double value = ((Double)numericData.get(nameOfField));
if (value == null) {
return defaultValue;
}
return value.doubleValue();
} | [
"public",
"double",
"getNumber",
"(",
"String",
"nameOfField",
",",
"double",
"defaultValue",
")",
"{",
"Double",
"value",
"=",
"(",
"(",
"Double",
")",
"numericData",
".",
"get",
"(",
"nameOfField",
")",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"value",
".",
"doubleValue",
"(",
")",
";",
"}"
] | Get number stored at given location
@param nameOfField The name of the number to retrieve
@param defaultValue The value to return if the specified value hasn't been set
@return The number saved at this location | [
"Get",
"number",
"stored",
"at",
"given",
"location"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/SavedState.java#L72-L80 |
1,815 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/SavedState.java | SavedState.getString | public String getString(String nameOfField, String defaultValue) {
String value = (String) stringData.get(nameOfField);
if (value == null) {
return defaultValue;
}
return value;
} | java | public String getString(String nameOfField, String defaultValue) {
String value = (String) stringData.get(nameOfField);
if (value == null) {
return defaultValue;
}
return value;
} | [
"public",
"String",
"getString",
"(",
"String",
"nameOfField",
",",
"String",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"(",
"String",
")",
"stringData",
".",
"get",
"(",
"nameOfField",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"value",
";",
"}"
] | Get the String at the given location
@param nameOfField location of string
@param defaultValue The value to return if the specified value hasn't been set
@return String stored at the location given | [
"Get",
"the",
"String",
"at",
"the",
"given",
"location"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/SavedState.java#L110-L118 |
1,816 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/SavedState.java | SavedState.isWebstartAvailable | private boolean isWebstartAvailable() {
try {
Class.forName("javax.jnlp.ServiceManager");
// this causes to go and see if the service is available
ServiceManager.lookup("javax.jnlp.PersistenceService");
Log.info("Webstart detected using Muffins");
} catch (Exception e) {
Log.info("Using Local File System");
return false;
}
return true;
} | java | private boolean isWebstartAvailable() {
try {
Class.forName("javax.jnlp.ServiceManager");
// this causes to go and see if the service is available
ServiceManager.lookup("javax.jnlp.PersistenceService");
Log.info("Webstart detected using Muffins");
} catch (Exception e) {
Log.info("Using Local File System");
return false;
}
return true;
} | [
"private",
"boolean",
"isWebstartAvailable",
"(",
")",
"{",
"try",
"{",
"Class",
".",
"forName",
"(",
"\"javax.jnlp.ServiceManager\"",
")",
";",
"// this causes to go and see if the service is available\r",
"ServiceManager",
".",
"lookup",
"(",
"\"javax.jnlp.PersistenceService\"",
")",
";",
"Log",
".",
"info",
"(",
"\"Webstart detected using Muffins\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"info",
"(",
"\"Using Local File System\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Quick test to see if running through Java webstart
@return True if jws running | [
"Quick",
"test",
"to",
"see",
"if",
"running",
"through",
"Java",
"webstart"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/SavedState.java#L164-L175 |
1,817 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/ibxm/OpenALMODPlayer.java | OpenALMODPlayer.init | public void init() {
try {
AL.create();
soundWorks = true;
} catch (LWJGLException e) {
System.err.println("Failed to initialise LWJGL OpenAL");
soundWorks = false;
return;
}
if (soundWorks) {
IntBuffer sources = BufferUtils.createIntBuffer(1);
AL10.alGenSources(sources);
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
System.err.println("Failed to create sources");
soundWorks = false;
} else {
source = sources.get(0);
}
}
} | java | public void init() {
try {
AL.create();
soundWorks = true;
} catch (LWJGLException e) {
System.err.println("Failed to initialise LWJGL OpenAL");
soundWorks = false;
return;
}
if (soundWorks) {
IntBuffer sources = BufferUtils.createIntBuffer(1);
AL10.alGenSources(sources);
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
System.err.println("Failed to create sources");
soundWorks = false;
} else {
source = sources.get(0);
}
}
} | [
"public",
"void",
"init",
"(",
")",
"{",
"try",
"{",
"AL",
".",
"create",
"(",
")",
";",
"soundWorks",
"=",
"true",
";",
"}",
"catch",
"(",
"LWJGLException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Failed to initialise LWJGL OpenAL\"",
")",
";",
"soundWorks",
"=",
"false",
";",
"return",
";",
"}",
"if",
"(",
"soundWorks",
")",
"{",
"IntBuffer",
"sources",
"=",
"BufferUtils",
".",
"createIntBuffer",
"(",
"1",
")",
";",
"AL10",
".",
"alGenSources",
"(",
"sources",
")",
";",
"if",
"(",
"AL10",
".",
"alGetError",
"(",
")",
"!=",
"AL10",
".",
"AL_NO_ERROR",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Failed to create sources\"",
")",
";",
"soundWorks",
"=",
"false",
";",
"}",
"else",
"{",
"source",
"=",
"sources",
".",
"get",
"(",
"0",
")",
";",
"}",
"}",
"}"
] | Initialise OpenAL LWJGL styley | [
"Initialise",
"OpenAL",
"LWJGL",
"styley"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/ibxm/OpenALMODPlayer.java#L51-L73 |
1,818 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/ibxm/OpenALMODPlayer.java | OpenALMODPlayer.setup | public void setup(float pitch, float gain) {
AL10.alSourcef(source, AL10.AL_PITCH, pitch);
AL10.alSourcef(source, AL10.AL_GAIN, gain);
} | java | public void setup(float pitch, float gain) {
AL10.alSourcef(source, AL10.AL_PITCH, pitch);
AL10.alSourcef(source, AL10.AL_GAIN, gain);
} | [
"public",
"void",
"setup",
"(",
"float",
"pitch",
",",
"float",
"gain",
")",
"{",
"AL10",
".",
"alSourcef",
"(",
"source",
",",
"AL10",
".",
"AL_PITCH",
",",
"pitch",
")",
";",
"AL10",
".",
"alSourcef",
"(",
"source",
",",
"AL10",
".",
"AL_GAIN",
",",
"gain",
")",
";",
"}"
] | Setup the playback properties
@param pitch The pitch to play back at
@param gain The volume to play back at | [
"Setup",
"the",
"playback",
"properties"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/ibxm/OpenALMODPlayer.java#L155-L158 |
1,819 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/ibxm/OpenALMODPlayer.java | OpenALMODPlayer.loadModule | public static Module loadModule(InputStream in) throws IOException {
Module module;
DataInputStream din;
byte[] xm_header, s3m_header, mod_header, output_buffer;
int frames;
din = new DataInputStream(in);
module = null;
xm_header = new byte[ 60 ];
din.readFully( xm_header );
if( FastTracker2.is_xm( xm_header ) ) {
module = FastTracker2.load_xm( xm_header, din );
} else {
s3m_header = new byte[ 96 ];
System.arraycopy( xm_header, 0, s3m_header, 0, 60 );
din.readFully( s3m_header, 60, 36 );
if( ScreamTracker3.is_s3m( s3m_header ) ) {
module = ScreamTracker3.load_s3m( s3m_header, din );
} else {
mod_header = new byte[ 1084 ];
System.arraycopy( s3m_header, 0, mod_header, 0, 96 );
din.readFully( mod_header, 96, 988 );
module = ProTracker.load_mod( mod_header, din );
}
}
din.close();
return module;
} | java | public static Module loadModule(InputStream in) throws IOException {
Module module;
DataInputStream din;
byte[] xm_header, s3m_header, mod_header, output_buffer;
int frames;
din = new DataInputStream(in);
module = null;
xm_header = new byte[ 60 ];
din.readFully( xm_header );
if( FastTracker2.is_xm( xm_header ) ) {
module = FastTracker2.load_xm( xm_header, din );
} else {
s3m_header = new byte[ 96 ];
System.arraycopy( xm_header, 0, s3m_header, 0, 60 );
din.readFully( s3m_header, 60, 36 );
if( ScreamTracker3.is_s3m( s3m_header ) ) {
module = ScreamTracker3.load_s3m( s3m_header, din );
} else {
mod_header = new byte[ 1084 ];
System.arraycopy( s3m_header, 0, mod_header, 0, 96 );
din.readFully( mod_header, 96, 988 );
module = ProTracker.load_mod( mod_header, din );
}
}
din.close();
return module;
} | [
"public",
"static",
"Module",
"loadModule",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"Module",
"module",
";",
"DataInputStream",
"din",
";",
"byte",
"[",
"]",
"xm_header",
",",
"s3m_header",
",",
"mod_header",
",",
"output_buffer",
";",
"int",
"frames",
";",
"din",
"=",
"new",
"DataInputStream",
"(",
"in",
")",
";",
"module",
"=",
"null",
";",
"xm_header",
"=",
"new",
"byte",
"[",
"60",
"]",
";",
"din",
".",
"readFully",
"(",
"xm_header",
")",
";",
"if",
"(",
"FastTracker2",
".",
"is_xm",
"(",
"xm_header",
")",
")",
"{",
"module",
"=",
"FastTracker2",
".",
"load_xm",
"(",
"xm_header",
",",
"din",
")",
";",
"}",
"else",
"{",
"s3m_header",
"=",
"new",
"byte",
"[",
"96",
"]",
";",
"System",
".",
"arraycopy",
"(",
"xm_header",
",",
"0",
",",
"s3m_header",
",",
"0",
",",
"60",
")",
";",
"din",
".",
"readFully",
"(",
"s3m_header",
",",
"60",
",",
"36",
")",
";",
"if",
"(",
"ScreamTracker3",
".",
"is_s3m",
"(",
"s3m_header",
")",
")",
"{",
"module",
"=",
"ScreamTracker3",
".",
"load_s3m",
"(",
"s3m_header",
",",
"din",
")",
";",
"}",
"else",
"{",
"mod_header",
"=",
"new",
"byte",
"[",
"1084",
"]",
";",
"System",
".",
"arraycopy",
"(",
"s3m_header",
",",
"0",
",",
"mod_header",
",",
"0",
",",
"96",
")",
";",
"din",
".",
"readFully",
"(",
"mod_header",
",",
"96",
",",
"988",
")",
";",
"module",
"=",
"ProTracker",
".",
"load_mod",
"(",
"mod_header",
",",
"din",
")",
";",
"}",
"}",
"din",
".",
"close",
"(",
")",
";",
"return",
"module",
";",
"}"
] | Load a module using the IBXM
@param in The input stream to read the module from
@return The module loaded
@throws IOException Indicates a failure to access the module | [
"Load",
"a",
"module",
"using",
"the",
"IBXM"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/ibxm/OpenALMODPlayer.java#L177-L207 |
1,820 | nguillaumin/slick2d-maven | slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/ImagePanel.java | ImagePanel.setImage | public void setImage(BufferedImage image) {
this.image = image;
setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
setSize(new Dimension(image.getWidth(), image.getHeight()));
getParent().repaint(0);
} | java | public void setImage(BufferedImage image) {
this.image = image;
setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
setSize(new Dimension(image.getWidth(), image.getHeight()));
getParent().repaint(0);
} | [
"public",
"void",
"setImage",
"(",
"BufferedImage",
"image",
")",
"{",
"this",
".",
"image",
"=",
"image",
";",
"setPreferredSize",
"(",
"new",
"Dimension",
"(",
"image",
".",
"getWidth",
"(",
")",
",",
"image",
".",
"getHeight",
"(",
")",
")",
")",
";",
"setSize",
"(",
"new",
"Dimension",
"(",
"image",
".",
"getWidth",
"(",
")",
",",
"image",
".",
"getHeight",
"(",
")",
")",
")",
";",
"getParent",
"(",
")",
".",
"repaint",
"(",
"0",
")",
";",
"}"
] | Set the image to be displayed
@param image The image to be displayed | [
"Set",
"the",
"image",
"to",
"be",
"displayed"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-scalar/src/main/java/org/newdawn/slick/tools/scalar/ImagePanel.java#L53-L58 |
1,821 | nguillaumin/slick2d-maven | slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/HieroConfig.java | HieroConfig.listFiles | public static File[] listFiles(final String ext) {
init();
return config.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(ext);
}
});
} | java | public static File[] listFiles(final String ext) {
init();
return config.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(ext);
}
});
} | [
"public",
"static",
"File",
"[",
"]",
"listFiles",
"(",
"final",
"String",
"ext",
")",
"{",
"init",
"(",
")",
";",
"return",
"config",
".",
"listFiles",
"(",
"new",
"FilenameFilter",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"File",
"dir",
",",
"String",
"name",
")",
"{",
"return",
"name",
".",
"endsWith",
"(",
"ext",
")",
";",
"}",
"}",
")",
";",
"}"
] | List the files with a given extension in the configuration directory
@param ext The extension to search for
@return The list of files from the configuration directory | [
"List",
"the",
"files",
"with",
"a",
"given",
"extension",
"in",
"the",
"configuration",
"directory"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-hiero/src/main/java/org/newdawn/slick/tools/hiero/HieroConfig.java#L50-L59 |
1,822 | nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java | MinMaxPanel.setEnabledForced | public void setEnabledForced(boolean e)
{
enabled.setEnabled(e);
minSpinner.setEnabled(e);
maxSpinner.setEnabled(e);
} | java | public void setEnabledForced(boolean e)
{
enabled.setEnabled(e);
minSpinner.setEnabled(e);
maxSpinner.setEnabled(e);
} | [
"public",
"void",
"setEnabledForced",
"(",
"boolean",
"e",
")",
"{",
"enabled",
".",
"setEnabled",
"(",
"e",
")",
";",
"minSpinner",
".",
"setEnabled",
"(",
"e",
")",
";",
"maxSpinner",
".",
"setEnabled",
"(",
"e",
")",
";",
"}"
] | Force the state of this component
@param e True if we want this component to be enabled | [
"Force",
"the",
"state",
"of",
"this",
"component"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java#L133-L138 |
1,823 | nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java | MinMaxPanel.setMin | public void setMin(int value) {
updateDisable = true;
minSpinner.setValue(new Integer(value));
updateDisable = false;
} | java | public void setMin(int value) {
updateDisable = true;
minSpinner.setValue(new Integer(value));
updateDisable = false;
} | [
"public",
"void",
"setMin",
"(",
"int",
"value",
")",
"{",
"updateDisable",
"=",
"true",
";",
"minSpinner",
".",
"setValue",
"(",
"new",
"Integer",
"(",
"value",
")",
")",
";",
"updateDisable",
"=",
"false",
";",
"}"
] | Set the minimum value
@param value The value to use as the lower bound | [
"Set",
"the",
"minimum",
"value"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java#L145-L149 |
1,824 | nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java | MinMaxPanel.setMax | public void setMax(int value) {
updateDisable = true;
maxSpinner.setValue(new Integer(value));
updateDisable = false;
} | java | public void setMax(int value) {
updateDisable = true;
maxSpinner.setValue(new Integer(value));
updateDisable = false;
} | [
"public",
"void",
"setMax",
"(",
"int",
"value",
")",
"{",
"updateDisable",
"=",
"true",
";",
"maxSpinner",
".",
"setValue",
"(",
"new",
"Integer",
"(",
"value",
")",
")",
";",
"updateDisable",
"=",
"false",
";",
"}"
] | Set the maximum value
@param value The value to use as the upper bound | [
"Set",
"the",
"maximum",
"value"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java#L156-L160 |
1,825 | nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java | MinMaxPanel.fireUpdated | void fireUpdated(Object source) {
if (updateDisable) {
return;
}
if (source == maxSpinner) {
if (getMax() < getMin()) {
setMin(getMax());
}
}
if (source == minSpinner) {
if (getMax() < getMin()) {
setMax(getMin());
}
}
for (int i=0;i<listeners.size();i++) {
((InputPanelListener) listeners.get(i)).minMaxUpdated(this);
}
} | java | void fireUpdated(Object source) {
if (updateDisable) {
return;
}
if (source == maxSpinner) {
if (getMax() < getMin()) {
setMin(getMax());
}
}
if (source == minSpinner) {
if (getMax() < getMin()) {
setMax(getMin());
}
}
for (int i=0;i<listeners.size();i++) {
((InputPanelListener) listeners.get(i)).minMaxUpdated(this);
}
} | [
"void",
"fireUpdated",
"(",
"Object",
"source",
")",
"{",
"if",
"(",
"updateDisable",
")",
"{",
"return",
";",
"}",
"if",
"(",
"source",
"==",
"maxSpinner",
")",
"{",
"if",
"(",
"getMax",
"(",
")",
"<",
"getMin",
"(",
")",
")",
"{",
"setMin",
"(",
"getMax",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"source",
"==",
"minSpinner",
")",
"{",
"if",
"(",
"getMax",
"(",
")",
"<",
"getMin",
"(",
")",
")",
"{",
"setMax",
"(",
"getMin",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"listeners",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"(",
"(",
"InputPanelListener",
")",
"listeners",
".",
"get",
"(",
"i",
")",
")",
".",
"minMaxUpdated",
"(",
"this",
")",
";",
"}",
"}"
] | Notify listeners a change has occured on this panel
@param source The source of this event | [
"Notify",
"listeners",
"a",
"change",
"has",
"occured",
"on",
"this",
"panel"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java#L185-L204 |
1,826 | nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java | MinMaxPanel.setEnabledValue | public void setEnabledValue(boolean e) {
if (enablement) {
enabled.setSelected(e);
}
minSpinner.setEnabled(enabled.isSelected() || !enablement);
maxSpinner.setEnabled(enabled.isSelected() || !enablement);
} | java | public void setEnabledValue(boolean e) {
if (enablement) {
enabled.setSelected(e);
}
minSpinner.setEnabled(enabled.isSelected() || !enablement);
maxSpinner.setEnabled(enabled.isSelected() || !enablement);
} | [
"public",
"void",
"setEnabledValue",
"(",
"boolean",
"e",
")",
"{",
"if",
"(",
"enablement",
")",
"{",
"enabled",
".",
"setSelected",
"(",
"e",
")",
";",
"}",
"minSpinner",
".",
"setEnabled",
"(",
"enabled",
".",
"isSelected",
"(",
")",
"||",
"!",
"enablement",
")",
";",
"maxSpinner",
".",
"setEnabled",
"(",
"enabled",
".",
"isSelected",
"(",
")",
"||",
"!",
"enablement",
")",
";",
"}"
] | Indicate if this panel should be enabled
@param e True if this panel option should be enabled | [
"Indicate",
"if",
"this",
"panel",
"should",
"be",
"enabled"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/MinMaxPanel.java#L220-L226 |
1,827 | nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/tiled/TileSet.java | TileSet.setTileSetImage | public void setTileSetImage(Image image) {
tiles = new SpriteSheet(image, tileWidth, tileHeight, tileSpacing,
tileMargin);
tilesAcross = tiles.getHorizontalCount();
tilesDown = tiles.getVerticalCount();
if (tilesAcross <= 0) {
tilesAcross = 1;
}
if (tilesDown <= 0) {
tilesDown = 1;
}
lastGID = (tilesAcross * tilesDown) + firstGID - 1;
} | java | public void setTileSetImage(Image image) {
tiles = new SpriteSheet(image, tileWidth, tileHeight, tileSpacing,
tileMargin);
tilesAcross = tiles.getHorizontalCount();
tilesDown = tiles.getVerticalCount();
if (tilesAcross <= 0) {
tilesAcross = 1;
}
if (tilesDown <= 0) {
tilesDown = 1;
}
lastGID = (tilesAcross * tilesDown) + firstGID - 1;
} | [
"public",
"void",
"setTileSetImage",
"(",
"Image",
"image",
")",
"{",
"tiles",
"=",
"new",
"SpriteSheet",
"(",
"image",
",",
"tileWidth",
",",
"tileHeight",
",",
"tileSpacing",
",",
"tileMargin",
")",
";",
"tilesAcross",
"=",
"tiles",
".",
"getHorizontalCount",
"(",
")",
";",
"tilesDown",
"=",
"tiles",
".",
"getVerticalCount",
"(",
")",
";",
"if",
"(",
"tilesAcross",
"<=",
"0",
")",
"{",
"tilesAcross",
"=",
"1",
";",
"}",
"if",
"(",
"tilesDown",
"<=",
"0",
")",
"{",
"tilesDown",
"=",
"1",
";",
"}",
"lastGID",
"=",
"(",
"tilesAcross",
"*",
"tilesDown",
")",
"+",
"firstGID",
"-",
"1",
";",
"}"
] | Set the image to use for this sprite sheet image to use for this tileset
@param image
The image to use for this tileset | [
"Set",
"the",
"image",
"to",
"use",
"for",
"this",
"sprite",
"sheet",
"image",
"to",
"use",
"for",
"this",
"tileset"
] | 8251f88a0ed6a70e726d2468842455cd1f80893f | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/tiled/TileSet.java#L197-L211 |
1,828 | MobiDevelop/android-split-pane-layout | split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java | SplitPaneLayout.remeasure | private void remeasure() {
// TODO: Performance: Guard against calling too often, can it be done without requestLayout?
forceLayout();
measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)
);
requestLayout();
} | java | private void remeasure() {
// TODO: Performance: Guard against calling too often, can it be done without requestLayout?
forceLayout();
measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)
);
requestLayout();
} | [
"private",
"void",
"remeasure",
"(",
")",
"{",
"// TODO: Performance: Guard against calling too often, can it be done without requestLayout?",
"forceLayout",
"(",
")",
";",
"measure",
"(",
"MeasureSpec",
".",
"makeMeasureSpec",
"(",
"getMeasuredWidth",
"(",
")",
",",
"MeasureSpec",
".",
"EXACTLY",
")",
",",
"MeasureSpec",
".",
"makeMeasureSpec",
"(",
"getMeasuredHeight",
"(",
")",
",",
"MeasureSpec",
".",
"EXACTLY",
")",
")",
";",
"requestLayout",
"(",
")",
";",
"}"
] | Convenience for calling own measure method. | [
"Convenience",
"for",
"calling",
"own",
"measure",
"method",
"."
] | 8148353ae986c1840f28cfc9095d140b3a9f7a75 | https://github.com/MobiDevelop/android-split-pane-layout/blob/8148353ae986c1840f28cfc9095d140b3a9f7a75/split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java#L427-L434 |
1,829 | MobiDevelop/android-split-pane-layout | split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java | SplitPaneLayout.setSplitterPosition | public void setSplitterPosition(int position) {
mSplitterPosition = clamp(position, 0, Integer.MAX_VALUE);
mSplitterPositionPercent = -1;
remeasure();
notifySplitterPositionChanged(false);
} | java | public void setSplitterPosition(int position) {
mSplitterPosition = clamp(position, 0, Integer.MAX_VALUE);
mSplitterPositionPercent = -1;
remeasure();
notifySplitterPositionChanged(false);
} | [
"public",
"void",
"setSplitterPosition",
"(",
"int",
"position",
")",
"{",
"mSplitterPosition",
"=",
"clamp",
"(",
"position",
",",
"0",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"mSplitterPositionPercent",
"=",
"-",
"1",
";",
"remeasure",
"(",
")",
";",
"notifySplitterPositionChanged",
"(",
"false",
")",
";",
"}"
] | Sets the current position of the splitter in pixels.
@param position the desired position of the splitter | [
"Sets",
"the",
"current",
"position",
"of",
"the",
"splitter",
"in",
"pixels",
"."
] | 8148353ae986c1840f28cfc9095d140b3a9f7a75 | https://github.com/MobiDevelop/android-split-pane-layout/blob/8148353ae986c1840f28cfc9095d140b3a9f7a75/split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java#L582-L587 |
1,830 | MobiDevelop/android-split-pane-layout | split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java | SplitPaneLayout.setSplitterPositionPercent | public void setSplitterPositionPercent(float position) {
mSplitterPosition = Integer.MIN_VALUE;
mSplitterPositionPercent = clamp(position, 0, 1);
remeasure();
notifySplitterPositionChanged(false);
} | java | public void setSplitterPositionPercent(float position) {
mSplitterPosition = Integer.MIN_VALUE;
mSplitterPositionPercent = clamp(position, 0, 1);
remeasure();
notifySplitterPositionChanged(false);
} | [
"public",
"void",
"setSplitterPositionPercent",
"(",
"float",
"position",
")",
"{",
"mSplitterPosition",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"mSplitterPositionPercent",
"=",
"clamp",
"(",
"position",
",",
"0",
",",
"1",
")",
";",
"remeasure",
"(",
")",
";",
"notifySplitterPositionChanged",
"(",
"false",
")",
";",
"}"
] | Sets the current position of the splitter as a percentage of the layout.
@param position the desired position of the splitter | [
"Sets",
"the",
"current",
"position",
"of",
"the",
"splitter",
"as",
"a",
"percentage",
"of",
"the",
"layout",
"."
] | 8148353ae986c1840f28cfc9095d140b3a9f7a75 | https://github.com/MobiDevelop/android-split-pane-layout/blob/8148353ae986c1840f28cfc9095d140b3a9f7a75/split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java#L603-L608 |
1,831 | MobiDevelop/android-split-pane-layout | split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java | SplitPaneLayout.setPaneSizeMin | public void setPaneSizeMin(int paneSizeMin) {
mPaneSizeMin = paneSizeMin;
if (isMeasured) {
int newSplitterPosition = clamp(mSplitterPosition, getMinSplitterPosition(), getMaxSplitterPosition());
if(newSplitterPosition != mSplitterPosition) {
setSplitterPosition(newSplitterPosition);
}
}
} | java | public void setPaneSizeMin(int paneSizeMin) {
mPaneSizeMin = paneSizeMin;
if (isMeasured) {
int newSplitterPosition = clamp(mSplitterPosition, getMinSplitterPosition(), getMaxSplitterPosition());
if(newSplitterPosition != mSplitterPosition) {
setSplitterPosition(newSplitterPosition);
}
}
} | [
"public",
"void",
"setPaneSizeMin",
"(",
"int",
"paneSizeMin",
")",
"{",
"mPaneSizeMin",
"=",
"paneSizeMin",
";",
"if",
"(",
"isMeasured",
")",
"{",
"int",
"newSplitterPosition",
"=",
"clamp",
"(",
"mSplitterPosition",
",",
"getMinSplitterPosition",
"(",
")",
",",
"getMaxSplitterPosition",
"(",
")",
")",
";",
"if",
"(",
"newSplitterPosition",
"!=",
"mSplitterPosition",
")",
"{",
"setSplitterPosition",
"(",
"newSplitterPosition",
")",
";",
"}",
"}",
"}"
] | Sets the minimum size of panes, in pixels.
@param paneSizeMin the minimum size of panes, in pixels | [
"Sets",
"the",
"minimum",
"size",
"of",
"panes",
"in",
"pixels",
"."
] | 8148353ae986c1840f28cfc9095d140b3a9f7a75 | https://github.com/MobiDevelop/android-split-pane-layout/blob/8148353ae986c1840f28cfc9095d140b3a9f7a75/split-pane-layout/src/main/java/com/mobidevelop/spl/widget/SplitPaneLayout.java#L645-L653 |
1,832 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java | PublicDiffCriteria.differs | public boolean differs(ClassInfo oldInfo, ClassInfo newInfo) {
if (Tools.isClassAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
// Yes classes can have a null supername, e.g. java.lang.Object !
if(oldInfo.getSupername() == null) {
if(newInfo.getSupername() != null) {
return true;
}
} else if (!oldInfo.getSupername().equals(newInfo.getSupername())) {
return true;
}
final Set<String> oldInterfaces
= new HashSet(Arrays.asList(oldInfo.getInterfaces()));
final Set<String> newInterfaces
= new HashSet(Arrays.asList(newInfo.getInterfaces()));
if (!oldInterfaces.equals(newInterfaces))
return true;
return false;
} | java | public boolean differs(ClassInfo oldInfo, ClassInfo newInfo) {
if (Tools.isClassAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
// Yes classes can have a null supername, e.g. java.lang.Object !
if(oldInfo.getSupername() == null) {
if(newInfo.getSupername() != null) {
return true;
}
} else if (!oldInfo.getSupername().equals(newInfo.getSupername())) {
return true;
}
final Set<String> oldInterfaces
= new HashSet(Arrays.asList(oldInfo.getInterfaces()));
final Set<String> newInterfaces
= new HashSet(Arrays.asList(newInfo.getInterfaces()));
if (!oldInterfaces.equals(newInterfaces))
return true;
return false;
} | [
"public",
"boolean",
"differs",
"(",
"ClassInfo",
"oldInfo",
",",
"ClassInfo",
"newInfo",
")",
"{",
"if",
"(",
"Tools",
".",
"isClassAccessChange",
"(",
"oldInfo",
".",
"getAccess",
"(",
")",
",",
"newInfo",
".",
"getAccess",
"(",
")",
")",
")",
"return",
"true",
";",
"// Yes classes can have a null supername, e.g. java.lang.Object !",
"if",
"(",
"oldInfo",
".",
"getSupername",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"newInfo",
".",
"getSupername",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"oldInfo",
".",
"getSupername",
"(",
")",
".",
"equals",
"(",
"newInfo",
".",
"getSupername",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"final",
"Set",
"<",
"String",
">",
"oldInterfaces",
"=",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"oldInfo",
".",
"getInterfaces",
"(",
")",
")",
")",
";",
"final",
"Set",
"<",
"String",
">",
"newInterfaces",
"=",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"newInfo",
".",
"getInterfaces",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"oldInterfaces",
".",
"equals",
"(",
"newInterfaces",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Check if there is a change between two versions of a class.
Returns true if the access flags differ, or if the superclass differs
or if the implemented interfaces differ.
@param oldInfo Info about the old version of the class.
@param newInfo Info about the new version of the class.
@return True if the classes differ, false otherwise. | [
"Check",
"if",
"there",
"is",
"a",
"change",
"between",
"two",
"versions",
"of",
"a",
"class",
".",
"Returns",
"true",
"if",
"the",
"access",
"flags",
"differ",
"or",
"if",
"the",
"superclass",
"differs",
"or",
"if",
"the",
"implemented",
"interfaces",
"differ",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java#L73-L91 |
1,833 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java | PublicDiffCriteria.differs | public boolean differs(MethodInfo oldInfo, MethodInfo newInfo) {
if (Tools.isMethodAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getExceptions() == null
|| newInfo.getExceptions() == null) {
if (oldInfo.getExceptions() != newInfo.getExceptions())
return true;
} else {
final Set<String> oldExceptions
= new HashSet(Arrays.asList(oldInfo.getExceptions()));
final Set<String> newExceptions
= new HashSet(Arrays.asList(newInfo.getExceptions()));
if (!oldExceptions.equals(newExceptions))
return true;
}
return false;
} | java | public boolean differs(MethodInfo oldInfo, MethodInfo newInfo) {
if (Tools.isMethodAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getExceptions() == null
|| newInfo.getExceptions() == null) {
if (oldInfo.getExceptions() != newInfo.getExceptions())
return true;
} else {
final Set<String> oldExceptions
= new HashSet(Arrays.asList(oldInfo.getExceptions()));
final Set<String> newExceptions
= new HashSet(Arrays.asList(newInfo.getExceptions()));
if (!oldExceptions.equals(newExceptions))
return true;
}
return false;
} | [
"public",
"boolean",
"differs",
"(",
"MethodInfo",
"oldInfo",
",",
"MethodInfo",
"newInfo",
")",
"{",
"if",
"(",
"Tools",
".",
"isMethodAccessChange",
"(",
"oldInfo",
".",
"getAccess",
"(",
")",
",",
"newInfo",
".",
"getAccess",
"(",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"oldInfo",
".",
"getExceptions",
"(",
")",
"==",
"null",
"||",
"newInfo",
".",
"getExceptions",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"oldInfo",
".",
"getExceptions",
"(",
")",
"!=",
"newInfo",
".",
"getExceptions",
"(",
")",
")",
"return",
"true",
";",
"}",
"else",
"{",
"final",
"Set",
"<",
"String",
">",
"oldExceptions",
"=",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"oldInfo",
".",
"getExceptions",
"(",
")",
")",
")",
";",
"final",
"Set",
"<",
"String",
">",
"newExceptions",
"=",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"newInfo",
".",
"getExceptions",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"oldExceptions",
".",
"equals",
"(",
"newExceptions",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Check if there is a change between two versions of a method.
Returns true if the access flags differ, or if the thrown
exceptions differ.
@param oldInfo Info about the old version of the method.
@param newInfo Info about the new version of the method.
@return True if the methods differ, false otherwise. | [
"Check",
"if",
"there",
"is",
"a",
"change",
"between",
"two",
"versions",
"of",
"a",
"method",
".",
"Returns",
"true",
"if",
"the",
"access",
"flags",
"differ",
"or",
"if",
"the",
"thrown",
"exceptions",
"differ",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java#L102-L118 |
1,834 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java | PublicDiffCriteria.differs | public boolean differs(FieldInfo oldInfo, FieldInfo newInfo) {
if (Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getValue() == null || newInfo.getValue() == null) {
if (oldInfo.getValue() != newInfo.getValue())
return true;
} else if (!oldInfo.getValue().equals(newInfo.getValue()))
return true;
return false;
} | java | public boolean differs(FieldInfo oldInfo, FieldInfo newInfo) {
if (Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getValue() == null || newInfo.getValue() == null) {
if (oldInfo.getValue() != newInfo.getValue())
return true;
} else if (!oldInfo.getValue().equals(newInfo.getValue()))
return true;
return false;
} | [
"public",
"boolean",
"differs",
"(",
"FieldInfo",
"oldInfo",
",",
"FieldInfo",
"newInfo",
")",
"{",
"if",
"(",
"Tools",
".",
"isFieldAccessChange",
"(",
"oldInfo",
".",
"getAccess",
"(",
")",
",",
"newInfo",
".",
"getAccess",
"(",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"oldInfo",
".",
"getValue",
"(",
")",
"==",
"null",
"||",
"newInfo",
".",
"getValue",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"oldInfo",
".",
"getValue",
"(",
")",
"!=",
"newInfo",
".",
"getValue",
"(",
")",
")",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"!",
"oldInfo",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"newInfo",
".",
"getValue",
"(",
")",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Check if there is a change between two versions of a field.
Returns true if the access flags differ, or if the inital value
of the field differs.
@param oldInfo Info about the old version of the field.
@param newInfo Info about the new version of the field.
@return True if the fields differ, false otherwise. | [
"Check",
"if",
"there",
"is",
"a",
"change",
"between",
"two",
"versions",
"of",
"a",
"field",
".",
"Returns",
"true",
"if",
"the",
"access",
"flags",
"differ",
"or",
"if",
"the",
"inital",
"value",
"of",
"the",
"field",
"differs",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java#L129-L138 |
1,835 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/ClassInfoVisitor.java | ClassInfoVisitor.getClassInfo | public ClassInfo getClassInfo() {
return new ClassInfo(version, access, name, signature, supername,
interfaces, methodMap, fieldMap);
} | java | public ClassInfo getClassInfo() {
return new ClassInfo(version, access, name, signature, supername,
interfaces, methodMap, fieldMap);
} | [
"public",
"ClassInfo",
"getClassInfo",
"(",
")",
"{",
"return",
"new",
"ClassInfo",
"(",
"version",
",",
"access",
",",
"name",
",",
"signature",
",",
"supername",
",",
"interfaces",
",",
"methodMap",
",",
"fieldMap",
")",
";",
"}"
] | The the classInfo this ClassInfoVisitor has built up about a class | [
"The",
"the",
"classInfo",
"this",
"ClassInfoVisitor",
"has",
"built",
"up",
"about",
"a",
"class"
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/ClassInfoVisitor.java#L91-L94 |
1,836 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/ClassInfoVisitor.java | ClassInfoVisitor.visit | public void visit(int version, int access, String name, String signature,
String supername, String[] interfaces) {
this.version = version;
this.access = access;
this.name = name;
this.signature = signature;
this.supername = supername;
this.interfaces = interfaces;
} | java | public void visit(int version, int access, String name, String signature,
String supername, String[] interfaces) {
this.version = version;
this.access = access;
this.name = name;
this.signature = signature;
this.supername = supername;
this.interfaces = interfaces;
} | [
"public",
"void",
"visit",
"(",
"int",
"version",
",",
"int",
"access",
",",
"String",
"name",
",",
"String",
"signature",
",",
"String",
"supername",
",",
"String",
"[",
"]",
"interfaces",
")",
"{",
"this",
".",
"version",
"=",
"version",
";",
"this",
".",
"access",
"=",
"access",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"signature",
"=",
"signature",
";",
"this",
".",
"supername",
"=",
"supername",
";",
"this",
".",
"interfaces",
"=",
"interfaces",
";",
"}"
] | Receive notification of information about a class from ASM.
@param version the class file version number.
@param access the access flags for the class.
@param name the internal name of the class.
@param signature the signature of the class.
@param supername the internal name of the super class.
@param interfaces the internal names of interfaces implemented. | [
"Receive",
"notification",
"of",
"information",
"about",
"a",
"class",
"from",
"ASM",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/ClassInfoVisitor.java#L106-L114 |
1,837 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/JarDiff.java | JarDiff.loadClassInfo | public synchronized ClassInfo loadClassInfo(ClassReader reader)
throws IOException
{
infoVisitor.reset();
reader.accept(infoVisitor, 0);
return infoVisitor.getClassInfo();
} | java | public synchronized ClassInfo loadClassInfo(ClassReader reader)
throws IOException
{
infoVisitor.reset();
reader.accept(infoVisitor, 0);
return infoVisitor.getClassInfo();
} | [
"public",
"synchronized",
"ClassInfo",
"loadClassInfo",
"(",
"ClassReader",
"reader",
")",
"throws",
"IOException",
"{",
"infoVisitor",
".",
"reset",
"(",
")",
";",
"reader",
".",
"accept",
"(",
"infoVisitor",
",",
"0",
")",
";",
"return",
"infoVisitor",
".",
"getClassInfo",
"(",
")",
";",
"}"
] | Load classinfo given a ClassReader.
@param reader the ClassReader
@return the ClassInfo | [
"Load",
"classinfo",
"given",
"a",
"ClassReader",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/JarDiff.java#L160-L166 |
1,838 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/JarDiff.java | JarDiff.diff | public void diff(DiffHandler handler, DiffCriteria criteria)
throws DiffException
{
diff(handler, criteria, oldVersion, newVersion, oldClassInfo, newClassInfo);
} | java | public void diff(DiffHandler handler, DiffCriteria criteria)
throws DiffException
{
diff(handler, criteria, oldVersion, newVersion, oldClassInfo, newClassInfo);
} | [
"public",
"void",
"diff",
"(",
"DiffHandler",
"handler",
",",
"DiffCriteria",
"criteria",
")",
"throws",
"DiffException",
"{",
"diff",
"(",
"handler",
",",
"criteria",
",",
"oldVersion",
",",
"newVersion",
",",
"oldClassInfo",
",",
"newClassInfo",
")",
";",
"}"
] | Perform a diff sending the output to the specified handler, using
the specified criteria to select diffs.
@param handler The handler to receive and handle differences.
@param criteria The criteria we use to select differences.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Perform",
"a",
"diff",
"sending",
"the",
"output",
"to",
"the",
"specified",
"handler",
"using",
"the",
"specified",
"criteria",
"to",
"select",
"diffs",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/JarDiff.java#L285-L289 |
1,839 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/JarDiff.java | JarDiff.cloneDeprecated | private static ClassInfo cloneDeprecated(ClassInfo classInfo) {
return new ClassInfo(classInfo.getVersion(), classInfo.getAccess()
| Opcodes.ACC_DEPRECATED, classInfo.getName(),
classInfo.getSignature(), classInfo.getSupername(),
classInfo.getInterfaces(), classInfo.getMethodMap(),
classInfo.getFieldMap());
} | java | private static ClassInfo cloneDeprecated(ClassInfo classInfo) {
return new ClassInfo(classInfo.getVersion(), classInfo.getAccess()
| Opcodes.ACC_DEPRECATED, classInfo.getName(),
classInfo.getSignature(), classInfo.getSupername(),
classInfo.getInterfaces(), classInfo.getMethodMap(),
classInfo.getFieldMap());
} | [
"private",
"static",
"ClassInfo",
"cloneDeprecated",
"(",
"ClassInfo",
"classInfo",
")",
"{",
"return",
"new",
"ClassInfo",
"(",
"classInfo",
".",
"getVersion",
"(",
")",
",",
"classInfo",
".",
"getAccess",
"(",
")",
"|",
"Opcodes",
".",
"ACC_DEPRECATED",
",",
"classInfo",
".",
"getName",
"(",
")",
",",
"classInfo",
".",
"getSignature",
"(",
")",
",",
"classInfo",
".",
"getSupername",
"(",
")",
",",
"classInfo",
".",
"getInterfaces",
"(",
")",
",",
"classInfo",
".",
"getMethodMap",
"(",
")",
",",
"classInfo",
".",
"getFieldMap",
"(",
")",
")",
";",
"}"
] | Clones the class info, but changes access, setting deprecated flag.
@param classInfo
the original class info
@return the cloned and deprecated info. | [
"Clones",
"the",
"class",
"info",
"but",
"changes",
"access",
"setting",
"deprecated",
"flag",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/JarDiff.java#L520-L526 |
1,840 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/JarDiff.java | JarDiff.cloneDeprecated | private static MethodInfo cloneDeprecated(MethodInfo methodInfo) {
return new MethodInfo(methodInfo.getAccess() | Opcodes.ACC_DEPRECATED,
methodInfo.getName(), methodInfo.getDesc(),
methodInfo.getSignature(), methodInfo.getExceptions());
} | java | private static MethodInfo cloneDeprecated(MethodInfo methodInfo) {
return new MethodInfo(methodInfo.getAccess() | Opcodes.ACC_DEPRECATED,
methodInfo.getName(), methodInfo.getDesc(),
methodInfo.getSignature(), methodInfo.getExceptions());
} | [
"private",
"static",
"MethodInfo",
"cloneDeprecated",
"(",
"MethodInfo",
"methodInfo",
")",
"{",
"return",
"new",
"MethodInfo",
"(",
"methodInfo",
".",
"getAccess",
"(",
")",
"|",
"Opcodes",
".",
"ACC_DEPRECATED",
",",
"methodInfo",
".",
"getName",
"(",
")",
",",
"methodInfo",
".",
"getDesc",
"(",
")",
",",
"methodInfo",
".",
"getSignature",
"(",
")",
",",
"methodInfo",
".",
"getExceptions",
"(",
")",
")",
";",
"}"
] | Clones the method, but changes access, setting deprecated flag.
@param methodInfo
the original method info
@return the cloned and deprecated method info. | [
"Clones",
"the",
"method",
"but",
"changes",
"access",
"setting",
"deprecated",
"flag",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/JarDiff.java#L535-L539 |
1,841 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/JarDiff.java | JarDiff.cloneDeprecated | private static FieldInfo cloneDeprecated(FieldInfo fieldInfo) {
return new FieldInfo(fieldInfo.getAccess() | Opcodes.ACC_DEPRECATED,
fieldInfo.getName(), fieldInfo.getDesc(),
fieldInfo.getSignature(), fieldInfo.getValue());
} | java | private static FieldInfo cloneDeprecated(FieldInfo fieldInfo) {
return new FieldInfo(fieldInfo.getAccess() | Opcodes.ACC_DEPRECATED,
fieldInfo.getName(), fieldInfo.getDesc(),
fieldInfo.getSignature(), fieldInfo.getValue());
} | [
"private",
"static",
"FieldInfo",
"cloneDeprecated",
"(",
"FieldInfo",
"fieldInfo",
")",
"{",
"return",
"new",
"FieldInfo",
"(",
"fieldInfo",
".",
"getAccess",
"(",
")",
"|",
"Opcodes",
".",
"ACC_DEPRECATED",
",",
"fieldInfo",
".",
"getName",
"(",
")",
",",
"fieldInfo",
".",
"getDesc",
"(",
")",
",",
"fieldInfo",
".",
"getSignature",
"(",
")",
",",
"fieldInfo",
".",
"getValue",
"(",
")",
")",
";",
"}"
] | Clones the field info, but changes access, setting deprecated flag.
@param fieldInfo
the original field info
@return the cloned and deprecated field info. | [
"Clones",
"the",
"field",
"info",
"but",
"changes",
"access",
"setting",
"deprecated",
"flag",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/JarDiff.java#L548-L552 |
1,842 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.startDiff | public void startDiff(String oldJar, String newJar) throws DiffException {
Element tmp = doc.createElementNS(XML_URI, "diff");
tmp.setAttribute( "old", oldJar);
tmp.setAttribute( "new", newJar);
doc.appendChild(tmp);
currentNode = tmp;
} | java | public void startDiff(String oldJar, String newJar) throws DiffException {
Element tmp = doc.createElementNS(XML_URI, "diff");
tmp.setAttribute( "old", oldJar);
tmp.setAttribute( "new", newJar);
doc.appendChild(tmp);
currentNode = tmp;
} | [
"public",
"void",
"startDiff",
"(",
"String",
"oldJar",
",",
"String",
"newJar",
")",
"throws",
"DiffException",
"{",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"diff\"",
")",
";",
"tmp",
".",
"setAttribute",
"(",
"\"old\"",
",",
"oldJar",
")",
";",
"tmp",
".",
"setAttribute",
"(",
"\"new\"",
",",
"newJar",
")",
";",
"doc",
".",
"appendChild",
"(",
"tmp",
")",
";",
"currentNode",
"=",
"tmp",
";",
"}"
] | Start the diff.
This writes out the start of a <diff> node.
@param oldJar ignored
@param newJar ignored
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Start",
"the",
"diff",
".",
"This",
"writes",
"out",
"the",
"start",
"of",
"a",
"<",
";",
"diff>",
";",
"node",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L127-L133 |
1,843 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.contains | public void contains(ClassInfo info) throws DiffException {
Element tmp = doc.createElementNS(XML_URI, "class");
tmp.setAttribute("name", info.getName());
currentNode.appendChild(tmp);
} | java | public void contains(ClassInfo info) throws DiffException {
Element tmp = doc.createElementNS(XML_URI, "class");
tmp.setAttribute("name", info.getName());
currentNode.appendChild(tmp);
} | [
"public",
"void",
"contains",
"(",
"ClassInfo",
"info",
")",
"throws",
"DiffException",
"{",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"class\"",
")",
";",
"tmp",
".",
"setAttribute",
"(",
"\"name\"",
",",
"info",
".",
"getName",
"(",
")",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"}"
] | Add a contained class.
@param info information about a class
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Add",
"a",
"contained",
"class",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L166-L170 |
1,844 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.startAdded | public void startAdded() throws DiffException {
Element tmp = doc.createElementNS(XML_URI, "added");
currentNode.appendChild(tmp);
currentNode = tmp;
} | java | public void startAdded() throws DiffException {
Element tmp = doc.createElementNS(XML_URI, "added");
currentNode.appendChild(tmp);
currentNode = tmp;
} | [
"public",
"void",
"startAdded",
"(",
")",
"throws",
"DiffException",
"{",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"added\"",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"currentNode",
"=",
"tmp",
";",
"}"
] | Start the added section.
This opens the <added> tag.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Start",
"the",
"added",
"section",
".",
"This",
"opens",
"the",
"<",
";",
"added>",
";",
"tag",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L235-L239 |
1,845 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.startClassChanged | public void startClassChanged(String internalName) throws DiffException
{
Element tmp = doc.createElementNS(XML_URI, "classchanged");
tmp.setAttribute( "name", internalName);
currentNode.appendChild(tmp);
currentNode = tmp;
} | java | public void startClassChanged(String internalName) throws DiffException
{
Element tmp = doc.createElementNS(XML_URI, "classchanged");
tmp.setAttribute( "name", internalName);
currentNode.appendChild(tmp);
currentNode = tmp;
} | [
"public",
"void",
"startClassChanged",
"(",
"String",
"internalName",
")",
"throws",
"DiffException",
"{",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"classchanged\"",
")",
";",
"tmp",
".",
"setAttribute",
"(",
"\"name\"",
",",
"internalName",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"currentNode",
"=",
"tmp",
";",
"}"
] | Start a changed section for an individual class.
This writes out an <classchanged> node with the real class
name as the name attribute.
@param internalName the internal name of the class that has changed.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Start",
"a",
"changed",
"section",
"for",
"an",
"individual",
"class",
".",
"This",
"writes",
"out",
"an",
"<",
";",
"classchanged>",
";",
"node",
"with",
"the",
"real",
"class",
"name",
"as",
"the",
"name",
"attribute",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L286-L292 |
1,846 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.classChanged | public void classChanged(ClassInfo oldInfo, ClassInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "classchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeClassInfo(oldInfo);
this.currentNode = to;
writeClassInfo(newInfo);
this.currentNode = currentNode;
} | java | public void classChanged(ClassInfo oldInfo, ClassInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "classchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeClassInfo(oldInfo);
this.currentNode = to;
writeClassInfo(newInfo);
this.currentNode = currentNode;
} | [
"public",
"void",
"classChanged",
"(",
"ClassInfo",
"oldInfo",
",",
"ClassInfo",
"newInfo",
")",
"throws",
"DiffException",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"classchange\"",
")",
";",
"Element",
"from",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"from\"",
")",
";",
"Element",
"to",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"to\"",
")",
";",
"tmp",
".",
"appendChild",
"(",
"from",
")",
";",
"tmp",
".",
"appendChild",
"(",
"to",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"this",
".",
"currentNode",
"=",
"from",
";",
"writeClassInfo",
"(",
"oldInfo",
")",
";",
"this",
".",
"currentNode",
"=",
"to",
";",
"writeClassInfo",
"(",
"newInfo",
")",
";",
"this",
".",
"currentNode",
"=",
"currentNode",
";",
"}"
] | Write out info aboout a changed class.
This writes out a <classchange> node, followed by a
<from> node, with the old information about the class
followed by a <to> node with the new information about the
class.
@param oldInfo Info about the old class.
@param newInfo Info about the new class.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Write",
"out",
"info",
"aboout",
"a",
"changed",
"class",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"classchange>",
";",
"node",
"followed",
"by",
"a",
"<",
";",
"from>",
";",
"node",
"with",
"the",
"old",
"information",
"about",
"the",
"class",
"followed",
"by",
"a",
"<",
";",
"to>",
";",
"node",
"with",
"the",
"new",
"information",
"about",
"the",
"class",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L358-L373 |
1,847 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.fieldChanged | public void fieldChanged(FieldInfo oldInfo, FieldInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "fieldchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeFieldInfo(oldInfo);
this.currentNode = to;
writeFieldInfo(newInfo);
this.currentNode = currentNode;
} | java | public void fieldChanged(FieldInfo oldInfo, FieldInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "fieldchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeFieldInfo(oldInfo);
this.currentNode = to;
writeFieldInfo(newInfo);
this.currentNode = currentNode;
} | [
"public",
"void",
"fieldChanged",
"(",
"FieldInfo",
"oldInfo",
",",
"FieldInfo",
"newInfo",
")",
"throws",
"DiffException",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"fieldchange\"",
")",
";",
"Element",
"from",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"from\"",
")",
";",
"Element",
"to",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"to\"",
")",
";",
"tmp",
".",
"appendChild",
"(",
"from",
")",
";",
"tmp",
".",
"appendChild",
"(",
"to",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"this",
".",
"currentNode",
"=",
"from",
";",
"writeFieldInfo",
"(",
"oldInfo",
")",
";",
"this",
".",
"currentNode",
"=",
"to",
";",
"writeFieldInfo",
"(",
"newInfo",
")",
";",
"this",
".",
"currentNode",
"=",
"currentNode",
";",
"}"
] | Write out info aboout a changed field.
This writes out a <fieldchange> node, followed by a
<from> node, with the old information about the field
followed by a <to> node with the new information about the
field.
@param oldInfo Info about the old field.
@param newInfo Info about the new field.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Write",
"out",
"info",
"aboout",
"a",
"changed",
"field",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"fieldchange>",
";",
"node",
"followed",
"by",
"a",
"<",
";",
"from>",
";",
"node",
"with",
"the",
"old",
"information",
"about",
"the",
"field",
"followed",
"by",
"a",
"<",
";",
"to>",
";",
"node",
"with",
"the",
"new",
"information",
"about",
"the",
"field",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L396-L411 |
1,848 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.methodChanged | public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "methodchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeMethodInfo(oldInfo);
this.currentNode = to;
writeMethodInfo(newInfo);
this.currentNode = currentNode;
} | java | public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo)
throws DiffException
{
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "methodchange");
Element from = doc.createElementNS(XML_URI, "from");
Element to = doc.createElementNS(XML_URI, "to");
tmp.appendChild(from);
tmp.appendChild(to);
currentNode.appendChild(tmp);
this.currentNode = from;
writeMethodInfo(oldInfo);
this.currentNode = to;
writeMethodInfo(newInfo);
this.currentNode = currentNode;
} | [
"public",
"void",
"methodChanged",
"(",
"MethodInfo",
"oldInfo",
",",
"MethodInfo",
"newInfo",
")",
"throws",
"DiffException",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"methodchange\"",
")",
";",
"Element",
"from",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"from\"",
")",
";",
"Element",
"to",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"to\"",
")",
";",
"tmp",
".",
"appendChild",
"(",
"from",
")",
";",
"tmp",
".",
"appendChild",
"(",
"to",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"this",
".",
"currentNode",
"=",
"from",
";",
"writeMethodInfo",
"(",
"oldInfo",
")",
";",
"this",
".",
"currentNode",
"=",
"to",
";",
"writeMethodInfo",
"(",
"newInfo",
")",
";",
"this",
".",
"currentNode",
"=",
"currentNode",
";",
"}"
] | Write out info aboout a changed method.
This writes out a <methodchange> node, followed by a
<from> node, with the old information about the method
followed by a <to> node with the new information about the
method.
@param oldInfo Info about the old method.
@param newInfo Info about the new method.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"Write",
"out",
"info",
"aboout",
"a",
"changed",
"method",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"methodchange>",
";",
"node",
"followed",
"by",
"a",
"<",
";",
"from>",
";",
"node",
"with",
"the",
"old",
"information",
"about",
"the",
"method",
"followed",
"by",
"a",
"<",
";",
"to>",
";",
"node",
"with",
"the",
"new",
"information",
"about",
"the",
"method",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L433-L448 |
1,849 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.endDiff | public void endDiff() throws DiffException {
DOMSource source = new DOMSource(doc);
try {
transformer.transform(source, result);
} catch (TransformerException te) {
throw new DiffException(te);
}
} | java | public void endDiff() throws DiffException {
DOMSource source = new DOMSource(doc);
try {
transformer.transform(source, result);
} catch (TransformerException te) {
throw new DiffException(te);
}
} | [
"public",
"void",
"endDiff",
"(",
")",
"throws",
"DiffException",
"{",
"DOMSource",
"source",
"=",
"new",
"DOMSource",
"(",
"doc",
")",
";",
"try",
"{",
"transformer",
".",
"transform",
"(",
"source",
",",
"result",
")",
";",
"}",
"catch",
"(",
"TransformerException",
"te",
")",
"{",
"throw",
"new",
"DiffException",
"(",
"te",
")",
";",
"}",
"}"
] | End the diff.
This closes the <diff> node.
@throws DiffException when there is an underlying exception, e.g.
writing to a file caused an IOException | [
"End",
"the",
"diff",
".",
"This",
"closes",
"the",
"<",
";",
"diff>",
";",
"node",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L488-L495 |
1,850 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.writeClassInfo | protected void writeClassInfo(ClassInfo info) {
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "class");
currentNode.appendChild(tmp);
this.currentNode = tmp;
addAccessFlags(info);
if (info.getName() != null)
tmp.setAttribute( "name",
info.getName());
if (info.getSignature() != null)
tmp.setAttribute( "signature",
info.getSignature());
if (info.getSupername() != null)
tmp.setAttribute( "superclass",
info.getSupername());
String[] interfaces = info.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
Element iface = doc.createElementNS(XML_URI, "implements");
tmp.appendChild(iface);
iface.setAttribute( "name",
interfaces[i]);
}
this.currentNode = currentNode;
} | java | protected void writeClassInfo(ClassInfo info) {
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "class");
currentNode.appendChild(tmp);
this.currentNode = tmp;
addAccessFlags(info);
if (info.getName() != null)
tmp.setAttribute( "name",
info.getName());
if (info.getSignature() != null)
tmp.setAttribute( "signature",
info.getSignature());
if (info.getSupername() != null)
tmp.setAttribute( "superclass",
info.getSupername());
String[] interfaces = info.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
Element iface = doc.createElementNS(XML_URI, "implements");
tmp.appendChild(iface);
iface.setAttribute( "name",
interfaces[i]);
}
this.currentNode = currentNode;
} | [
"protected",
"void",
"writeClassInfo",
"(",
"ClassInfo",
"info",
")",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"class\"",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"this",
".",
"currentNode",
"=",
"tmp",
";",
"addAccessFlags",
"(",
"info",
")",
";",
"if",
"(",
"info",
".",
"getName",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"name\"",
",",
"info",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getSignature",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"signature\"",
",",
"info",
".",
"getSignature",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getSupername",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"superclass\"",
",",
"info",
".",
"getSupername",
"(",
")",
")",
";",
"String",
"[",
"]",
"interfaces",
"=",
"info",
".",
"getInterfaces",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"interfaces",
".",
"length",
";",
"i",
"++",
")",
"{",
"Element",
"iface",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"implements\"",
")",
";",
"tmp",
".",
"appendChild",
"(",
"iface",
")",
";",
"iface",
".",
"setAttribute",
"(",
"\"name\"",
",",
"interfaces",
"[",
"i",
"]",
")",
";",
"}",
"this",
".",
"currentNode",
"=",
"currentNode",
";",
"}"
] | Write out information about a class.
This writes out a <class> node, which contains information about
what interfaces are implemented each in a <implements> node.
@param info Info about the class to write out. | [
"Write",
"out",
"information",
"about",
"a",
"class",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"class>",
";",
"node",
"which",
"contains",
"information",
"about",
"what",
"interfaces",
"are",
"implemented",
"each",
"in",
"a",
"<",
";",
"implements>",
";",
"node",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L504-L527 |
1,851 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.writeMethodInfo | protected void writeMethodInfo(MethodInfo info) {
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "method");
currentNode.appendChild(tmp);
this.currentNode = tmp;
addAccessFlags(info);
if (info.getName() != null)
tmp.setAttribute( "name", info.getName());
if (info.getSignature() != null)
tmp.setAttribute( "signature", info.getSignature());
if (info.getDesc() != null)
addMethodNodes(info.getDesc());
String[] exceptions = info.getExceptions();
if (exceptions != null) {
for (int i = 0; i < exceptions.length; i++) {
Element excep = doc.createElementNS(XML_URI, "exception");
excep.setAttribute( "name", exceptions[i]);
tmp.appendChild(excep);
}
}
this.currentNode = currentNode;
} | java | protected void writeMethodInfo(MethodInfo info) {
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "method");
currentNode.appendChild(tmp);
this.currentNode = tmp;
addAccessFlags(info);
if (info.getName() != null)
tmp.setAttribute( "name", info.getName());
if (info.getSignature() != null)
tmp.setAttribute( "signature", info.getSignature());
if (info.getDesc() != null)
addMethodNodes(info.getDesc());
String[] exceptions = info.getExceptions();
if (exceptions != null) {
for (int i = 0; i < exceptions.length; i++) {
Element excep = doc.createElementNS(XML_URI, "exception");
excep.setAttribute( "name", exceptions[i]);
tmp.appendChild(excep);
}
}
this.currentNode = currentNode;
} | [
"protected",
"void",
"writeMethodInfo",
"(",
"MethodInfo",
"info",
")",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"method\"",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"this",
".",
"currentNode",
"=",
"tmp",
";",
"addAccessFlags",
"(",
"info",
")",
";",
"if",
"(",
"info",
".",
"getName",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"name\"",
",",
"info",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getSignature",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"signature\"",
",",
"info",
".",
"getSignature",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getDesc",
"(",
")",
"!=",
"null",
")",
"addMethodNodes",
"(",
"info",
".",
"getDesc",
"(",
")",
")",
";",
"String",
"[",
"]",
"exceptions",
"=",
"info",
".",
"getExceptions",
"(",
")",
";",
"if",
"(",
"exceptions",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"exceptions",
".",
"length",
";",
"i",
"++",
")",
"{",
"Element",
"excep",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"exception\"",
")",
";",
"excep",
".",
"setAttribute",
"(",
"\"name\"",
",",
"exceptions",
"[",
"i",
"]",
")",
";",
"tmp",
".",
"appendChild",
"(",
"excep",
")",
";",
"}",
"}",
"this",
".",
"currentNode",
"=",
"currentNode",
";",
"}"
] | Write out information about a method.
This writes out a <method> node which contains information about
the arguments, the return type, and the exceptions thrown by the
method.
@param info Info about the method. | [
"Write",
"out",
"information",
"about",
"a",
"method",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"method>",
";",
"node",
"which",
"contains",
"information",
"about",
"the",
"arguments",
"the",
"return",
"type",
"and",
"the",
"exceptions",
"thrown",
"by",
"the",
"method",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L537-L559 |
1,852 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.writeFieldInfo | protected void writeFieldInfo(FieldInfo info) {
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "field");
currentNode.appendChild(tmp);
this.currentNode = tmp;
addAccessFlags(info);
if (info.getName() != null)
tmp.setAttribute( "name",
info.getName());
if (info.getSignature() != null)
tmp.setAttribute( "signature",
info.getSignature());
if (info.getValue() != null)
tmp.setAttribute( "value",
info.getValue().toString());
if (info.getDesc() != null)
addTypeNode(info.getDesc());
this.currentNode = currentNode;
} | java | protected void writeFieldInfo(FieldInfo info) {
Node currentNode = this.currentNode;
Element tmp = doc.createElementNS(XML_URI, "field");
currentNode.appendChild(tmp);
this.currentNode = tmp;
addAccessFlags(info);
if (info.getName() != null)
tmp.setAttribute( "name",
info.getName());
if (info.getSignature() != null)
tmp.setAttribute( "signature",
info.getSignature());
if (info.getValue() != null)
tmp.setAttribute( "value",
info.getValue().toString());
if (info.getDesc() != null)
addTypeNode(info.getDesc());
this.currentNode = currentNode;
} | [
"protected",
"void",
"writeFieldInfo",
"(",
"FieldInfo",
"info",
")",
"{",
"Node",
"currentNode",
"=",
"this",
".",
"currentNode",
";",
"Element",
"tmp",
"=",
"doc",
".",
"createElementNS",
"(",
"XML_URI",
",",
"\"field\"",
")",
";",
"currentNode",
".",
"appendChild",
"(",
"tmp",
")",
";",
"this",
".",
"currentNode",
"=",
"tmp",
";",
"addAccessFlags",
"(",
"info",
")",
";",
"if",
"(",
"info",
".",
"getName",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"name\"",
",",
"info",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getSignature",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"signature\"",
",",
"info",
".",
"getSignature",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getValue",
"(",
")",
"!=",
"null",
")",
"tmp",
".",
"setAttribute",
"(",
"\"value\"",
",",
"info",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"getDesc",
"(",
")",
"!=",
"null",
")",
"addTypeNode",
"(",
"info",
".",
"getDesc",
"(",
")",
")",
";",
"this",
".",
"currentNode",
"=",
"currentNode",
";",
"}"
] | Write out information about a field.
This writes out a <field> node with attributes describing the
field.
@param info Info about the field. | [
"Write",
"out",
"information",
"about",
"a",
"field",
".",
"This",
"writes",
"out",
"a",
"<",
";",
"field>",
";",
"node",
"with",
"attributes",
"describing",
"the",
"field",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L568-L587 |
1,853 | jeluard/semantic-versioning | api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java | DOMDiffHandler.addAccessFlags | protected void addAccessFlags(AbstractInfo info) {
Element currentNode = (Element) this.currentNode;
currentNode.setAttribute( "access", info.getAccessType());
if (info.isAbstract())
currentNode.setAttribute( "abstract", "yes");
if (info.isAnnotation())
currentNode.setAttribute( "annotation", "yes");
if (info.isBridge())
currentNode.setAttribute( "bridge", "yes");
if (info.isDeprecated())
currentNode.setAttribute( "deprecated", "yes");
if (info.isEnum())
currentNode.setAttribute( "enum", "yes");
if (info.isFinal())
currentNode.setAttribute( "final", "yes");
if (info.isInterface())
currentNode.setAttribute( "interface", "yes");
if (info.isNative())
currentNode.setAttribute( "native", "yes");
if (info.isStatic())
currentNode.setAttribute( "static", "yes");
if (info.isStrict())
currentNode.setAttribute( "strict", "yes");
if (info.isSuper())
currentNode.setAttribute( "super", "yes");
if (info.isSynchronized())
currentNode.setAttribute( "synchronized", "yes");
if (info.isSynthetic())
currentNode.setAttribute( "synthetic", "yes");
if (info.isTransient())
currentNode.setAttribute( "transient", "yes");
if (info.isVarargs())
currentNode.setAttribute( "varargs", "yes");
if (info.isVolatile())
currentNode.setAttribute( "volatile", "yes");
} | java | protected void addAccessFlags(AbstractInfo info) {
Element currentNode = (Element) this.currentNode;
currentNode.setAttribute( "access", info.getAccessType());
if (info.isAbstract())
currentNode.setAttribute( "abstract", "yes");
if (info.isAnnotation())
currentNode.setAttribute( "annotation", "yes");
if (info.isBridge())
currentNode.setAttribute( "bridge", "yes");
if (info.isDeprecated())
currentNode.setAttribute( "deprecated", "yes");
if (info.isEnum())
currentNode.setAttribute( "enum", "yes");
if (info.isFinal())
currentNode.setAttribute( "final", "yes");
if (info.isInterface())
currentNode.setAttribute( "interface", "yes");
if (info.isNative())
currentNode.setAttribute( "native", "yes");
if (info.isStatic())
currentNode.setAttribute( "static", "yes");
if (info.isStrict())
currentNode.setAttribute( "strict", "yes");
if (info.isSuper())
currentNode.setAttribute( "super", "yes");
if (info.isSynchronized())
currentNode.setAttribute( "synchronized", "yes");
if (info.isSynthetic())
currentNode.setAttribute( "synthetic", "yes");
if (info.isTransient())
currentNode.setAttribute( "transient", "yes");
if (info.isVarargs())
currentNode.setAttribute( "varargs", "yes");
if (info.isVolatile())
currentNode.setAttribute( "volatile", "yes");
} | [
"protected",
"void",
"addAccessFlags",
"(",
"AbstractInfo",
"info",
")",
"{",
"Element",
"currentNode",
"=",
"(",
"Element",
")",
"this",
".",
"currentNode",
";",
"currentNode",
".",
"setAttribute",
"(",
"\"access\"",
",",
"info",
".",
"getAccessType",
"(",
")",
")",
";",
"if",
"(",
"info",
".",
"isAbstract",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"abstract\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isAnnotation",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"annotation\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isBridge",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"bridge\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isDeprecated",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"deprecated\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isEnum",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"enum\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isFinal",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"final\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isInterface",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"interface\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isNative",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"native\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isStatic",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"static\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isStrict",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"strict\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isSuper",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"super\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isSynchronized",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"synchronized\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isSynthetic",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"synthetic\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isTransient",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"transient\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isVarargs",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"varargs\"",
",",
"\"yes\"",
")",
";",
"if",
"(",
"info",
".",
"isVolatile",
"(",
")",
")",
"currentNode",
".",
"setAttribute",
"(",
"\"volatile\"",
",",
"\"yes\"",
")",
";",
"}"
] | Add attributes describing some access flags.
This adds the attributes to the attr field.
@see #attr
@param info Info describing the access flags. | [
"Add",
"attributes",
"describing",
"some",
"access",
"flags",
".",
"This",
"adds",
"the",
"attributes",
"to",
"the",
"attr",
"field",
"."
] | d0bfbeddca8ac4202f5225810227c72a708360a9 | https://github.com/jeluard/semantic-versioning/blob/d0bfbeddca8ac4202f5225810227c72a708360a9/api/src/main/java/org/osjava/jardiff/DOMDiffHandler.java#L596-L631 |
1,854 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/PasswordUtils.java | PasswordUtils.encrypt | public static String encrypt(final String aText, final String aSalt) throws NullPointerException, IOException {
Objects.requireNonNull(aText, LOGGER.getI18n("Text to encrypt is null"));
Objects.requireNonNull(aSalt, LOGGER.getI18n("Salt to encrypt with is null"));
try {
final MessageDigest digest = MessageDigest.getInstance("SHA");
final String saltedText = aText + aSalt;
digest.update(saltedText.getBytes("UTF-8"));
return Base64.encodeBytes(digest.digest());
} catch (final NoSuchAlgorithmException details) {
throw new I18nRuntimeException(details); // programming error
} catch (final UnsupportedEncodingException details) {
throw new I18nRuntimeException(details); // programming error
}
} | java | public static String encrypt(final String aText, final String aSalt) throws NullPointerException, IOException {
Objects.requireNonNull(aText, LOGGER.getI18n("Text to encrypt is null"));
Objects.requireNonNull(aSalt, LOGGER.getI18n("Salt to encrypt with is null"));
try {
final MessageDigest digest = MessageDigest.getInstance("SHA");
final String saltedText = aText + aSalt;
digest.update(saltedText.getBytes("UTF-8"));
return Base64.encodeBytes(digest.digest());
} catch (final NoSuchAlgorithmException details) {
throw new I18nRuntimeException(details); // programming error
} catch (final UnsupportedEncodingException details) {
throw new I18nRuntimeException(details); // programming error
}
} | [
"public",
"static",
"String",
"encrypt",
"(",
"final",
"String",
"aText",
",",
"final",
"String",
"aSalt",
")",
"throws",
"NullPointerException",
",",
"IOException",
"{",
"Objects",
".",
"requireNonNull",
"(",
"aText",
",",
"LOGGER",
".",
"getI18n",
"(",
"\"Text to encrypt is null\"",
")",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"aSalt",
",",
"LOGGER",
".",
"getI18n",
"(",
"\"Salt to encrypt with is null\"",
")",
")",
";",
"try",
"{",
"final",
"MessageDigest",
"digest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA\"",
")",
";",
"final",
"String",
"saltedText",
"=",
"aText",
"+",
"aSalt",
";",
"digest",
".",
"update",
"(",
"saltedText",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
")",
";",
"return",
"Base64",
".",
"encodeBytes",
"(",
"digest",
".",
"digest",
"(",
")",
")",
";",
"}",
"catch",
"(",
"final",
"NoSuchAlgorithmException",
"details",
")",
"{",
"throw",
"new",
"I18nRuntimeException",
"(",
"details",
")",
";",
"// programming error",
"}",
"catch",
"(",
"final",
"UnsupportedEncodingException",
"details",
")",
"{",
"throw",
"new",
"I18nRuntimeException",
"(",
"details",
")",
";",
"// programming error",
"}",
"}"
] | Encrypts the supplied text using the supplied salt.
@param aText The text to be encrypted
@param aSalt The salt to use in the encryption
@return The encrypted password
@throws IOException If there is trouble encrypting the supplied text | [
"Encrypts",
"the",
"supplied",
"text",
"using",
"the",
"supplied",
"salt",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/PasswordUtils.java#L54-L68 |
1,855 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/Logger.java | Logger.setLineNumber | private MDCCloseable setLineNumber() {
final int lineNum = Thread.currentThread().getStackTrace()[3].getLineNumber();
return MDC.putCloseable(LINE_NUM, Integer.toString(lineNum));
} | java | private MDCCloseable setLineNumber() {
final int lineNum = Thread.currentThread().getStackTrace()[3].getLineNumber();
return MDC.putCloseable(LINE_NUM, Integer.toString(lineNum));
} | [
"private",
"MDCCloseable",
"setLineNumber",
"(",
")",
"{",
"final",
"int",
"lineNum",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getStackTrace",
"(",
")",
"[",
"3",
"]",
".",
"getLineNumber",
"(",
")",
";",
"return",
"MDC",
".",
"putCloseable",
"(",
"LINE_NUM",
",",
"Integer",
".",
"toString",
"(",
"lineNum",
")",
")",
";",
"}"
] | Sets the line number.
@return A handle that can remove the line number after it's no longer needed | [
"Sets",
"the",
"line",
"number",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/Logger.java#L1215-L1218 |
1,856 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/BufferedFileWriter.java | BufferedFileWriter.getWriter | private static Writer getWriter(final File aFile) throws FileNotFoundException {
try {
return new OutputStreamWriter(new FileOutputStream(aFile), StandardCharsets.UTF_8.name());
} catch (final java.io.UnsupportedEncodingException details) {
throw new UnsupportedEncodingException(details, StandardCharsets.UTF_8.name());
}
} | java | private static Writer getWriter(final File aFile) throws FileNotFoundException {
try {
return new OutputStreamWriter(new FileOutputStream(aFile), StandardCharsets.UTF_8.name());
} catch (final java.io.UnsupportedEncodingException details) {
throw new UnsupportedEncodingException(details, StandardCharsets.UTF_8.name());
}
} | [
"private",
"static",
"Writer",
"getWriter",
"(",
"final",
"File",
"aFile",
")",
"throws",
"FileNotFoundException",
"{",
"try",
"{",
"return",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"aFile",
")",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"}",
"catch",
"(",
"final",
"java",
".",
"io",
".",
"UnsupportedEncodingException",
"details",
")",
"{",
"throw",
"new",
"UnsupportedEncodingException",
"(",
"details",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"}",
"}"
] | Gets a writer that can write to the supplied file using the UTF-8 charset.
@param aFile A file to which to write
@return A writer that writes to the supplied file
@throws FileNotFoundException If the supplied file cannot be found | [
"Gets",
"a",
"writer",
"that",
"can",
"write",
"to",
"the",
"supplied",
"file",
"using",
"the",
"UTF",
"-",
"8",
"charset",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/BufferedFileWriter.java#L47-L53 |
1,857 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/Stopwatch.java | Stopwatch.stop | public Stopwatch stop() {
if (!myTimerIsRunning) {
throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_041));
}
myStop = System.currentTimeMillis();
myTimerIsRunning = false;
return this;
} | java | public Stopwatch stop() {
if (!myTimerIsRunning) {
throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_041));
}
myStop = System.currentTimeMillis();
myTimerIsRunning = false;
return this;
} | [
"public",
"Stopwatch",
"stop",
"(",
")",
"{",
"if",
"(",
"!",
"myTimerIsRunning",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_041",
")",
")",
";",
"}",
"myStop",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"myTimerIsRunning",
"=",
"false",
";",
"return",
"this",
";",
"}"
] | Stop the stopwatch.
@throws IllegalStateException if the stopwatch is not already running.
@return The stopwatch | [
"Stop",
"the",
"stopwatch",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/Stopwatch.java#L42-L51 |
1,858 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/Stopwatch.java | Stopwatch.getSeconds | public String getSeconds() {
if (myTimerIsRunning) {
throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_042));
}
final StringBuilder result = new StringBuilder();
final long timeGap = myStop - myStart;
return result.append(timeGap / 1000).append(" secs, ").append(timeGap % 1000).append(" msecs ").toString();
} | java | public String getSeconds() {
if (myTimerIsRunning) {
throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_042));
}
final StringBuilder result = new StringBuilder();
final long timeGap = myStop - myStart;
return result.append(timeGap / 1000).append(" secs, ").append(timeGap % 1000).append(" msecs ").toString();
} | [
"public",
"String",
"getSeconds",
"(",
")",
"{",
"if",
"(",
"myTimerIsRunning",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_042",
")",
")",
";",
"}",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"long",
"timeGap",
"=",
"myStop",
"-",
"myStart",
";",
"return",
"result",
".",
"append",
"(",
"timeGap",
"/",
"1000",
")",
".",
"append",
"(",
"\" secs, \"",
")",
".",
"append",
"(",
"timeGap",
"%",
"1000",
")",
".",
"append",
"(",
"\" msecs \"",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Express the "reading" on the stopwatch in seconds.
@return Time elapsed in stopwatch in seconds
@throws IllegalStateException if the Stopwatch has never been used, or if the stopwatch is still running. | [
"Express",
"the",
"reading",
"on",
"the",
"stopwatch",
"in",
"seconds",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/Stopwatch.java#L83-L92 |
1,859 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/Stopwatch.java | Stopwatch.getMilliseconds | public String getMilliseconds() {
if (myTimerIsRunning) {
throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_042));
}
return new StringBuilder().append(myStop - myStart).append(" msecs").toString();
} | java | public String getMilliseconds() {
if (myTimerIsRunning) {
throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_042));
}
return new StringBuilder().append(myStop - myStart).append(" msecs").toString();
} | [
"public",
"String",
"getMilliseconds",
"(",
")",
"{",
"if",
"(",
"myTimerIsRunning",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_042",
")",
")",
";",
"}",
"return",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"myStop",
"-",
"myStart",
")",
".",
"append",
"(",
"\" msecs\"",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Express the "reading" on the stopwatch in milliseconds.
@return Time elapsed in stopwatch in milliseconds
@throws IllegalStateException if the Stopwatch has never been used, or if the stopwatch is still running. | [
"Express",
"the",
"reading",
"on",
"the",
"stopwatch",
"in",
"milliseconds",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/Stopwatch.java#L100-L106 |
1,860 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/NativeLibraryLoader.java | NativeLibraryLoader.load | public static void load(final String aNativeLibrary) throws IOException {
final String libFileName = getPlatformLibraryName(aNativeLibrary);
final File tmpDir = new File(System.getProperty("java.io.tmpdir"));
final File libFile = new File(tmpDir, libFileName);
// Check to see whether it already exists before we go creating it again?
if (!libFile.exists() || libFile.length() == 0) {
final URL url = ClasspathUtils.findFirst(libFileName);
if (url == null) {
throw new FileNotFoundException(LOGGER.getMessage(MessageCodes.UTIL_002, aNativeLibrary));
}
final JarFile jarFile = new JarFile(url.getFile());
final JarEntry jarEntry = jarFile.getJarEntry(libFileName);
final InputStream inStream = jarFile.getInputStream(jarEntry);
final BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(libFile));
IOUtils.copyStream(inStream, outStream);
IOUtils.closeQuietly(inStream);
IOUtils.closeQuietly(outStream);
IOUtils.closeQuietly(jarFile);
}
if (libFile.exists() && libFile.length() > 0) {
System.load(libFile.getAbsolutePath());
} else {
throw new IOException(LOGGER.getI18n(MessageCodes.UTIL_039, libFile));
}
} | java | public static void load(final String aNativeLibrary) throws IOException {
final String libFileName = getPlatformLibraryName(aNativeLibrary);
final File tmpDir = new File(System.getProperty("java.io.tmpdir"));
final File libFile = new File(tmpDir, libFileName);
// Check to see whether it already exists before we go creating it again?
if (!libFile.exists() || libFile.length() == 0) {
final URL url = ClasspathUtils.findFirst(libFileName);
if (url == null) {
throw new FileNotFoundException(LOGGER.getMessage(MessageCodes.UTIL_002, aNativeLibrary));
}
final JarFile jarFile = new JarFile(url.getFile());
final JarEntry jarEntry = jarFile.getJarEntry(libFileName);
final InputStream inStream = jarFile.getInputStream(jarEntry);
final BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(libFile));
IOUtils.copyStream(inStream, outStream);
IOUtils.closeQuietly(inStream);
IOUtils.closeQuietly(outStream);
IOUtils.closeQuietly(jarFile);
}
if (libFile.exists() && libFile.length() > 0) {
System.load(libFile.getAbsolutePath());
} else {
throw new IOException(LOGGER.getI18n(MessageCodes.UTIL_039, libFile));
}
} | [
"public",
"static",
"void",
"load",
"(",
"final",
"String",
"aNativeLibrary",
")",
"throws",
"IOException",
"{",
"final",
"String",
"libFileName",
"=",
"getPlatformLibraryName",
"(",
"aNativeLibrary",
")",
";",
"final",
"File",
"tmpDir",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
")",
";",
"final",
"File",
"libFile",
"=",
"new",
"File",
"(",
"tmpDir",
",",
"libFileName",
")",
";",
"// Check to see whether it already exists before we go creating it again?",
"if",
"(",
"!",
"libFile",
".",
"exists",
"(",
")",
"||",
"libFile",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"final",
"URL",
"url",
"=",
"ClasspathUtils",
".",
"findFirst",
"(",
"libFileName",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"LOGGER",
".",
"getMessage",
"(",
"MessageCodes",
".",
"UTIL_002",
",",
"aNativeLibrary",
")",
")",
";",
"}",
"final",
"JarFile",
"jarFile",
"=",
"new",
"JarFile",
"(",
"url",
".",
"getFile",
"(",
")",
")",
";",
"final",
"JarEntry",
"jarEntry",
"=",
"jarFile",
".",
"getJarEntry",
"(",
"libFileName",
")",
";",
"final",
"InputStream",
"inStream",
"=",
"jarFile",
".",
"getInputStream",
"(",
"jarEntry",
")",
";",
"final",
"BufferedOutputStream",
"outStream",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"libFile",
")",
")",
";",
"IOUtils",
".",
"copyStream",
"(",
"inStream",
",",
"outStream",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"inStream",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"outStream",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"jarFile",
")",
";",
"}",
"if",
"(",
"libFile",
".",
"exists",
"(",
")",
"&&",
"libFile",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"System",
".",
"load",
"(",
"libFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IOException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_039",
",",
"libFile",
")",
")",
";",
"}",
"}"
] | Loads a native library from the classpath.
@param aNativeLibrary A native library to load from the classpath
@throws IOException If there is trouble reading from the Jar file or file system | [
"Loads",
"a",
"native",
"library",
"from",
"the",
"classpath",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/NativeLibraryLoader.java#L54-L83 |
1,861 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/NativeLibraryLoader.java | NativeLibraryLoader.getArchitecture | public static Architecture getArchitecture() {
if (Architecture.UNKNOWN == myArchitecture) {
final Processor processor = getProcessor();
if (Processor.UNKNOWN != processor) {
final String name = System.getProperty(OS_NAME).toLowerCase(Locale.US);
if (name.indexOf("nix") >= 0 || name.indexOf("nux") >= 0) {
if (Processor.INTEL_32 == processor) {
myArchitecture = Architecture.LINUX_32;
} else if (Processor.INTEL_64 == processor) {
myArchitecture = Architecture.LINUX_64;
} else if (Processor.ARM == processor) {
myArchitecture = Architecture.LINUX_ARM;
}
} else if (name.indexOf("win") >= 0) {
if (Processor.INTEL_32 == processor) {
myArchitecture = Architecture.WINDOWS_32;
} else if (Processor.INTEL_64 == processor) {
myArchitecture = Architecture.WINDOWS_64;
}
} else if (name.indexOf("mac") >= 0) {
if (Processor.INTEL_32 == processor) {
myArchitecture = Architecture.OSX_32;
} else if (Processor.INTEL_64 == processor) {
myArchitecture = Architecture.OSX_64;
} else if (Processor.PPC == processor) {
myArchitecture = Architecture.OSX_PPC;
}
}
}
}
LOGGER.debug(MessageCodes.UTIL_023, myArchitecture, System.getProperty(OS_NAME).toLowerCase(Locale.US));
return myArchitecture;
} | java | public static Architecture getArchitecture() {
if (Architecture.UNKNOWN == myArchitecture) {
final Processor processor = getProcessor();
if (Processor.UNKNOWN != processor) {
final String name = System.getProperty(OS_NAME).toLowerCase(Locale.US);
if (name.indexOf("nix") >= 0 || name.indexOf("nux") >= 0) {
if (Processor.INTEL_32 == processor) {
myArchitecture = Architecture.LINUX_32;
} else if (Processor.INTEL_64 == processor) {
myArchitecture = Architecture.LINUX_64;
} else if (Processor.ARM == processor) {
myArchitecture = Architecture.LINUX_ARM;
}
} else if (name.indexOf("win") >= 0) {
if (Processor.INTEL_32 == processor) {
myArchitecture = Architecture.WINDOWS_32;
} else if (Processor.INTEL_64 == processor) {
myArchitecture = Architecture.WINDOWS_64;
}
} else if (name.indexOf("mac") >= 0) {
if (Processor.INTEL_32 == processor) {
myArchitecture = Architecture.OSX_32;
} else if (Processor.INTEL_64 == processor) {
myArchitecture = Architecture.OSX_64;
} else if (Processor.PPC == processor) {
myArchitecture = Architecture.OSX_PPC;
}
}
}
}
LOGGER.debug(MessageCodes.UTIL_023, myArchitecture, System.getProperty(OS_NAME).toLowerCase(Locale.US));
return myArchitecture;
} | [
"public",
"static",
"Architecture",
"getArchitecture",
"(",
")",
"{",
"if",
"(",
"Architecture",
".",
"UNKNOWN",
"==",
"myArchitecture",
")",
"{",
"final",
"Processor",
"processor",
"=",
"getProcessor",
"(",
")",
";",
"if",
"(",
"Processor",
".",
"UNKNOWN",
"!=",
"processor",
")",
"{",
"final",
"String",
"name",
"=",
"System",
".",
"getProperty",
"(",
"OS_NAME",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"US",
")",
";",
"if",
"(",
"name",
".",
"indexOf",
"(",
"\"nix\"",
")",
">=",
"0",
"||",
"name",
".",
"indexOf",
"(",
"\"nux\"",
")",
">=",
"0",
")",
"{",
"if",
"(",
"Processor",
".",
"INTEL_32",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"LINUX_32",
";",
"}",
"else",
"if",
"(",
"Processor",
".",
"INTEL_64",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"LINUX_64",
";",
"}",
"else",
"if",
"(",
"Processor",
".",
"ARM",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"LINUX_ARM",
";",
"}",
"}",
"else",
"if",
"(",
"name",
".",
"indexOf",
"(",
"\"win\"",
")",
">=",
"0",
")",
"{",
"if",
"(",
"Processor",
".",
"INTEL_32",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"WINDOWS_32",
";",
"}",
"else",
"if",
"(",
"Processor",
".",
"INTEL_64",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"WINDOWS_64",
";",
"}",
"}",
"else",
"if",
"(",
"name",
".",
"indexOf",
"(",
"\"mac\"",
")",
">=",
"0",
")",
"{",
"if",
"(",
"Processor",
".",
"INTEL_32",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"OSX_32",
";",
"}",
"else",
"if",
"(",
"Processor",
".",
"INTEL_64",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"OSX_64",
";",
"}",
"else",
"if",
"(",
"Processor",
".",
"PPC",
"==",
"processor",
")",
"{",
"myArchitecture",
"=",
"Architecture",
".",
"OSX_PPC",
";",
"}",
"}",
"}",
"}",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"UTIL_023",
",",
"myArchitecture",
",",
"System",
".",
"getProperty",
"(",
"OS_NAME",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"US",
")",
")",
";",
"return",
"myArchitecture",
";",
"}"
] | Gets the architecture of the machine running the JVM.
@return The architecture of the machine running the JVM | [
"Gets",
"the",
"architecture",
"of",
"the",
"machine",
"running",
"the",
"JVM",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/NativeLibraryLoader.java#L90-L125 |
1,862 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/NativeLibraryLoader.java | NativeLibraryLoader.getPlatformLibraryName | public static String getPlatformLibraryName(final String aLibraryName) {
String libName = null;
switch (getArchitecture()) {
case LINUX_32:
case LINUX_64:
case LINUX_ARM:
libName = LIB_PREFIX + aLibraryName + ".so";
break;
case WINDOWS_32:
case WINDOWS_64:
libName = aLibraryName + ".dll";
break;
case OSX_32:
case OSX_64:
libName = LIB_PREFIX + aLibraryName + ".dylib";
break;
default:
LOGGER.warn("Unexpected architecture value: {}", getArchitecture());
break;
}
LOGGER.debug(MessageCodes.UTIL_025, libName);
return libName;
} | java | public static String getPlatformLibraryName(final String aLibraryName) {
String libName = null;
switch (getArchitecture()) {
case LINUX_32:
case LINUX_64:
case LINUX_ARM:
libName = LIB_PREFIX + aLibraryName + ".so";
break;
case WINDOWS_32:
case WINDOWS_64:
libName = aLibraryName + ".dll";
break;
case OSX_32:
case OSX_64:
libName = LIB_PREFIX + aLibraryName + ".dylib";
break;
default:
LOGGER.warn("Unexpected architecture value: {}", getArchitecture());
break;
}
LOGGER.debug(MessageCodes.UTIL_025, libName);
return libName;
} | [
"public",
"static",
"String",
"getPlatformLibraryName",
"(",
"final",
"String",
"aLibraryName",
")",
"{",
"String",
"libName",
"=",
"null",
";",
"switch",
"(",
"getArchitecture",
"(",
")",
")",
"{",
"case",
"LINUX_32",
":",
"case",
"LINUX_64",
":",
"case",
"LINUX_ARM",
":",
"libName",
"=",
"LIB_PREFIX",
"+",
"aLibraryName",
"+",
"\".so\"",
";",
"break",
";",
"case",
"WINDOWS_32",
":",
"case",
"WINDOWS_64",
":",
"libName",
"=",
"aLibraryName",
"+",
"\".dll\"",
";",
"break",
";",
"case",
"OSX_32",
":",
"case",
"OSX_64",
":",
"libName",
"=",
"LIB_PREFIX",
"+",
"aLibraryName",
"+",
"\".dylib\"",
";",
"break",
";",
"default",
":",
"LOGGER",
".",
"warn",
"(",
"\"Unexpected architecture value: {}\"",
",",
"getArchitecture",
"(",
")",
")",
";",
"break",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"UTIL_025",
",",
"libName",
")",
";",
"return",
"libName",
";",
"}"
] | Gets the library name for the current platform.
@param aLibraryName The platform-independent library name
@return The library name for the current platform | [
"Gets",
"the",
"library",
"name",
"for",
"the",
"current",
"platform",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/NativeLibraryLoader.java#L158-L182 |
1,863 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.trimTo | public static String trimTo(final String aString, final String aDefault) {
if (aString == null) {
return aDefault;
}
final String trimmed = aString.trim();
return trimmed.length() == 0 ? aDefault : trimmed;
} | java | public static String trimTo(final String aString, final String aDefault) {
if (aString == null) {
return aDefault;
}
final String trimmed = aString.trim();
return trimmed.length() == 0 ? aDefault : trimmed;
} | [
"public",
"static",
"String",
"trimTo",
"(",
"final",
"String",
"aString",
",",
"final",
"String",
"aDefault",
")",
"{",
"if",
"(",
"aString",
"==",
"null",
")",
"{",
"return",
"aDefault",
";",
"}",
"final",
"String",
"trimmed",
"=",
"aString",
".",
"trim",
"(",
")",
";",
"return",
"trimmed",
".",
"length",
"(",
")",
"==",
"0",
"?",
"aDefault",
":",
"trimmed",
";",
"}"
] | Trims a string; if there is nothing left after the trimming, returns whatever the default value passed in is.
@param aString The string to be trimmed
@param aDefault A default string to return if a null string is passed in
@return The trimmed string or the default value if string is empty | [
"Trims",
"a",
"string",
";",
"if",
"there",
"is",
"nothing",
"left",
"after",
"the",
"trimming",
"returns",
"whatever",
"the",
"default",
"value",
"passed",
"in",
"is",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L68-L75 |
1,864 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.padStart | public static String padStart(final String aString, final String aPadding, final int aRepeatCount) {
if (aRepeatCount != 0) {
final StringBuilder buffer = new StringBuilder();
for (int index = 0; index < aRepeatCount; index++) {
buffer.append(aPadding);
}
return buffer.append(aString).toString();
}
return aString;
} | java | public static String padStart(final String aString, final String aPadding, final int aRepeatCount) {
if (aRepeatCount != 0) {
final StringBuilder buffer = new StringBuilder();
for (int index = 0; index < aRepeatCount; index++) {
buffer.append(aPadding);
}
return buffer.append(aString).toString();
}
return aString;
} | [
"public",
"static",
"String",
"padStart",
"(",
"final",
"String",
"aString",
",",
"final",
"String",
"aPadding",
",",
"final",
"int",
"aRepeatCount",
")",
"{",
"if",
"(",
"aRepeatCount",
"!=",
"0",
")",
"{",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"aRepeatCount",
";",
"index",
"++",
")",
"{",
"buffer",
".",
"append",
"(",
"aPadding",
")",
";",
"}",
"return",
"buffer",
".",
"append",
"(",
"aString",
")",
".",
"toString",
"(",
")",
";",
"}",
"return",
"aString",
";",
"}"
] | Pads the beginning of a supplied string with the repetition of a supplied value.
@param aString The string to pad
@param aPadding The string to be repeated as the padding
@param aRepeatCount How many times to repeat the padding
@return The front padded string | [
"Pads",
"the",
"beginning",
"of",
"a",
"supplied",
"string",
"with",
"the",
"repetition",
"of",
"a",
"supplied",
"value",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L163-L175 |
1,865 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.toCharCount | public static String toCharCount(final String aString, final int aCount) {
final StringBuilder builder = new StringBuilder();
final String[] words = aString.split("\\s");
int count = 0;
for (final String word : words) {
count += word.length();
if (count < aCount) {
builder.append(word);
if ((count += 1) < aCount) {
builder.append(' ');
} else {
builder.append(EOL).append(DOUBLE_SPACE);
count = 2;
}
} else {
builder.append(EOL).append(DOUBLE_SPACE).append(word);
count = word.length() + 2; // two spaces at start of line
}
}
return builder.toString();
} | java | public static String toCharCount(final String aString, final int aCount) {
final StringBuilder builder = new StringBuilder();
final String[] words = aString.split("\\s");
int count = 0;
for (final String word : words) {
count += word.length();
if (count < aCount) {
builder.append(word);
if ((count += 1) < aCount) {
builder.append(' ');
} else {
builder.append(EOL).append(DOUBLE_SPACE);
count = 2;
}
} else {
builder.append(EOL).append(DOUBLE_SPACE).append(word);
count = word.length() + 2; // two spaces at start of line
}
}
return builder.toString();
} | [
"public",
"static",
"String",
"toCharCount",
"(",
"final",
"String",
"aString",
",",
"final",
"int",
"aCount",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"String",
"[",
"]",
"words",
"=",
"aString",
".",
"split",
"(",
"\"\\\\s\"",
")",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"final",
"String",
"word",
":",
"words",
")",
"{",
"count",
"+=",
"word",
".",
"length",
"(",
")",
";",
"if",
"(",
"count",
"<",
"aCount",
")",
"{",
"builder",
".",
"append",
"(",
"word",
")",
";",
"if",
"(",
"(",
"count",
"+=",
"1",
")",
"<",
"aCount",
")",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"EOL",
")",
".",
"append",
"(",
"DOUBLE_SPACE",
")",
";",
"count",
"=",
"2",
";",
"}",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"EOL",
")",
".",
"append",
"(",
"DOUBLE_SPACE",
")",
".",
"append",
"(",
"word",
")",
";",
"count",
"=",
"word",
".",
"length",
"(",
")",
"+",
"2",
";",
"// two spaces at start of line",
"}",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Formats a string with or without line breaks into a string with lines with less than a supplied number of
characters per line.
@param aString A string to format
@param aCount A number of characters to allow per line
@return A string formatted using the supplied count | [
"Formats",
"a",
"string",
"with",
"or",
"without",
"line",
"breaks",
"into",
"a",
"string",
"with",
"lines",
"with",
"less",
"than",
"a",
"supplied",
"number",
"of",
"characters",
"per",
"line",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L207-L231 |
1,866 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.repeat | public static String repeat(final String aValue, final int aRepeatCount) {
final StringBuilder buffer = new StringBuilder();
for (int index = 0; index < aRepeatCount; index++) {
buffer.append(aValue);
}
return buffer.toString();
} | java | public static String repeat(final String aValue, final int aRepeatCount) {
final StringBuilder buffer = new StringBuilder();
for (int index = 0; index < aRepeatCount; index++) {
buffer.append(aValue);
}
return buffer.toString();
} | [
"public",
"static",
"String",
"repeat",
"(",
"final",
"String",
"aValue",
",",
"final",
"int",
"aRepeatCount",
")",
"{",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"aRepeatCount",
";",
"index",
"++",
")",
"{",
"buffer",
".",
"append",
"(",
"aValue",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Creates a new string from the repetition of a supplied value.
@param aValue The string to repeat, creating a new string
@param aRepeatCount The number of times to repeat the supplied value
@return The new string containing the supplied value repeated the specified number of times | [
"Creates",
"a",
"new",
"string",
"from",
"the",
"repetition",
"of",
"a",
"supplied",
"value",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L240-L248 |
1,867 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.read | public static String read(final File aFile) throws IOException {
String string = new String(readBytes(aFile), StandardCharsets.UTF_8.name());
if (string.endsWith(EOL)) {
string = string.substring(0, string.length() - 1);
}
return string;
} | java | public static String read(final File aFile) throws IOException {
String string = new String(readBytes(aFile), StandardCharsets.UTF_8.name());
if (string.endsWith(EOL)) {
string = string.substring(0, string.length() - 1);
}
return string;
} | [
"public",
"static",
"String",
"read",
"(",
"final",
"File",
"aFile",
")",
"throws",
"IOException",
"{",
"String",
"string",
"=",
"new",
"String",
"(",
"readBytes",
"(",
"aFile",
")",
",",
"StandardCharsets",
".",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"if",
"(",
"string",
".",
"endsWith",
"(",
"EOL",
")",
")",
"{",
"string",
"=",
"string",
".",
"substring",
"(",
"0",
",",
"string",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"string",
";",
"}"
] | Reads the contents of a file into a string using the UTF-8 character set encoding.
@param aFile The file from which to read
@return The information read from the file
@throws IOException If the supplied file could not be read | [
"Reads",
"the",
"contents",
"of",
"a",
"file",
"into",
"a",
"string",
"using",
"the",
"UTF",
"-",
"8",
"character",
"set",
"encoding",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L306-L314 |
1,868 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.trim | public static String[] trim(final String... aStringArray) {
final ArrayList<String> list = new ArrayList<>();
for (final String string : aStringArray) {
if (string != null && !"".equals(string)) {
list.add(string);
}
}
return list.toArray(new String[0]);
} | java | public static String[] trim(final String... aStringArray) {
final ArrayList<String> list = new ArrayList<>();
for (final String string : aStringArray) {
if (string != null && !"".equals(string)) {
list.add(string);
}
}
return list.toArray(new String[0]);
} | [
"public",
"static",
"String",
"[",
"]",
"trim",
"(",
"final",
"String",
"...",
"aStringArray",
")",
"{",
"final",
"ArrayList",
"<",
"String",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"String",
"string",
":",
"aStringArray",
")",
"{",
"if",
"(",
"string",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"string",
")",
")",
"{",
"list",
".",
"add",
"(",
"string",
")",
";",
"}",
"}",
"return",
"list",
".",
"toArray",
"(",
"new",
"String",
"[",
"0",
"]",
")",
";",
"}"
] | Removes empty and null strings from a string array.
@param aStringArray A varargs that may contain empty or null strings
@return A string array without empty or null strings | [
"Removes",
"empty",
"and",
"null",
"strings",
"from",
"a",
"string",
"array",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L322-L332 |
1,869 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.isEmpty | public static boolean isEmpty(final String aString) {
boolean result = true;
if (aString != null) {
for (int index = 0; index < aString.length(); index++) {
if (!Character.isWhitespace(aString.charAt(index))) {
result = false;
break;
}
}
}
return result;
} | java | public static boolean isEmpty(final String aString) {
boolean result = true;
if (aString != null) {
for (int index = 0; index < aString.length(); index++) {
if (!Character.isWhitespace(aString.charAt(index))) {
result = false;
break;
}
}
}
return result;
} | [
"public",
"static",
"boolean",
"isEmpty",
"(",
"final",
"String",
"aString",
")",
"{",
"boolean",
"result",
"=",
"true",
";",
"if",
"(",
"aString",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"aString",
".",
"length",
"(",
")",
";",
"index",
"++",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isWhitespace",
"(",
"aString",
".",
"charAt",
"(",
"index",
")",
")",
")",
"{",
"result",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Returns true if the supplied string is null, empty, or contains nothing but whitespace.
@param aString A string to test to see if it is null, empty or contains nothing but whitespace
@return True if the supplied string is empty; else, false | [
"Returns",
"true",
"if",
"the",
"supplied",
"string",
"is",
"null",
"empty",
"or",
"contains",
"nothing",
"but",
"whitespace",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L340-L353 |
1,870 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.joinKeys | public static String joinKeys(final Map<String, ?> aMap, final char aSeparator) {
if (aMap.isEmpty()) {
return "";
}
final Iterator<String> iterator = aMap.keySet().iterator();
final StringBuilder buffer = new StringBuilder();
while (iterator.hasNext()) {
buffer.append(iterator.next()).append(aSeparator);
}
final int length = buffer.length() - 1;
return buffer.charAt(length) == aSeparator ? buffer.substring(0, length) : buffer.toString();
} | java | public static String joinKeys(final Map<String, ?> aMap, final char aSeparator) {
if (aMap.isEmpty()) {
return "";
}
final Iterator<String> iterator = aMap.keySet().iterator();
final StringBuilder buffer = new StringBuilder();
while (iterator.hasNext()) {
buffer.append(iterator.next()).append(aSeparator);
}
final int length = buffer.length() - 1;
return buffer.charAt(length) == aSeparator ? buffer.substring(0, length) : buffer.toString();
} | [
"public",
"static",
"String",
"joinKeys",
"(",
"final",
"Map",
"<",
"String",
",",
"?",
">",
"aMap",
",",
"final",
"char",
"aSeparator",
")",
"{",
"if",
"(",
"aMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"final",
"Iterator",
"<",
"String",
">",
"iterator",
"=",
"aMap",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"buffer",
".",
"append",
"(",
"iterator",
".",
"next",
"(",
")",
")",
".",
"append",
"(",
"aSeparator",
")",
";",
"}",
"final",
"int",
"length",
"=",
"buffer",
".",
"length",
"(",
")",
"-",
"1",
";",
"return",
"buffer",
".",
"charAt",
"(",
"length",
")",
"==",
"aSeparator",
"?",
"buffer",
".",
"substring",
"(",
"0",
",",
"length",
")",
":",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Turns the keys in a map into a character delimited string. The order is only consistent if the map is sorted.
@param aMap The map from which to pull the keys
@param aSeparator The character separator for the construction of the string
@return A string constructed from the keys in the map | [
"Turns",
"the",
"keys",
"in",
"a",
"map",
"into",
"a",
"character",
"delimited",
"string",
".",
"The",
"order",
"is",
"only",
"consistent",
"if",
"the",
"map",
"is",
"sorted",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L399-L414 |
1,871 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.upcase | public static String upcase(final String aString) {
return aString.substring(0, 1).toUpperCase(Locale.getDefault()) + aString.substring(1);
} | java | public static String upcase(final String aString) {
return aString.substring(0, 1).toUpperCase(Locale.getDefault()) + aString.substring(1);
} | [
"public",
"static",
"String",
"upcase",
"(",
"final",
"String",
"aString",
")",
"{",
"return",
"aString",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
"Locale",
".",
"getDefault",
"(",
")",
")",
"+",
"aString",
".",
"substring",
"(",
"1",
")",
";",
"}"
] | Upcases a string.
@param aString A string to upcase
@return The upcased string | [
"Upcases",
"a",
"string",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L556-L558 |
1,872 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.toUpcaseString | public static String toUpcaseString(final int aInt) {
switch (aInt) {
case 1:
return "First";
case 2:
return "Second";
case 3:
return "Third";
case 4:
return "Fourth";
case 5:
return "Fifth";
case 6:
return "Sixth";
case 7:
return "Seventh";
case 8:
return "Eighth";
case 9:
return "Ninth";
case 10:
return "Tenth";
case 11:
return "Eleventh";
case 12:
return "Twelveth";
case 13:
return "Thirteenth";
case 14:
return "Fourteenth";
case 15:
return "Fifthteenth";
case 16:
return "Sixteenth";
case 17:
return "Seventeenth";
case 18:
return "Eighteenth";
case 19:
return "Nineteenth";
case 20:
return "Twentieth";
default:
throw new UnsupportedOperationException(LOGGER.getI18n(MessageCodes.UTIL_046, aInt));
}
} | java | public static String toUpcaseString(final int aInt) {
switch (aInt) {
case 1:
return "First";
case 2:
return "Second";
case 3:
return "Third";
case 4:
return "Fourth";
case 5:
return "Fifth";
case 6:
return "Sixth";
case 7:
return "Seventh";
case 8:
return "Eighth";
case 9:
return "Ninth";
case 10:
return "Tenth";
case 11:
return "Eleventh";
case 12:
return "Twelveth";
case 13:
return "Thirteenth";
case 14:
return "Fourteenth";
case 15:
return "Fifthteenth";
case 16:
return "Sixteenth";
case 17:
return "Seventeenth";
case 18:
return "Eighteenth";
case 19:
return "Nineteenth";
case 20:
return "Twentieth";
default:
throw new UnsupportedOperationException(LOGGER.getI18n(MessageCodes.UTIL_046, aInt));
}
} | [
"public",
"static",
"String",
"toUpcaseString",
"(",
"final",
"int",
"aInt",
")",
"{",
"switch",
"(",
"aInt",
")",
"{",
"case",
"1",
":",
"return",
"\"First\"",
";",
"case",
"2",
":",
"return",
"\"Second\"",
";",
"case",
"3",
":",
"return",
"\"Third\"",
";",
"case",
"4",
":",
"return",
"\"Fourth\"",
";",
"case",
"5",
":",
"return",
"\"Fifth\"",
";",
"case",
"6",
":",
"return",
"\"Sixth\"",
";",
"case",
"7",
":",
"return",
"\"Seventh\"",
";",
"case",
"8",
":",
"return",
"\"Eighth\"",
";",
"case",
"9",
":",
"return",
"\"Ninth\"",
";",
"case",
"10",
":",
"return",
"\"Tenth\"",
";",
"case",
"11",
":",
"return",
"\"Eleventh\"",
";",
"case",
"12",
":",
"return",
"\"Twelveth\"",
";",
"case",
"13",
":",
"return",
"\"Thirteenth\"",
";",
"case",
"14",
":",
"return",
"\"Fourteenth\"",
";",
"case",
"15",
":",
"return",
"\"Fifthteenth\"",
";",
"case",
"16",
":",
"return",
"\"Sixteenth\"",
";",
"case",
"17",
":",
"return",
"\"Seventeenth\"",
";",
"case",
"18",
":",
"return",
"\"Eighteenth\"",
";",
"case",
"19",
":",
"return",
"\"Nineteenth\"",
";",
"case",
"20",
":",
"return",
"\"Twentieth\"",
";",
"default",
":",
"throw",
"new",
"UnsupportedOperationException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_046",
",",
"aInt",
")",
")",
";",
"}",
"}"
] | Returns an up-cased human-friendly string representation for the supplied int; for instance, "1" becomes
"First", "2" becomes "Second", etc.
@param aInt An int to convert into a string
@return The string form of the supplied int | [
"Returns",
"an",
"up",
"-",
"cased",
"human",
"-",
"friendly",
"string",
"representation",
"for",
"the",
"supplied",
"int",
";",
"for",
"instance",
"1",
"becomes",
"First",
"2",
"becomes",
"Second",
"etc",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L567-L612 |
1,873 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/I18nRuntimeException.java | I18nRuntimeException.format | private static String format(final String aBundleName, final String aMessageKey, final Object... aVarargs) {
return format(null, aBundleName, aMessageKey, aVarargs);
} | java | private static String format(final String aBundleName, final String aMessageKey, final Object... aVarargs) {
return format(null, aBundleName, aMessageKey, aVarargs);
} | [
"private",
"static",
"String",
"format",
"(",
"final",
"String",
"aBundleName",
",",
"final",
"String",
"aMessageKey",
",",
"final",
"Object",
"...",
"aVarargs",
")",
"{",
"return",
"format",
"(",
"null",
",",
"aBundleName",
",",
"aMessageKey",
",",
"aVarargs",
")",
";",
"}"
] | Constructs our I18n exception message using the supplied bundle name.
@param aBundleName A name of a bundle in which to look up the supplied key.
@param aMessageKey A key value to look up in the <code>ResourceBundle</code>.
@param aVarargs Additional details to use in formatting the message.
@return A formatted exception message | [
"Constructs",
"our",
"I18n",
"exception",
"message",
"using",
"the",
"supplied",
"bundle",
"name",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/I18nRuntimeException.java#L146-L148 |
1,874 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.stripExt | public static String stripExt(final String aFileName) {
final int index = aFileName.lastIndexOf(DOT);
if (index != -1) {
return aFileName.substring(0, index);
}
return aFileName;
} | java | public static String stripExt(final String aFileName) {
final int index = aFileName.lastIndexOf(DOT);
if (index != -1) {
return aFileName.substring(0, index);
}
return aFileName;
} | [
"public",
"static",
"String",
"stripExt",
"(",
"final",
"String",
"aFileName",
")",
"{",
"final",
"int",
"index",
"=",
"aFileName",
".",
"lastIndexOf",
"(",
"DOT",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"return",
"aFileName",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"}",
"return",
"aFileName",
";",
"}"
] | Return a file name without the dot extension.
@param aFileName The file name from which we want to strip the extension
@return The file name without the extension | [
"Return",
"a",
"file",
"name",
"without",
"the",
"dot",
"extension",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L435-L443 |
1,875 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.getSize | public static long getSize(final File aFile) {
long size = 0;
if (aFile != null && aFile.exists()) {
if (aFile.isDirectory()) {
for (final File file : aFile.listFiles()) {
size += getSize(file);
}
} else {
size += aFile.length();
}
}
return size;
} | java | public static long getSize(final File aFile) {
long size = 0;
if (aFile != null && aFile.exists()) {
if (aFile.isDirectory()) {
for (final File file : aFile.listFiles()) {
size += getSize(file);
}
} else {
size += aFile.length();
}
}
return size;
} | [
"public",
"static",
"long",
"getSize",
"(",
"final",
"File",
"aFile",
")",
"{",
"long",
"size",
"=",
"0",
";",
"if",
"(",
"aFile",
"!=",
"null",
"&&",
"aFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"aFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"for",
"(",
"final",
"File",
"file",
":",
"aFile",
".",
"listFiles",
"(",
")",
")",
"{",
"size",
"+=",
"getSize",
"(",
"file",
")",
";",
"}",
"}",
"else",
"{",
"size",
"+=",
"aFile",
".",
"length",
"(",
")",
";",
"}",
"}",
"return",
"size",
";",
"}"
] | Gets the calculated size of a directory of files.
@param aFile A file or directory from which to calculate size
@return The calculated size of the supplied directory or file | [
"Gets",
"the",
"calculated",
"size",
"of",
"a",
"directory",
"of",
"files",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L467-L481 |
1,876 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.delete | public static boolean delete(final File aDir) {
if (aDir.exists() && aDir.listFiles() != null) {
for (final File file : aDir.listFiles()) {
if (file.isDirectory()) {
if (!delete(file)) {
LOGGER.error(MessageCodes.UTIL_012, file);
}
} else {
if (file.exists() && !file.delete()) {
LOGGER.error(MessageCodes.UTIL_012, file);
}
}
}
} else if (LOGGER.isDebugEnabled() && aDir.listFiles() == null) {
LOGGER.debug(MessageCodes.UTIL_013, aDir);
}
return aDir.delete();
} | java | public static boolean delete(final File aDir) {
if (aDir.exists() && aDir.listFiles() != null) {
for (final File file : aDir.listFiles()) {
if (file.isDirectory()) {
if (!delete(file)) {
LOGGER.error(MessageCodes.UTIL_012, file);
}
} else {
if (file.exists() && !file.delete()) {
LOGGER.error(MessageCodes.UTIL_012, file);
}
}
}
} else if (LOGGER.isDebugEnabled() && aDir.listFiles() == null) {
LOGGER.debug(MessageCodes.UTIL_013, aDir);
}
return aDir.delete();
} | [
"public",
"static",
"boolean",
"delete",
"(",
"final",
"File",
"aDir",
")",
"{",
"if",
"(",
"aDir",
".",
"exists",
"(",
")",
"&&",
"aDir",
".",
"listFiles",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"File",
"file",
":",
"aDir",
".",
"listFiles",
"(",
")",
")",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"!",
"delete",
"(",
"file",
")",
")",
"{",
"LOGGER",
".",
"error",
"(",
"MessageCodes",
".",
"UTIL_012",
",",
"file",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"file",
".",
"exists",
"(",
")",
"&&",
"!",
"file",
".",
"delete",
"(",
")",
")",
"{",
"LOGGER",
".",
"error",
"(",
"MessageCodes",
".",
"UTIL_012",
",",
"file",
")",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
"&&",
"aDir",
".",
"listFiles",
"(",
")",
"==",
"null",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"UTIL_013",
",",
"aDir",
")",
";",
"}",
"return",
"aDir",
".",
"delete",
"(",
")",
";",
"}"
] | Deletes a directory and all its children.
@param aDir A directory to delete
@return True if file was successfully deleted; else, false | [
"Deletes",
"a",
"directory",
"and",
"all",
"its",
"children",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L489-L507 |
1,877 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.copy | public static void copy(final File aFromFile, final File aToFile) throws IOException {
if (aFromFile.isDirectory() && aToFile.isFile() || aFromFile.isFile() && aToFile.isDirectory()) {
throw new IOException(LOGGER.getI18n(MessageCodes.UTIL_037, aFromFile, aToFile));
}
if (aFromFile.isDirectory()) {
if (!aToFile.exists() && !aToFile.mkdirs()) {
throw new IOException(LOGGER.getI18n(MessageCodes.UTIL_035, aToFile.getAbsolutePath()));
}
for (final File file : aFromFile.listFiles()) {
copy(file, new File(aToFile, file.getName()));
}
} else {
copyFile(aFromFile, aToFile);
}
} | java | public static void copy(final File aFromFile, final File aToFile) throws IOException {
if (aFromFile.isDirectory() && aToFile.isFile() || aFromFile.isFile() && aToFile.isDirectory()) {
throw new IOException(LOGGER.getI18n(MessageCodes.UTIL_037, aFromFile, aToFile));
}
if (aFromFile.isDirectory()) {
if (!aToFile.exists() && !aToFile.mkdirs()) {
throw new IOException(LOGGER.getI18n(MessageCodes.UTIL_035, aToFile.getAbsolutePath()));
}
for (final File file : aFromFile.listFiles()) {
copy(file, new File(aToFile, file.getName()));
}
} else {
copyFile(aFromFile, aToFile);
}
} | [
"public",
"static",
"void",
"copy",
"(",
"final",
"File",
"aFromFile",
",",
"final",
"File",
"aToFile",
")",
"throws",
"IOException",
"{",
"if",
"(",
"aFromFile",
".",
"isDirectory",
"(",
")",
"&&",
"aToFile",
".",
"isFile",
"(",
")",
"||",
"aFromFile",
".",
"isFile",
"(",
")",
"&&",
"aToFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_037",
",",
"aFromFile",
",",
"aToFile",
")",
")",
";",
"}",
"if",
"(",
"aFromFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"!",
"aToFile",
".",
"exists",
"(",
")",
"&&",
"!",
"aToFile",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"LOGGER",
".",
"getI18n",
"(",
"MessageCodes",
".",
"UTIL_035",
",",
"aToFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"for",
"(",
"final",
"File",
"file",
":",
"aFromFile",
".",
"listFiles",
"(",
")",
")",
"{",
"copy",
"(",
"file",
",",
"new",
"File",
"(",
"aToFile",
",",
"file",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"copyFile",
"(",
"aFromFile",
",",
"aToFile",
")",
";",
"}",
"}"
] | Copies a file or directory from one place to another. This copies a file to a file or a directory to a
directory. It does not copy a file to a directory.
@param aFromFile A file or directory source
@param aToFile A file or directory destination
@throws IOException If there is an exception copying the files or directories | [
"Copies",
"a",
"file",
"or",
"directory",
"from",
"one",
"place",
"to",
"another",
".",
"This",
"copies",
"a",
"file",
"to",
"a",
"file",
"or",
"a",
"directory",
"to",
"a",
"directory",
".",
"It",
"does",
"not",
"copy",
"a",
"file",
"to",
"a",
"directory",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L517-L533 |
1,878 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.hash | public static String hash(final File aFile, final String aAlgorithm) throws NoSuchAlgorithmException,
IOException {
final MessageDigest md = MessageDigest.getInstance(aAlgorithm);
final FileInputStream inStream = new FileInputStream(aFile);
final DigestInputStream mdStream = new DigestInputStream(inStream, md);
final byte[] bytes = new byte[8192];
int bytesRead = 0;
while (bytesRead != -1) {
bytesRead = mdStream.read(bytes);
}
final Formatter formatter = new Formatter();
for (final byte bite : md.digest()) {
formatter.format("%02x", bite);
}
IOUtils.closeQuietly(mdStream);
final String hash = formatter.toString();
formatter.close();
return hash;
} | java | public static String hash(final File aFile, final String aAlgorithm) throws NoSuchAlgorithmException,
IOException {
final MessageDigest md = MessageDigest.getInstance(aAlgorithm);
final FileInputStream inStream = new FileInputStream(aFile);
final DigestInputStream mdStream = new DigestInputStream(inStream, md);
final byte[] bytes = new byte[8192];
int bytesRead = 0;
while (bytesRead != -1) {
bytesRead = mdStream.read(bytes);
}
final Formatter formatter = new Formatter();
for (final byte bite : md.digest()) {
formatter.format("%02x", bite);
}
IOUtils.closeQuietly(mdStream);
final String hash = formatter.toString();
formatter.close();
return hash;
} | [
"public",
"static",
"String",
"hash",
"(",
"final",
"File",
"aFile",
",",
"final",
"String",
"aAlgorithm",
")",
"throws",
"NoSuchAlgorithmException",
",",
"IOException",
"{",
"final",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"aAlgorithm",
")",
";",
"final",
"FileInputStream",
"inStream",
"=",
"new",
"FileInputStream",
"(",
"aFile",
")",
";",
"final",
"DigestInputStream",
"mdStream",
"=",
"new",
"DigestInputStream",
"(",
"inStream",
",",
"md",
")",
";",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"8192",
"]",
";",
"int",
"bytesRead",
"=",
"0",
";",
"while",
"(",
"bytesRead",
"!=",
"-",
"1",
")",
"{",
"bytesRead",
"=",
"mdStream",
".",
"read",
"(",
"bytes",
")",
";",
"}",
"final",
"Formatter",
"formatter",
"=",
"new",
"Formatter",
"(",
")",
";",
"for",
"(",
"final",
"byte",
"bite",
":",
"md",
".",
"digest",
"(",
")",
")",
"{",
"formatter",
".",
"format",
"(",
"\"%02x\"",
",",
"bite",
")",
";",
"}",
"IOUtils",
".",
"closeQuietly",
"(",
"mdStream",
")",
";",
"final",
"String",
"hash",
"=",
"formatter",
".",
"toString",
"(",
")",
";",
"formatter",
".",
"close",
"(",
")",
";",
"return",
"hash",
";",
"}"
] | Get a hash for a supplied file.
@param aFile A file to get a hash for
@param aAlgorithm A hash algorithm supported by <code>MessageDigest</code>
@return A hash string
@throws NoSuchAlgorithmException If the supplied algorithm isn't supported
@throws IOException If there is trouble reading the file | [
"Get",
"a",
"hash",
"for",
"a",
"supplied",
"file",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L576-L601 |
1,879 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.convertToPermissionsSet | public static Set<PosixFilePermission> convertToPermissionsSet(final int aMode) {
final Set<PosixFilePermission> result = EnumSet.noneOf(PosixFilePermission.class);
if (isSet(aMode, 0400)) {
result.add(PosixFilePermission.OWNER_READ);
}
if (isSet(aMode, 0200)) {
result.add(PosixFilePermission.OWNER_WRITE);
}
if (isSet(aMode, 0100)) {
result.add(PosixFilePermission.OWNER_EXECUTE);
}
if (isSet(aMode, 040)) {
result.add(PosixFilePermission.GROUP_READ);
}
if (isSet(aMode, 020)) {
result.add(PosixFilePermission.GROUP_WRITE);
}
if (isSet(aMode, 010)) {
result.add(PosixFilePermission.GROUP_EXECUTE);
}
if (isSet(aMode, 04)) {
result.add(PosixFilePermission.OTHERS_READ);
}
if (isSet(aMode, 02)) {
result.add(PosixFilePermission.OTHERS_WRITE);
}
if (isSet(aMode, 01)) {
result.add(PosixFilePermission.OTHERS_EXECUTE);
}
return result;
} | java | public static Set<PosixFilePermission> convertToPermissionsSet(final int aMode) {
final Set<PosixFilePermission> result = EnumSet.noneOf(PosixFilePermission.class);
if (isSet(aMode, 0400)) {
result.add(PosixFilePermission.OWNER_READ);
}
if (isSet(aMode, 0200)) {
result.add(PosixFilePermission.OWNER_WRITE);
}
if (isSet(aMode, 0100)) {
result.add(PosixFilePermission.OWNER_EXECUTE);
}
if (isSet(aMode, 040)) {
result.add(PosixFilePermission.GROUP_READ);
}
if (isSet(aMode, 020)) {
result.add(PosixFilePermission.GROUP_WRITE);
}
if (isSet(aMode, 010)) {
result.add(PosixFilePermission.GROUP_EXECUTE);
}
if (isSet(aMode, 04)) {
result.add(PosixFilePermission.OTHERS_READ);
}
if (isSet(aMode, 02)) {
result.add(PosixFilePermission.OTHERS_WRITE);
}
if (isSet(aMode, 01)) {
result.add(PosixFilePermission.OTHERS_EXECUTE);
}
return result;
} | [
"public",
"static",
"Set",
"<",
"PosixFilePermission",
">",
"convertToPermissionsSet",
"(",
"final",
"int",
"aMode",
")",
"{",
"final",
"Set",
"<",
"PosixFilePermission",
">",
"result",
"=",
"EnumSet",
".",
"noneOf",
"(",
"PosixFilePermission",
".",
"class",
")",
";",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"0400",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"OWNER_READ",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"0200",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"OWNER_WRITE",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"0100",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"OWNER_EXECUTE",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"040",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"GROUP_READ",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"020",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"GROUP_WRITE",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"010",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"GROUP_EXECUTE",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"04",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"OTHERS_READ",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"02",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"OTHERS_WRITE",
")",
";",
"}",
"if",
"(",
"isSet",
"(",
"aMode",
",",
"01",
")",
")",
"{",
"result",
".",
"add",
"(",
"PosixFilePermission",
".",
"OTHERS_EXECUTE",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Converts an file permissions mode integer to a PosixFilePermission set.
@param aMode An integer permissions mode.
@return A PosixFilePermission set | [
"Converts",
"an",
"file",
"permissions",
"mode",
"integer",
"to",
"a",
"PosixFilePermission",
"set",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L643-L683 |
1,880 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.convertToInt | public static int convertToInt(final Set<PosixFilePermission> aPermSet) {
int result = 0;
if (aPermSet.contains(PosixFilePermission.OWNER_READ)) {
result = result | 0400;
}
if (aPermSet.contains(PosixFilePermission.OWNER_WRITE)) {
result = result | 0200;
}
if (aPermSet.contains(PosixFilePermission.OWNER_EXECUTE)) {
result = result | 0100;
}
if (aPermSet.contains(PosixFilePermission.GROUP_READ)) {
result = result | 040;
}
if (aPermSet.contains(PosixFilePermission.GROUP_WRITE)) {
result = result | 020;
}
if (aPermSet.contains(PosixFilePermission.GROUP_EXECUTE)) {
result = result | 010;
}
if (aPermSet.contains(PosixFilePermission.OTHERS_READ)) {
result = result | 04;
}
if (aPermSet.contains(PosixFilePermission.OTHERS_WRITE)) {
result = result | 02;
}
if (aPermSet.contains(PosixFilePermission.OTHERS_EXECUTE)) {
result = result | 01;
}
return result;
} | java | public static int convertToInt(final Set<PosixFilePermission> aPermSet) {
int result = 0;
if (aPermSet.contains(PosixFilePermission.OWNER_READ)) {
result = result | 0400;
}
if (aPermSet.contains(PosixFilePermission.OWNER_WRITE)) {
result = result | 0200;
}
if (aPermSet.contains(PosixFilePermission.OWNER_EXECUTE)) {
result = result | 0100;
}
if (aPermSet.contains(PosixFilePermission.GROUP_READ)) {
result = result | 040;
}
if (aPermSet.contains(PosixFilePermission.GROUP_WRITE)) {
result = result | 020;
}
if (aPermSet.contains(PosixFilePermission.GROUP_EXECUTE)) {
result = result | 010;
}
if (aPermSet.contains(PosixFilePermission.OTHERS_READ)) {
result = result | 04;
}
if (aPermSet.contains(PosixFilePermission.OTHERS_WRITE)) {
result = result | 02;
}
if (aPermSet.contains(PosixFilePermission.OTHERS_EXECUTE)) {
result = result | 01;
}
return result;
} | [
"public",
"static",
"int",
"convertToInt",
"(",
"final",
"Set",
"<",
"PosixFilePermission",
">",
"aPermSet",
")",
"{",
"int",
"result",
"=",
"0",
";",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"OWNER_READ",
")",
")",
"{",
"result",
"=",
"result",
"|",
"0400",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"OWNER_WRITE",
")",
")",
"{",
"result",
"=",
"result",
"|",
"0200",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"OWNER_EXECUTE",
")",
")",
"{",
"result",
"=",
"result",
"|",
"0100",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"GROUP_READ",
")",
")",
"{",
"result",
"=",
"result",
"|",
"040",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"GROUP_WRITE",
")",
")",
"{",
"result",
"=",
"result",
"|",
"020",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"GROUP_EXECUTE",
")",
")",
"{",
"result",
"=",
"result",
"|",
"010",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"OTHERS_READ",
")",
")",
"{",
"result",
"=",
"result",
"|",
"04",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"OTHERS_WRITE",
")",
")",
"{",
"result",
"=",
"result",
"|",
"02",
";",
"}",
"if",
"(",
"aPermSet",
".",
"contains",
"(",
"PosixFilePermission",
".",
"OTHERS_EXECUTE",
")",
")",
"{",
"result",
"=",
"result",
"|",
"01",
";",
"}",
"return",
"result",
";",
"}"
] | Convert a PosixFilePermission set to an integer permissions mode.
@param aPermSet A PosixFilePermission set
@return A permissions mode integer | [
"Convert",
"a",
"PosixFilePermission",
"set",
"to",
"an",
"integer",
"permissions",
"mode",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L691-L731 |
1,881 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.copyFile | private static boolean copyFile(final File aSourceFile, final File aDestFile) throws IOException {
FileOutputStream outputStream = null;
FileInputStream inputStream = null;
boolean success = true;
// destructive copy
if (aDestFile.exists() && !aDestFile.delete()) {
success = false;
}
if (success && !aDestFile.createNewFile()) {
LOGGER.warn(MessageCodes.UTIL_014, aDestFile.getAbsolutePath());
success = false;
}
if (success) {
try {
final FileChannel source;
outputStream = new FileOutputStream(aDestFile);
inputStream = new FileInputStream(aSourceFile);
source = inputStream.getChannel();
outputStream.getChannel().transferFrom(source, 0, source.size());
} finally {
IOUtils.closeQuietly(outputStream);
IOUtils.closeQuietly(inputStream);
}
}
if (success && aDestFile.exists() && aSourceFile.canRead()) {
success = aDestFile.setReadable(true, true);
}
if (success && aDestFile.exists() && aSourceFile.canWrite()) {
success = aDestFile.setWritable(true, true);
}
if (success && aDestFile.exists() && aSourceFile.canExecute()) {
success = aDestFile.setExecutable(true, true);
}
if (!success && !aDestFile.delete() && LOGGER.isWarnEnabled()) {
LOGGER.warn(MessageCodes.UTIL_015, aDestFile);
}
return success;
} | java | private static boolean copyFile(final File aSourceFile, final File aDestFile) throws IOException {
FileOutputStream outputStream = null;
FileInputStream inputStream = null;
boolean success = true;
// destructive copy
if (aDestFile.exists() && !aDestFile.delete()) {
success = false;
}
if (success && !aDestFile.createNewFile()) {
LOGGER.warn(MessageCodes.UTIL_014, aDestFile.getAbsolutePath());
success = false;
}
if (success) {
try {
final FileChannel source;
outputStream = new FileOutputStream(aDestFile);
inputStream = new FileInputStream(aSourceFile);
source = inputStream.getChannel();
outputStream.getChannel().transferFrom(source, 0, source.size());
} finally {
IOUtils.closeQuietly(outputStream);
IOUtils.closeQuietly(inputStream);
}
}
if (success && aDestFile.exists() && aSourceFile.canRead()) {
success = aDestFile.setReadable(true, true);
}
if (success && aDestFile.exists() && aSourceFile.canWrite()) {
success = aDestFile.setWritable(true, true);
}
if (success && aDestFile.exists() && aSourceFile.canExecute()) {
success = aDestFile.setExecutable(true, true);
}
if (!success && !aDestFile.delete() && LOGGER.isWarnEnabled()) {
LOGGER.warn(MessageCodes.UTIL_015, aDestFile);
}
return success;
} | [
"private",
"static",
"boolean",
"copyFile",
"(",
"final",
"File",
"aSourceFile",
",",
"final",
"File",
"aDestFile",
")",
"throws",
"IOException",
"{",
"FileOutputStream",
"outputStream",
"=",
"null",
";",
"FileInputStream",
"inputStream",
"=",
"null",
";",
"boolean",
"success",
"=",
"true",
";",
"// destructive copy",
"if",
"(",
"aDestFile",
".",
"exists",
"(",
")",
"&&",
"!",
"aDestFile",
".",
"delete",
"(",
")",
")",
"{",
"success",
"=",
"false",
";",
"}",
"if",
"(",
"success",
"&&",
"!",
"aDestFile",
".",
"createNewFile",
"(",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"MessageCodes",
".",
"UTIL_014",
",",
"aDestFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"success",
"=",
"false",
";",
"}",
"if",
"(",
"success",
")",
"{",
"try",
"{",
"final",
"FileChannel",
"source",
";",
"outputStream",
"=",
"new",
"FileOutputStream",
"(",
"aDestFile",
")",
";",
"inputStream",
"=",
"new",
"FileInputStream",
"(",
"aSourceFile",
")",
";",
"source",
"=",
"inputStream",
".",
"getChannel",
"(",
")",
";",
"outputStream",
".",
"getChannel",
"(",
")",
".",
"transferFrom",
"(",
"source",
",",
"0",
",",
"source",
".",
"size",
"(",
")",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"outputStream",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"inputStream",
")",
";",
"}",
"}",
"if",
"(",
"success",
"&&",
"aDestFile",
".",
"exists",
"(",
")",
"&&",
"aSourceFile",
".",
"canRead",
"(",
")",
")",
"{",
"success",
"=",
"aDestFile",
".",
"setReadable",
"(",
"true",
",",
"true",
")",
";",
"}",
"if",
"(",
"success",
"&&",
"aDestFile",
".",
"exists",
"(",
")",
"&&",
"aSourceFile",
".",
"canWrite",
"(",
")",
")",
"{",
"success",
"=",
"aDestFile",
".",
"setWritable",
"(",
"true",
",",
"true",
")",
";",
"}",
"if",
"(",
"success",
"&&",
"aDestFile",
".",
"exists",
"(",
")",
"&&",
"aSourceFile",
".",
"canExecute",
"(",
")",
")",
"{",
"success",
"=",
"aDestFile",
".",
"setExecutable",
"(",
"true",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"success",
"&&",
"!",
"aDestFile",
".",
"delete",
"(",
")",
"&&",
"LOGGER",
".",
"isWarnEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"MessageCodes",
".",
"UTIL_015",
",",
"aDestFile",
")",
";",
"}",
"return",
"success",
";",
"}"
] | Copies a non-directory file from one location to another.
@param aSourceFile A file to copy
@param aDestFile A destination location for the copied file
@return True if the copy was successful; else, false
@throws IOException If there is a problem copying the file | [
"Copies",
"a",
"non",
"-",
"directory",
"file",
"from",
"one",
"location",
"to",
"another",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L745-L791 |
1,882 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.copyMetadata | private static void copyMetadata(final File aFile, final Element aElement) {
final SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT, Locale.US);
final StringBuilder permissions = new StringBuilder();
final Date date = new Date(aFile.lastModified());
aElement.setAttribute(FILE_PATH, aFile.getAbsolutePath());
aElement.setAttribute(MODIFIED, formatter.format(date));
if (aFile.canRead()) {
permissions.append('r');
}
if (aFile.canWrite()) {
permissions.append('w');
}
aElement.setAttribute("permissions", permissions.toString());
} | java | private static void copyMetadata(final File aFile, final Element aElement) {
final SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT, Locale.US);
final StringBuilder permissions = new StringBuilder();
final Date date = new Date(aFile.lastModified());
aElement.setAttribute(FILE_PATH, aFile.getAbsolutePath());
aElement.setAttribute(MODIFIED, formatter.format(date));
if (aFile.canRead()) {
permissions.append('r');
}
if (aFile.canWrite()) {
permissions.append('w');
}
aElement.setAttribute("permissions", permissions.toString());
} | [
"private",
"static",
"void",
"copyMetadata",
"(",
"final",
"File",
"aFile",
",",
"final",
"Element",
"aElement",
")",
"{",
"final",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"DATE_FORMAT",
",",
"Locale",
".",
"US",
")",
";",
"final",
"StringBuilder",
"permissions",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"Date",
"date",
"=",
"new",
"Date",
"(",
"aFile",
".",
"lastModified",
"(",
")",
")",
";",
"aElement",
".",
"setAttribute",
"(",
"FILE_PATH",
",",
"aFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"aElement",
".",
"setAttribute",
"(",
"MODIFIED",
",",
"formatter",
".",
"format",
"(",
"date",
")",
")",
";",
"if",
"(",
"aFile",
".",
"canRead",
"(",
")",
")",
"{",
"permissions",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"if",
"(",
"aFile",
".",
"canWrite",
"(",
")",
")",
"{",
"permissions",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"aElement",
".",
"setAttribute",
"(",
"\"permissions\"",
",",
"permissions",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Copy file metadata into the supplied file element.
@param aFile A file to extract metadata from
@param aElement A destination element for the file metadata | [
"Copy",
"file",
"metadata",
"into",
"the",
"supplied",
"file",
"element",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L862-L879 |
1,883 | opencredo/opencredo-esper | esper-si-support/src/main/java/org/opencredo/esper/integration/throughput/EsperChannelThroughputMonitor.java | EsperChannelThroughputMonitor.update | public void update(long throughput) {
if (LOG.isDebugEnabled()) {
LOG.debug("Received throughput of " + throughput + " on channel - " + this.channel.getComponentName());
}
this.throughput = throughput;
} | java | public void update(long throughput) {
if (LOG.isDebugEnabled()) {
LOG.debug("Received throughput of " + throughput + " on channel - " + this.channel.getComponentName());
}
this.throughput = throughput;
} | [
"public",
"void",
"update",
"(",
"long",
"throughput",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Received throughput of \"",
"+",
"throughput",
"+",
"\" on channel - \"",
"+",
"this",
".",
"channel",
".",
"getComponentName",
"(",
")",
")",
";",
"}",
"this",
".",
"throughput",
"=",
"throughput",
";",
"}"
] | Method used by the Esper subscriber contract where the payload of the
event is passed to the subscriber. In this case the payload is a
calculated throughput.
@param throughput
the calculated throughput for the channel | [
"Method",
"used",
"by",
"the",
"Esper",
"subscriber",
"contract",
"where",
"the",
"payload",
"of",
"the",
"event",
"is",
"passed",
"to",
"the",
"subscriber",
".",
"In",
"this",
"case",
"the",
"payload",
"is",
"a",
"calculated",
"throughput",
"."
] | a88c9fd0301a4d6962da70d85577c27d50d08825 | https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-si-support/src/main/java/org/opencredo/esper/integration/throughput/EsperChannelThroughputMonitor.java#L149-L154 |
1,884 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/XMLResourceBundle.java | XMLResourceBundle.get | public String get(final String aMessage, final String... aArray) {
return StringUtils.format(super.getString(aMessage), aArray);
} | java | public String get(final String aMessage, final String... aArray) {
return StringUtils.format(super.getString(aMessage), aArray);
} | [
"public",
"String",
"get",
"(",
"final",
"String",
"aMessage",
",",
"final",
"String",
"...",
"aArray",
")",
"{",
"return",
"StringUtils",
".",
"format",
"(",
"super",
".",
"getString",
"(",
"aMessage",
")",
",",
"aArray",
")",
";",
"}"
] | Return a message value with the supplied values integrated into it.
@param aMessage A message in which to include the supplied string values
@param aArray The string values to insert into the supplied message
@return A message with the supplied values integrated into it | [
"Return",
"a",
"message",
"value",
"with",
"the",
"supplied",
"values",
"integrated",
"into",
"it",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/XMLResourceBundle.java#L91-L93 |
1,885 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/XMLResourceBundle.java | XMLResourceBundle.get | public String get(final String aMessage, final String aDetail) {
return StringUtils.format(super.getString(aMessage), aDetail);
} | java | public String get(final String aMessage, final String aDetail) {
return StringUtils.format(super.getString(aMessage), aDetail);
} | [
"public",
"String",
"get",
"(",
"final",
"String",
"aMessage",
",",
"final",
"String",
"aDetail",
")",
"{",
"return",
"StringUtils",
".",
"format",
"(",
"super",
".",
"getString",
"(",
"aMessage",
")",
",",
"aDetail",
")",
";",
"}"
] | Return a message value with the supplied string integrated into it.
@param aMessage A message in which to include the supplied string value
@param aDetail A string value to be included into the supplied message
@return A message with the supplied string value integrated into it | [
"Return",
"a",
"message",
"value",
"with",
"the",
"supplied",
"string",
"integrated",
"into",
"it",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/XMLResourceBundle.java#L102-L104 |
1,886 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/XMLResourceBundle.java | XMLResourceBundle.get | public String get(final String aMessage, final File... aFileArray) {
final String[] details = new String[aFileArray.length];
for (int index = 0; index < details.length; index++) {
details[index] = aFileArray[index].getAbsolutePath();
}
LOGGER.debug(MessageCodes.UTIL_026, aMessage, details);
return StringUtils.format(super.getString(aMessage), details);
} | java | public String get(final String aMessage, final File... aFileArray) {
final String[] details = new String[aFileArray.length];
for (int index = 0; index < details.length; index++) {
details[index] = aFileArray[index].getAbsolutePath();
}
LOGGER.debug(MessageCodes.UTIL_026, aMessage, details);
return StringUtils.format(super.getString(aMessage), details);
} | [
"public",
"String",
"get",
"(",
"final",
"String",
"aMessage",
",",
"final",
"File",
"...",
"aFileArray",
")",
"{",
"final",
"String",
"[",
"]",
"details",
"=",
"new",
"String",
"[",
"aFileArray",
".",
"length",
"]",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"details",
".",
"length",
";",
"index",
"++",
")",
"{",
"details",
"[",
"index",
"]",
"=",
"aFileArray",
"[",
"index",
"]",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"UTIL_026",
",",
"aMessage",
",",
"details",
")",
";",
"return",
"StringUtils",
".",
"format",
"(",
"super",
".",
"getString",
"(",
"aMessage",
")",
",",
"details",
")",
";",
"}"
] | Returns the string form of the requested message with the file values integrated into it.
@param aMessage A message key to use to return a message value
@param aFileArray An array of files, whose names should be integrated into the message value
@return The message value with the supplied file names integrated | [
"Returns",
"the",
"string",
"form",
"of",
"the",
"requested",
"message",
"with",
"the",
"file",
"values",
"integrated",
"into",
"it",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/XMLResourceBundle.java#L123-L132 |
1,887 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/XMLResourceBundle.java | XMLResourceBundle.get | public String get(final String aMessage, final File aFile) {
return StringUtils.format(super.getString(aMessage), new String[] { aFile.getAbsolutePath() });
} | java | public String get(final String aMessage, final File aFile) {
return StringUtils.format(super.getString(aMessage), new String[] { aFile.getAbsolutePath() });
} | [
"public",
"String",
"get",
"(",
"final",
"String",
"aMessage",
",",
"final",
"File",
"aFile",
")",
"{",
"return",
"StringUtils",
".",
"format",
"(",
"super",
".",
"getString",
"(",
"aMessage",
")",
",",
"new",
"String",
"[",
"]",
"{",
"aFile",
".",
"getAbsolutePath",
"(",
")",
"}",
")",
";",
"}"
] | Returns the string form of the requested message with the file value integrated into it.
@param aMessage A message key to use to return a message value
@param aFile A file whose name should be integrated into the message value
@return The message value with the supplied file name integrated | [
"Returns",
"the",
"string",
"form",
"of",
"the",
"requested",
"message",
"with",
"the",
"file",
"value",
"integrated",
"into",
"it",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/XMLResourceBundle.java#L141-L143 |
1,888 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/ZipUtils.java | ZipUtils.zip | public static void zip(final File aFileSystemDir, final File aOutputZipFile) throws FileNotFoundException,
IOException {
zip(aFileSystemDir, aOutputZipFile, new RegexFileFilter(WILDCARD));
} | java | public static void zip(final File aFileSystemDir, final File aOutputZipFile) throws FileNotFoundException,
IOException {
zip(aFileSystemDir, aOutputZipFile, new RegexFileFilter(WILDCARD));
} | [
"public",
"static",
"void",
"zip",
"(",
"final",
"File",
"aFileSystemDir",
",",
"final",
"File",
"aOutputZipFile",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"zip",
"(",
"aFileSystemDir",
",",
"aOutputZipFile",
",",
"new",
"RegexFileFilter",
"(",
"WILDCARD",
")",
")",
";",
"}"
] | Recursively zip a file system directory.
@param aFileSystemDir A directory to be recursively zipped up
@param aOutputZipFile An output Zip file
@throws FileNotFoundException If a file expected to be there is not found
@throws IOException If there is trouble writing to a Zip file | [
"Recursively",
"zip",
"a",
"file",
"system",
"directory",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/ZipUtils.java#L35-L38 |
1,889 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/ZipUtils.java | ZipUtils.zip | public static void zip(final File aFileSystemDir, final File aOutputZipFile, final FilenameFilter aIncludesFilter,
final File... aIncludesFileList) throws FileNotFoundException, IOException {
final ZipOutputStream zipFileStream = new ZipOutputStream(new FileOutputStream(aOutputZipFile));
final String parentDirPath = aFileSystemDir.getParentFile().getAbsolutePath();
dirToZip(aFileSystemDir, parentDirPath, aIncludesFilter, zipFileStream);
// Supplied additional files are just written into the root folder of the package
for (final File file : aIncludesFileList) {
final String path = File.separator + aFileSystemDir.getName() + File.separator + file.getName();
final ZipEntry entry = new ZipEntry(path);
final FileInputStream inFileStream = new FileInputStream(file);
zipFileStream.putNextEntry(entry);
IOUtils.copyStream(inFileStream, zipFileStream);
IOUtils.closeQuietly(inFileStream);
}
IOUtils.closeQuietly(zipFileStream);
} | java | public static void zip(final File aFileSystemDir, final File aOutputZipFile, final FilenameFilter aIncludesFilter,
final File... aIncludesFileList) throws FileNotFoundException, IOException {
final ZipOutputStream zipFileStream = new ZipOutputStream(new FileOutputStream(aOutputZipFile));
final String parentDirPath = aFileSystemDir.getParentFile().getAbsolutePath();
dirToZip(aFileSystemDir, parentDirPath, aIncludesFilter, zipFileStream);
// Supplied additional files are just written into the root folder of the package
for (final File file : aIncludesFileList) {
final String path = File.separator + aFileSystemDir.getName() + File.separator + file.getName();
final ZipEntry entry = new ZipEntry(path);
final FileInputStream inFileStream = new FileInputStream(file);
zipFileStream.putNextEntry(entry);
IOUtils.copyStream(inFileStream, zipFileStream);
IOUtils.closeQuietly(inFileStream);
}
IOUtils.closeQuietly(zipFileStream);
} | [
"public",
"static",
"void",
"zip",
"(",
"final",
"File",
"aFileSystemDir",
",",
"final",
"File",
"aOutputZipFile",
",",
"final",
"FilenameFilter",
"aIncludesFilter",
",",
"final",
"File",
"...",
"aIncludesFileList",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"final",
"ZipOutputStream",
"zipFileStream",
"=",
"new",
"ZipOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"aOutputZipFile",
")",
")",
";",
"final",
"String",
"parentDirPath",
"=",
"aFileSystemDir",
".",
"getParentFile",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"dirToZip",
"(",
"aFileSystemDir",
",",
"parentDirPath",
",",
"aIncludesFilter",
",",
"zipFileStream",
")",
";",
"// Supplied additional files are just written into the root folder of the package",
"for",
"(",
"final",
"File",
"file",
":",
"aIncludesFileList",
")",
"{",
"final",
"String",
"path",
"=",
"File",
".",
"separator",
"+",
"aFileSystemDir",
".",
"getName",
"(",
")",
"+",
"File",
".",
"separator",
"+",
"file",
".",
"getName",
"(",
")",
";",
"final",
"ZipEntry",
"entry",
"=",
"new",
"ZipEntry",
"(",
"path",
")",
";",
"final",
"FileInputStream",
"inFileStream",
"=",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"zipFileStream",
".",
"putNextEntry",
"(",
"entry",
")",
";",
"IOUtils",
".",
"copyStream",
"(",
"inFileStream",
",",
"zipFileStream",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"inFileStream",
")",
";",
"}",
"IOUtils",
".",
"closeQuietly",
"(",
"zipFileStream",
")",
";",
"}"
] | Recursively zip up a file system directory.
@param aFileSystemDir A directory to be recursively zipped up
@param aOutputZipFile An output Zip file
@param aIncludesFilter A file name filter indicating which files to include
@param aIncludesFileList A varargs of additional files to include in the zipped directory
@throws FileNotFoundException If a file expected to be there is not found
@throws IOException If there is trouble writing to the Zip file | [
"Recursively",
"zip",
"up",
"a",
"file",
"system",
"directory",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/ZipUtils.java#L64-L83 |
1,890 | opencredo/opencredo-esper | esper-template/src/main/java/org/opencredo/esper/config/xml/EsperStatementParser.java | EsperStatementParser.parseStatements | @SuppressWarnings("unchecked")
public ManagedSet parseStatements(Element element, ParserContext parserContext) {
ManagedSet statements = new ManagedSet();
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element childElement = (Element) child;
String localName = child.getLocalName();
if ("statement".equals(localName)) {
BeanDefinition definition = parserContext.getDelegate().parseCustomElement(childElement);
statements.add(definition);
} else if ("ref".equals(localName)) {
String ref = childElement.getAttribute("bean");
statements.add(new RuntimeBeanReference(ref));
}
}
}
return statements;
} | java | @SuppressWarnings("unchecked")
public ManagedSet parseStatements(Element element, ParserContext parserContext) {
ManagedSet statements = new ManagedSet();
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element childElement = (Element) child;
String localName = child.getLocalName();
if ("statement".equals(localName)) {
BeanDefinition definition = parserContext.getDelegate().parseCustomElement(childElement);
statements.add(definition);
} else if ("ref".equals(localName)) {
String ref = childElement.getAttribute("bean");
statements.add(new RuntimeBeanReference(ref));
}
}
}
return statements;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ManagedSet",
"parseStatements",
"(",
"Element",
"element",
",",
"ParserContext",
"parserContext",
")",
"{",
"ManagedSet",
"statements",
"=",
"new",
"ManagedSet",
"(",
")",
";",
"NodeList",
"childNodes",
"=",
"element",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"childNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"child",
"=",
"childNodes",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"child",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"Element",
"childElement",
"=",
"(",
"Element",
")",
"child",
";",
"String",
"localName",
"=",
"child",
".",
"getLocalName",
"(",
")",
";",
"if",
"(",
"\"statement\"",
".",
"equals",
"(",
"localName",
")",
")",
"{",
"BeanDefinition",
"definition",
"=",
"parserContext",
".",
"getDelegate",
"(",
")",
".",
"parseCustomElement",
"(",
"childElement",
")",
";",
"statements",
".",
"add",
"(",
"definition",
")",
";",
"}",
"else",
"if",
"(",
"\"ref\"",
".",
"equals",
"(",
"localName",
")",
")",
"{",
"String",
"ref",
"=",
"childElement",
".",
"getAttribute",
"(",
"\"bean\"",
")",
";",
"statements",
".",
"add",
"(",
"new",
"RuntimeBeanReference",
"(",
"ref",
")",
")",
";",
"}",
"}",
"}",
"return",
"statements",
";",
"}"
] | Parses out the individual statement elements for further processing.
@param element
the esper-template context
@param parserContext
the parser's context
@return a set of initialized esper statements | [
"Parses",
"out",
"the",
"individual",
"statement",
"elements",
"for",
"further",
"processing",
"."
] | a88c9fd0301a4d6962da70d85577c27d50d08825 | https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/config/xml/EsperStatementParser.java#L100-L125 |
1,891 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.closeQuietly | public static void closeQuietly(final Reader aReader) {
if (aReader != null) {
try {
aReader.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | java | public static void closeQuietly(final Reader aReader) {
if (aReader != null) {
try {
aReader.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"Reader",
"aReader",
")",
"{",
"if",
"(",
"aReader",
"!=",
"null",
")",
"{",
"try",
"{",
"aReader",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"details",
")",
"{",
"LOGGER",
".",
"error",
"(",
"details",
".",
"getMessage",
"(",
")",
",",
"details",
")",
";",
"}",
"}",
"}"
] | Closes a reader, catching and logging any exceptions.
@param aReader A supplied reader to close | [
"Closes",
"a",
"reader",
"catching",
"and",
"logging",
"any",
"exceptions",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L39-L47 |
1,892 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.closeQuietly | public static void closeQuietly(final Writer aWriter) {
if (aWriter != null) {
try {
aWriter.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | java | public static void closeQuietly(final Writer aWriter) {
if (aWriter != null) {
try {
aWriter.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"Writer",
"aWriter",
")",
"{",
"if",
"(",
"aWriter",
"!=",
"null",
")",
"{",
"try",
"{",
"aWriter",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"details",
")",
"{",
"LOGGER",
".",
"error",
"(",
"details",
".",
"getMessage",
"(",
")",
",",
"details",
")",
";",
"}",
"}",
"}"
] | Closes a writer, catching and logging any exceptions.
@param aWriter A supplied writer to close | [
"Closes",
"a",
"writer",
"catching",
"and",
"logging",
"any",
"exceptions",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L54-L62 |
1,893 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.closeQuietly | public static void closeQuietly(final InputStream aInputStream) {
if (aInputStream != null) {
try {
aInputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | java | public static void closeQuietly(final InputStream aInputStream) {
if (aInputStream != null) {
try {
aInputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"InputStream",
"aInputStream",
")",
"{",
"if",
"(",
"aInputStream",
"!=",
"null",
")",
"{",
"try",
"{",
"aInputStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"details",
")",
"{",
"LOGGER",
".",
"error",
"(",
"details",
".",
"getMessage",
"(",
")",
",",
"details",
")",
";",
"}",
"}",
"}"
] | Closes an input stream, catching and logging any exceptions.
@param aInputStream A supplied input stream to close | [
"Closes",
"an",
"input",
"stream",
"catching",
"and",
"logging",
"any",
"exceptions",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L69-L77 |
1,894 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.closeQuietly | public static void closeQuietly(final ImageInputStream aImageInputStream) {
if (aImageInputStream != null) {
try {
aImageInputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | java | public static void closeQuietly(final ImageInputStream aImageInputStream) {
if (aImageInputStream != null) {
try {
aImageInputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"ImageInputStream",
"aImageInputStream",
")",
"{",
"if",
"(",
"aImageInputStream",
"!=",
"null",
")",
"{",
"try",
"{",
"aImageInputStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"details",
")",
"{",
"LOGGER",
".",
"error",
"(",
"details",
".",
"getMessage",
"(",
")",
",",
"details",
")",
";",
"}",
"}",
"}"
] | Closes an image input stream, catching and logging any exceptions
@param aImageInputStream A supplied image input stream to close | [
"Closes",
"an",
"image",
"input",
"stream",
"catching",
"and",
"logging",
"any",
"exceptions"
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L84-L92 |
1,895 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.closeQuietly | public static void closeQuietly(final ImageOutputStream aImageOutputStream) {
if (aImageOutputStream != null) {
try {
aImageOutputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | java | public static void closeQuietly(final ImageOutputStream aImageOutputStream) {
if (aImageOutputStream != null) {
try {
aImageOutputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"ImageOutputStream",
"aImageOutputStream",
")",
"{",
"if",
"(",
"aImageOutputStream",
"!=",
"null",
")",
"{",
"try",
"{",
"aImageOutputStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"details",
")",
"{",
"LOGGER",
".",
"error",
"(",
"details",
".",
"getMessage",
"(",
")",
",",
"details",
")",
";",
"}",
"}",
"}"
] | Closes an image output stream, catching and logging any exceptions.
@param aImageOutputStream A supplied image output stream to close | [
"Closes",
"an",
"image",
"output",
"stream",
"catching",
"and",
"logging",
"any",
"exceptions",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L99-L107 |
1,896 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/IOUtils.java | IOUtils.closeQuietly | public static void closeQuietly(final OutputStream aOutputStream) {
if (aOutputStream != null) {
try {
aOutputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | java | public static void closeQuietly(final OutputStream aOutputStream) {
if (aOutputStream != null) {
try {
aOutputStream.close();
} catch (final IOException details) {
LOGGER.error(details.getMessage(), details);
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"OutputStream",
"aOutputStream",
")",
"{",
"if",
"(",
"aOutputStream",
"!=",
"null",
")",
"{",
"try",
"{",
"aOutputStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"details",
")",
"{",
"LOGGER",
".",
"error",
"(",
"details",
".",
"getMessage",
"(",
")",
",",
"details",
")",
";",
"}",
"}",
"}"
] | Closes an output stream, catching and logging any exceptions.
@param aOutputStream A supplied output stream to close | [
"Closes",
"an",
"output",
"stream",
"catching",
"and",
"logging",
"any",
"exceptions",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/IOUtils.java#L114-L122 |
1,897 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/DOMUtils.java | DOMUtils.toXML | public static String toXML(final Node aNode) throws TransformerException {
try {
final TransformerFactory transFactory = TransformerFactory.newInstance();
final Transformer transformer = transFactory.newTransformer();
final StringWriter buffer = new StringWriter();
final DOMSource domSource = new DOMSource(aNode);
final StreamResult streamResult = new StreamResult(buffer);
final String omitDeclaration = OutputKeys.OMIT_XML_DECLARATION;
transformer.setOutputProperty(omitDeclaration, "yes");
transformer.transform(domSource, streamResult);
return buffer.toString();
} catch (final TransformerConfigurationException details) {
throw new I18nRuntimeException(details);
}
} | java | public static String toXML(final Node aNode) throws TransformerException {
try {
final TransformerFactory transFactory = TransformerFactory.newInstance();
final Transformer transformer = transFactory.newTransformer();
final StringWriter buffer = new StringWriter();
final DOMSource domSource = new DOMSource(aNode);
final StreamResult streamResult = new StreamResult(buffer);
final String omitDeclaration = OutputKeys.OMIT_XML_DECLARATION;
transformer.setOutputProperty(omitDeclaration, "yes");
transformer.transform(domSource, streamResult);
return buffer.toString();
} catch (final TransformerConfigurationException details) {
throw new I18nRuntimeException(details);
}
} | [
"public",
"static",
"String",
"toXML",
"(",
"final",
"Node",
"aNode",
")",
"throws",
"TransformerException",
"{",
"try",
"{",
"final",
"TransformerFactory",
"transFactory",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"final",
"Transformer",
"transformer",
"=",
"transFactory",
".",
"newTransformer",
"(",
")",
";",
"final",
"StringWriter",
"buffer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"final",
"DOMSource",
"domSource",
"=",
"new",
"DOMSource",
"(",
"aNode",
")",
";",
"final",
"StreamResult",
"streamResult",
"=",
"new",
"StreamResult",
"(",
"buffer",
")",
";",
"final",
"String",
"omitDeclaration",
"=",
"OutputKeys",
".",
"OMIT_XML_DECLARATION",
";",
"transformer",
".",
"setOutputProperty",
"(",
"omitDeclaration",
",",
"\"yes\"",
")",
";",
"transformer",
".",
"transform",
"(",
"domSource",
",",
"streamResult",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"TransformerConfigurationException",
"details",
")",
"{",
"throw",
"new",
"I18nRuntimeException",
"(",
"details",
")",
";",
"}",
"}"
] | Returns an XML string representation of the supplied node.
@param aNode A W3C node
@return An XML string representation of the supplied node
@throws TransformerException If there is trouble with the XSL transformation | [
"Returns",
"an",
"XML",
"string",
"representation",
"of",
"the",
"supplied",
"node",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/DOMUtils.java#L31-L47 |
1,898 | ksclarke/freelib-utils | src/main/java/info/freelibrary/util/XMLBundleControl.java | XMLBundleControl.getFormats | @Override
public List<String> getFormats(final String aBaseName) {
Objects.requireNonNull(aBaseName);
return Arrays.asList(FORMAT);
} | java | @Override
public List<String> getFormats(final String aBaseName) {
Objects.requireNonNull(aBaseName);
return Arrays.asList(FORMAT);
} | [
"@",
"Override",
"public",
"List",
"<",
"String",
">",
"getFormats",
"(",
"final",
"String",
"aBaseName",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"aBaseName",
")",
";",
"return",
"Arrays",
".",
"asList",
"(",
"FORMAT",
")",
";",
"}"
] | Returns a list of formats supported for the supplied base name.
@param aBaseName for which to get formats
@return A {@link List} of strings | [
"Returns",
"a",
"list",
"of",
"formats",
"supported",
"for",
"the",
"supplied",
"base",
"name",
"."
] | 54e822ae4c11b3d74793fd82a1a535ffafffaf45 | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/XMLBundleControl.java#L28-L32 |
1,899 | opencredo/opencredo-esper | esper-template/src/main/java/org/opencredo/esper/EsperTemplate.java | EsperTemplate.setupEPStatements | private void setupEPStatements() {
for (EsperStatement statement : statements) {
EPStatement epStatement = epServiceProvider.getEPAdministrator().createEPL(statement.getEPL());
statement.setEPStatement(epStatement);
}
} | java | private void setupEPStatements() {
for (EsperStatement statement : statements) {
EPStatement epStatement = epServiceProvider.getEPAdministrator().createEPL(statement.getEPL());
statement.setEPStatement(epStatement);
}
} | [
"private",
"void",
"setupEPStatements",
"(",
")",
"{",
"for",
"(",
"EsperStatement",
"statement",
":",
"statements",
")",
"{",
"EPStatement",
"epStatement",
"=",
"epServiceProvider",
".",
"getEPAdministrator",
"(",
")",
".",
"createEPL",
"(",
"statement",
".",
"getEPL",
"(",
")",
")",
";",
"statement",
".",
"setEPStatement",
"(",
"epStatement",
")",
";",
"}",
"}"
] | Add the appropriate statements to the esper runtime. | [
"Add",
"the",
"appropriate",
"statements",
"to",
"the",
"esper",
"runtime",
"."
] | a88c9fd0301a4d6962da70d85577c27d50d08825 | https://github.com/opencredo/opencredo-esper/blob/a88c9fd0301a4d6962da70d85577c27d50d08825/esper-template/src/main/java/org/opencredo/esper/EsperTemplate.java#L157-L162 |
Subsets and Splits