id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
32,200
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/axis/HelixAxisAligner.java
HelixAxisAligner.getMidPoint
private Point3d getMidPoint(Point3d p1, Point3d p2, Point3d p3) { Vector3d v1 = new Vector3d(); v1.sub(p1, p2); Vector3d v2 = new Vector3d(); v2.sub(p3, p2); Vector3d v3 = new Vector3d(); v3.add(v1); v3.add(v2); v3.normalize(); // calculat the total distance between to subunits double dTotal = v1.length(); // calculate the rise along the y-axis. The helix axis is aligned with y-axis, // therfore, the rise between subunits is the y-distance double rise = p2.y - p1.y; // use phythagorean theoremm to calculate chord length between two subunit centers double chord = Math.sqrt(dTotal*dTotal - rise*rise); // System.out.println("Chord d: " + dTotal + " rise: " + rise + "chord: " + chord); double angle = helixLayers.getByLargestContacts().getAxisAngle().angle; // using the axis angle and the chord length, we can calculate the radius of the helix // http://en.wikipedia.org/wiki/Chord_%28geometry%29 double radius = chord/Math.sin(angle/2)/2; // can this go to zero? // System.out.println("Radius: " + radius); // project the radius onto the vector that points toward the helix axis v3.scale(radius); v3.add(p2); // System.out.println("Angle: " + Math.toDegrees(helixLayers.getByLowestAngle().getAxisAngle().angle)); Point3d cor = new Point3d(v3); return cor; }
java
private Point3d getMidPoint(Point3d p1, Point3d p2, Point3d p3) { Vector3d v1 = new Vector3d(); v1.sub(p1, p2); Vector3d v2 = new Vector3d(); v2.sub(p3, p2); Vector3d v3 = new Vector3d(); v3.add(v1); v3.add(v2); v3.normalize(); // calculat the total distance between to subunits double dTotal = v1.length(); // calculate the rise along the y-axis. The helix axis is aligned with y-axis, // therfore, the rise between subunits is the y-distance double rise = p2.y - p1.y; // use phythagorean theoremm to calculate chord length between two subunit centers double chord = Math.sqrt(dTotal*dTotal - rise*rise); // System.out.println("Chord d: " + dTotal + " rise: " + rise + "chord: " + chord); double angle = helixLayers.getByLargestContacts().getAxisAngle().angle; // using the axis angle and the chord length, we can calculate the radius of the helix // http://en.wikipedia.org/wiki/Chord_%28geometry%29 double radius = chord/Math.sin(angle/2)/2; // can this go to zero? // System.out.println("Radius: " + radius); // project the radius onto the vector that points toward the helix axis v3.scale(radius); v3.add(p2); // System.out.println("Angle: " + Math.toDegrees(helixLayers.getByLowestAngle().getAxisAngle().angle)); Point3d cor = new Point3d(v3); return cor; }
[ "private", "Point3d", "getMidPoint", "(", "Point3d", "p1", ",", "Point3d", "p2", ",", "Point3d", "p3", ")", "{", "Vector3d", "v1", "=", "new", "Vector3d", "(", ")", ";", "v1", ".", "sub", "(", "p1", ",", "p2", ")", ";", "Vector3d", "v2", "=", "new"...
Return a midpoint of a helix, calculated from three positions of three adjacent subunit centers. @param p1 center of first subunit @param p2 center of second subunit @param p3 center of third subunit @return midpoint of helix
[ "Return", "a", "midpoint", "of", "a", "helix", "calculated", "from", "three", "positions", "of", "three", "adjacent", "subunit", "centers", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/axis/HelixAxisAligner.java#L311-L342
32,201
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/axis/HelixAxisAligner.java
HelixAxisAligner.calcBoundaries
private void calcBoundaries() { minBoundary.x = Double.MAX_VALUE; maxBoundary.x = Double.MIN_VALUE; minBoundary.y = Double.MAX_VALUE; maxBoundary.x = Double.MIN_VALUE; minBoundary.z = Double.MAX_VALUE; maxBoundary.z = Double.MIN_VALUE; xzRadiusMax = Double.MIN_VALUE; Point3d probe = new Point3d(); for (Point3d[] list: subunits.getTraces()) { for (Point3d p: list) { probe.set(p); transformationMatrix.transform(probe); minBoundary.x = Math.min(minBoundary.x, probe.x); maxBoundary.x = Math.max(maxBoundary.x, probe.x); minBoundary.y = Math.min(minBoundary.y, probe.y); maxBoundary.y = Math.max(maxBoundary.y, probe.y); minBoundary.z = Math.min(minBoundary.z, probe.z); maxBoundary.z = Math.max(maxBoundary.z, probe.z); xzRadiusMax = Math.max(xzRadiusMax, Math.sqrt(probe.x*probe.x + probe.z * probe.z)); } } // System.out.println("MinBoundary: " + minBoundary); // System.out.println("MaxBoundary: " + maxBoundary); // System.out.println("zxRadius: " + xzRadiusMax); }
java
private void calcBoundaries() { minBoundary.x = Double.MAX_VALUE; maxBoundary.x = Double.MIN_VALUE; minBoundary.y = Double.MAX_VALUE; maxBoundary.x = Double.MIN_VALUE; minBoundary.z = Double.MAX_VALUE; maxBoundary.z = Double.MIN_VALUE; xzRadiusMax = Double.MIN_VALUE; Point3d probe = new Point3d(); for (Point3d[] list: subunits.getTraces()) { for (Point3d p: list) { probe.set(p); transformationMatrix.transform(probe); minBoundary.x = Math.min(minBoundary.x, probe.x); maxBoundary.x = Math.max(maxBoundary.x, probe.x); minBoundary.y = Math.min(minBoundary.y, probe.y); maxBoundary.y = Math.max(maxBoundary.y, probe.y); minBoundary.z = Math.min(minBoundary.z, probe.z); maxBoundary.z = Math.max(maxBoundary.z, probe.z); xzRadiusMax = Math.max(xzRadiusMax, Math.sqrt(probe.x*probe.x + probe.z * probe.z)); } } // System.out.println("MinBoundary: " + minBoundary); // System.out.println("MaxBoundary: " + maxBoundary); // System.out.println("zxRadius: " + xzRadiusMax); }
[ "private", "void", "calcBoundaries", "(", ")", "{", "minBoundary", ".", "x", "=", "Double", ".", "MAX_VALUE", ";", "maxBoundary", ".", "x", "=", "Double", ".", "MIN_VALUE", ";", "minBoundary", ".", "y", "=", "Double", ".", "MAX_VALUE", ";", "maxBoundary", ...
Calculates the min and max boundaries of the structure after it has been transformed into its canonical orientation.
[ "Calculates", "the", "min", "and", "max", "boundaries", "of", "the", "structure", "after", "it", "has", "been", "transformed", "into", "its", "canonical", "orientation", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/axis/HelixAxisAligner.java#L517-L545
32,202
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java
MultipleAlignmentJmol.getJmolString
public static String getJmolString(MultipleAlignment multAln, List<Atom[]> transformedAtoms, ColorBrewer colorPalette, boolean colorByBlocks) { // Color by blocks if specified if (colorByBlocks) return getMultiBlockJmolString(multAln, transformedAtoms, colorPalette, colorByBlocks); Color[] colors = colorPalette.getColorPalette(multAln.size()); StringBuffer j = new StringBuffer(); j.append(DEFAULT_SCRIPT); // Color the equivalent residues of every structure StringBuffer sel = new StringBuffer(); sel.append("select *; color lightgrey; backbone 0.1; "); List<List<String>> allPDB = new ArrayList<List<String>>(); // Get the aligned residues of every structure for (int i = 0; i < multAln.size(); i++) { List<String> pdb = MultipleAlignmentJmolDisplay.getPDBresnum(i, multAln, transformedAtoms.get(i)); allPDB.add(pdb); sel.append("select "); int pos = 0; for (String res : pdb) { if (pos > 0) sel.append(","); pos++; sel.append(res); sel.append("/" + (i + 1)); } if (pos == 0) sel.append("none"); sel.append("; backbone 0.3 ; color [" + colors[i].getRed() + "," + colors[i].getGreen() + "," + colors[i].getBlue() + "]; "); } j.append(sel); j.append("model 0; "); j.append(LIGAND_DISPLAY_SCRIPT); return j.toString(); }
java
public static String getJmolString(MultipleAlignment multAln, List<Atom[]> transformedAtoms, ColorBrewer colorPalette, boolean colorByBlocks) { // Color by blocks if specified if (colorByBlocks) return getMultiBlockJmolString(multAln, transformedAtoms, colorPalette, colorByBlocks); Color[] colors = colorPalette.getColorPalette(multAln.size()); StringBuffer j = new StringBuffer(); j.append(DEFAULT_SCRIPT); // Color the equivalent residues of every structure StringBuffer sel = new StringBuffer(); sel.append("select *; color lightgrey; backbone 0.1; "); List<List<String>> allPDB = new ArrayList<List<String>>(); // Get the aligned residues of every structure for (int i = 0; i < multAln.size(); i++) { List<String> pdb = MultipleAlignmentJmolDisplay.getPDBresnum(i, multAln, transformedAtoms.get(i)); allPDB.add(pdb); sel.append("select "); int pos = 0; for (String res : pdb) { if (pos > 0) sel.append(","); pos++; sel.append(res); sel.append("/" + (i + 1)); } if (pos == 0) sel.append("none"); sel.append("; backbone 0.3 ; color [" + colors[i].getRed() + "," + colors[i].getGreen() + "," + colors[i].getBlue() + "]; "); } j.append(sel); j.append("model 0; "); j.append(LIGAND_DISPLAY_SCRIPT); return j.toString(); }
[ "public", "static", "String", "getJmolString", "(", "MultipleAlignment", "multAln", ",", "List", "<", "Atom", "[", "]", ">", "transformedAtoms", ",", "ColorBrewer", "colorPalette", ",", "boolean", "colorByBlocks", ")", "{", "// Color by blocks if specified", "if", "...
Generate a Jmol command String that colors the aligned residues of every structure.
[ "Generate", "a", "Jmol", "command", "String", "that", "colors", "the", "aligned", "residues", "of", "every", "structure", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java#L419-L465
32,203
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java
MultipleAlignmentJmol.getMultiBlockJmolString
public static String getMultiBlockJmolString(MultipleAlignment multAln, List<Atom[]> transformedAtoms, ColorBrewer colorPalette, boolean colorByBlocks) { StringWriter jmol = new StringWriter(); jmol.append(DEFAULT_SCRIPT); jmol.append("select *; color lightgrey; backbone 0.1; "); int blockNum = multAln.getBlocks().size(); Color[] colors = colorPalette.getColorPalette(blockNum); // For every structure color all the blocks with the printBlock method for (int str = 0; str < transformedAtoms.size(); str++) { jmol.append("select */" + (str + 1) + "; color lightgrey; model " + (str + 1) + "; "); int index = 0; for (BlockSet bs : multAln.getBlockSets()) { for (Block b : bs.getBlocks()) { List<List<Integer>> alignRes = b.getAlignRes(); printJmolScript4Block(transformedAtoms.get(str), alignRes, colors[index], jmol, str, index, blockNum); index++; } } } jmol.append("model 0; "); jmol.append(LIGAND_DISPLAY_SCRIPT); return jmol.toString(); }
java
public static String getMultiBlockJmolString(MultipleAlignment multAln, List<Atom[]> transformedAtoms, ColorBrewer colorPalette, boolean colorByBlocks) { StringWriter jmol = new StringWriter(); jmol.append(DEFAULT_SCRIPT); jmol.append("select *; color lightgrey; backbone 0.1; "); int blockNum = multAln.getBlocks().size(); Color[] colors = colorPalette.getColorPalette(blockNum); // For every structure color all the blocks with the printBlock method for (int str = 0; str < transformedAtoms.size(); str++) { jmol.append("select */" + (str + 1) + "; color lightgrey; model " + (str + 1) + "; "); int index = 0; for (BlockSet bs : multAln.getBlockSets()) { for (Block b : bs.getBlocks()) { List<List<Integer>> alignRes = b.getAlignRes(); printJmolScript4Block(transformedAtoms.get(str), alignRes, colors[index], jmol, str, index, blockNum); index++; } } } jmol.append("model 0; "); jmol.append(LIGAND_DISPLAY_SCRIPT); return jmol.toString(); }
[ "public", "static", "String", "getMultiBlockJmolString", "(", "MultipleAlignment", "multAln", ",", "List", "<", "Atom", "[", "]", ">", "transformedAtoms", ",", "ColorBrewer", "colorPalette", ",", "boolean", "colorByBlocks", ")", "{", "StringWriter", "jmol", "=", "...
Colors every Block of the structures with a different color, following the palette. It colors each Block differently, no matter if it is from the same or different BlockSet.
[ "Colors", "every", "Block", "of", "the", "structures", "with", "a", "different", "color", "following", "the", "palette", ".", "It", "colors", "each", "Block", "differently", "no", "matter", "if", "it", "is", "from", "the", "same", "or", "different", "BlockSe...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java#L472-L504
32,204
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GridCell.java
GridCell.getContactsWithinCell
public List<Contact> getContactsWithinCell(){ List<Contact> contacts = new ArrayList<Contact>(); Point3d[] iAtoms = grid.getIAtoms(); Point3d[] jAtoms = grid.getJAtoms(); double cutoff = grid.getCutoff(); if (jAtoms==null) { for (int i:iIndices) { for (int j:iIndices) { if (j>i) { double distance = iAtoms[i].distance(iAtoms[j]); if (distance<cutoff) contacts.add(new Contact(i, j, distance)); } } } } else { for (int i:iIndices) { for (int j:jIndices) { double distance = iAtoms[i].distance(jAtoms[j]); if (distance<cutoff) contacts.add(new Contact(i, j, distance)); } } } return contacts; }
java
public List<Contact> getContactsWithinCell(){ List<Contact> contacts = new ArrayList<Contact>(); Point3d[] iAtoms = grid.getIAtoms(); Point3d[] jAtoms = grid.getJAtoms(); double cutoff = grid.getCutoff(); if (jAtoms==null) { for (int i:iIndices) { for (int j:iIndices) { if (j>i) { double distance = iAtoms[i].distance(iAtoms[j]); if (distance<cutoff) contacts.add(new Contact(i, j, distance)); } } } } else { for (int i:iIndices) { for (int j:jIndices) { double distance = iAtoms[i].distance(jAtoms[j]); if (distance<cutoff) contacts.add(new Contact(i, j, distance)); } } } return contacts; }
[ "public", "List", "<", "Contact", ">", "getContactsWithinCell", "(", ")", "{", "List", "<", "Contact", ">", "contacts", "=", "new", "ArrayList", "<", "Contact", ">", "(", ")", ";", "Point3d", "[", "]", "iAtoms", "=", "grid", ".", "getIAtoms", "(", ")",...
Calculates all distances of atoms within this cell returning those that are within the given cutoff as a list of Contacts containing the indices of the pair and the calculated distance. If {@link Grid#getJAtoms()} is null, distances are within the iAtoms only @return
[ "Calculates", "all", "distances", "of", "atoms", "within", "this", "cell", "returning", "those", "that", "are", "within", "the", "given", "cutoff", "as", "a", "list", "of", "Contacts", "containing", "the", "indices", "of", "the", "pair", "and", "the", "calcu...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GridCell.java#L71-L99
32,205
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GridCell.java
GridCell.hasContactToAtom
public boolean hasContactToAtom(Point3d[] iAtoms, Point3d[] jAtoms, Point3d query, double cutoff) { for( int i : iIndices ) { double distance = iAtoms[i].distance(query); if( distance<cutoff) return true; } if (jAtoms!=null) { for( int i : jIndices ) { double distance = jAtoms[i].distance(query); if( distance<cutoff) return true; } } return false; }
java
public boolean hasContactToAtom(Point3d[] iAtoms, Point3d[] jAtoms, Point3d query, double cutoff) { for( int i : iIndices ) { double distance = iAtoms[i].distance(query); if( distance<cutoff) return true; } if (jAtoms!=null) { for( int i : jIndices ) { double distance = jAtoms[i].distance(query); if( distance<cutoff) return true; } } return false; }
[ "public", "boolean", "hasContactToAtom", "(", "Point3d", "[", "]", "iAtoms", ",", "Point3d", "[", "]", "jAtoms", ",", "Point3d", "query", ",", "double", "cutoff", ")", "{", "for", "(", "int", "i", ":", "iIndices", ")", "{", "double", "distance", "=", "...
Tests whether any atom in this cell has a contact with the specified query atom @param iAtoms the first set of atoms to which the iIndices correspond @param jAtoms the second set of atoms to which the jIndices correspond, or null @param query test point @param cutoff @return
[ "Tests", "whether", "any", "atom", "in", "this", "cell", "has", "a", "contact", "with", "the", "specified", "query", "atom" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GridCell.java#L153-L167
32,206
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MultipleAlignmentJmolDisplay.java
MultipleAlignmentJmolDisplay.showMultipleAligmentPanel
public static void showMultipleAligmentPanel(MultipleAlignment multAln, AbstractAlignmentJmol jmol) throws StructureException { MultipleAligPanel me = new MultipleAligPanel(multAln, jmol); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle(jmol.getTitle()); me.setPreferredSize(new Dimension( me.getCoordManager().getPreferredWidth() , me.getCoordManager().getPreferredHeight())); JMenuBar menu = MenuCreator.getAlignmentPanelMenu( frame,me,null, multAln); frame.setJMenuBar(menu); JScrollPane scroll = new JScrollPane(me); scroll.setAutoscrolls(true); MultipleStatusDisplay status = new MultipleStatusDisplay(me); me.addAlignmentPositionListener(status); Box vBox = Box.createVerticalBox(); vBox.add(scroll); vBox.add(status); frame.getContentPane().add(vBox); frame.pack(); frame.setVisible(true); frame.addWindowListener(me); frame.addWindowListener(status); }
java
public static void showMultipleAligmentPanel(MultipleAlignment multAln, AbstractAlignmentJmol jmol) throws StructureException { MultipleAligPanel me = new MultipleAligPanel(multAln, jmol); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle(jmol.getTitle()); me.setPreferredSize(new Dimension( me.getCoordManager().getPreferredWidth() , me.getCoordManager().getPreferredHeight())); JMenuBar menu = MenuCreator.getAlignmentPanelMenu( frame,me,null, multAln); frame.setJMenuBar(menu); JScrollPane scroll = new JScrollPane(me); scroll.setAutoscrolls(true); MultipleStatusDisplay status = new MultipleStatusDisplay(me); me.addAlignmentPositionListener(status); Box vBox = Box.createVerticalBox(); vBox.add(scroll); vBox.add(status); frame.getContentPane().add(vBox); frame.pack(); frame.setVisible(true); frame.addWindowListener(me); frame.addWindowListener(status); }
[ "public", "static", "void", "showMultipleAligmentPanel", "(", "MultipleAlignment", "multAln", ",", "AbstractAlignmentJmol", "jmol", ")", "throws", "StructureException", "{", "MultipleAligPanel", "me", "=", "new", "MultipleAligPanel", "(", "multAln", ",", "jmol", ")", ...
Creates a new Frame with the MultipleAlignment Sequence Panel. The panel can communicate with the Jmol 3D visualization by selecting the aligned residues of every structure. @param multAln @param jmol @throws StructureException
[ "Creates", "a", "new", "Frame", "with", "the", "MultipleAlignment", "Sequence", "Panel", ".", "The", "panel", "can", "communicate", "with", "the", "Jmol", "3D", "visualization", "by", "selecting", "the", "aligned", "residues", "of", "every", "structure", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MultipleAlignmentJmolDisplay.java#L105-L137
32,207
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MultipleAlignmentJmolDisplay.java
MultipleAlignmentJmolDisplay.display
public static MultipleAlignmentJmol display(MultipleAlignment multAln) throws StructureException { List<Atom[]> rotatedAtoms = MultipleAlignmentDisplay.getRotatedAtoms(multAln); MultipleAlignmentJmol jmol = new MultipleAlignmentJmol(multAln, rotatedAtoms); jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle()); return jmol; }
java
public static MultipleAlignmentJmol display(MultipleAlignment multAln) throws StructureException { List<Atom[]> rotatedAtoms = MultipleAlignmentDisplay.getRotatedAtoms(multAln); MultipleAlignmentJmol jmol = new MultipleAlignmentJmol(multAln, rotatedAtoms); jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle()); return jmol; }
[ "public", "static", "MultipleAlignmentJmol", "display", "(", "MultipleAlignment", "multAln", ")", "throws", "StructureException", "{", "List", "<", "Atom", "[", "]", ">", "rotatedAtoms", "=", "MultipleAlignmentDisplay", ".", "getRotatedAtoms", "(", "multAln", ")", "...
Display a MultipleAlignment with a JmolPanel. New structures are downloaded if they were not cached in the alignment and they are entirely transformed here with the superposition information in the Multiple Alignment. @param multAln @return MultipleAlignmentJmol instance @throws StructureException
[ "Display", "a", "MultipleAlignment", "with", "a", "JmolPanel", ".", "New", "structures", "are", "downloaded", "if", "they", "were", "not", "cached", "in", "the", "alignment", "and", "they", "are", "entirely", "transformed", "here", "with", "the", "superposition"...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MultipleAlignmentJmolDisplay.java#L183-L193
32,208
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/domain/LocalProteinDomainParser.java
LocalProteinDomainParser.suggestDomains
public static List<Domain> suggestDomains(Structure s) throws StructureException{ Atom[] ca = StructureTools.getRepresentativeAtomArray(s); return suggestDomains(ca); }
java
public static List<Domain> suggestDomains(Structure s) throws StructureException{ Atom[] ca = StructureTools.getRepresentativeAtomArray(s); return suggestDomains(ca); }
[ "public", "static", "List", "<", "Domain", ">", "suggestDomains", "(", "Structure", "s", ")", "throws", "StructureException", "{", "Atom", "[", "]", "ca", "=", "StructureTools", ".", "getRepresentativeAtomArray", "(", "s", ")", ";", "return", "suggestDomains", ...
Suggest domains for a protein structure @param s the protein structure @return a list of possible domains @throws StructureException
[ "Suggest", "domains", "for", "a", "protein", "structure" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/domain/LocalProteinDomainParser.java#L65-L70
32,209
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/domain/LocalProteinDomainParser.java
LocalProteinDomainParser.suggestDomains
public static List<Domain> suggestDomains(Atom[] ca) throws StructureException{ GetDistanceMatrix distMaxCalculator = new GetDistanceMatrix(); PDPDistanceMatrix pdpMatrix = distMaxCalculator.getDistanceMatrix(ca); Domain dom = new Domain(); Chain c = ca[0].getGroup().getChain(); dom.setId("D"+c.getStructure().getPDBCode()+c.getId()+"1"); dom.setSize(ca.length); dom.setNseg(1); dom.getSegmentAtPos(0).setFrom(0); dom.getSegmentAtPos(0).setTo(ca.length-1); CutSites cutSites = new CutSites(); // Do the initial splitting CutDomain cutDomain = new CutDomain(ca,pdpMatrix); cutDomain.cutDomain(dom, cutSites, pdpMatrix); List<Domain> domains = cutDomain.getDomains(); // domains = ClusterDomains.cluster(domains, pdpMatrix); ShortSegmentRemover.cleanup(domains); return domains; }
java
public static List<Domain> suggestDomains(Atom[] ca) throws StructureException{ GetDistanceMatrix distMaxCalculator = new GetDistanceMatrix(); PDPDistanceMatrix pdpMatrix = distMaxCalculator.getDistanceMatrix(ca); Domain dom = new Domain(); Chain c = ca[0].getGroup().getChain(); dom.setId("D"+c.getStructure().getPDBCode()+c.getId()+"1"); dom.setSize(ca.length); dom.setNseg(1); dom.getSegmentAtPos(0).setFrom(0); dom.getSegmentAtPos(0).setTo(ca.length-1); CutSites cutSites = new CutSites(); // Do the initial splitting CutDomain cutDomain = new CutDomain(ca,pdpMatrix); cutDomain.cutDomain(dom, cutSites, pdpMatrix); List<Domain> domains = cutDomain.getDomains(); // domains = ClusterDomains.cluster(domains, pdpMatrix); ShortSegmentRemover.cleanup(domains); return domains; }
[ "public", "static", "List", "<", "Domain", ">", "suggestDomains", "(", "Atom", "[", "]", "ca", ")", "throws", "StructureException", "{", "GetDistanceMatrix", "distMaxCalculator", "=", "new", "GetDistanceMatrix", "(", ")", ";", "PDPDistanceMatrix", "pdpMatrix", "="...
Suggest domains for a set of Calpha atoms @param ca an array of Calpha atoms @return a list of possible domains @throws StructureException
[ "Suggest", "domains", "for", "a", "set", "of", "Calpha", "atoms" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/domain/LocalProteinDomainParser.java#L79-L111
32,210
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/GuiWrapper.java
GuiWrapper.showStructure
public static void showStructure(Structure structure) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException{ Class<?> structureAlignmentJmol = Class.forName(strucAligJmol); Object strucAligJ = structureAlignmentJmol.newInstance(); Method setS = structureAlignmentJmol.getMethod("setStructure", new Class[] {Structure.class}); setS.invoke(strucAligJ,structure); }
java
public static void showStructure(Structure structure) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException{ Class<?> structureAlignmentJmol = Class.forName(strucAligJmol); Object strucAligJ = structureAlignmentJmol.newInstance(); Method setS = structureAlignmentJmol.getMethod("setStructure", new Class[] {Structure.class}); setS.invoke(strucAligJ,structure); }
[ "public", "static", "void", "showStructure", "(", "Structure", "structure", ")", "throws", "ClassNotFoundException", ",", "NoSuchMethodException", ",", "InvocationTargetException", ",", "IllegalAccessException", ",", "InstantiationException", "{", "Class", "<", "?", ">", ...
Shows a structure in Jmol @since 3.0.5
[ "Shows", "a", "structure", "in", "Jmol" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/GuiWrapper.java#L99-L110
32,211
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java
AtomCache.notifyShutdown
public void notifyShutdown() { // System.out.println(" AtomCache got notify shutdown.."); if (pdpprovider != null) { if (pdpprovider instanceof RemotePDPProvider) { RemotePDPProvider remotePDP = (RemotePDPProvider) pdpprovider; remotePDP.flushCache(); } } // todo: use a SCOP implementation that is backed by SerializableCache ScopDatabase scopInstallation = ScopFactory.getSCOP(); if (scopInstallation != null) { if (scopInstallation instanceof CachedRemoteScopInstallation) { CachedRemoteScopInstallation cacheScop = (CachedRemoteScopInstallation) scopInstallation; cacheScop.flushCache(); } } }
java
public void notifyShutdown() { // System.out.println(" AtomCache got notify shutdown.."); if (pdpprovider != null) { if (pdpprovider instanceof RemotePDPProvider) { RemotePDPProvider remotePDP = (RemotePDPProvider) pdpprovider; remotePDP.flushCache(); } } // todo: use a SCOP implementation that is backed by SerializableCache ScopDatabase scopInstallation = ScopFactory.getSCOP(); if (scopInstallation != null) { if (scopInstallation instanceof CachedRemoteScopInstallation) { CachedRemoteScopInstallation cacheScop = (CachedRemoteScopInstallation) scopInstallation; cacheScop.flushCache(); } } }
[ "public", "void", "notifyShutdown", "(", ")", "{", "// System.out.println(\" AtomCache got notify shutdown..\");", "if", "(", "pdpprovider", "!=", "null", ")", "{", "if", "(", "pdpprovider", "instanceof", "RemotePDPProvider", ")", "{", "RemotePDPProvider", "remotePDP", ...
Send a signal to the cache that the system is shutting down. Notifies underlying SerializableCache instances to flush themselves...
[ "Send", "a", "signal", "to", "the", "cache", "that", "the", "system", "is", "shutting", "down", ".", "Notifies", "underlying", "SerializableCache", "instances", "to", "flush", "themselves", "..." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java#L669-L687
32,212
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java
AtomCache.getStructureForPdbId
public Structure getStructureForPdbId(String pdbId) throws IOException, StructureException { if(pdbId == null) return null; if(pdbId.length() != 4) { throw new StructureException("Unrecognized PDB ID: "+pdbId); } while (checkLoading(pdbId)) { // waiting for loading to be finished... try { Thread.sleep(100); } catch (InterruptedException e) { logger.error(e.getMessage()); } } Structure s; if (useMmtf) { logger.debug("loading from mmtf"); s = loadStructureFromMmtfByPdbId(pdbId); } else if (useMmCif) { logger.debug("loading from mmcif"); s = loadStructureFromCifByPdbId(pdbId); } else { logger.debug("loading from pdb"); s = loadStructureFromPdbByPdbId(pdbId); } return s; }
java
public Structure getStructureForPdbId(String pdbId) throws IOException, StructureException { if(pdbId == null) return null; if(pdbId.length() != 4) { throw new StructureException("Unrecognized PDB ID: "+pdbId); } while (checkLoading(pdbId)) { // waiting for loading to be finished... try { Thread.sleep(100); } catch (InterruptedException e) { logger.error(e.getMessage()); } } Structure s; if (useMmtf) { logger.debug("loading from mmtf"); s = loadStructureFromMmtfByPdbId(pdbId); } else if (useMmCif) { logger.debug("loading from mmcif"); s = loadStructureFromCifByPdbId(pdbId); } else { logger.debug("loading from pdb"); s = loadStructureFromPdbByPdbId(pdbId); } return s; }
[ "public", "Structure", "getStructureForPdbId", "(", "String", "pdbId", ")", "throws", "IOException", ",", "StructureException", "{", "if", "(", "pdbId", "==", "null", ")", "return", "null", ";", "if", "(", "pdbId", ".", "length", "(", ")", "!=", "4", ")", ...
Loads a structure directly by PDB ID @param pdbId @return @throws IOException @throws StructureException
[ "Loads", "a", "structure", "directly", "by", "PDB", "ID" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java#L867-L897
32,213
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/DotPlotPanel.java
DotPlotPanel.showDotPlotJFrame
private static JFrame showDotPlotJFrame(AFPChain afpChain ) { DotPlotPanel dotplot = new DotPlotPanel(afpChain); //Create JFrame String title = String.format("Dot plot of %s vs. %s", afpChain.getName1(),afpChain.getName2()); // Create window JFrame frame = new JFrame(title); frame.addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent e){ JFrame f = (JFrame) e.getSource(); f.setVisible(false); f.dispose(); } }); frame.getContentPane().add(dotplot); frame.pack(); frame.setVisible(true); return frame; }
java
private static JFrame showDotPlotJFrame(AFPChain afpChain ) { DotPlotPanel dotplot = new DotPlotPanel(afpChain); //Create JFrame String title = String.format("Dot plot of %s vs. %s", afpChain.getName1(),afpChain.getName2()); // Create window JFrame frame = new JFrame(title); frame.addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent e){ JFrame f = (JFrame) e.getSource(); f.setVisible(false); f.dispose(); } }); frame.getContentPane().add(dotplot); frame.pack(); frame.setVisible(true); return frame; }
[ "private", "static", "JFrame", "showDotPlotJFrame", "(", "AFPChain", "afpChain", ")", "{", "DotPlotPanel", "dotplot", "=", "new", "DotPlotPanel", "(", "afpChain", ")", ";", "//Create JFrame", "String", "title", "=", "String", ".", "format", "(", "\"Dot plot of %s ...
Helper function to create and display a JFrame with a single DotPlotPanel @param afpChain @param background
[ "Helper", "function", "to", "create", "and", "display", "a", "JFrame", "with", "a", "single", "DotPlotPanel" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/DotPlotPanel.java#L149-L175
32,214
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/SSBondImpl.java
SSBondImpl.toPDB
@Override public void toPDB(StringBuffer buf){ /*12 - 14 LString(3) "CYS" Residue name. 16 Character chainID1 Chain identifier. 18 - 21 Integer seqNum1 Residue sequence number. 22 AChar icode1 Insertion code. 26 - 28 LString(3) "CYS" Residue name. 30 Character chainID2 Chain identifier. 32 - 35 Integer seqNum2 Residue sequence number. 36 AChar icode2 Insertion code. 60 - 65 SymOP sym1 Symmetry oper for 1st resid 67 - 72 SymOP sym2 Symmetry oper for 2nd resid */ //01234567890123456789012345678901234567890123456789012345678901234567890123456789 //SSBOND 1 CYS 5 CYS 55 5PTI 67 //SSBOND 2 CYS 14 CYS 38 //SSBOND 3 CYS 30 CYS 51 buf.append("SSBOND "); buf.append(String.format("%3d", serNum)); buf.append(String.format(" CYS %s %4s%1s ", chainID1, resnum1, insCode1)); buf.append(String.format(" CYS %s %4s%1s ", chainID2, resnum2, insCode2)); }
java
@Override public void toPDB(StringBuffer buf){ /*12 - 14 LString(3) "CYS" Residue name. 16 Character chainID1 Chain identifier. 18 - 21 Integer seqNum1 Residue sequence number. 22 AChar icode1 Insertion code. 26 - 28 LString(3) "CYS" Residue name. 30 Character chainID2 Chain identifier. 32 - 35 Integer seqNum2 Residue sequence number. 36 AChar icode2 Insertion code. 60 - 65 SymOP sym1 Symmetry oper for 1st resid 67 - 72 SymOP sym2 Symmetry oper for 2nd resid */ //01234567890123456789012345678901234567890123456789012345678901234567890123456789 //SSBOND 1 CYS 5 CYS 55 5PTI 67 //SSBOND 2 CYS 14 CYS 38 //SSBOND 3 CYS 30 CYS 51 buf.append("SSBOND "); buf.append(String.format("%3d", serNum)); buf.append(String.format(" CYS %s %4s%1s ", chainID1, resnum1, insCode1)); buf.append(String.format(" CYS %s %4s%1s ", chainID2, resnum2, insCode2)); }
[ "@", "Override", "public", "void", "toPDB", "(", "StringBuffer", "buf", ")", "{", "/*12 - 14 LString(3) \"CYS\" Residue name.\n\t\t16 Character chainID1 Chain identifier.\n\t\t18 - 21 Integer seqNum1 Residue sequence number.\n\t\t22 ...
Append the PDB representation of this SSBOND to the provided StringBuffer @param buf a StringBuffer to print the PDB representation to
[ "Append", "the", "PDB", "representation", "of", "this", "SSBOND", "to", "the", "provided", "StringBuffer" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/SSBondImpl.java#L69-L94
32,215
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.getSurvivalTimePercentile
public Double getSurvivalTimePercentile(String group, double percentile) { StrataInfo si = sfi.getStrataInfoHashMap().get(group); ArrayList<Double> percentage = si.getSurv(); Integer percentileIndex = null; for (int i = 0; i < percentage.size(); i++) { if (percentage.get(i) == percentile) { if (i + 1 < percentage.size()) { percentileIndex = i + 1; } break; } else if (percentage.get(i) < percentile) { percentileIndex = i; break; } } if (percentileIndex != null) { return si.getTime().get(percentileIndex); } else { return null; } }
java
public Double getSurvivalTimePercentile(String group, double percentile) { StrataInfo si = sfi.getStrataInfoHashMap().get(group); ArrayList<Double> percentage = si.getSurv(); Integer percentileIndex = null; for (int i = 0; i < percentage.size(); i++) { if (percentage.get(i) == percentile) { if (i + 1 < percentage.size()) { percentileIndex = i + 1; } break; } else if (percentage.get(i) < percentile) { percentileIndex = i; break; } } if (percentileIndex != null) { return si.getTime().get(percentileIndex); } else { return null; } }
[ "public", "Double", "getSurvivalTimePercentile", "(", "String", "group", ",", "double", "percentile", ")", "{", "StrataInfo", "si", "=", "sfi", ".", "getStrataInfoHashMap", "(", ")", ".", "get", "(", "group", ")", ";", "ArrayList", "<", "Double", ">", "perce...
To get the median percentile for a particular group pass the value of .50. @param group @param percentile @return
[ "To", "get", "the", "median", "percentile", "for", "a", "particular", "group", "pass", "the", "value", "of", ".", "50", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L105-L126
32,216
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.setSurvivalData
public void setSurvivalData(ArrayList<String> title, SurvFitInfo sfi, Double userSetMaxTime) { this.title = title; LinkedHashMap<String, StrataInfo> strataInfoHashMap = sfi.getStrataInfoHashMap(); Double mTime = null; for (StrataInfo si : strataInfoHashMap.values()) { for (double t : si.getTime()) { if (mTime == null || t > mTime) { mTime = t; } } } int evenCheck = Math.round(mTime.floatValue()); if (evenCheck % 2 == 1) { evenCheck = evenCheck + 1; } this.maxTime = evenCheck; if (userSetMaxTime != null && userSetMaxTime > maxTime) { this.maxTime = userSetMaxTime; } this.sfi = sfi; if (sfi.getStrataInfoHashMap().size() == 1) { return; } this.repaint(); }
java
public void setSurvivalData(ArrayList<String> title, SurvFitInfo sfi, Double userSetMaxTime) { this.title = title; LinkedHashMap<String, StrataInfo> strataInfoHashMap = sfi.getStrataInfoHashMap(); Double mTime = null; for (StrataInfo si : strataInfoHashMap.values()) { for (double t : si.getTime()) { if (mTime == null || t > mTime) { mTime = t; } } } int evenCheck = Math.round(mTime.floatValue()); if (evenCheck % 2 == 1) { evenCheck = evenCheck + 1; } this.maxTime = evenCheck; if (userSetMaxTime != null && userSetMaxTime > maxTime) { this.maxTime = userSetMaxTime; } this.sfi = sfi; if (sfi.getStrataInfoHashMap().size() == 1) { return; } this.repaint(); }
[ "public", "void", "setSurvivalData", "(", "ArrayList", "<", "String", ">", "title", ",", "SurvFitInfo", "sfi", ",", "Double", "userSetMaxTime", ")", "{", "this", ".", "title", "=", "title", ";", "LinkedHashMap", "<", "String", ",", "StrataInfo", ">", "strata...
Allow setting of points in the figure where weighted correction has been done and percentage has already been calculated. @param title @param sfi @param userSetMaxTime
[ "Allow", "setting", "of", "points", "in", "the", "figure", "where", "weighted", "correction", "has", "been", "done", "and", "percentage", "has", "already", "been", "calculated", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L253-L279
32,217
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.setSurvivalData
public void setSurvivalData(ArrayList<String> title, LinkedHashMap<String, ArrayList<CensorStatus>> survivalData, Boolean useWeighted) throws Exception { this.setSurvivalData(title, survivalData, null, useWeighted); }
java
public void setSurvivalData(ArrayList<String> title, LinkedHashMap<String, ArrayList<CensorStatus>> survivalData, Boolean useWeighted) throws Exception { this.setSurvivalData(title, survivalData, null, useWeighted); }
[ "public", "void", "setSurvivalData", "(", "ArrayList", "<", "String", ">", "title", ",", "LinkedHashMap", "<", "String", ",", "ArrayList", "<", "CensorStatus", ">", ">", "survivalData", ",", "Boolean", "useWeighted", ")", "throws", "Exception", "{", "this", "....
The data will set the max time which will result in off time points for tick marks @param title @param survivalData @param useWeighted @throws Exception
[ "The", "data", "will", "set", "the", "max", "time", "which", "will", "result", "in", "off", "time", "points", "for", "tick", "marks" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L290-L292
32,218
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.saveSurvivalData
public void saveSurvivalData(String fileName) throws Exception { FileWriter fw = new FileWriter(fileName); fw.write("index\tTIME\tSTATUS\tGROUP\r\n"); int index = 0; for (String group : survivalData.keySet()) { ArrayList<CensorStatus> sd = survivalData.get(group); for (CensorStatus cs : sd) { String line = index + "\t" + cs.time + "\t" + cs.censored + "\t" + cs.group + "\r\n"; index++; fw.write(line); } } fw.close(); }
java
public void saveSurvivalData(String fileName) throws Exception { FileWriter fw = new FileWriter(fileName); fw.write("index\tTIME\tSTATUS\tGROUP\r\n"); int index = 0; for (String group : survivalData.keySet()) { ArrayList<CensorStatus> sd = survivalData.get(group); for (CensorStatus cs : sd) { String line = index + "\t" + cs.time + "\t" + cs.censored + "\t" + cs.group + "\r\n"; index++; fw.write(line); } } fw.close(); }
[ "public", "void", "saveSurvivalData", "(", "String", "fileName", ")", "throws", "Exception", "{", "FileWriter", "fw", "=", "new", "FileWriter", "(", "fileName", ")", ";", "fw", ".", "write", "(", "\"index\\tTIME\\tSTATUS\\tGROUP\\r\\n\"", ")", ";", "int", "index...
Save data from survival curve to text file @param fileName @throws Exception
[ "Save", "data", "from", "survival", "curve", "to", "text", "file" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L340-L353
32,219
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.getTimeX
private int getTimeX(double value) { double d = left + (((right - left) * value) / (maxTime - minTime)); return (int) d; }
java
private int getTimeX(double value) { double d = left + (((right - left) * value) / (maxTime - minTime)); return (int) d; }
[ "private", "int", "getTimeX", "(", "double", "value", ")", "{", "double", "d", "=", "left", "+", "(", "(", "(", "right", "-", "left", ")", "*", "value", ")", "/", "(", "maxTime", "-", "minTime", ")", ")", ";", "return", "(", "int", ")", "d", ";...
Get the X coordinate based on a time value @param value @return
[ "Get", "the", "X", "coordinate", "based", "on", "a", "time", "value" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L458-L461
32,220
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.getPercentageY
private int getPercentageY(double value) { value = 1.0 - value; double d = top + (((bottom - top) * value) / (maxPercentage - minPercentage)); return (int) d; }
java
private int getPercentageY(double value) { value = 1.0 - value; double d = top + (((bottom - top) * value) / (maxPercentage - minPercentage)); return (int) d; }
[ "private", "int", "getPercentageY", "(", "double", "value", ")", "{", "value", "=", "1.0", "-", "value", ";", "double", "d", "=", "top", "+", "(", "(", "(", "bottom", "-", "top", ")", "*", "value", ")", "/", "(", "maxPercentage", "-", "minPercentage"...
Get the Y coordinate based on percent value 0.0-1.0 @param value @return
[ "Get", "the", "Y", "coordinate", "based", "on", "percent", "value", "0", ".", "0", "-", "1", ".", "0" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L469-L473
32,221
biojava/biojava
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
KaplanMeierFigure.savePNGKMNumRisk
public void savePNGKMNumRisk(String fileName) { if (fileName.startsWith("null") || fileName.startsWith("Null") || fileName.startsWith("NULL")) { return; } this.fileName = fileName; NumbersAtRiskPanel numbersAtRiskPanel = new NumbersAtRiskPanel(); numbersAtRiskPanel.setKaplanMeierFigure(this); numbersAtRiskPanel.setSize(this.getWidth(), numbersAtRiskPanel.getHeight()); BufferedImage imageKM = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = imageKM.createGraphics(); this.paint(graphics2D); BufferedImage imageNumRisk = new BufferedImage(numbersAtRiskPanel.getWidth(), numbersAtRiskPanel.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D graphics2DNumRisk = imageNumRisk.createGraphics(); numbersAtRiskPanel.paint(graphics2DNumRisk); BufferedImage image = new BufferedImage(numbersAtRiskPanel.getWidth(), numbersAtRiskPanel.getHeight() + this.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); g.drawImage(imageKM, 0, 0, null); g.drawImage(imageNumRisk, 0, this.getHeight(), null); try { ImageIO.write(image, "png", new File(fileName)); } catch (Exception ex) { ex.printStackTrace(); } }
java
public void savePNGKMNumRisk(String fileName) { if (fileName.startsWith("null") || fileName.startsWith("Null") || fileName.startsWith("NULL")) { return; } this.fileName = fileName; NumbersAtRiskPanel numbersAtRiskPanel = new NumbersAtRiskPanel(); numbersAtRiskPanel.setKaplanMeierFigure(this); numbersAtRiskPanel.setSize(this.getWidth(), numbersAtRiskPanel.getHeight()); BufferedImage imageKM = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = imageKM.createGraphics(); this.paint(graphics2D); BufferedImage imageNumRisk = new BufferedImage(numbersAtRiskPanel.getWidth(), numbersAtRiskPanel.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D graphics2DNumRisk = imageNumRisk.createGraphics(); numbersAtRiskPanel.paint(graphics2DNumRisk); BufferedImage image = new BufferedImage(numbersAtRiskPanel.getWidth(), numbersAtRiskPanel.getHeight() + this.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); g.drawImage(imageKM, 0, 0, null); g.drawImage(imageNumRisk, 0, this.getHeight(), null); try { ImageIO.write(image, "png", new File(fileName)); } catch (Exception ex) { ex.printStackTrace(); } }
[ "public", "void", "savePNGKMNumRisk", "(", "String", "fileName", ")", "{", "if", "(", "fileName", ".", "startsWith", "(", "\"null\"", ")", "||", "fileName", ".", "startsWith", "(", "\"Null\"", ")", "||", "fileName", ".", "startsWith", "(", "\"NULL\"", ")", ...
Combine the KM and Num risk into one image @param fileName
[ "Combine", "the", "KM", "and", "Num", "risk", "into", "one", "image" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L704-L735
32,222
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.java
StubRunnerConfiguration.batchStubRunner
@Bean public BatchStubRunner batchStubRunner() { StubRunnerOptionsBuilder builder = builder(); if (this.props.getProxyHost() != null) { builder.withProxy(this.props.getProxyHost(), this.props.getProxyPort()); } StubRunnerOptions stubRunnerOptions = builder.build(); BatchStubRunner batchStubRunner = new BatchStubRunnerFactory(stubRunnerOptions, this.provider.get(stubRunnerOptions), this.contractVerifierMessaging != null ? this.contractVerifierMessaging : new NoOpStubMessages()).buildBatchStubRunner(); // TODO: Consider running it in a separate thread RunningStubs runningStubs = batchStubRunner.runStubs(); registerPort(runningStubs); return batchStubRunner; }
java
@Bean public BatchStubRunner batchStubRunner() { StubRunnerOptionsBuilder builder = builder(); if (this.props.getProxyHost() != null) { builder.withProxy(this.props.getProxyHost(), this.props.getProxyPort()); } StubRunnerOptions stubRunnerOptions = builder.build(); BatchStubRunner batchStubRunner = new BatchStubRunnerFactory(stubRunnerOptions, this.provider.get(stubRunnerOptions), this.contractVerifierMessaging != null ? this.contractVerifierMessaging : new NoOpStubMessages()).buildBatchStubRunner(); // TODO: Consider running it in a separate thread RunningStubs runningStubs = batchStubRunner.runStubs(); registerPort(runningStubs); return batchStubRunner; }
[ "@", "Bean", "public", "BatchStubRunner", "batchStubRunner", "(", ")", "{", "StubRunnerOptionsBuilder", "builder", "=", "builder", "(", ")", ";", "if", "(", "this", ".", "props", ".", "getProxyHost", "(", ")", "!=", "null", ")", "{", "builder", ".", "withP...
Bean that initializes stub runners, runs them and on shutdown closes them. Upon its instantiation JAR with stubs is downloaded and unpacked to a temporary folder and WireMock server are started for each of those stubs @return the batch stub runner bean
[ "Bean", "that", "initializes", "stub", "runners", "runs", "them", "and", "on", "shutdown", "closes", "them", ".", "Upon", "its", "instantiation", "JAR", "with", "stubs", "is", "downloaded", "and", "unpacked", "to", "a", "temporary", "folder", "and", "WireMock"...
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.java#L75-L90
32,223
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/ContractProjectUpdater.java
ContractProjectUpdater.updateContractProject
public void updateContractProject(String projectName, Path rootStubsFolder) { File clonedRepo = this.gitContractsRepo .clonedRepo(this.stubRunnerOptions.stubRepositoryRoot); GitStubDownloaderProperties properties = new GitStubDownloaderProperties( this.stubRunnerOptions.stubRepositoryRoot, this.stubRunnerOptions); copyStubs(projectName, rootStubsFolder, clonedRepo); GitRepo gitRepo = new GitRepo(clonedRepo, properties); String msg = StubRunnerPropertyUtils .getProperty(this.stubRunnerOptions.getProperties(), GIT_COMMIT_MESSAGE); GitRepo.CommitResult commit = gitRepo.commit(clonedRepo, commitMessage(projectName, msg)); if (commit == GitRepo.CommitResult.EMPTY) { log.info("There were no changes to commit. Won't push the changes"); return; } String attempts = StubRunnerPropertyUtils.getProperty( this.stubRunnerOptions.getProperties(), GIT_ATTEMPTS_NO_PROP); int intAttempts = StringUtils.hasText(attempts) ? Integer.parseInt(attempts) : DEFAULT_ATTEMPTS_NO; String wait = StubRunnerPropertyUtils.getProperty( this.stubRunnerOptions.getProperties(), GIT_WAIT_BETWEEN_ATTEMPTS); long longWait = StringUtils.hasText(wait) ? Long.parseLong(wait) : DEFAULT_WAIT_BETWEEN_ATTEMPTS; tryToPushCurrentBranch(clonedRepo, gitRepo, intAttempts, longWait); }
java
public void updateContractProject(String projectName, Path rootStubsFolder) { File clonedRepo = this.gitContractsRepo .clonedRepo(this.stubRunnerOptions.stubRepositoryRoot); GitStubDownloaderProperties properties = new GitStubDownloaderProperties( this.stubRunnerOptions.stubRepositoryRoot, this.stubRunnerOptions); copyStubs(projectName, rootStubsFolder, clonedRepo); GitRepo gitRepo = new GitRepo(clonedRepo, properties); String msg = StubRunnerPropertyUtils .getProperty(this.stubRunnerOptions.getProperties(), GIT_COMMIT_MESSAGE); GitRepo.CommitResult commit = gitRepo.commit(clonedRepo, commitMessage(projectName, msg)); if (commit == GitRepo.CommitResult.EMPTY) { log.info("There were no changes to commit. Won't push the changes"); return; } String attempts = StubRunnerPropertyUtils.getProperty( this.stubRunnerOptions.getProperties(), GIT_ATTEMPTS_NO_PROP); int intAttempts = StringUtils.hasText(attempts) ? Integer.parseInt(attempts) : DEFAULT_ATTEMPTS_NO; String wait = StubRunnerPropertyUtils.getProperty( this.stubRunnerOptions.getProperties(), GIT_WAIT_BETWEEN_ATTEMPTS); long longWait = StringUtils.hasText(wait) ? Long.parseLong(wait) : DEFAULT_WAIT_BETWEEN_ATTEMPTS; tryToPushCurrentBranch(clonedRepo, gitRepo, intAttempts, longWait); }
[ "public", "void", "updateContractProject", "(", "String", "projectName", ",", "Path", "rootStubsFolder", ")", "{", "File", "clonedRepo", "=", "this", ".", "gitContractsRepo", ".", "clonedRepo", "(", "this", ".", "stubRunnerOptions", ".", "stubRepositoryRoot", ")", ...
Merges the folder with stubs with the project containing contracts. @param projectName name of the project @param rootStubsFolder root folder of the stubs
[ "Merges", "the", "folder", "with", "stubs", "with", "the", "project", "containing", "contracts", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/ContractProjectUpdater.java#L74-L98
32,224
spring-cloud/spring-cloud-contract
spring-cloud-contract-spec/src/main/groovy/repackaged/nl/flotsam/xeger/Xeger.java
Xeger.getRandomInt
static int getRandomInt(int min, int max, Random random) { // Use random.nextInt as it guarantees a uniform distribution int maxForRandom = max - min + 1; return random.nextInt(maxForRandom) + min; }
java
static int getRandomInt(int min, int max, Random random) { // Use random.nextInt as it guarantees a uniform distribution int maxForRandom = max - min + 1; return random.nextInt(maxForRandom) + min; }
[ "static", "int", "getRandomInt", "(", "int", "min", ",", "int", "max", ",", "Random", "random", ")", "{", "// Use random.nextInt as it guarantees a uniform distribution", "int", "maxForRandom", "=", "max", "-", "min", "+", "1", ";", "return", "random", ".", "nex...
Generates a random number within the given bounds. @param min The minimum number (inclusive). @param max The maximum number (inclusive). @param random The object used as the randomizer. @return A random number in the given range.
[ "Generates", "a", "random", "number", "within", "the", "given", "bounds", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-spec/src/main/groovy/repackaged/nl/flotsam/xeger/Xeger.java#L94-L98
32,225
spring-cloud/spring-cloud-contract
spring-cloud-contract-spec/src/main/groovy/repackaged/nl/flotsam/xeger/Xeger.java
Xeger.generate
public String generate() { StringBuilder builder = new StringBuilder(); int counter = 0; generate(builder, this.automaton.getInitialState(), counter); return builder.toString(); }
java
public String generate() { StringBuilder builder = new StringBuilder(); int counter = 0; generate(builder, this.automaton.getInitialState(), counter); return builder.toString(); }
[ "public", "String", "generate", "(", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "int", "counter", "=", "0", ";", "generate", "(", "builder", ",", "this", ".", "automaton", ".", "getInitialState", "(", ")", ",", "cou...
Generates a random String that is guaranteed to match the regular expression passed to the constructor. @return generated regexp
[ "Generates", "a", "random", "String", "that", "is", "guaranteed", "to", "match", "the", "regular", "expression", "passed", "to", "the", "constructor", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-spec/src/main/groovy/repackaged/nl/flotsam/xeger/Xeger.java#L105-L110
32,226
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/AetherFactories.java
AetherFactories.fromSystemPropOrEnv
private static String fromSystemPropOrEnv(String prop) { String resolvedProp = System.getProperty(prop); if (StringUtils.hasText(resolvedProp)) { return resolvedProp; } return System.getenv(prop); }
java
private static String fromSystemPropOrEnv(String prop) { String resolvedProp = System.getProperty(prop); if (StringUtils.hasText(resolvedProp)) { return resolvedProp; } return System.getenv(prop); }
[ "private", "static", "String", "fromSystemPropOrEnv", "(", "String", "prop", ")", "{", "String", "resolvedProp", "=", "System", ".", "getProperty", "(", "prop", ")", ";", "if", "(", "StringUtils", ".", "hasText", "(", "resolvedProp", ")", ")", "{", "return",...
system prop takes precedence over env var
[ "system", "prop", "takes", "precedence", "over", "env", "var" ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/AetherFactories.java#L126-L132
32,227
spring-cloud/spring-cloud-contract
spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/ContractResultHandler.java
WireMockHttpServletRequestAdapter.getBody
@Override public byte[] getBody() { if (this.cachedBody == null || this.cachedBody.length == 0) { try { if (this.request instanceof MockHttpServletRequest) { this.cachedBody = ((MockHttpServletRequest) this.request) .getContentAsByteArray(); return this.cachedBody; } byte[] body = toByteArray(this.request.getInputStream()); boolean isGzipped = hasGzipEncoding() || Gzip.isGzipped(body); this.cachedBody = isGzipped ? Gzip.unGzip(body) : body; } catch (IOException ioe) { throw new RuntimeException(ioe); } } return this.cachedBody; }
java
@Override public byte[] getBody() { if (this.cachedBody == null || this.cachedBody.length == 0) { try { if (this.request instanceof MockHttpServletRequest) { this.cachedBody = ((MockHttpServletRequest) this.request) .getContentAsByteArray(); return this.cachedBody; } byte[] body = toByteArray(this.request.getInputStream()); boolean isGzipped = hasGzipEncoding() || Gzip.isGzipped(body); this.cachedBody = isGzipped ? Gzip.unGzip(body) : body; } catch (IOException ioe) { throw new RuntimeException(ioe); } } return this.cachedBody; }
[ "@", "Override", "public", "byte", "[", "]", "getBody", "(", ")", "{", "if", "(", "this", ".", "cachedBody", "==", "null", "||", "this", ".", "cachedBody", ".", "length", "==", "0", ")", "{", "try", "{", "if", "(", "this", ".", "request", "instance...
Something's wrong with reading the body from request
[ "Something", "s", "wrong", "with", "reading", "the", "body", "from", "request" ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/ContractResultHandler.java#L209-L227
32,228
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java
GitRepo.cloneProject
File cloneProject(URI projectUri) { try { log.info("Cloning repo from [" + projectUri + "] to [" + this.basedir + "]"); Git git = cloneToBasedir(projectUri, this.basedir); if (git != null) { git.close(); } File clonedRepo = git.getRepository().getWorkTree(); log.info("Cloned repo to [" + clonedRepo + "]"); return clonedRepo; } catch (Exception e) { throw new IllegalStateException("Exception occurred while cloning repo", e); } }
java
File cloneProject(URI projectUri) { try { log.info("Cloning repo from [" + projectUri + "] to [" + this.basedir + "]"); Git git = cloneToBasedir(projectUri, this.basedir); if (git != null) { git.close(); } File clonedRepo = git.getRepository().getWorkTree(); log.info("Cloned repo to [" + clonedRepo + "]"); return clonedRepo; } catch (Exception e) { throw new IllegalStateException("Exception occurred while cloning repo", e); } }
[ "File", "cloneProject", "(", "URI", "projectUri", ")", "{", "try", "{", "log", ".", "info", "(", "\"Cloning repo from [\"", "+", "projectUri", "+", "\"] to [\"", "+", "this", ".", "basedir", "+", "\"]\"", ")", ";", "Git", "git", "=", "cloneToBasedir", "(",...
Clones the project. @param projectUri - URI of the project @return file where the project was cloned
[ "Clones", "the", "project", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java#L104-L118
32,229
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java
GitRepo.checkout
void checkout(File project, String branch) { try { String currentBranch = currentBranch(project); if (currentBranch.equals(branch)) { log.info("Won't check out the same branch. Skipping"); return; } log.info("Checking out branch [" + branch + "]"); checkoutBranch(project, branch); log.info("Successfully checked out the branch [" + branch + "]"); } catch (Exception e) { throw new IllegalStateException(e); } }
java
void checkout(File project, String branch) { try { String currentBranch = currentBranch(project); if (currentBranch.equals(branch)) { log.info("Won't check out the same branch. Skipping"); return; } log.info("Checking out branch [" + branch + "]"); checkoutBranch(project, branch); log.info("Successfully checked out the branch [" + branch + "]"); } catch (Exception e) { throw new IllegalStateException(e); } }
[ "void", "checkout", "(", "File", "project", ",", "String", "branch", ")", "{", "try", "{", "String", "currentBranch", "=", "currentBranch", "(", "project", ")", ";", "if", "(", "currentBranch", ".", "equals", "(", "branch", ")", ")", "{", "log", ".", "...
Checks out a branch for a project. @param project - a Git project @param branch - branch to check out
[ "Checks", "out", "a", "branch", "for", "a", "project", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java#L125-L139
32,230
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java
GitRepo.pull
void pull(File project) { try { try (Git git = this.gitFactory.open(project)) { PullCommand command = this.gitFactory.pull(git); command.setRebase(true).call(); } } catch (Exception e) { throw new IllegalStateException(e); } }
java
void pull(File project) { try { try (Git git = this.gitFactory.open(project)) { PullCommand command = this.gitFactory.pull(git); command.setRebase(true).call(); } } catch (Exception e) { throw new IllegalStateException(e); } }
[ "void", "pull", "(", "File", "project", ")", "{", "try", "{", "try", "(", "Git", "git", "=", "this", ".", "gitFactory", ".", "open", "(", "project", ")", ")", "{", "PullCommand", "command", "=", "this", ".", "gitFactory", ".", "pull", "(", "git", "...
Pulls changes for the project. @param project - a Git project
[ "Pulls", "changes", "for", "the", "project", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java#L145-L155
32,231
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java
GitRepo.commit
CommitResult commit(File project, String message) { try (Git git = this.gitFactory.open(file(project))) { git.add().addFilepattern(".").call(); git.commit().setAllowEmpty(false).setMessage(message).call(); log.info("Commited successfully with message [" + message + "]"); return CommitResult.SUCCESSFUL; } catch (EmptyCommitException e) { log.info("There were no changes detected. Will not commit an empty commit"); return CommitResult.EMPTY; } catch (Exception e) { throw new IllegalStateException(e); } }
java
CommitResult commit(File project, String message) { try (Git git = this.gitFactory.open(file(project))) { git.add().addFilepattern(".").call(); git.commit().setAllowEmpty(false).setMessage(message).call(); log.info("Commited successfully with message [" + message + "]"); return CommitResult.SUCCESSFUL; } catch (EmptyCommitException e) { log.info("There were no changes detected. Will not commit an empty commit"); return CommitResult.EMPTY; } catch (Exception e) { throw new IllegalStateException(e); } }
[ "CommitResult", "commit", "(", "File", "project", ",", "String", "message", ")", "{", "try", "(", "Git", "git", "=", "this", ".", "gitFactory", ".", "open", "(", "file", "(", "project", ")", ")", ")", "{", "git", ".", "add", "(", ")", ".", "addFile...
Performs a commit. @param project - a Git project @param message - commit message @return result of the commit
[ "Performs", "a", "commit", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java#L163-L177
32,232
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java
GitRepo.pushCurrentBranch
void pushCurrentBranch(File project) { try (Git git = this.gitFactory.open(file(project))) { this.gitFactory.push(git).call(); } catch (Exception e) { throw new IllegalStateException(e); } }
java
void pushCurrentBranch(File project) { try (Git git = this.gitFactory.open(file(project))) { this.gitFactory.push(git).call(); } catch (Exception e) { throw new IllegalStateException(e); } }
[ "void", "pushCurrentBranch", "(", "File", "project", ")", "{", "try", "(", "Git", "git", "=", "this", ".", "gitFactory", ".", "open", "(", "file", "(", "project", ")", ")", ")", "{", "this", ".", "gitFactory", ".", "push", "(", "git", ")", ".", "ca...
Pushes the commits od current branch. @param project - Git project
[ "Pushes", "the", "commits", "od", "current", "branch", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/GitRepo.java#L192-L199
32,233
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/provider/wiremock/WireMockHttpServerStub.java
WireMockHttpServerStub.helpers
@Deprecated protected Map<String, Helper> helpers() { Map<String, Helper> helpers = new HashMap<>(); helpers.put(HandlebarsJsonPathHelper.NAME, new HandlebarsJsonPathHelper()); helpers.put(HandlebarsEscapeHelper.NAME, new HandlebarsEscapeHelper()); return helpers; }
java
@Deprecated protected Map<String, Helper> helpers() { Map<String, Helper> helpers = new HashMap<>(); helpers.put(HandlebarsJsonPathHelper.NAME, new HandlebarsJsonPathHelper()); helpers.put(HandlebarsEscapeHelper.NAME, new HandlebarsEscapeHelper()); return helpers; }
[ "@", "Deprecated", "protected", "Map", "<", "String", ",", "Helper", ">", "helpers", "(", ")", "{", "Map", "<", "String", ",", "Helper", ">", "helpers", "=", "new", "HashMap", "<>", "(", ")", ";", "helpers", ".", "put", "(", "HandlebarsJsonPathHelper", ...
Override this if you want to register your own helpers. @deprecated - please use the {@link WireMockExtensions} mechanism and pass the helpers in your implementation @return a mapping of helper names to its implementations
[ "Override", "this", "if", "you", "want", "to", "register", "your", "own", "helpers", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/provider/wiremock/WireMockHttpServerStub.java#L106-L112
32,234
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierUtil.java
ContractVerifierUtil.fileToBytes
public static byte[] fileToBytes(Object testClass, String relativePath) { try { URL url = testClass.getClass().getResource(relativePath); if (url == null) { throw new FileNotFoundException(relativePath); } return Files.readAllBytes(Paths.get(url.toURI())); } catch (IOException | URISyntaxException ex) { throw new IllegalStateException(ex); } }
java
public static byte[] fileToBytes(Object testClass, String relativePath) { try { URL url = testClass.getClass().getResource(relativePath); if (url == null) { throw new FileNotFoundException(relativePath); } return Files.readAllBytes(Paths.get(url.toURI())); } catch (IOException | URISyntaxException ex) { throw new IllegalStateException(ex); } }
[ "public", "static", "byte", "[", "]", "fileToBytes", "(", "Object", "testClass", ",", "String", "relativePath", ")", "{", "try", "{", "URL", "url", "=", "testClass", ".", "getClass", "(", ")", ".", "getResource", "(", "relativePath", ")", ";", "if", "(",...
Helper method to convert a file to bytes. @param testClass - test class relative to which the file is stored @param relativePath - relative path to the file @return bytes of the file @since 2.1.0
[ "Helper", "method", "to", "convert", "a", "file", "to", "bytes", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierUtil.java#L58-L69
32,235
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierUtil.java
ContractVerifierUtil.valueFromXPath
public static String valueFromXPath(Document parsedXml, String path) { XPath xPath = XPathFactory.newInstance().newXPath(); try { return xPath.evaluate(path, parsedXml.getDocumentElement()); } catch (XPathExpressionException exception) { LOG.error("Incorrect xpath provided: " + path, exception); throw new IllegalArgumentException(); } }
java
public static String valueFromXPath(Document parsedXml, String path) { XPath xPath = XPathFactory.newInstance().newXPath(); try { return xPath.evaluate(path, parsedXml.getDocumentElement()); } catch (XPathExpressionException exception) { LOG.error("Incorrect xpath provided: " + path, exception); throw new IllegalArgumentException(); } }
[ "public", "static", "String", "valueFromXPath", "(", "Document", "parsedXml", ",", "String", "path", ")", "{", "XPath", "xPath", "=", "XPathFactory", ".", "newInstance", "(", ")", ".", "newXPath", "(", ")", ";", "try", "{", "return", "xPath", ".", "evaluat...
Helper method to retrieve XML node value with provided xPath. @param parsedXml - a {@link Document} object with parsed XML content @param path - the xPath expression to retrieve the value with @return {@link String} value of the XML node @since 2.1.0
[ "Helper", "method", "to", "retrieve", "XML", "node", "value", "with", "provided", "xPath", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/util/ContractVerifierUtil.java#L78-L87
32,236
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/ContractDownloader.java
ContractDownloader.unpackedDownloadedContracts
public File unpackedDownloadedContracts(ContractVerifierConfigProperties config) { File contractsDirectory = unpackAndDownloadContracts(); updatePropertiesWithInclusion(contractsDirectory, config); return contractsDirectory; }
java
public File unpackedDownloadedContracts(ContractVerifierConfigProperties config) { File contractsDirectory = unpackAndDownloadContracts(); updatePropertiesWithInclusion(contractsDirectory, config); return contractsDirectory; }
[ "public", "File", "unpackedDownloadedContracts", "(", "ContractVerifierConfigProperties", "config", ")", "{", "File", "contractsDirectory", "=", "unpackAndDownloadContracts", "(", ")", ";", "updatePropertiesWithInclusion", "(", "contractsDirectory", ",", "config", ")", ";",...
Downloads JAR containing all the contracts. Plugin configuration gets updated with the inclusion pattern for the downloaded contracts. The JAR with the contracts contains all the contracts for all the projects. We're interested only in its subset. @param config - Plugin configuration that will get updated with the inclusion pattern @return location of the unpacked downloaded stubs
[ "Downloads", "JAR", "containing", "all", "the", "contracts", ".", "Plugin", "configuration", "gets", "updated", "with", "the", "inclusion", "pattern", "for", "the", "downloaded", "contracts", ".", "The", "JAR", "with", "the", "contracts", "contains", "all", "the...
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/ContractDownloader.java#L73-L77
32,237
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.allElementsMatch
public CollectionAssert allElementsMatch(String regex) { isNotNull(); isNotEmpty(); for (Object anActual : this.actual) { if (anActual == null) { failWithMessageRelatedToRegex(regex, anActual); } String value = anActual.toString(); if (!value.matches(regex)) { failWithMessageRelatedToRegex(regex, value); } } return this; }
java
public CollectionAssert allElementsMatch(String regex) { isNotNull(); isNotEmpty(); for (Object anActual : this.actual) { if (anActual == null) { failWithMessageRelatedToRegex(regex, anActual); } String value = anActual.toString(); if (!value.matches(regex)) { failWithMessageRelatedToRegex(regex, value); } } return this; }
[ "public", "CollectionAssert", "allElementsMatch", "(", "String", "regex", ")", "{", "isNotNull", "(", ")", ";", "isNotEmpty", "(", ")", ";", "for", "(", "Object", "anActual", ":", "this", ".", "actual", ")", "{", "if", "(", "anActual", "==", "null", ")",...
Asserts all elements of the collection whether they match a regular expression. @param regex - regular expression to check against @return this
[ "Asserts", "all", "elements", "of", "the", "collection", "whether", "they", "match", "a", "regular", "expression", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L54-L67
32,238
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.hasFlattenedSizeGreaterThanOrEqualTo
public CollectionAssert hasFlattenedSizeGreaterThanOrEqualTo(int size) { isNotNull(); int flattenedSize = flattenedSize(0, this.actual); if (!(flattenedSize >= size)) { failWithMessage("The flattened size <%s> is not greater or equal to <%s>", flattenedSize, size); } return this; }
java
public CollectionAssert hasFlattenedSizeGreaterThanOrEqualTo(int size) { isNotNull(); int flattenedSize = flattenedSize(0, this.actual); if (!(flattenedSize >= size)) { failWithMessage("The flattened size <%s> is not greater or equal to <%s>", flattenedSize, size); } return this; }
[ "public", "CollectionAssert", "hasFlattenedSizeGreaterThanOrEqualTo", "(", "int", "size", ")", "{", "isNotNull", "(", ")", ";", "int", "flattenedSize", "=", "flattenedSize", "(", "0", ",", "this", ".", "actual", ")", ";", "if", "(", "!", "(", "flattenedSize", ...
Flattens the collection and checks whether size is greater than or equal to the provided value. @param size - the flattened collection should have size greater than or equal to this value @return this
[ "Flattens", "the", "collection", "and", "checks", "whether", "size", "is", "greater", "than", "or", "equal", "to", "the", "provided", "value", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L80-L88
32,239
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.hasFlattenedSizeLessThanOrEqualTo
public CollectionAssert hasFlattenedSizeLessThanOrEqualTo(int size) { isNotNull(); int flattenedSize = flattenedSize(0, this.actual); if (!(flattenedSize <= size)) { failWithMessage("The flattened size <%s> is not less or equal to <%s>", flattenedSize, size); } return this; }
java
public CollectionAssert hasFlattenedSizeLessThanOrEqualTo(int size) { isNotNull(); int flattenedSize = flattenedSize(0, this.actual); if (!(flattenedSize <= size)) { failWithMessage("The flattened size <%s> is not less or equal to <%s>", flattenedSize, size); } return this; }
[ "public", "CollectionAssert", "hasFlattenedSizeLessThanOrEqualTo", "(", "int", "size", ")", "{", "isNotNull", "(", ")", ";", "int", "flattenedSize", "=", "flattenedSize", "(", "0", ",", "this", ".", "actual", ")", ";", "if", "(", "!", "(", "flattenedSize", "...
Flattens the collection and checks whether size is less than or equal to the provided value. @param size - the flattened collection should have size less than or equal to this value @return this
[ "Flattens", "the", "collection", "and", "checks", "whether", "size", "is", "less", "than", "or", "equal", "to", "the", "provided", "value", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L97-L105
32,240
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.hasFlattenedSizeBetween
public CollectionAssert hasFlattenedSizeBetween(int lowerBound, int higherBound) { isNotNull(); int flattenedSize = flattenedSize(0, this.actual); if (!(flattenedSize >= lowerBound && flattenedSize <= higherBound)) { failWithMessage("The flattened size <%s> is not between <%s> and <%s>", flattenedSize, lowerBound, higherBound); } return this; }
java
public CollectionAssert hasFlattenedSizeBetween(int lowerBound, int higherBound) { isNotNull(); int flattenedSize = flattenedSize(0, this.actual); if (!(flattenedSize >= lowerBound && flattenedSize <= higherBound)) { failWithMessage("The flattened size <%s> is not between <%s> and <%s>", flattenedSize, lowerBound, higherBound); } return this; }
[ "public", "CollectionAssert", "hasFlattenedSizeBetween", "(", "int", "lowerBound", ",", "int", "higherBound", ")", "{", "isNotNull", "(", ")", ";", "int", "flattenedSize", "=", "flattenedSize", "(", "0", ",", "this", ".", "actual", ")", ";", "if", "(", "!", ...
Flattens the collection and checks whether size is between the provided value. @param lowerBound - the flattened collection should have size greater than or equal to this value @param higherBound - the flattened collection should have size less than or equal to this value @return this
[ "Flattens", "the", "collection", "and", "checks", "whether", "size", "is", "between", "the", "provided", "value", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L115-L123
32,241
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.hasSizeGreaterThanOrEqualTo
public CollectionAssert hasSizeGreaterThanOrEqualTo(int size) { isNotNull(); int actualSize = size(this.actual); if (!(actualSize >= size)) { failWithMessage("The size <%s> is not greater or equal to <%s>", actualSize, size); } return this; }
java
public CollectionAssert hasSizeGreaterThanOrEqualTo(int size) { isNotNull(); int actualSize = size(this.actual); if (!(actualSize >= size)) { failWithMessage("The size <%s> is not greater or equal to <%s>", actualSize, size); } return this; }
[ "public", "CollectionAssert", "hasSizeGreaterThanOrEqualTo", "(", "int", "size", ")", "{", "isNotNull", "(", ")", ";", "int", "actualSize", "=", "size", "(", "this", ".", "actual", ")", ";", "if", "(", "!", "(", "actualSize", ">=", "size", ")", ")", "{",...
Checks whether size is greater than or equal to the provided value. @param size - the collection should have size greater than or equal to this value @return this
[ "Checks", "whether", "size", "is", "greater", "than", "or", "equal", "to", "the", "provided", "value", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L130-L138
32,242
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.hasSizeLessThanOrEqualTo
public CollectionAssert hasSizeLessThanOrEqualTo(int size) { isNotNull(); int actualSize = size(this.actual); if (!(actualSize <= size)) { failWithMessage("The size <%s> is not less or equal to <%s>", actualSize, size); } return this; }
java
public CollectionAssert hasSizeLessThanOrEqualTo(int size) { isNotNull(); int actualSize = size(this.actual); if (!(actualSize <= size)) { failWithMessage("The size <%s> is not less or equal to <%s>", actualSize, size); } return this; }
[ "public", "CollectionAssert", "hasSizeLessThanOrEqualTo", "(", "int", "size", ")", "{", "isNotNull", "(", ")", ";", "int", "actualSize", "=", "size", "(", "this", ".", "actual", ")", ";", "if", "(", "!", "(", "actualSize", "<=", "size", ")", ")", "{", ...
Checks whether size is less than or equal to the provided value. @param size - the collection should have size less than or equal to this value @return this
[ "Checks", "whether", "size", "is", "less", "than", "or", "equal", "to", "the", "provided", "value", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L145-L153
32,243
spring-cloud/spring-cloud-contract
spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java
CollectionAssert.hasSizeBetween
public CollectionAssert hasSizeBetween(int lowerBound, int higherBound) { isNotNull(); int size = size(this.actual); if (!(size >= lowerBound && size <= higherBound)) { failWithMessage("The size <%s> is not between <%s> and <%s>", size, lowerBound, higherBound); } return this; }
java
public CollectionAssert hasSizeBetween(int lowerBound, int higherBound) { isNotNull(); int size = size(this.actual); if (!(size >= lowerBound && size <= higherBound)) { failWithMessage("The size <%s> is not between <%s> and <%s>", size, lowerBound, higherBound); } return this; }
[ "public", "CollectionAssert", "hasSizeBetween", "(", "int", "lowerBound", ",", "int", "higherBound", ")", "{", "isNotNull", "(", ")", ";", "int", "size", "=", "size", "(", "this", ".", "actual", ")", ";", "if", "(", "!", "(", "size", ">=", "lowerBound", ...
Checks whether size is between the provided value. @param lowerBound - the collection should have size greater than or equal to this value @param higherBound - the collection should have size less than or equal to this value @return this
[ "Checks", "whether", "size", "is", "between", "the", "provided", "value", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/assertion/CollectionAssert.java#L163-L171
32,244
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/util/StubsParser.java
StubsParser.fromString
public static List<StubConfiguration> fromString(Collection<String> collection, String defaultClassifier) { List<StubConfiguration> stubs = new ArrayList<>(); for (String config : collection) { if (StringUtils.hasText(config)) { stubs.add(StubSpecification.parse(config, defaultClassifier).stub); } } return stubs; }
java
public static List<StubConfiguration> fromString(Collection<String> collection, String defaultClassifier) { List<StubConfiguration> stubs = new ArrayList<>(); for (String config : collection) { if (StringUtils.hasText(config)) { stubs.add(StubSpecification.parse(config, defaultClassifier).stub); } } return stubs; }
[ "public", "static", "List", "<", "StubConfiguration", ">", "fromString", "(", "Collection", "<", "String", ">", "collection", ",", "String", "defaultClassifier", ")", "{", "List", "<", "StubConfiguration", ">", "stubs", "=", "new", "ArrayList", "<>", "(", ")",...
The string is expected to be a map with entry called "stubs" that contains a list of Strings in the format <ul> <li>groupid:artifactid:version:classifier:port</li> <li>groupid:artifactid:version:classifier</li> <li>groupid:artifactid:version</li> <li>groupid:artifactid</li> </ul> In the latter case the provided default stub classifier will be passed. Example: "a:b,c:d:e" @param collection collection of ids @param defaultClassifier default classifier to append if one is missing @return parsed stub configurations
[ "The", "string", "is", "expected", "to", "be", "a", "map", "with", "entry", "called", "stubs", "that", "contains", "a", "list", "of", "Strings", "in", "the", "format" ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/util/StubsParser.java#L59-L68
32,245
spring-cloud/spring-cloud-contract
spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubConfiguration.java
StubConfiguration.groupIdAndArtifactMatches
public boolean groupIdAndArtifactMatches(String ivyNotationAsString) { String[] parts = ivyNotationFrom(ivyNotationAsString); String groupId = parts[0]; String artifactId = parts[1]; if (groupId == null) { return this.artifactId.equals(artifactId); } return this.groupId.equals(groupId) && this.artifactId.equals(artifactId); }
java
public boolean groupIdAndArtifactMatches(String ivyNotationAsString) { String[] parts = ivyNotationFrom(ivyNotationAsString); String groupId = parts[0]; String artifactId = parts[1]; if (groupId == null) { return this.artifactId.equals(artifactId); } return this.groupId.equals(groupId) && this.artifactId.equals(artifactId); }
[ "public", "boolean", "groupIdAndArtifactMatches", "(", "String", "ivyNotationAsString", ")", "{", "String", "[", "]", "parts", "=", "ivyNotationFrom", "(", "ivyNotationAsString", ")", ";", "String", "groupId", "=", "parts", "[", "0", "]", ";", "String", "artifac...
Checks if ivy notation matches group and artifact ids. @param ivyNotationAsString - e.g. group:artifact:version:classifier @return {@code true} if artifact id matches and there's no group id. Or if both group id and artifact id are present and matching
[ "Checks", "if", "ivy", "notation", "matches", "group", "and", "artifact", "ids", "." ]
857da51950a87b393286e3bb1b2208c420c01087
https://github.com/spring-cloud/spring-cloud-contract/blob/857da51950a87b393286e3bb1b2208c420c01087/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubConfiguration.java#L124-L132
32,246
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/util/ServiceLoaderUtils.java
ServiceLoaderUtils.load
public static <T> List<T> load(final Class<T> type, final ClassLoader classLoader) { final List<T> loaded = new ArrayList<>(); final Iterator<T> iterator = ServiceLoader.load(type, classLoader).iterator(); while (hasNextSafely(iterator)) { try { final T next = iterator.next(); loaded.add(next); LOGGER.debug("Found {}", type); } catch (Exception e) { LOGGER.error("Could not load {}: {}", type, e); } } return loaded; }
java
public static <T> List<T> load(final Class<T> type, final ClassLoader classLoader) { final List<T> loaded = new ArrayList<>(); final Iterator<T> iterator = ServiceLoader.load(type, classLoader).iterator(); while (hasNextSafely(iterator)) { try { final T next = iterator.next(); loaded.add(next); LOGGER.debug("Found {}", type); } catch (Exception e) { LOGGER.error("Could not load {}: {}", type, e); } } return loaded; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "load", "(", "final", "Class", "<", "T", ">", "type", ",", "final", "ClassLoader", "classLoader", ")", "{", "final", "List", "<", "T", ">", "loaded", "=", "new", "ArrayList", "<>", "(", ")",...
Load implementation by given type. @param <T> type of implementation. @param type the type of implementation to load. @param classLoader the class loader to search for implementations. @return loaded implementations.
[ "Load", "implementation", "by", "given", "type", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/util/ServiceLoaderUtils.java#L48-L61
32,247
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/internal/AllureThreadContext.java
AllureThreadContext.start
public void start(final String uuid) { Objects.requireNonNull(uuid, "step uuid"); context.get().push(uuid); }
java
public void start(final String uuid) { Objects.requireNonNull(uuid, "step uuid"); context.get().push(uuid); }
[ "public", "void", "start", "(", "final", "String", "uuid", ")", "{", "Objects", ".", "requireNonNull", "(", "uuid", ",", "\"step uuid\"", ")", ";", "context", ".", "get", "(", ")", ".", "push", "(", "uuid", ")", ";", "}" ]
Adds new uuid.
[ "Adds", "new", "uuid", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/internal/AllureThreadContext.java#L54-L57
32,248
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/internal/AllureThreadContext.java
AllureThreadContext.stop
public Optional<String> stop() { final LinkedList<String> uuids = context.get(); if (!uuids.isEmpty()) { return Optional.of(uuids.pop()); } return Optional.empty(); }
java
public Optional<String> stop() { final LinkedList<String> uuids = context.get(); if (!uuids.isEmpty()) { return Optional.of(uuids.pop()); } return Optional.empty(); }
[ "public", "Optional", "<", "String", ">", "stop", "(", ")", "{", "final", "LinkedList", "<", "String", ">", "uuids", "=", "context", ".", "get", "(", ")", ";", "if", "(", "!", "uuids", ".", "isEmpty", "(", ")", ")", "{", "return", "Optional", ".", ...
Removes latest added uuid. Ignores empty context. @return removed uuid.
[ "Removes", "latest", "added", "uuid", ".", "Ignores", "empty", "context", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/internal/AllureThreadContext.java#L64-L70
32,249
allure-framework/allure-java
allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java
LabelBuilder.tryHandleNamedLink
private void tryHandleNamedLink(final String tagString) { final String namedLinkPatternString = PLAIN_LINK + "\\.(\\w+-?)+=(\\w+(-|_)?)+"; final Pattern namedLinkPattern = Pattern.compile(namedLinkPatternString, Pattern.CASE_INSENSITIVE); if (namedLinkPattern.matcher(tagString).matches()) { final String type = tagString.split(COMPOSITE_TAG_DELIMITER)[0].split("[.]")[1]; final String name = tagString.split(COMPOSITE_TAG_DELIMITER)[1]; getScenarioLinks().add(ResultsUtils.createLink(null, name, null, type)); } else { LOGGER.warn("Composite named tag {} does not match regex {}. Skipping", tagString, namedLinkPatternString); } }
java
private void tryHandleNamedLink(final String tagString) { final String namedLinkPatternString = PLAIN_LINK + "\\.(\\w+-?)+=(\\w+(-|_)?)+"; final Pattern namedLinkPattern = Pattern.compile(namedLinkPatternString, Pattern.CASE_INSENSITIVE); if (namedLinkPattern.matcher(tagString).matches()) { final String type = tagString.split(COMPOSITE_TAG_DELIMITER)[0].split("[.]")[1]; final String name = tagString.split(COMPOSITE_TAG_DELIMITER)[1]; getScenarioLinks().add(ResultsUtils.createLink(null, name, null, type)); } else { LOGGER.warn("Composite named tag {} does not match regex {}. Skipping", tagString, namedLinkPatternString); } }
[ "private", "void", "tryHandleNamedLink", "(", "final", "String", "tagString", ")", "{", "final", "String", "namedLinkPatternString", "=", "PLAIN_LINK", "+", "\"\\\\.(\\\\w+-?)+=(\\\\w+(-|_)?)+\"", ";", "final", "Pattern", "namedLinkPattern", "=", "Pattern", ".", "compil...
Handle composite named links. @param tagString Full tag name and value
[ "Handle", "composite", "named", "links", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java#L139-L151
32,250
allure-framework/allure-java
allure-java-migration/src/main/java/io/qameta/allure/aspects/Allure1Utils.java
Allure1Utils.getParametersAsString
public static String getParametersAsString(final Object... parameters) { if (parameters == null || parameters.length == 0) { return ""; } final StringBuilder builder = new StringBuilder(); builder.append('['); for (int i = 0; i < parameters.length; i++) { builder.append(arrayToString(parameters[i])); if (i < parameters.length - 1) { builder.append(", "); } } return builder.append(']').toString(); }
java
public static String getParametersAsString(final Object... parameters) { if (parameters == null || parameters.length == 0) { return ""; } final StringBuilder builder = new StringBuilder(); builder.append('['); for (int i = 0; i < parameters.length; i++) { builder.append(arrayToString(parameters[i])); if (i < parameters.length - 1) { builder.append(", "); } } return builder.append(']').toString(); }
[ "public", "static", "String", "getParametersAsString", "(", "final", "Object", "...", "parameters", ")", "{", "if", "(", "parameters", "==", "null", "||", "parameters", ".", "length", "==", "0", ")", "{", "return", "\"\"", ";", "}", "final", "StringBuilder",...
Convert array of given parameters to sting.
[ "Convert", "array", "of", "given", "parameters", "to", "sting", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-migration/src/main/java/io/qameta/allure/aspects/Allure1Utils.java#L67-L80
32,251
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.startPrepareFixture
public void startPrepareFixture(final String containerUuid, final String uuid, final FixtureResult result) { storage.getContainer(containerUuid).ifPresent(container -> { synchronized (storage) { container.getBefores().add(result); } }); notifier.beforeFixtureStart(result); startFixture(uuid, result); notifier.afterFixtureStart(result); }
java
public void startPrepareFixture(final String containerUuid, final String uuid, final FixtureResult result) { storage.getContainer(containerUuid).ifPresent(container -> { synchronized (storage) { container.getBefores().add(result); } }); notifier.beforeFixtureStart(result); startFixture(uuid, result); notifier.afterFixtureStart(result); }
[ "public", "void", "startPrepareFixture", "(", "final", "String", "containerUuid", ",", "final", "String", "uuid", ",", "final", "FixtureResult", "result", ")", "{", "storage", ".", "getContainer", "(", "containerUuid", ")", ".", "ifPresent", "(", "container", "-...
Start a new prepare fixture with given parent. @param containerUuid the uuid of parent container. @param uuid the fixture uuid. @param result the fixture.
[ "Start", "a", "new", "prepare", "fixture", "with", "given", "parent", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L183-L192
32,252
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.startTearDownFixture
public void startTearDownFixture(final String containerUuid, final String uuid, final FixtureResult result) { storage.getContainer(containerUuid).ifPresent(container -> { synchronized (storage) { container.getAfters().add(result); } }); notifier.beforeFixtureStart(result); startFixture(uuid, result); notifier.afterFixtureStart(result); }
java
public void startTearDownFixture(final String containerUuid, final String uuid, final FixtureResult result) { storage.getContainer(containerUuid).ifPresent(container -> { synchronized (storage) { container.getAfters().add(result); } }); notifier.beforeFixtureStart(result); startFixture(uuid, result); notifier.afterFixtureStart(result); }
[ "public", "void", "startTearDownFixture", "(", "final", "String", "containerUuid", ",", "final", "String", "uuid", ",", "final", "FixtureResult", "result", ")", "{", "storage", ".", "getContainer", "(", "containerUuid", ")", ".", "ifPresent", "(", "container", "...
Start a new tear down fixture with given parent. @param containerUuid the uuid of parent container. @param uuid the fixture uuid. @param result the fixture.
[ "Start", "a", "new", "tear", "down", "fixture", "with", "given", "parent", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L201-L211
32,253
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.startFixture
private void startFixture(final String uuid, final FixtureResult result) { storage.put(uuid, result); result.setStage(Stage.RUNNING); result.setStart(System.currentTimeMillis()); threadContext.clear(); threadContext.start(uuid); }
java
private void startFixture(final String uuid, final FixtureResult result) { storage.put(uuid, result); result.setStage(Stage.RUNNING); result.setStart(System.currentTimeMillis()); threadContext.clear(); threadContext.start(uuid); }
[ "private", "void", "startFixture", "(", "final", "String", "uuid", ",", "final", "FixtureResult", "result", ")", "{", "storage", ".", "put", "(", "uuid", ",", "result", ")", ";", "result", ".", "setStage", "(", "Stage", ".", "RUNNING", ")", ";", "result"...
Start a new fixture with given uuid. @param uuid the uuid of fixture. @param result the test fixture.
[ "Start", "a", "new", "fixture", "with", "given", "uuid", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L219-L225
32,254
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.updateFixture
public void updateFixture(final String uuid, final Consumer<FixtureResult> update) { final Optional<FixtureResult> found = storage.getFixture(uuid); if (!found.isPresent()) { LOGGER.error("Could not update test fixture: test fixture with uuid {} not found", uuid); return; } final FixtureResult fixture = found.get(); notifier.beforeFixtureUpdate(fixture); update.accept(fixture); notifier.afterFixtureUpdate(fixture); }
java
public void updateFixture(final String uuid, final Consumer<FixtureResult> update) { final Optional<FixtureResult> found = storage.getFixture(uuid); if (!found.isPresent()) { LOGGER.error("Could not update test fixture: test fixture with uuid {} not found", uuid); return; } final FixtureResult fixture = found.get(); notifier.beforeFixtureUpdate(fixture); update.accept(fixture); notifier.afterFixtureUpdate(fixture); }
[ "public", "void", "updateFixture", "(", "final", "String", "uuid", ",", "final", "Consumer", "<", "FixtureResult", ">", "update", ")", "{", "final", "Optional", "<", "FixtureResult", ">", "found", "=", "storage", ".", "getFixture", "(", "uuid", ")", ";", "...
Updates fixture by given uuid. @param uuid the uuid of fixture. @param update the update function.
[ "Updates", "fixture", "by", "given", "uuid", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L248-L259
32,255
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.stopFixture
public void stopFixture(final String uuid) { final Optional<FixtureResult> found = storage.getFixture(uuid); if (!found.isPresent()) { LOGGER.error("Could not stop test fixture: test fixture with uuid {} not found", uuid); return; } final FixtureResult fixture = found.get(); notifier.beforeFixtureStop(fixture); fixture.setStage(Stage.FINISHED); fixture.setStop(System.currentTimeMillis()); storage.remove(uuid); threadContext.clear(); notifier.afterFixtureStop(fixture); }
java
public void stopFixture(final String uuid) { final Optional<FixtureResult> found = storage.getFixture(uuid); if (!found.isPresent()) { LOGGER.error("Could not stop test fixture: test fixture with uuid {} not found", uuid); return; } final FixtureResult fixture = found.get(); notifier.beforeFixtureStop(fixture); fixture.setStage(Stage.FINISHED); fixture.setStop(System.currentTimeMillis()); storage.remove(uuid); threadContext.clear(); notifier.afterFixtureStop(fixture); }
[ "public", "void", "stopFixture", "(", "final", "String", "uuid", ")", "{", "final", "Optional", "<", "FixtureResult", ">", "found", "=", "storage", ".", "getFixture", "(", "uuid", ")", ";", "if", "(", "!", "found", ".", "isPresent", "(", ")", ")", "{",...
Stops fixture by given uuid. @param uuid the uuid of fixture.
[ "Stops", "fixture", "by", "given", "uuid", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L266-L282
32,256
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.startStep
public void startStep(final String parentUuid, final String uuid, final StepResult result) { notifier.beforeStepStart(result); result.setStage(Stage.RUNNING); result.setStart(System.currentTimeMillis()); threadContext.start(uuid); storage.put(uuid, result); storage.get(parentUuid, WithSteps.class).ifPresent(parentStep -> { synchronized (storage) { parentStep.getSteps().add(result); } }); notifier.afterStepStart(result); }
java
public void startStep(final String parentUuid, final String uuid, final StepResult result) { notifier.beforeStepStart(result); result.setStage(Stage.RUNNING); result.setStart(System.currentTimeMillis()); threadContext.start(uuid); storage.put(uuid, result); storage.get(parentUuid, WithSteps.class).ifPresent(parentStep -> { synchronized (storage) { parentStep.getSteps().add(result); } }); notifier.afterStepStart(result); }
[ "public", "void", "startStep", "(", "final", "String", "parentUuid", ",", "final", "String", "uuid", ",", "final", "StepResult", "result", ")", "{", "notifier", ".", "beforeStepStart", "(", "result", ")", ";", "result", ".", "setStage", "(", "Stage", ".", ...
Start a new step as child of specified parent. @param parentUuid the uuid of parent test case or step. @param uuid the uuid of step. @param result the step.
[ "Start", "a", "new", "step", "as", "child", "of", "specified", "parent", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L471-L487
32,257
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.updateStep
public void updateStep(final String uuid, final Consumer<StepResult> update) { final Optional<StepResult> found = storage.getStep(uuid); if (!found.isPresent()) { LOGGER.error("Could not update step: step with uuid {} not found", uuid); return; } final StepResult step = found.get(); notifier.beforeStepUpdate(step); update.accept(step); notifier.afterStepUpdate(step); }
java
public void updateStep(final String uuid, final Consumer<StepResult> update) { final Optional<StepResult> found = storage.getStep(uuid); if (!found.isPresent()) { LOGGER.error("Could not update step: step with uuid {} not found", uuid); return; } final StepResult step = found.get(); notifier.beforeStepUpdate(step); update.accept(step); notifier.afterStepUpdate(step); }
[ "public", "void", "updateStep", "(", "final", "String", "uuid", ",", "final", "Consumer", "<", "StepResult", ">", "update", ")", "{", "final", "Optional", "<", "StepResult", ">", "found", "=", "storage", ".", "getStep", "(", "uuid", ")", ";", "if", "(", ...
Updates step by specified uuid. @param uuid the uuid of step. @param update the update function.
[ "Updates", "step", "by", "specified", "uuid", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L510-L522
32,258
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.stopStep
public void stopStep(final String uuid) { final Optional<StepResult> found = storage.getStep(uuid); if (!found.isPresent()) { LOGGER.error("Could not stop step: step with uuid {} not found", uuid); return; } final StepResult step = found.get(); notifier.beforeStepStop(step); step.setStage(Stage.FINISHED); step.setStop(System.currentTimeMillis()); storage.remove(uuid); threadContext.stop(); notifier.afterStepStop(step); }
java
public void stopStep(final String uuid) { final Optional<StepResult> found = storage.getStep(uuid); if (!found.isPresent()) { LOGGER.error("Could not stop step: step with uuid {} not found", uuid); return; } final StepResult step = found.get(); notifier.beforeStepStop(step); step.setStage(Stage.FINISHED); step.setStop(System.currentTimeMillis()); storage.remove(uuid); threadContext.stop(); notifier.afterStepStop(step); }
[ "public", "void", "stopStep", "(", "final", "String", "uuid", ")", "{", "final", "Optional", "<", "StepResult", ">", "found", "=", "storage", ".", "getStep", "(", "uuid", ")", ";", "if", "(", "!", "found", ".", "isPresent", "(", ")", ")", "{", "LOGGE...
Stops step by given uuid. @param uuid the uuid of step to stop.
[ "Stops", "step", "by", "given", "uuid", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L544-L561
32,259
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java
AllureLifecycle.addAttachment
public void addAttachment(final String name, final String type, final String fileExtension, final InputStream stream) { writeAttachment(prepareAttachment(name, type, fileExtension), stream); }
java
public void addAttachment(final String name, final String type, final String fileExtension, final InputStream stream) { writeAttachment(prepareAttachment(name, type, fileExtension), stream); }
[ "public", "void", "addAttachment", "(", "final", "String", "name", ",", "final", "String", "type", ",", "final", "String", "fileExtension", ",", "final", "InputStream", "stream", ")", "{", "writeAttachment", "(", "prepareAttachment", "(", "name", ",", "type", ...
Adds attachment to current running test or step. @param name the name of attachment @param type the content type of attachment @param fileExtension the attachment file extension @param stream attachment content
[ "Adds", "attachment", "to", "current", "running", "test", "or", "step", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java#L585-L588
32,260
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java
AnnotationUtils.getLinks
public static List<Link> getLinks(final AnnotatedElement annotatedElement) { final List<Link> result = new ArrayList<>(); result.addAll(extractLinks(annotatedElement, io.qameta.allure.Link.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotatedElement, io.qameta.allure.Issue.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotatedElement, io.qameta.allure.TmsLink.class, ResultsUtils::createLink)); return result; }
java
public static List<Link> getLinks(final AnnotatedElement annotatedElement) { final List<Link> result = new ArrayList<>(); result.addAll(extractLinks(annotatedElement, io.qameta.allure.Link.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotatedElement, io.qameta.allure.Issue.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotatedElement, io.qameta.allure.TmsLink.class, ResultsUtils::createLink)); return result; }
[ "public", "static", "List", "<", "Link", ">", "getLinks", "(", "final", "AnnotatedElement", "annotatedElement", ")", "{", "final", "List", "<", "Link", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "result", ".", "addAll", "(", "extractLinks...
Returns links created from Allure annotations specified on annotated element. @param annotatedElement the element to search annotations on. @return discovered links.
[ "Returns", "links", "created", "from", "Allure", "annotations", "specified", "on", "annotated", "element", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java#L62-L68
32,261
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java
AnnotationUtils.getLinks
public static List<Link> getLinks(final Collection<Annotation> annotations) { final List<Link> result = new ArrayList<>(); result.addAll(extractLinks(annotations, io.qameta.allure.Link.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotations, io.qameta.allure.Issue.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotations, io.qameta.allure.TmsLink.class, ResultsUtils::createLink)); return result; }
java
public static List<Link> getLinks(final Collection<Annotation> annotations) { final List<Link> result = new ArrayList<>(); result.addAll(extractLinks(annotations, io.qameta.allure.Link.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotations, io.qameta.allure.Issue.class, ResultsUtils::createLink)); result.addAll(extractLinks(annotations, io.qameta.allure.TmsLink.class, ResultsUtils::createLink)); return result; }
[ "public", "static", "List", "<", "Link", ">", "getLinks", "(", "final", "Collection", "<", "Annotation", ">", "annotations", ")", "{", "final", "List", "<", "Link", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "result", ".", "addAll", "...
Returns links from given annotations. @param annotations annotations to analyse. @return discovered links.
[ "Returns", "links", "from", "given", "annotations", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java#L86-L92
32,262
allure-framework/allure-java
allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java
AnnotationUtils.getLabels
public static Set<Label> getLabels(final Collection<Annotation> annotations) { return annotations.stream() .flatMap(AnnotationUtils::extractRepeatable) .map(AnnotationUtils::getMarks) .flatMap(Collection::stream) .collect(Collectors.toSet()); }
java
public static Set<Label> getLabels(final Collection<Annotation> annotations) { return annotations.stream() .flatMap(AnnotationUtils::extractRepeatable) .map(AnnotationUtils::getMarks) .flatMap(Collection::stream) .collect(Collectors.toSet()); }
[ "public", "static", "Set", "<", "Label", ">", "getLabels", "(", "final", "Collection", "<", "Annotation", ">", "annotations", ")", "{", "return", "annotations", ".", "stream", "(", ")", ".", "flatMap", "(", "AnnotationUtils", "::", "extractRepeatable", ")", ...
Returns labels from given annotations. @param annotations annotations to analyse. @return discovered labels.
[ "Returns", "labels", "from", "given", "annotations", "." ]
64015ca2b789aa6f7b19c793f1512e2f11d0174e
https://github.com/allure-framework/allure-java/blob/64015ca2b789aa6f7b19c793f1512e2f11d0174e/allure-java-commons/src/main/java/io/qameta/allure/util/AnnotationUtils.java#L121-L127
32,263
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.isRunning
public boolean isRunning() { try { client.get("/"); return true; } catch (IOException e) { LOGGER.debug("isRunning()", e); return false; } }
java
public boolean isRunning() { try { client.get("/"); return true; } catch (IOException e) { LOGGER.debug("isRunning()", e); return false; } }
[ "public", "boolean", "isRunning", "(", ")", "{", "try", "{", "client", ".", "get", "(", "\"/\"", ")", ";", "return", "true", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "debug", "(", "\"isRunning()\"", ",", "e", ")", ";", "...
Get the current status of the Jenkins end-point by pinging it. @return true if Jenkins is up and running, false otherwise
[ "Get", "the", "current", "status", "of", "the", "Jenkins", "end", "-", "point", "by", "pinging", "it", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L99-L107
32,264
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.getView
public View getView(FolderJob folder, String name) throws IOException { try { View resultView = client.get(UrlUtils.toViewBaseUrl(folder, name) + "/", View.class); resultView.setClient(client); // TODO: Think about the following? Does there exists a simpler/more // elegant method? for (Job job : resultView.getJobs()) { job.setClient(client); } for (View view : resultView.getViews()) { view.setClient(client); } return resultView; } catch (HttpResponseException e) { LOGGER.debug("getView(folder={}, name={}) status={}", folder, name, e.getStatusCode()); if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { // TODO: Think hard about this. return null; } throw e; } }
java
public View getView(FolderJob folder, String name) throws IOException { try { View resultView = client.get(UrlUtils.toViewBaseUrl(folder, name) + "/", View.class); resultView.setClient(client); // TODO: Think about the following? Does there exists a simpler/more // elegant method? for (Job job : resultView.getJobs()) { job.setClient(client); } for (View view : resultView.getViews()) { view.setClient(client); } return resultView; } catch (HttpResponseException e) { LOGGER.debug("getView(folder={}, name={}) status={}", folder, name, e.getStatusCode()); if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { // TODO: Think hard about this. return null; } throw e; } }
[ "public", "View", "getView", "(", "FolderJob", "folder", ",", "String", "name", ")", "throws", "IOException", "{", "try", "{", "View", "resultView", "=", "client", ".", "get", "(", "UrlUtils", ".", "toViewBaseUrl", "(", "folder", ",", "name", ")", "+", "...
Get a single view object from the given folder @param folder The name of the folder. @param name name of the view in Jenkins @return the view object @throws IOException in case of an error.
[ "Get", "a", "single", "view", "object", "from", "the", "given", "folder" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L239-L261
32,265
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.getJob
public JobWithDetails getJob(String jobName) throws IOException { return getJob(null, UrlUtils.toFullJobPath(jobName)); }
java
public JobWithDetails getJob(String jobName) throws IOException { return getJob(null, UrlUtils.toFullJobPath(jobName)); }
[ "public", "JobWithDetails", "getJob", "(", "String", "jobName", ")", "throws", "IOException", "{", "return", "getJob", "(", "null", ",", "UrlUtils", ".", "toFullJobPath", "(", "jobName", ")", ")", ";", "}" ]
Get a single Job from the server. @param jobName name of the job to get details of. @return A single Job, null if not present @throws IOException in case of an error.
[ "Get", "a", "single", "Job", "from", "the", "server", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L270-L272
32,266
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.getJob
public JobWithDetails getJob(FolderJob folder, String jobName) throws IOException { try { JobWithDetails job = client.get(UrlUtils.toJobBaseUrl(folder, jobName), JobWithDetails.class); job.setClient(client); return job; } catch (HttpResponseException e) { LOGGER.debug("getJob(folder={}, jobName={}) status={}", folder, jobName, e.getStatusCode()); if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { // TODO: Think hard about this. return null; } throw e; } }
java
public JobWithDetails getJob(FolderJob folder, String jobName) throws IOException { try { JobWithDetails job = client.get(UrlUtils.toJobBaseUrl(folder, jobName), JobWithDetails.class); job.setClient(client); return job; } catch (HttpResponseException e) { LOGGER.debug("getJob(folder={}, jobName={}) status={}", folder, jobName, e.getStatusCode()); if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { // TODO: Think hard about this. return null; } throw e; } }
[ "public", "JobWithDetails", "getJob", "(", "FolderJob", "folder", ",", "String", "jobName", ")", "throws", "IOException", "{", "try", "{", "JobWithDetails", "job", "=", "client", ".", "get", "(", "UrlUtils", ".", "toJobBaseUrl", "(", "folder", ",", "jobName", ...
Get a single Job from the given folder. @param folder {@link FolderJob} @param jobName name of the job to get details of. @return A single Job, null if not present @throws IOException in case of an error.
[ "Get", "a", "single", "Job", "from", "the", "given", "folder", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L282-L296
32,267
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.createView
public JenkinsServer createView(String viewName, String viewXml) throws IOException { return createView(null, viewName, viewXml, false); }
java
public JenkinsServer createView(String viewName, String viewXml) throws IOException { return createView(null, viewName, viewXml, false); }
[ "public", "JenkinsServer", "createView", "(", "String", "viewName", ",", "String", "viewXml", ")", "throws", "IOException", "{", "return", "createView", "(", "null", ",", "viewName", ",", "viewXml", ",", "false", ")", ";", "}" ]
Create a view on the server using the provided xml @param viewName name of the view to be created. @param viewXml The configuration for the view. @throws IOException in case of an error.
[ "Create", "a", "view", "on", "the", "server", "using", "the", "provided", "xml" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L401-L403
32,268
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.createView
public JenkinsServer createView(String viewName, String viewXml, Boolean crumbFlag) throws IOException { return createView(null, viewName, viewXml, crumbFlag); }
java
public JenkinsServer createView(String viewName, String viewXml, Boolean crumbFlag) throws IOException { return createView(null, viewName, viewXml, crumbFlag); }
[ "public", "JenkinsServer", "createView", "(", "String", "viewName", ",", "String", "viewXml", ",", "Boolean", "crumbFlag", ")", "throws", "IOException", "{", "return", "createView", "(", "null", ",", "viewName", ",", "viewXml", ",", "crumbFlag", ")", ";", "}" ...
Create a view on the server using the provided xml. @param viewName name of the view to be created. @param viewXml The configuration for the view. @param crumbFlag <code>true</code> to add <b>crumbIssuer</b> <code>false</code> otherwise. @throws IOException in case of an error.
[ "Create", "a", "view", "on", "the", "server", "using", "the", "provided", "xml", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L414-L416
32,269
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.getJobXml
public String getJobXml(FolderJob folder, String jobName) throws IOException { return client.get(UrlUtils.toJobBaseUrl(folder, jobName) + "/config.xml"); }
java
public String getJobXml(FolderJob folder, String jobName) throws IOException { return client.get(UrlUtils.toJobBaseUrl(folder, jobName) + "/config.xml"); }
[ "public", "String", "getJobXml", "(", "FolderJob", "folder", ",", "String", "jobName", ")", "throws", "IOException", "{", "return", "client", ".", "get", "(", "UrlUtils", ".", "toJobBaseUrl", "(", "folder", ",", "jobName", ")", "+", "\"/config.xml\"", ")", "...
Get the xml description of an existing job. @param jobName name of the job. @param folder {@link FolderJob} @return the new job object @throws IOException in case of an error.
[ "Get", "the", "xml", "description", "of", "an", "existing", "job", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L523-L525
32,270
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.getLabel
public LabelWithDetails getLabel(String labelName) throws IOException { return client.get("/label/" + EncodingUtils.encode(labelName), LabelWithDetails.class); }
java
public LabelWithDetails getLabel(String labelName) throws IOException { return client.get("/label/" + EncodingUtils.encode(labelName), LabelWithDetails.class); }
[ "public", "LabelWithDetails", "getLabel", "(", "String", "labelName", ")", "throws", "IOException", "{", "return", "client", ".", "get", "(", "\"/label/\"", "+", "EncodingUtils", ".", "encode", "(", "labelName", ")", ",", "LabelWithDetails", ".", "class", ")", ...
Get the description of an existing Label @param labelName name of the label. @return {@link LabelWithDetails} @throws IOException in case of an error.
[ "Get", "the", "description", "of", "an", "existing", "Label" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L534-L536
32,271
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.updateView
public JenkinsServer updateView(String viewName, String viewXml) throws IOException { return this.updateView(viewName, viewXml, true); }
java
public JenkinsServer updateView(String viewName, String viewXml) throws IOException { return this.updateView(viewName, viewXml, true); }
[ "public", "JenkinsServer", "updateView", "(", "String", "viewName", ",", "String", "viewXml", ")", "throws", "IOException", "{", "return", "this", ".", "updateView", "(", "viewName", ",", "viewXml", ",", "true", ")", ";", "}" ]
Update the xml description of an existing view @param viewName name of the view. @param viewXml the view configuration. @throws IOException in case of an error.
[ "Update", "the", "xml", "description", "of", "an", "existing", "view" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L581-L583
32,272
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.enableJob
public JenkinsServer enableJob(String jobName, boolean crumbFlag) throws IOException { client.post("/job/" + EncodingUtils.encode(jobName) + "/enable", crumbFlag); return this; }
java
public JenkinsServer enableJob(String jobName, boolean crumbFlag) throws IOException { client.post("/job/" + EncodingUtils.encode(jobName) + "/enable", crumbFlag); return this; }
[ "public", "JenkinsServer", "enableJob", "(", "String", "jobName", ",", "boolean", "crumbFlag", ")", "throws", "IOException", "{", "client", ".", "post", "(", "\"/job/\"", "+", "EncodingUtils", ".", "encode", "(", "jobName", ")", "+", "\"/enable\"", ",", "crumb...
Enable a job from Jenkins. @param jobName The name of the job to be deleted. @param crumbFlag <code>true</code> to add <b>crumbIssuer</b> <code>false</code> otherwise. @throws IOException In case of an failure.
[ "Enable", "a", "job", "from", "Jenkins", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L773-L776
32,273
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.runScript
public String runScript(String script, boolean crumbFlag) throws IOException { return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, crumbFlag); }
java
public String runScript(String script, boolean crumbFlag) throws IOException { return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, crumbFlag); }
[ "public", "String", "runScript", "(", "String", "script", ",", "boolean", "crumbFlag", ")", "throws", "IOException", "{", "return", "client", ".", "post_text", "(", "\"/scriptText\"", ",", "\"script=\"", "+", "script", ",", "ContentType", ".", "APPLICATION_FORM_UR...
Runs the provided groovy script on the server and returns the result. This is similar to running groovy scripts using the script console. In the instance where your script causes an exception, the server still returns a 200 status, so detecting errors is very challenging. It is recommended to use heuristics to check your return string for stack traces by detecting strings like "groovy.lang.(something)Exception". @param script The script to run. @param crumbFlag <code>true</code> to add <b>crumbIssuer</b> <code>false</code> otherwise. @return results The results of the run of the script. @throws IOException in case of an error.
[ "Runs", "the", "provided", "groovy", "script", "on", "the", "server", "and", "returns", "the", "result", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L812-L814
32,274
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java
JenkinsServer.restart
public JenkinsServer restart(Boolean crumbFlag) throws IOException { try { client.post("/restart", crumbFlag); } catch (org.apache.http.client.ClientProtocolException e) { LOGGER.error("restart()", e); } return this; }
java
public JenkinsServer restart(Boolean crumbFlag) throws IOException { try { client.post("/restart", crumbFlag); } catch (org.apache.http.client.ClientProtocolException e) { LOGGER.error("restart()", e); } return this; }
[ "public", "JenkinsServer", "restart", "(", "Boolean", "crumbFlag", ")", "throws", "IOException", "{", "try", "{", "client", ".", "post", "(", "\"/restart\"", ",", "crumbFlag", ")", ";", "}", "catch", "(", "org", ".", "apache", ".", "http", ".", "client", ...
Restart Jenkins without waiting for any existing build to complete @param crumbFlag <code>true</code> to add <b>crumbIssuer</b> <code>false</code> otherwise. @throws IOException in case of an error.
[ "Restart", "Jenkins", "without", "waiting", "for", "any", "existing", "build", "to", "complete" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L931-L938
32,275
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/JenkinsHttpClient.java
JenkinsHttpClient.addAuthentication
protected static HttpClientBuilder addAuthentication(final HttpClientBuilder builder, final URI uri, final String username, String password) { if (isNotBlank(username)) { CredentialsProvider provider = new BasicCredentialsProvider(); AuthScope scope = new AuthScope(uri.getHost(), uri.getPort(), "realm"); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); provider.setCredentials(scope, credentials); builder.setDefaultCredentialsProvider(provider); builder.addInterceptorFirst(new PreemptiveAuth()); } return builder; }
java
protected static HttpClientBuilder addAuthentication(final HttpClientBuilder builder, final URI uri, final String username, String password) { if (isNotBlank(username)) { CredentialsProvider provider = new BasicCredentialsProvider(); AuthScope scope = new AuthScope(uri.getHost(), uri.getPort(), "realm"); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); provider.setCredentials(scope, credentials); builder.setDefaultCredentialsProvider(provider); builder.addInterceptorFirst(new PreemptiveAuth()); } return builder; }
[ "protected", "static", "HttpClientBuilder", "addAuthentication", "(", "final", "HttpClientBuilder", "builder", ",", "final", "URI", "uri", ",", "final", "String", "username", ",", "String", "password", ")", "{", "if", "(", "isNotBlank", "(", "username", ")", ")"...
Add authentication to supplied builder. @param builder the builder to configure @param uri the server URI @param username the username @param password the password @return the passed in builder
[ "Add", "authentication", "to", "supplied", "builder", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/JenkinsHttpClient.java#L457-L470
32,276
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/ResponseUtils.java
ResponseUtils.getJenkinsVersion
public static String getJenkinsVersion(final HttpResponse response) { final Header[] hdrs = response.getHeaders("X-Jenkins"); return hdrs.length == 0 ? "" : hdrs[0].getValue(); }
java
public static String getJenkinsVersion(final HttpResponse response) { final Header[] hdrs = response.getHeaders("X-Jenkins"); return hdrs.length == 0 ? "" : hdrs[0].getValue(); }
[ "public", "static", "String", "getJenkinsVersion", "(", "final", "HttpResponse", "response", ")", "{", "final", "Header", "[", "]", "hdrs", "=", "response", ".", "getHeaders", "(", "\"X-Jenkins\"", ")", ";", "return", "hdrs", ".", "length", "==", "0", "?", ...
Get Jenkins version from supplied response if any. @param response the response @return the version or empty string
[ "Get", "Jenkins", "version", "from", "supplied", "response", "if", "any", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/ResponseUtils.java#L32-L35
32,277
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/JobWithDetails.java
JobWithDetails.getBuildByNumber
public Optional<Build> getBuildByNumber(final int buildNumber) { return builds.stream().filter(isBuildNumberEqualTo(buildNumber)).findFirst(); }
java
public Optional<Build> getBuildByNumber(final int buildNumber) { return builds.stream().filter(isBuildNumberEqualTo(buildNumber)).findFirst(); }
[ "public", "Optional", "<", "Build", ">", "getBuildByNumber", "(", "final", "int", "buildNumber", ")", "{", "return", "builds", ".", "stream", "(", ")", ".", "filter", "(", "isBuildNumberEqualTo", "(", "buildNumber", ")", ")", ".", "findFirst", "(", ")", ";...
Get a build by the given buildNumber. @param buildNumber The number to select the build by. @return The an Optional with the {@link Build} selected by the given buildnumber
[ "Get", "a", "build", "by", "the", "given", "buildNumber", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/JobWithDetails.java#L456-L458
32,278
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java
UrlUtils.toJobBaseUrl
public static String toJobBaseUrl(final FolderJob folder, final String jobName) { final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); sb.append(UrlUtils.toBaseUrl(folder)); if (sb.charAt(sb.length() - 1) != '/') sb.append('/'); sb.append("job/"); final String[] jobNameParts = jobName.split("/"); for (int i = 0; i < jobNameParts.length; i++) { sb.append(EncodingUtils.encode(jobNameParts[i])); if (i != jobNameParts.length - 1) sb.append('/'); } return sb.toString(); }
java
public static String toJobBaseUrl(final FolderJob folder, final String jobName) { final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); sb.append(UrlUtils.toBaseUrl(folder)); if (sb.charAt(sb.length() - 1) != '/') sb.append('/'); sb.append("job/"); final String[] jobNameParts = jobName.split("/"); for (int i = 0; i < jobNameParts.length; i++) { sb.append(EncodingUtils.encode(jobNameParts[i])); if (i != jobNameParts.length - 1) sb.append('/'); } return sb.toString(); }
[ "public", "static", "String", "toJobBaseUrl", "(", "final", "FolderJob", "folder", ",", "final", "String", "jobName", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "DEFAULT_BUFFER_SIZE", ")", ";", "sb", ".", "append", "(", "UrlUti...
Helper to create the base url for a job, with or without a given folder @param folder the folder or {@code null} @param jobName the name of the job. @return converted base url.
[ "Helper", "to", "create", "the", "base", "url", "for", "a", "job", "with", "or", "without", "a", "given", "folder" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java#L49-L61
32,279
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java
UrlUtils.toViewBaseUrl
public static String toViewBaseUrl(final FolderJob folder, final String name) { final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); final String base = UrlUtils.toBaseUrl(folder); sb.append(base); if (!base.endsWith("/")) sb.append('/'); sb.append("view/") .append(EncodingUtils.encode(name)); return sb.toString(); }
java
public static String toViewBaseUrl(final FolderJob folder, final String name) { final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); final String base = UrlUtils.toBaseUrl(folder); sb.append(base); if (!base.endsWith("/")) sb.append('/'); sb.append("view/") .append(EncodingUtils.encode(name)); return sb.toString(); }
[ "public", "static", "String", "toViewBaseUrl", "(", "final", "FolderJob", "folder", ",", "final", "String", "name", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "DEFAULT_BUFFER_SIZE", ")", ";", "final", "String", "base", "=", "Ur...
Helper to create the base url for a view, with or without a given folder @param folder the folder or {@code null} @param name the of the view. @return converted view url.
[ "Helper", "to", "create", "the", "base", "url", "for", "a", "view", "with", "or", "without", "a", "given", "folder" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java#L70-L78
32,280
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java
UrlUtils.toFullJobPath
public static String toFullJobPath(final String jobName) { final String[] parts = jobName.split("/"); if (parts.length == 1) return parts[0]; final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i != parts.length -1) sb.append("/job/"); } return sb.toString(); }
java
public static String toFullJobPath(final String jobName) { final String[] parts = jobName.split("/"); if (parts.length == 1) return parts[0]; final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i != parts.length -1) sb.append("/job/"); } return sb.toString(); }
[ "public", "static", "String", "toFullJobPath", "(", "final", "String", "jobName", ")", "{", "final", "String", "[", "]", "parts", "=", "jobName", ".", "split", "(", "\"/\"", ")", ";", "if", "(", "parts", ".", "length", "==", "1", ")", "return", "parts"...
Parses the provided job name for folders to get the full path for the job. @param jobName the fullName of the job. @return the path of the job including folders if present.
[ "Parses", "the", "provided", "job", "name", "for", "folders", "to", "get", "the", "full", "path", "for", "the", "job", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java#L86-L96
32,281
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java
UrlUtils.toJsonApiUri
public static URI toJsonApiUri(final URI uri, final String context, final String path) { String p = path; if (!p.matches("(?i)https?://.*")) p = join(context, p); if (!p.contains("?")) { p = join(p, "api/json"); } else { final String[] components = p.split("\\?", 2); p = join(components[0], "api/json") + "?" + components[1]; } return uri.resolve("/").resolve(p.replace(" ", "%20")); }
java
public static URI toJsonApiUri(final URI uri, final String context, final String path) { String p = path; if (!p.matches("(?i)https?://.*")) p = join(context, p); if (!p.contains("?")) { p = join(p, "api/json"); } else { final String[] components = p.split("\\?", 2); p = join(components[0], "api/json") + "?" + components[1]; } return uri.resolve("/").resolve(p.replace(" ", "%20")); }
[ "public", "static", "URI", "toJsonApiUri", "(", "final", "URI", "uri", ",", "final", "String", "context", ",", "final", "String", "path", ")", "{", "String", "p", "=", "path", ";", "if", "(", "!", "p", ".", "matches", "(", "\"(?i)https?://.*\"", ")", "...
Create a JSON URI from the supplied parameters. @param uri the server URI @param context the server context if any @param path the specific API path @return new full URI instance
[ "Create", "a", "JSON", "URI", "from", "the", "supplied", "parameters", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java#L127-L138
32,282
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java
UrlUtils.toNoApiUri
public static URI toNoApiUri(final URI uri, final String context, final String path) { final String p = path.matches("(?i)https?://.*") ? path : join(context, path); return uri.resolve("/").resolve(p); }
java
public static URI toNoApiUri(final URI uri, final String context, final String path) { final String p = path.matches("(?i)https?://.*") ? path : join(context, path); return uri.resolve("/").resolve(p); }
[ "public", "static", "URI", "toNoApiUri", "(", "final", "URI", "uri", ",", "final", "String", "context", ",", "final", "String", "path", ")", "{", "final", "String", "p", "=", "path", ".", "matches", "(", "\"(?i)https?://.*\"", ")", "?", "path", ":", "joi...
Create a URI from the supplied parameters. @param uri the server URI @param context the server context if any @param path the specific API path @return new full URI instance
[ "Create", "a", "URI", "from", "the", "supplied", "parameters", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java#L149-L152
32,283
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java
Job.getFileFromWorkspace
public String getFileFromWorkspace(String fileName) throws IOException { InputStream is = client.getFile(URI.create(url + "/ws/" + fileName)); ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length; while ((length = is.read(buffer)) != -1) { result.write(buffer, 0, length); } return result.toString("UTF-8"); }
java
public String getFileFromWorkspace(String fileName) throws IOException { InputStream is = client.getFile(URI.create(url + "/ws/" + fileName)); ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length; while ((length = is.read(buffer)) != -1) { result.write(buffer, 0, length); } return result.toString("UTF-8"); }
[ "public", "String", "getFileFromWorkspace", "(", "String", "fileName", ")", "throws", "IOException", "{", "InputStream", "is", "=", "client", ".", "getFile", "(", "URI", ".", "create", "(", "url", "+", "\"/ws/\"", "+", "fileName", ")", ")", ";", "ByteArrayOu...
Get a file from workspace. @param fileName The name of the file to download from workspace. You can also access files which are in sub folders of the workspace. @return The string which contains the content of the file. @throws IOException in case of an error.
[ "Get", "a", "file", "from", "workspace", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java#L69-L78
32,284
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java
Job.build
public QueueReference build() throws IOException { ExtractHeader location = client.post(url + "build", null, ExtractHeader.class, false); return new QueueReference(location.getLocation()); }
java
public QueueReference build() throws IOException { ExtractHeader location = client.post(url + "build", null, ExtractHeader.class, false); return new QueueReference(location.getLocation()); }
[ "public", "QueueReference", "build", "(", ")", "throws", "IOException", "{", "ExtractHeader", "location", "=", "client", ".", "post", "(", "url", "+", "\"build\"", ",", "null", ",", "ExtractHeader", ".", "class", ",", "false", ")", ";", "return", "new", "Q...
Trigger a build without parameters @return {@link QueueReference} for further analysis of the queued build. @throws IOException in case of an error.
[ "Trigger", "a", "build", "without", "parameters" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java#L86-L90
32,285
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java
Job.build
public QueueReference build(Map<String, String> params, Map<String, File> fileParams) throws IOException { return build(params,fileParams,false); }
java
public QueueReference build(Map<String, String> params, Map<String, File> fileParams) throws IOException { return build(params,fileParams,false); }
[ "public", "QueueReference", "build", "(", "Map", "<", "String", ",", "String", ">", "params", ",", "Map", "<", "String", ",", "File", ">", "fileParams", ")", "throws", "IOException", "{", "return", "build", "(", "params", ",", "fileParams", ",", "false", ...
Trigger a parameterized build with file parameters @param params the job parameters @param fileParams the job file parameters @return {@link QueueReference} for further analysis of the queued build. @throws IOException in case of an error.
[ "Trigger", "a", "parameterized", "build", "with", "file", "parameters" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java#L135-L137
32,286
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java
Job.build
public QueueReference build(Map<String, String> params, Map<String, File> fileParams, boolean crumbFlag) throws IOException { String qs = params.entrySet().stream() .map(s -> s.getKey() + "=" + s.getValue()) .collect(Collectors.joining("&")); // String qs = join(Collections2.transform(params.entrySet(), new MapEntryToQueryStringPair()), "&"); ExtractHeader location = client.post(url + "buildWithParameters?" + qs,null, ExtractHeader.class, fileParams, crumbFlag); return new QueueReference(location.getLocation()); }
java
public QueueReference build(Map<String, String> params, Map<String, File> fileParams, boolean crumbFlag) throws IOException { String qs = params.entrySet().stream() .map(s -> s.getKey() + "=" + s.getValue()) .collect(Collectors.joining("&")); // String qs = join(Collections2.transform(params.entrySet(), new MapEntryToQueryStringPair()), "&"); ExtractHeader location = client.post(url + "buildWithParameters?" + qs,null, ExtractHeader.class, fileParams, crumbFlag); return new QueueReference(location.getLocation()); }
[ "public", "QueueReference", "build", "(", "Map", "<", "String", ",", "String", ">", "params", ",", "Map", "<", "String", ",", "File", ">", "fileParams", ",", "boolean", "crumbFlag", ")", "throws", "IOException", "{", "String", "qs", "=", "params", ".", "...
Trigger a parameterized build with file parameters and crumbFlag @param params the job parameters @param fileParams the job file parameters @param crumbFlag determines whether crumb flag is used @return {@link QueueReference} for further analysis of the queued build. @throws IOException in case of an error.
[ "Trigger", "a", "parameterized", "build", "with", "file", "parameters", "and", "crumbFlag" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Job.java#L148-L155
32,287
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/helper/ComparableVersion.java
ComparableVersion.main
public static void main( String... args ) { System.out.println( "Display parameters as parsed by Maven (in canonical form) and comparison result:" ); if ( args.length == 0 ) { return; } ComparableVersion prev = null; int i = 1; for ( String version : args ) { ComparableVersion c = new ComparableVersion( version ); if ( prev != null ) { int compare = prev.compareTo( c ); System.out.println( " " + prev.toString() + ' ' + ( ( compare == 0 ) ? "==" : ( ( compare < 0 ) ? "<" : ">" ) ) + ' ' + version ); } System.out.println( String.valueOf( i++ ) + ". " + version + " == " + c.getCanonical() ); prev = c; } }
java
public static void main( String... args ) { System.out.println( "Display parameters as parsed by Maven (in canonical form) and comparison result:" ); if ( args.length == 0 ) { return; } ComparableVersion prev = null; int i = 1; for ( String version : args ) { ComparableVersion c = new ComparableVersion( version ); if ( prev != null ) { int compare = prev.compareTo( c ); System.out.println( " " + prev.toString() + ' ' + ( ( compare == 0 ) ? "==" : ( ( compare < 0 ) ? "<" : ">" ) ) + ' ' + version ); } System.out.println( String.valueOf( i++ ) + ". " + version + " == " + c.getCanonical() ); prev = c; } }
[ "public", "static", "void", "main", "(", "String", "...", "args", ")", "{", "System", ".", "out", ".", "println", "(", "\"Display parameters as parsed by Maven (in canonical form) and comparison result:\"", ")", ";", "if", "(", "args", ".", "length", "==", "0", ")...
Main to test version parsing and comparison. @param args the version strings to parse and compare
[ "Main", "to", "test", "version", "parsing", "and", "comparison", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/helper/ComparableVersion.java#L477-L502
32,288
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/FolderJob.java
FolderJob.getJobs
public Map<String, Job> getJobs() { //FIXME: Check for null of jobs? Can that happen? return jobs.stream() .map(SET_CLIENT(this.client)) .collect(Collectors.toMap(k -> k.getName(), Function.identity())); }
java
public Map<String, Job> getJobs() { //FIXME: Check for null of jobs? Can that happen? return jobs.stream() .map(SET_CLIENT(this.client)) .collect(Collectors.toMap(k -> k.getName(), Function.identity())); }
[ "public", "Map", "<", "String", ",", "Job", ">", "getJobs", "(", ")", "{", "//FIXME: Check for null of jobs? Can that happen?", "return", "jobs", ".", "stream", "(", ")", ".", "map", "(", "SET_CLIENT", "(", "this", ".", "client", ")", ")", ".", "collect", ...
Get a list of all the defined jobs in this folder @return list of defined jobs (summary level, for details {@link Job#details()}.
[ "Get", "a", "list", "of", "all", "the", "defined", "jobs", "in", "this", "folder" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/FolderJob.java#L53-L58
32,289
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/FolderJob.java
FolderJob.getJob
public Job getJob(String name) { //FIXME: Check for null of jobs? Can that happen? return jobs.stream() .map(SET_CLIENT(this.client)) .filter(item -> item.getName().equals(name)) .findAny() .orElseThrow(() -> new IllegalArgumentException("Job with name " + name + " does not exist.")); }
java
public Job getJob(String name) { //FIXME: Check for null of jobs? Can that happen? return jobs.stream() .map(SET_CLIENT(this.client)) .filter(item -> item.getName().equals(name)) .findAny() .orElseThrow(() -> new IllegalArgumentException("Job with name " + name + " does not exist.")); }
[ "public", "Job", "getJob", "(", "String", "name", ")", "{", "//FIXME: Check for null of jobs? Can that happen?", "return", "jobs", ".", "stream", "(", ")", ".", "map", "(", "SET_CLIENT", "(", "this", ".", "client", ")", ")", ".", "filter", "(", "item", "->",...
Get a job in this folder by name @param name the name of the job. @return the given job @throws IllegalArgumentException in case if the {@code name} does not exist.
[ "Get", "a", "job", "in", "this", "folder", "by", "name" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/FolderJob.java#L67-L74
32,290
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
BuildWithDetails.streamConsoleOutput
public void streamConsoleOutput(final BuildConsoleStreamListener listener, final int poolingInterval, final int poolingTimeout, boolean crumbFlag) throws InterruptedException, IOException { // Calculate start and timeout final long startTime = System.currentTimeMillis(); final long timeoutTime = startTime + (poolingTimeout * 1000); int bufferOffset = 0; while (true) { Thread.sleep(poolingInterval * 1000); ConsoleLog consoleLog = null; consoleLog = getConsoleOutputText(bufferOffset, crumbFlag); String logString = consoleLog.getConsoleLog(); if (logString != null && !logString.isEmpty()) { listener.onData(logString); } if (consoleLog.getHasMoreData()) { bufferOffset = consoleLog.getCurrentBufferSize(); } else { listener.finished(); break; } long currentTime = System.currentTimeMillis(); if (currentTime > timeoutTime) { LOGGER.warn("Pooling for build {0} for {2} timeout! Check if job stuck in jenkins", BuildWithDetails.this.getDisplayName(), BuildWithDetails.this.getNumber()); break; } } }
java
public void streamConsoleOutput(final BuildConsoleStreamListener listener, final int poolingInterval, final int poolingTimeout, boolean crumbFlag) throws InterruptedException, IOException { // Calculate start and timeout final long startTime = System.currentTimeMillis(); final long timeoutTime = startTime + (poolingTimeout * 1000); int bufferOffset = 0; while (true) { Thread.sleep(poolingInterval * 1000); ConsoleLog consoleLog = null; consoleLog = getConsoleOutputText(bufferOffset, crumbFlag); String logString = consoleLog.getConsoleLog(); if (logString != null && !logString.isEmpty()) { listener.onData(logString); } if (consoleLog.getHasMoreData()) { bufferOffset = consoleLog.getCurrentBufferSize(); } else { listener.finished(); break; } long currentTime = System.currentTimeMillis(); if (currentTime > timeoutTime) { LOGGER.warn("Pooling for build {0} for {2} timeout! Check if job stuck in jenkins", BuildWithDetails.this.getDisplayName(), BuildWithDetails.this.getNumber()); break; } } }
[ "public", "void", "streamConsoleOutput", "(", "final", "BuildConsoleStreamListener", "listener", ",", "final", "int", "poolingInterval", ",", "final", "int", "poolingTimeout", ",", "boolean", "crumbFlag", ")", "throws", "InterruptedException", ",", "IOException", "{", ...
Stream build console output log as text using BuildConsoleStreamListener Method can be used to asynchronously obtain logs for running build. @param listener interface used to asynchronously obtain logs @param poolingInterval interval (seconds) used to pool jenkins for logs @param poolingTimeout pooling timeout (seconds) used to break pooling in case build stuck @throws InterruptedException in case of an error. @throws IOException in case of an error.
[ "Stream", "build", "console", "output", "log", "as", "text", "using", "BuildConsoleStreamListener", "Method", "can", "be", "used", "to", "asynchronously", "obtain", "logs", "for", "running", "build", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java#L395-L424
32,291
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
BuildWithDetails.getConsoleOutputText
public ConsoleLog getConsoleOutputText(int bufferOffset, boolean crumbFlag) throws IOException { List<NameValuePair> formData = new ArrayList<>(); formData.add(new BasicNameValuePair("start", Integer.toString(bufferOffset))); String path = getUrl() + "logText/progressiveText"; HttpResponse httpResponse = client.post_form_with_result(path, formData, crumbFlag); Header moreDataHeader = httpResponse.getFirstHeader(MORE_DATA_HEADER); Header textSizeHeader = httpResponse.getFirstHeader(TEXT_SIZE_HEADER); String response = EntityUtils.toString(httpResponse.getEntity()); boolean hasMoreData = false; if (moreDataHeader != null) { hasMoreData = Boolean.TRUE.toString().equals(moreDataHeader.getValue()); } Integer currentBufferSize = bufferOffset; if (textSizeHeader != null) { try { currentBufferSize = Integer.parseInt(textSizeHeader.getValue()); } catch (NumberFormatException e) { LOGGER.warn("Cannot parse buffer size for job {0} build {1}. Using current offset!", this.getDisplayName(), this.getNumber()); } } return new ConsoleLog(response, hasMoreData, currentBufferSize); }
java
public ConsoleLog getConsoleOutputText(int bufferOffset, boolean crumbFlag) throws IOException { List<NameValuePair> formData = new ArrayList<>(); formData.add(new BasicNameValuePair("start", Integer.toString(bufferOffset))); String path = getUrl() + "logText/progressiveText"; HttpResponse httpResponse = client.post_form_with_result(path, formData, crumbFlag); Header moreDataHeader = httpResponse.getFirstHeader(MORE_DATA_HEADER); Header textSizeHeader = httpResponse.getFirstHeader(TEXT_SIZE_HEADER); String response = EntityUtils.toString(httpResponse.getEntity()); boolean hasMoreData = false; if (moreDataHeader != null) { hasMoreData = Boolean.TRUE.toString().equals(moreDataHeader.getValue()); } Integer currentBufferSize = bufferOffset; if (textSizeHeader != null) { try { currentBufferSize = Integer.parseInt(textSizeHeader.getValue()); } catch (NumberFormatException e) { LOGGER.warn("Cannot parse buffer size for job {0} build {1}. Using current offset!", this.getDisplayName(), this.getNumber()); } } return new ConsoleLog(response, hasMoreData, currentBufferSize); }
[ "public", "ConsoleLog", "getConsoleOutputText", "(", "int", "bufferOffset", ",", "boolean", "crumbFlag", ")", "throws", "IOException", "{", "List", "<", "NameValuePair", ">", "formData", "=", "new", "ArrayList", "<>", "(", ")", ";", "formData", ".", "add", "("...
Get build console output log as text. Use this method to periodically obtain logs from jenkins and skip chunks that were already received @param bufferOffset offset in console lo @param crumbFlag <code>true</code> or <code>false</code>. @return ConsoleLog object containing console output of the build. The line separation is done by {@code CR+LF}. @throws IOException in case of a failure.
[ "Get", "build", "console", "output", "log", "as", "text", ".", "Use", "this", "method", "to", "periodically", "obtain", "logs", "from", "jenkins", "and", "skip", "chunks", "that", "were", "already", "received" ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java#L436-L458
32,292
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
BuildWithDetails.getChangeSet
public BuildChangeSet getChangeSet() { BuildChangeSet result; if (changeSet != null) { result = changeSet; } else if (changeSets != null && !changeSets.isEmpty()) { result = changeSets.get(0); } else { result = null; } return result; }
java
public BuildChangeSet getChangeSet() { BuildChangeSet result; if (changeSet != null) { result = changeSet; } else if (changeSets != null && !changeSets.isEmpty()) { result = changeSets.get(0); } else { result = null; } return result; }
[ "public", "BuildChangeSet", "getChangeSet", "(", ")", "{", "BuildChangeSet", "result", ";", "if", "(", "changeSet", "!=", "null", ")", "{", "result", "=", "changeSet", ";", "}", "else", "if", "(", "changeSets", "!=", "null", "&&", "!", "changeSets", ".", ...
Returns the change set of a build if available. If a build performs several scm checkouts (i.e. pipeline builds), the change set of the first checkout is returned. To get the complete list of change sets for all checkouts, use {@link #getChangeSets()} If no checkout is performed, null is returned. @return The change set of the build.
[ "Returns", "the", "change", "set", "of", "a", "build", "if", "available", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java#L473-L483
32,293
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
BuildWithDetails.getChangeSets
public List<BuildChangeSet> getChangeSets() { List<BuildChangeSet> result; if (changeSets != null) { result = changeSets; } else if (changeSet != null) { result = Collections.singletonList(changeSet); } else { result = null; } return result; }
java
public List<BuildChangeSet> getChangeSets() { List<BuildChangeSet> result; if (changeSets != null) { result = changeSets; } else if (changeSet != null) { result = Collections.singletonList(changeSet); } else { result = null; } return result; }
[ "public", "List", "<", "BuildChangeSet", ">", "getChangeSets", "(", ")", "{", "List", "<", "BuildChangeSet", ">", "result", ";", "if", "(", "changeSets", "!=", "null", ")", "{", "result", "=", "changeSets", ";", "}", "else", "if", "(", "changeSet", "!=",...
Returns the complete list of change sets for all checkout the build has performed. If no checkouts have been performed, returns null. @return The complete list of change sets of the build.
[ "Returns", "the", "complete", "list", "of", "change", "sets", "for", "all", "checkout", "the", "build", "has", "performed", ".", "If", "no", "checkouts", "have", "been", "performed", "returns", "null", "." ]
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java#L496-L506
32,294
jenkinsci/java-client-api
jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java
Build.Stop
public String Stop(boolean crumbFlag) throws HttpResponseException, IOException { try { return client.get(url + "stop"); } catch (HttpResponseException ex) { if (ex.getStatusCode() == HttpStatus.SC_METHOD_NOT_ALLOWED) { stopPost(crumbFlag); return ""; } throw ex; } }
java
public String Stop(boolean crumbFlag) throws HttpResponseException, IOException { try { return client.get(url + "stop"); } catch (HttpResponseException ex) { if (ex.getStatusCode() == HttpStatus.SC_METHOD_NOT_ALLOWED) { stopPost(crumbFlag); return ""; } throw ex; } }
[ "public", "String", "Stop", "(", "boolean", "crumbFlag", ")", "throws", "HttpResponseException", ",", "IOException", "{", "try", "{", "return", "client", ".", "get", "(", "url", "+", "\"stop\"", ")", ";", "}", "catch", "(", "HttpResponseException", "ex", ")"...
Stops the build which is currently in progress. This version takes in a crumbFlag. In some cases , an error is thrown which reads "No valid crumb was included in the request". This stop method is used incase those issues occur @param crumbFlag flag used to specify if a crumb is passed into for the request @return the client url @throws HttpResponseException in case of an error. @throws IOException in case of an error.
[ "Stops", "the", "build", "which", "is", "currently", "in", "progress", ".", "This", "version", "takes", "in", "a", "crumbFlag", ".", "In", "some", "cases", "an", "error", "is", "thrown", "which", "reads", "No", "valid", "crumb", "was", "included", "in", ...
c4f5953d3d4dda92cd946ad3bf2b811524c32da9
https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java#L167-L178
32,295
Tourenathan-G5organisation/SiliCompressor
silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java
FileUtils.getExtension
public static String getExtension(String uri) { if (uri == null) { return null; } int dot = uri.lastIndexOf("."); if (dot >= 0) { return uri.substring(dot); } else { // No extension. return ""; } }
java
public static String getExtension(String uri) { if (uri == null) { return null; } int dot = uri.lastIndexOf("."); if (dot >= 0) { return uri.substring(dot); } else { // No extension. return ""; } }
[ "public", "static", "String", "getExtension", "(", "String", "uri", ")", "{", "if", "(", "uri", "==", "null", ")", "{", "return", "null", ";", "}", "int", "dot", "=", "uri", ".", "lastIndexOf", "(", "\".\"", ")", ";", "if", "(", "dot", ">=", "0", ...
Gets the extension of a file name, like ".png" or ".jpg". @param uri @return Extension including the dot("."); "" if there is no extension; null if uri was null.
[ "Gets", "the", "extension", "of", "a", "file", "name", "like", ".", "png", "or", ".", "jpg", "." ]
546f6cd7b2a7a783e1122df46c1e237f8938fe72
https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/546f6cd7b2a7a783e1122df46c1e237f8938fe72/silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java#L71-L83
32,296
Tourenathan-G5organisation/SiliCompressor
silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java
FileUtils.getUri
public static Uri getUri(Context context, File file) { if (file != null) { return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, file); //Uri.fromFile(file); } return null; }
java
public static Uri getUri(Context context, File file) { if (file != null) { return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, file); //Uri.fromFile(file); } return null; }
[ "public", "static", "Uri", "getUri", "(", "Context", "context", ",", "File", "file", ")", "{", "if", "(", "file", "!=", "null", ")", "{", "return", "FileProvider", ".", "getUriForFile", "(", "context", ",", "FILE_PROVIDER_AUTHORITY", ",", "file", ")", ";",...
Convert File into Uri. @param file @return uri
[ "Convert", "File", "into", "Uri", "." ]
546f6cd7b2a7a783e1122df46c1e237f8938fe72
https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/546f6cd7b2a7a783e1122df46c1e237f8938fe72/silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java#L109-L115
32,297
Tourenathan-G5organisation/SiliCompressor
silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java
FileUtils.getFile
public static File getFile(Context context, Uri uri) { if (uri != null) { String path = getPath(context, uri); if (path != null && isLocal(path)) { return new File(path); } } return null; }
java
public static File getFile(Context context, Uri uri) { if (uri != null) { String path = getPath(context, uri); if (path != null && isLocal(path)) { return new File(path); } } return null; }
[ "public", "static", "File", "getFile", "(", "Context", "context", ",", "Uri", "uri", ")", "{", "if", "(", "uri", "!=", "null", ")", "{", "String", "path", "=", "getPath", "(", "context", ",", "uri", ")", ";", "if", "(", "path", "!=", "null", "&&", ...
Convert Uri into File, if possible. @return file A local file that the Uri was pointing to, or null if the Uri is unsupported or pointed to a remote resource. @see #getPath(Context, Uri) @author paulburke
[ "Convert", "Uri", "into", "File", "if", "possible", "." ]
546f6cd7b2a7a783e1122df46c1e237f8938fe72
https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/546f6cd7b2a7a783e1122df46c1e237f8938fe72/silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java#L342-L350
32,298
Tourenathan-G5organisation/SiliCompressor
silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java
FileUtils.getReadableFileSize
public static String getReadableFileSize(int size) { final int BYTES_IN_KILOBYTES = 1024; final DecimalFormat dec = new DecimalFormat("###.#"); final String KILOBYTES = " KB"; final String MEGABYTES = " MB"; final String GIGABYTES = " GB"; float fileSize = 0; String suffix = KILOBYTES; if (size > BYTES_IN_KILOBYTES) { fileSize = size / BYTES_IN_KILOBYTES; if (fileSize > BYTES_IN_KILOBYTES) { fileSize = fileSize / BYTES_IN_KILOBYTES; if (fileSize > BYTES_IN_KILOBYTES) { fileSize = fileSize / BYTES_IN_KILOBYTES; suffix = GIGABYTES; } else { suffix = MEGABYTES; } } } return String.valueOf(dec.format(fileSize) + suffix); }
java
public static String getReadableFileSize(int size) { final int BYTES_IN_KILOBYTES = 1024; final DecimalFormat dec = new DecimalFormat("###.#"); final String KILOBYTES = " KB"; final String MEGABYTES = " MB"; final String GIGABYTES = " GB"; float fileSize = 0; String suffix = KILOBYTES; if (size > BYTES_IN_KILOBYTES) { fileSize = size / BYTES_IN_KILOBYTES; if (fileSize > BYTES_IN_KILOBYTES) { fileSize = fileSize / BYTES_IN_KILOBYTES; if (fileSize > BYTES_IN_KILOBYTES) { fileSize = fileSize / BYTES_IN_KILOBYTES; suffix = GIGABYTES; } else { suffix = MEGABYTES; } } } return String.valueOf(dec.format(fileSize) + suffix); }
[ "public", "static", "String", "getReadableFileSize", "(", "int", "size", ")", "{", "final", "int", "BYTES_IN_KILOBYTES", "=", "1024", ";", "final", "DecimalFormat", "dec", "=", "new", "DecimalFormat", "(", "\"###.#\"", ")", ";", "final", "String", "KILOBYTES", ...
Get the file size in a human-readable string. @param size @return @author paulburke
[ "Get", "the", "file", "size", "in", "a", "human", "-", "readable", "string", "." ]
546f6cd7b2a7a783e1122df46c1e237f8938fe72
https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/546f6cd7b2a7a783e1122df46c1e237f8938fe72/silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java#L359-L381
32,299
Tourenathan-G5organisation/SiliCompressor
silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java
FileUtils.getThumbnail
public static Bitmap getThumbnail(Context context, File file) { return getThumbnail(context, getUri(context, file), getMimeType(file)); }
java
public static Bitmap getThumbnail(Context context, File file) { return getThumbnail(context, getUri(context, file), getMimeType(file)); }
[ "public", "static", "Bitmap", "getThumbnail", "(", "Context", "context", ",", "File", "file", ")", "{", "return", "getThumbnail", "(", "context", ",", "getUri", "(", "context", ",", "file", ")", ",", "getMimeType", "(", "file", ")", ")", ";", "}" ]
Attempt to retrieve the thumbnail of given File from the MediaStore. This should not be called on the UI thread. @param context @param file @return @author paulburke
[ "Attempt", "to", "retrieve", "the", "thumbnail", "of", "given", "File", "from", "the", "MediaStore", ".", "This", "should", "not", "be", "called", "on", "the", "UI", "thread", "." ]
546f6cd7b2a7a783e1122df46c1e237f8938fe72
https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/546f6cd7b2a7a783e1122df46c1e237f8938fe72/silicompressor/src/main/java/com/iceteck/silicompressorr/FileUtils.java#L392-L394