id
stringlengths
7
14
text
stringlengths
1
106k
1346655_3
public Image image(final String resourceName) { final URL imageUrl = getClass().getResource(resourceName); if (imageUrl != null) { try { return ImageIO.read(imageUrl); } catch (IOException e) { logger.error("Could not load image: " + resourceName, e); } } return null; }
1346655_4
public List<Light> lights() { return lights; }
1346655_5
public List<Light> lights() { return lights; }
1346655_6
public List<Light> lights() { return lights; }
1346655_7
public List<Light> lights() { return lights; }
1346655_8
public void turnNextLightOn() { Light light = findFirstLightOff(); if(light != null) light.turnOn(); }
1346655_9
public boolean areAllLightsOn() { return numberOfLightsOn() == lights.size(); }
1350993_0
public static synchronized SmoothieContainer getContainer() { if (container == null) { // This should really be done by a ServletContextListener when the webapp loads, but for now we are not modifying hudson-core, so bootstrap the container here. return new SmoothieContainerBootstrap().bootstrap(); ...
1354219_0
public static long binValueOf(final String binaryStr) { if (Strings.isEmpty(binaryStr)) { return 0; } long value = 0; long height = 1; for (int i = binaryStr.length() - 1; i >= 0; i--) { if ('1' == binaryStr.charAt(i)) { value += height; } height *= 2; } return value; }
1354219_1
public String buildText(String str1) { StringBuilder sb = new StringBuilder(); int prev = 0; for (int i = 0; i < str1.length(); i++) { char numChar = str1.charAt(i); String temp = basicOf(numChar - '0'); if (numChar - '0' > 0) { if (i - prev > 1) temp = CHINESE_NAMES[0] + temp; prev = i; ...
1354219_2
public String[] readNext() { String[] result = null; do { String nextLine = getNextLine(); if (!hasNext) { return result; // should throw if still pending? } String[] r = parser.parseLineMulti(nextLine); if (r.length > 0) { if (result == null) { result = r; } else { S...
1354219_3
public String toString() { if (ignoreCase) { return "lower(" + getProperty() + ") " + (ascending ? "asc" : "desc"); } else { return getProperty() + " " + (ascending ? "asc" : "desc"); } }
1354219_4
protected Object extract(Object target, String property) throws Exception { if (errorProperties.contains(property)) return null; Object value = null; try { value = expressionEvaluator.eval(property, target); } catch (EvaluationException e) { return null; } if (value instanceof Boolean) { if (nul...
1354219_5
public static boolean isZipFile(File zipFile) { try { ZipFile zf = new ZipFile(zipFile); boolean isZip = zf.getEntries().hasMoreElements(); zf.close(); return isZip; } catch (IOException e) { return false; } }
1354219_6
public static List<String> unzip(final File zipFile, final String destination) { return unzip(zipFile, destination, null); }
1354219_7
public static File zip(List<String> fileNames, String zipPath) { return zip(fileNames, zipPath, null); }
1354219_8
public static String encode(String password) { return encode(password, "MD5"); }
1358036_0
public static void removeSubGraph(Graph mGraph, Graph subGraph) throws NoSuchSubGraphException { //point to triples of mGraph that are to be removed (if something is removed) final Set<Triple> removingTriples = new HashSet<Triple>(); //we first check only the grounded triples and put the non-grounde...
1358036_1
public static void removeSubGraph(Graph mGraph, Graph subGraph) throws NoSuchSubGraphException { //point to triples of mGraph that are to be removed (if something is removed) final Set<Triple> removingTriples = new HashSet<Triple>(); //we first check only the grounded triples and put the non-grounde...
1358036_2
public static void removeSubGraph(Graph mGraph, Graph subGraph) throws NoSuchSubGraphException { //point to triples of mGraph that are to be removed (if something is removed) final Set<Triple> removingTriples = new HashSet<Triple>(); //we first check only the grounded triples and put the non-grounde...
1358036_3
@Override public boolean add(Triple e) { if (baseTripleCollections.length == 0) { throw new RuntimeException("no base graph for adding triples"); } return baseTripleCollections[0].add(e); }
1358036_4
@Override public boolean add(Triple e) { if (baseTripleCollections.length == 0) { throw new RuntimeException("no base graph for adding triples"); } return baseTripleCollections[0].add(e); }
1358036_5
public void addProperty(IRI predicate, RDFTerm object) { if (resource instanceof BlankNodeOrIRI) { graph.add(new TripleImpl((BlankNodeOrIRI) resource, predicate, object)); } else { throw new RuntimeException("Literals cannot be the subject of a statement"); } }
1358036_6
public void deleteProperties(IRI predicate) { if (resource instanceof BlankNodeOrIRI) { Iterator<Triple> tripleIter = graph.filter((BlankNodeOrIRI) resource, predicate, null); Collection<Triple> toDelete = new ArrayList<Triple>(); while (tripleIter.hasNext()) { Triple triple = tr...
1358036_7
public void deleteProperty(IRI predicate, RDFTerm object) { if (resource instanceof BlankNodeOrIRI) { graph.remove(new TripleImpl((BlankNodeOrIRI) resource, predicate, object)); } }
1358036_8
public GraphNode replaceWith(BlankNodeOrIRI replacement) { return replaceWith(replacement, false); }
1358036_9
@Override public boolean hasNext() { return next != null; }
135867_10
@Override protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); LOG.debug("showForm() state=" + state); String preAction = request.getParameter("prevAction"); if(pr...
135867_11
public User getCurrentUser(HttpServletRequest request) { try { User user = checkSingleLogin(request); if (user == null) { user = checkAutoLogin(request); } return user; } catch (Exception except) { return null; } }
135867_12
public void setRedirectAfterLoginCookie(HttpServletResponse response) { setRedirectAfterLoginCookie(response, _defaultRedirectAfterLogin); }
135867_13
public ActionError(String message, String details) { super(); _message = message; _details = details; _messageArguments = new Object[0]; _detailArguments = new Object[0]; _target = null; _detailsKey = null; _code = -1; }
135867_14
@Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); ...
135867_15
@Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); ...
135867_16
@Override protected final ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) {...
135867_17
@Override protected final ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) {...
135867_18
@Override protected final ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) {...
135867_19
@Override protected final ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) {...
135867_20
public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; } return state.getCurrentUser().getName(); }
1361294_0
public List<Person> list() { try (Connection con = ds.getConnection()) { ArrayList<Person> persons = new ArrayList<Person>(); ResultSet rs = con.createStatement().executeQuery(QUERY); while (rs.next()) { persons.add(read(rs)); } return persons; } catch (SQLExc...
1361294_1
public List<String> listQueues() { assertConnection(); return extJmsService.listQueues(); }
1361294_2
@XmlElement public double getAverage() { int sum = 0; for (Vote vote : votes) { sum += vote.getVote(); } return new Double(sum) / votes.size(); }
1361294_3
public Vote convert(DirectMessage message) { try { String text = message.getText(); String[] parts = text.split(" "); String topic = parts[0]; int voteNum = Integer.parseInt(parts[1]); String fromUser = message.getSender().getName(); return new Vote(topic, voteNum, fromUser, message.getCreatedAt()); } cat...
1365016_0
public void pack(final BoundingVolume sceneBounds) { final ReadOnlyVector3 center = sceneBounds.getCenter(); for (int i = 0; i < _corners.length; i++) { _corners[i].set(center); } if (sceneBounds instanceof BoundingBox) { final BoundingBox bbox = (BoundingBox) sceneBounds; bbox.g...
1365016_1
public final void readFully(final byte b[]) throws IOException { readFully(b, 0, b.length); }
1365016_2
public final void readFully(final byte b[]) throws IOException { readFully(b, 0, b.length); }
1365016_3
public final void readFully(final byte b[]) throws IOException { readFully(b, 0, b.length); }
1365016_4
public final void readFully(final byte b[]) throws IOException { readFully(b, 0, b.length); }
1365016_5
public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; }
1365016_6
public EnumSet<Key> getKeysReleasedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(previous._keysDown); result.removeAll(_keysDown); return result; }
1365016_7
public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; }
1365016_8
public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; }
1365016_9
public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; }
1365306_0
public static String[] getSplittedGav(String gav) { return gav.split(":"); }
1365306_1
public static ReleaseId getReleaseID(String gav, KieServices srv) { String[] parts = getSplittedGav(gav); return srv.newReleaseId(parts[0], parts[1], parts[2]); }
1365306_2
public static KieContainer getKieContainer(EnvConfig envConfig, KieServices srv) { KieContainer kieContainer; if (srv != null) { if (envConfig.isUpdatableKJar()) { kieContainer = srv.newKieContainer(GAVUtils.getReleaseID(envConfig.getKJarGAV(), srv)); KieScanner scanner = srv.new...
1365306_3
public boolean isFiringUntilHalt() { return firingUntilHalt; }
1365306_4
public boolean isFiringUntilHalt() { return firingUntilHalt; }
1365306_5
InternalFactHandle getFactHandleById(RemoteFactHandle remoteFH) { long id = fhIdMap.get(remoteFH); for (FactHandle fh : kieSession.getFactHandles(new ClassObjectFilter(remoteFH.getObject().getClass()))) { InternalFactHandle ifh = (InternalFactHandle) fh; if (ifh.getId() == id) { retu...
1365306_6
@Override public V put(K key, V value) { inverseMap.put(value, key); return super.put(key, value); }
1365306_7
public K getKey(V value) { return inverseMap.get(value); }
1365306_8
public static Properties getDefaultConfig() { return getDefaultConfigFromProps(CONF); }
1365306_9
public static synchronized Properties getStatic() { if (config == null) { config = new Properties(); config.put(KEY_SERIALIZER_KEY, "org.apache.kafka.common.serialization.StringSerializer"); config.put(VALUE_SERIALIZER_KEY, "org.apache.kafka.common.seria...
1365699_0
@Override public int run(String[] args) throws Exception { Map<String,String> parsedArgs = parseArgs(args); Path inputPath = new Path(parsedArgs.get("--input")); Path outputPath = new Path(parsedArgs.get("--output")); //IMPLEMENT ME return 0; }
1365699_1
@Override public int run(String[] args) throws Exception { Map<String,String> parsedArgs = parseArgs(args); Path inputPath = new Path(parsedArgs.get("--input")); Path outputPath = new Path(parsedArgs.get("--output")); double minimumQuality = Double.parseDouble(parsedArgs.get("--minimumQuality")); //IMPLEMENT ...
1365699_2
@Override public int run(String[] args) throws Exception { Map<String,String> parsedArgs = parseArgs(args); Path inputPath = new Path(parsedArgs.get("--input")); Path outputPath = new Path(parsedArgs.get("--output")); Job wordCount = prepareJob(inputPath, outputPath, TextInputFormat.class, FilteringWordCountMap...
1367811_0
public static File chop( final File original, final long tailToKeep ) { if ( !original.isFile() ) { throw new IllegalArgumentException( "Cannot behead directories: " + original ); } File truncatedFile = new File( original.getParentFile(), original.getName() + ".truncated" ); FileChannel whol...
1367811_1
public static File chop( final File original, final long tailToKeep ) { if ( !original.isFile() ) { throw new IllegalArgumentException( "Cannot behead directories: " + original ); } File truncatedFile = new File( original.getParentFile(), original.getName() + ".truncated" ); FileChannel whol...
1367811_2
public static File chop( final File original, final long tailToKeep ) { if ( !original.isFile() ) { throw new IllegalArgumentException( "Cannot behead directories: " + original ); } File truncatedFile = new File( original.getParentFile(), original.getName() + ".truncated" ); FileChannel whol...
1367811_3
public static OID parse(final String spec) { assert spec != null; String[] items = spec.split("@"); if (items.length != 2) { throw new IllegalArgumentException(); } return new OID(items[0], Integer.parseInt(items[1], 16)); }
1367811_4
public static OID get(final Object obj) { if (obj == null) { return NULL; } return new OID(obj.getClass().getName(), System.identityHashCode(obj)); }
1367811_5
public static String asRawVersion( String version, String timestamp, String sequence ) { StringBuilder buff = new StringBuilder(); if ( version == null ) { version = VersionSupport.UNKNOWN; } buff.append( version ); if ( timestamp != null ) { buff.append( "," ).append( timest...
1367811_6
public static String asRawVersion( String version, String timestamp, String sequence ) { StringBuilder buff = new StringBuilder(); if ( version == null ) { version = VersionSupport.UNKNOWN; } buff.append( version ); if ( timestamp != null ) { buff.append( "," ).append( timest...
1367811_7
public static String asCanonicalVersion( String version, String timestamp, String sequence ) { String derivedVersion = version; if ( derivedVersion == null ) { derivedVersion = VersionSupport.UNKNOWN; } String snapshot = "-SNAPSHOT"; if ( derivedVersion.contains( snapshot ) ) { ...
1367811_8
public static String asCanonicalVersion( String version, String timestamp, String sequence ) { String derivedVersion = version; if ( derivedVersion == null ) { derivedVersion = VersionSupport.UNKNOWN; } String snapshot = "-SNAPSHOT"; if ( derivedVersion.contains( snapshot ) ) { ...
1367811_9
@Override public String put(String key, String value) { throw new UnsupportedOperationException(); }
1368680_0
public <T> T newInstance(final Class<T> clazz) { try { return clazz.newInstance(); } catch (final InstantiationException e) { throw new RuntimeException(e); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } }
1368680_1
public <T> T newInstance(final Class<T> clazz) { try { return clazz.newInstance(); } catch (final InstantiationException e) { throw new RuntimeException(e); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } }
1368680_2
public Object read(final Object bean, final String fieldName) { return getAccessor(bean.getClass()).read(bean, fieldName); }
1368680_3
public Class<?> getFieldType(final Class<?> beanClass, final String fieldName) { return getAccessor(beanClass).getFieldType(fieldName); }
1368680_4
public Field getField(final Class<?> beanClass, final String fieldName) { return getAccessor(beanClass).getField(fieldName); }
1368680_5
public void write(final Object bean, final String fieldName, final Object param) { getAccessor(bean.getClass()).write(bean, fieldName, param); }
1368680_6
public Object read(final Object bean, final String propertyName) { return getAccessor(bean.getClass()).read(bean, propertyName); }
1368680_7
public void write(final Object bean, final String propertyName, final Object param) { getAccessor(bean.getClass()).write(bean, propertyName, param); }
1368680_8
@Override public List<Scope> getScopes() { return Collections.unmodifiableList(scopes); }
1368680_9
@Override public Scope getRootScope() { return scopes.get(0); }
1379319_0
public boolean detect(MassedBeing being1, MassedBeing being2) { //figure out which MassedBeing is smaller, which is bigger float height1 = being1.getBoundingBox().getMax().y - being1.getBoundingBox().getMin().y; float height2 = being2.getBoundingBox().getMax().y - being2.getBoundingBox().getMin().y; float width1 = ...
1379319_1
public static PVector calculateImpulse(PVector v1, PVector v2, float m1, float m2, float elasticity, PVector normal) { assert v1 != null : "Physics.calculateImpulse: v1 must be a valid PVector"; assert v2 != null : "Physics.calculateImpulse: v2 must be a valid PVector"; assert normal != null : "Physics.calculateI...
1381837_0
public static List<ComplexityThreshold> convertAbacusThresholdsToComplexityThresholds(String[] propertyThresholds) { List<ComplexityThreshold> complexityThresholds = new ArrayList<ComplexityThreshold>(); String[] temp; for (String propertyThreshold : propertyThresholds) { temp = propertyThreshold.split(PARSIN...
1381837_1
public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = ...
1381837_2
public static void initCounterThreshold(List<ComplexityThreshold> complexityThresholds) { for (ComplexityThreshold complexityThreshold : complexityThresholds) { complexityThreshold.initializeCounter(); } }
1381837_3
public static String buildComplexityDistributionMeasureValue(List<ComplexityThreshold> complexityThresholds) { String complexityDistributionMeasureValue = ""; for (Iterator<ComplexityThreshold> it = complexityThresholds.iterator(); it.hasNext();) { ComplexityThreshold complexityThreshold = it.next(); comple...
1381837_4
public void decorate(Resource rsrc, DecoratorContext dc) { computeAbacusComplexity(rsrc, dc); computeAbacusComplexityDistribution(rsrc, dc); }
1381837_5
public void decorate(Resource rsrc, DecoratorContext dc) { computeAbacusComplexity(rsrc, dc); computeAbacusComplexityDistribution(rsrc, dc); }
1381837_6
public void decorate(Resource rsrc, DecoratorContext dc) { computeAbacusComplexity(rsrc, dc); computeAbacusComplexityDistribution(rsrc, dc); }
1381837_7
public void decorate(Resource rsrc, DecoratorContext dc) { computeAbacusComplexity(rsrc, dc); computeAbacusComplexityDistribution(rsrc, dc); }
1381874_0
@JsonValue public JsonNode toJson() { ArrayNode key = mapper.createArrayNode(); for (Object component : components) { if (component == EMPTY_OBJECT) { key.addObject(); } else { key.addPOJO(component); } } return key; }
1381874_1
public static ComplexKey of(Object... components) { return new ComplexKey(components); }
1381874_2
private StringBuilder params() { if (params == null) { params = new StringBuilder(); } return params; }
1381874_3
public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); }
1381874_4
public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); }