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(); } return container; }
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; temp = temp + priorityOf(str1.length() - i); sb.append(temp); } } String result = sb.toString(); if (result.startsWith("一十")) result = result.substring(1); return result.replaceAll("零一十", "零十"); }
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 { String[] t = new String[result.length + r.length]; System.arraycopy(result, 0, t, 0, result.length); System.arraycopy(r, 0, t, result.length, r.length); result = t; } } } while (parser.isPending()); return result; }
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 (null == textResource) { return value; } else { if (Boolean.TRUE.equals(value)) return getText("common.yes", "Y"); else return getText("common.no", "N"); } } else { return value; } }
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-grounded in here: final Graph unGroundedTriples = new SimpleGraph(); for (Triple triple : subGraph) { if (isGrounded(triple)) { if (!mGraph.contains(triple)) { throw new NoSuchSubGraphException(); } removingTriples.add(triple); } else { unGroundedTriples.add(triple); } } //we first remove the context of bnodes we find in object position OBJ_BNODE_LOOP: while (true) { final Triple triple = getTripleWithBlankNodeObject(unGroundedTriples); if (triple == null) { break; } final GraphNode objectGN = new GraphNode(triple.getObject(), unGroundedTriples); BlankNodeOrIRI subject = triple.getSubject(); ImmutableGraph context = objectGN.getNodeContext(); Iterator<Triple> potentialIter = mGraph.filter(subject, triple.getPredicate(), null); while (potentialIter.hasNext()) { try { final Triple potentialTriple = potentialIter.next(); BlankNode potentialMatch = (BlankNode) potentialTriple.getObject(); final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext(); if (potentialContext.equals(context)) { removingTriples.addAll(potentialContext); unGroundedTriples.removeAll(context); continue OBJ_BNODE_LOOP; } } catch (ClassCastException e) { continue; } } throw new NoSuchSubGraphException(); } SUBJ_BNODE_LOOP: while (true) { final Triple triple = getTripleWithBlankNodeSubject(unGroundedTriples); if (triple == null) { break; } final GraphNode subjectGN = new GraphNode(triple.getSubject(), unGroundedTriples); RDFTerm object = triple.getObject(); if (object instanceof BlankNode) { object = null; } ImmutableGraph context = subjectGN.getNodeContext(); Iterator<Triple> potentialIter = mGraph.filter(null, triple.getPredicate(), object); while (potentialIter.hasNext()) { try { final Triple potentialTriple = potentialIter.next(); BlankNode potentialMatch = (BlankNode) potentialTriple.getSubject(); final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext(); if (potentialContext.equals(context)) { removingTriples.addAll(potentialContext); unGroundedTriples.removeAll(context); continue SUBJ_BNODE_LOOP; } } catch (ClassCastException e) { continue; } } throw new NoSuchSubGraphException(); } mGraph.removeAll(removingTriples); }
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-grounded in here: final Graph unGroundedTriples = new SimpleGraph(); for (Triple triple : subGraph) { if (isGrounded(triple)) { if (!mGraph.contains(triple)) { throw new NoSuchSubGraphException(); } removingTriples.add(triple); } else { unGroundedTriples.add(triple); } } //we first remove the context of bnodes we find in object position OBJ_BNODE_LOOP: while (true) { final Triple triple = getTripleWithBlankNodeObject(unGroundedTriples); if (triple == null) { break; } final GraphNode objectGN = new GraphNode(triple.getObject(), unGroundedTriples); BlankNodeOrIRI subject = triple.getSubject(); ImmutableGraph context = objectGN.getNodeContext(); Iterator<Triple> potentialIter = mGraph.filter(subject, triple.getPredicate(), null); while (potentialIter.hasNext()) { try { final Triple potentialTriple = potentialIter.next(); BlankNode potentialMatch = (BlankNode) potentialTriple.getObject(); final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext(); if (potentialContext.equals(context)) { removingTriples.addAll(potentialContext); unGroundedTriples.removeAll(context); continue OBJ_BNODE_LOOP; } } catch (ClassCastException e) { continue; } } throw new NoSuchSubGraphException(); } SUBJ_BNODE_LOOP: while (true) { final Triple triple = getTripleWithBlankNodeSubject(unGroundedTriples); if (triple == null) { break; } final GraphNode subjectGN = new GraphNode(triple.getSubject(), unGroundedTriples); RDFTerm object = triple.getObject(); if (object instanceof BlankNode) { object = null; } ImmutableGraph context = subjectGN.getNodeContext(); Iterator<Triple> potentialIter = mGraph.filter(null, triple.getPredicate(), object); while (potentialIter.hasNext()) { try { final Triple potentialTriple = potentialIter.next(); BlankNode potentialMatch = (BlankNode) potentialTriple.getSubject(); final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext(); if (potentialContext.equals(context)) { removingTriples.addAll(potentialContext); unGroundedTriples.removeAll(context); continue SUBJ_BNODE_LOOP; } } catch (ClassCastException e) { continue; } } throw new NoSuchSubGraphException(); } mGraph.removeAll(removingTriples); }
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-grounded in here: final Graph unGroundedTriples = new SimpleGraph(); for (Triple triple : subGraph) { if (isGrounded(triple)) { if (!mGraph.contains(triple)) { throw new NoSuchSubGraphException(); } removingTriples.add(triple); } else { unGroundedTriples.add(triple); } } //we first remove the context of bnodes we find in object position OBJ_BNODE_LOOP: while (true) { final Triple triple = getTripleWithBlankNodeObject(unGroundedTriples); if (triple == null) { break; } final GraphNode objectGN = new GraphNode(triple.getObject(), unGroundedTriples); BlankNodeOrIRI subject = triple.getSubject(); ImmutableGraph context = objectGN.getNodeContext(); Iterator<Triple> potentialIter = mGraph.filter(subject, triple.getPredicate(), null); while (potentialIter.hasNext()) { try { final Triple potentialTriple = potentialIter.next(); BlankNode potentialMatch = (BlankNode) potentialTriple.getObject(); final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext(); if (potentialContext.equals(context)) { removingTriples.addAll(potentialContext); unGroundedTriples.removeAll(context); continue OBJ_BNODE_LOOP; } } catch (ClassCastException e) { continue; } } throw new NoSuchSubGraphException(); } SUBJ_BNODE_LOOP: while (true) { final Triple triple = getTripleWithBlankNodeSubject(unGroundedTriples); if (triple == null) { break; } final GraphNode subjectGN = new GraphNode(triple.getSubject(), unGroundedTriples); RDFTerm object = triple.getObject(); if (object instanceof BlankNode) { object = null; } ImmutableGraph context = subjectGN.getNodeContext(); Iterator<Triple> potentialIter = mGraph.filter(null, triple.getPredicate(), object); while (potentialIter.hasNext()) { try { final Triple potentialTriple = potentialIter.next(); BlankNode potentialMatch = (BlankNode) potentialTriple.getSubject(); final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext(); if (potentialContext.equals(context)) { removingTriples.addAll(potentialContext); unGroundedTriples.removeAll(context); continue SUBJ_BNODE_LOOP; } } catch (ClassCastException e) { continue; } } throw new NoSuchSubGraphException(); } mGraph.removeAll(removingTriples); }
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 = tripleIter.next(); toDelete.add(triple); } for (Triple triple : toDelete) { graph.remove(triple); } } }
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(preAction != null && !preAction.equals("")) { state.setPreviousAction(preAction); } // Checking whether logged in User user = state.getCurrentUser(); if (user == null) { user = checkSingleLogin(request); if (user != null) user = authenticate(user.getToken(), convertRoles(_grantedRoles)); } if (user == null) { user = checkAutoLogin(request); if (user != null) user = authenticate(user.getToken(), convertRoles(_grantedRoles)); } if (user == null) { // do login // handle login from HTTP request String username = request.getParameter(LoginValidator.USERNAME_PARAM); String password = request.getParameter(LoginValidator.PASSWORD_PARAM); // LOG.debug("username: " + username + " password: " + password); if (username != null && !"".equals(username) && password != null) { user = authenticate(username, password, errors); } } if (user != null) { LOG.debug("User authenticated: " + user.getName()); state.setCurrentUser(user); String prevAction = state.getPreviousAction(); if (prevAction == null) { LOG.debug("Redirect after succesful login"); return redirectAfterLogin(request, response); } else { LOG.debug("Redirect after succesful login: " + prevAction); state.setPreviousAction(null); return new ModelAndView(new RedirectView(prevAction)); } } LOG.debug("" + errors); Map model = errors.getModel(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); }
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(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { // Do default action Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }
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(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { // Do default action Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }
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) { return super.processFormSubmission(request, response, command, errors); } // save request position state.setPreviousAction(request.getRequestURL().toString()); // redirect to login page return Constants.REDIRECTION_TO_LOGIN; }
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) { return super.processFormSubmission(request, response, command, errors); } // save request position state.setPreviousAction(request.getRequestURL().toString()); // redirect to login page return Constants.REDIRECTION_TO_LOGIN; }
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) { return super.processFormSubmission(request, response, command, errors); } // save request position state.setPreviousAction(request.getRequestURL().toString()); // redirect to login page return Constants.REDIRECTION_TO_LOGIN; }
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) { return super.processFormSubmission(request, response, command, errors); } // save request position state.setPreviousAction(request.getRequestURL().toString()); // redirect to login page return Constants.REDIRECTION_TO_LOGIN; }
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 (SQLException e) { throw new RuntimeException(e.getMessage(), e); } }
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()); } catch (Throwable e) { LOG.info("Invalid tweet " + message.getText() + ": " + e.getMessage()); return null; } }
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.getExtent(_extents); } else if (sceneBounds instanceof BoundingSphere) { final BoundingSphere bsphere = (BoundingSphere) sceneBounds; _extents.set(bsphere.getRadius(), bsphere.getRadius(), bsphere.getRadius()); } _corners[0].addLocal(_extents.getX(), _extents.getY(), _extents.getZ()); _corners[1].addLocal(_extents.getX(), -_extents.getY(), _extents.getZ()); _corners[2].addLocal(_extents.getX(), _extents.getY(), -_extents.getZ()); _corners[3].addLocal(_extents.getX(), -_extents.getY(), -_extents.getZ()); _corners[4].addLocal(-_extents.getX(), _extents.getY(), _extents.getZ()); _corners[5].addLocal(-_extents.getX(), -_extents.getY(), _extents.getZ()); _corners[6].addLocal(-_extents.getX(), _extents.getY(), -_extents.getZ()); _corners[7].addLocal(-_extents.getX(), -_extents.getY(), -_extents.getZ()); final ReadOnlyMatrix4 mvMatrix = getModelViewMatrix(); double optimalCameraNear = Double.MAX_VALUE; double optimalCameraFar = -Double.MAX_VALUE; final Vector4 position = Vector4.fetchTempInstance(); for (int i = 0; i < _corners.length; i++) { position.set(_corners[i].getX(), _corners[i].getY(), _corners[i].getZ(), 1); mvMatrix.applyPre(position, position); optimalCameraNear = Math.min(-position.getZ(), optimalCameraNear); optimalCameraFar = Math.max(-position.getZ(), optimalCameraFar); } Vector4.releaseTempInstance(position); // XXX: use of getFrustumNear and getFrustumFar seems suspicious... // XXX: It depends on the frustum being reset each update optimalCameraNear = Math.min(Math.max(getFrustumNear(), optimalCameraNear), getFrustumFar()); optimalCameraFar = Math.max(optimalCameraNear, Math.min(_maxFarPlaneDistance, optimalCameraFar)); final double change = optimalCameraNear / _frustumNear; setFrustumLeft(getFrustumLeft() * change); setFrustumRight(getFrustumRight() * change); setFrustumTop(getFrustumTop() * change); setFrustumBottom(getFrustumBottom() * change); setFrustumNear(optimalCameraNear); setFrustumFar(optimalCameraFar); }
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.newKieScanner(kieContainer); scanner.scanNow(); if (logger.isInfoEnabled()) { logger.info("Created new KieContainer with KJar:{} from maven repo", envConfig.getKJarGAV()); } } else { if (logger.isInfoEnabled()) { logger.info("Creating new Kie Session with the KJar deployed with the app"); } kieContainer = srv.newKieClasspathContainer(); } return kieContainer; } else { throw new IllegalStateException("KieServices is null"); } }
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) { return ifh; } } throw new IllegalArgumentException(); }
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.serialization.ByteArraySerializer"); config.put(KEY_DESERIALIZER_KEY, "org.apache.kafka.common.serialization.StringDeserializer"); config.put(VALUE_DESERIALIZER_KEY, "org.apache.kafka.common.serialization.ByteArrayDeserializer"); config.put(GROUP_ID_CONFIG, "drools"); } return config; }
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 ME return 0; }
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, FilteringWordCountMapper.class, Text.class, IntWritable.class, WordCountReducer.class, Text.class, IntWritable.class, TextOutputFormat.class); wordCount.waitForCompletion(true); return 0; }
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 whole = null; FileChannel chopped = null; try { whole = new FileInputStream( original ).getChannel(); chopped = new FileOutputStream( truncatedFile ).getChannel(); long originalLength = original.length(); long lengthToKeep = originalLength < tailToKeep ? 0 : originalLength - tailToKeep; whole.transferTo( lengthToKeep, originalLength, chopped ); } catch ( IOException e ) { throw new IllegalStateException( "Cannot behead file due to inconsistent internal state.", e ); } finally { Closer.close( whole, chopped ); } // Replace original with chopped file. boolean isRenamed = truncatedFile.renameTo( original ); if ( !( isRenamed ) ) { IllegalStateException renameException = new IllegalStateException( "Cannot replace original with chopped file to: " + original ); String originalPath = original.getAbsolutePath(); boolean isDeleted = original.delete(); if ( isDeleted ) { boolean isRenamedAgain = truncatedFile.renameTo( new File( originalPath ) ); if ( !isRenamedAgain ) { throw renameException; } } else { throw renameException; } } return original; }
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 whole = null; FileChannel chopped = null; try { whole = new FileInputStream( original ).getChannel(); chopped = new FileOutputStream( truncatedFile ).getChannel(); long originalLength = original.length(); long lengthToKeep = originalLength < tailToKeep ? 0 : originalLength - tailToKeep; whole.transferTo( lengthToKeep, originalLength, chopped ); } catch ( IOException e ) { throw new IllegalStateException( "Cannot behead file due to inconsistent internal state.", e ); } finally { Closer.close( whole, chopped ); } // Replace original with chopped file. boolean isRenamed = truncatedFile.renameTo( original ); if ( !( isRenamed ) ) { IllegalStateException renameException = new IllegalStateException( "Cannot replace original with chopped file to: " + original ); String originalPath = original.getAbsolutePath(); boolean isDeleted = original.delete(); if ( isDeleted ) { boolean isRenamedAgain = truncatedFile.renameTo( new File( originalPath ) ); if ( !isRenamedAgain ) { throw renameException; } } else { throw renameException; } } return original; }
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 whole = null; FileChannel chopped = null; try { whole = new FileInputStream( original ).getChannel(); chopped = new FileOutputStream( truncatedFile ).getChannel(); long originalLength = original.length(); long lengthToKeep = originalLength < tailToKeep ? 0 : originalLength - tailToKeep; whole.transferTo( lengthToKeep, originalLength, chopped ); } catch ( IOException e ) { throw new IllegalStateException( "Cannot behead file due to inconsistent internal state.", e ); } finally { Closer.close( whole, chopped ); } // Replace original with chopped file. boolean isRenamed = truncatedFile.renameTo( original ); if ( !( isRenamed ) ) { IllegalStateException renameException = new IllegalStateException( "Cannot replace original with chopped file to: " + original ); String originalPath = original.getAbsolutePath(); boolean isDeleted = original.delete(); if ( isDeleted ) { boolean isRenamedAgain = truncatedFile.renameTo( new File( originalPath ) ); if ( !isRenamedAgain ) { throw renameException; } } else { throw renameException; } } return original; }
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( timestamp ); } if ( sequence != null ) { buff.append( "#" ).append( sequence ); } return buff.toString(); }
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( timestamp ); } if ( sequence != null ) { buff.append( "#" ).append( sequence ); } return buff.toString(); }
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 ) ) { derivedVersion = asRawVersion( version.replace( snapshot, "" ), timestamp, sequence ); } return derivedVersion; }
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 ) ) { derivedVersion = asRawVersion( version.replace( snapshot, "" ), timestamp, sequence ); } return derivedVersion; }
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 = being1.getBoundingBox().getMax().x - being1.getBoundingBox().getMin().x; float width2 = being2.getBoundingBox().getMax().x - being2.getBoundingBox().getMin().x; MassedBeing smallerBeing; MassedBeing biggerBeing; float smallerBeingHeight, smallerBeingWidth; if(width1>width2 && height1>height2) { biggerBeing = being1; smallerBeing = being2; smallerBeingHeight = height2; smallerBeingWidth = width2; } else if(width1<width2 && height1<height2) { biggerBeing = being2; smallerBeing = being1; smallerBeingHeight = height1; smallerBeingWidth = width1; } else {//note: one must absolutely contain the other (be bigger on both axes) or will return false return false; } // find the projection vector between the bounding boxes of the beings // NOTE: always call on smallerBeing -- gives projection vector back IN to biggerBeing PVector projection = biggerBeing.getBoundingBox().projectionVector(smallerBeing.getBoundingBox()); if(projection == null || being1==being2) { return false; // if they aren't colliding } if(projection.x==0 && Math.abs(projection.y)<smallerBeingHeight) { projection.sub(makeVector(0, smallerBeingHeight * sign(projection.y))); MassedBeing.addImpulseCollision(biggerBeing, smallerBeing, projection); return true; } else if (projection.y==0 && Math.abs(projection.x)<smallerBeingWidth) { projection.sub(makeVector(smallerBeingWidth * sign(projection.x), 0)); MassedBeing.addImpulseCollision(biggerBeing, smallerBeing, projection); return true; } else return false; }
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.calculateImpulse: normal must be a valid PVector"; assert !(normal.x == 0 && normal.y == 0) : "Physics.calculateImpulse: normal must be nonzero"; PVector numerator = PVector.sub(v2, v1); // calculate relative velocity numerator.mult(-1 - elasticity); // factor by elasticity float result = numerator.dot(normal); // find normal component result /= normal.dot(normal); // normalize result /= (1 / m1 + 1 / m2); // factor in mass return PVector.mult(normal, result); }
1381837_0
public static List<ComplexityThreshold> convertAbacusThresholdsToComplexityThresholds(String[] propertyThresholds) { List<ComplexityThreshold> complexityThresholds = new ArrayList<ComplexityThreshold>(); String[] temp; for (String propertyThreshold : propertyThresholds) { temp = propertyThreshold.split(PARSING_SEPARATOR); Double thresholdValue = null; if (temp.length > 1) { thresholdValue = Double.valueOf(temp[1]); } complexityThresholds.add(new ComplexityThreshold(temp[0], thresholdValue)); } return complexityThresholds; }
1381837_1
public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = complexityThreshold.getComplexityName(); break; } else { if (cyclomaticComplexity.doubleValue() <= complexityThreshold.getThreshold().doubleValue()) { complexity = complexityThreshold.getComplexityName(); break; } } } return 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(); complexityDistributionMeasureValue += (complexityThreshold.getComplexityName() + EQUALITY_SEPARATOR + complexityThreshold.getCounter()); if (it.hasNext()) { complexityDistributionMeasureValue += ";"; } } return complexityDistributionMeasureValue; }
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); }