id
stringlengths
7
14
text
stringlengths
1
106k
291242_7
public static File urlToFile(URL url) { if(url.getProtocol() != "file") { return null; } String path = url.getPath(); if(path == null) return null; File candidate = new File(path); if(candidate.exists()) { return candidate; } else { return null; } }
291242_8
public static File urlToFile(URL url) { if(url.getProtocol() != "file") { return null; } String path = url.getPath(); if(path == null) return null; File candidate = new File(path); if(candidate.exists()) { return candidate; } else { return null; } }
291242_9
public <E extends Enum<?>> String getMessage(E key, Object... args) throws MessageConveyorException { Class<? extends Enum<?>> declaringClass = key.getDeclaringClass(); String declaringClassName = declaringClass.getName(); CAL10NBundle rb = cache.get(declaringClassName); if (rb == null || rb.hasChanged(...
291570_0
public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the...
291570_1
public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the...
291570_2
public static Class forName(String fqcn) throws UnknownClassException { Class clazz = THREAD_CL_ACCESSOR.loadClass(fqcn); if (clazz == null) { if (log.isTraceEnabled()) { log.trace("Unable to load class named [" + fqcn + "] from the thread context ClassLoader. Trying the...
291570_3
@RequiresPermissions("bankAccount:operate") public double withdrawFrom(long anAccountId, double anAmount) throws AccountNotFoundException, NotEnoughFundsException, InactiveAccountException { assertServiceState(); log.info("Making withdrawal of " + anAmount + " from account " + anAccountId); Account a = safe...
291570_4
@RequiresPermissions("bankAccount:operate") public double withdrawFrom(long anAccountId, double anAmount) throws AccountNotFoundException, NotEnoughFundsException, InactiveAccountException { assertServiceState(); log.info("Making withdrawal of " + anAmount + " from account " + anAccountId); Account a = safe...
291570_5
@RequiresPermissions("bankAccount:close") public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException { assertServiceState(); log.info("Closing account " + anAccountId); Account a = safellyRetrieveAccountForId(anAccountId); if (!a.isActive()) { throw ne...
291570_6
@RequiresPermissions("bankAccount:close") public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException { assertServiceState(); log.info("Closing account " + anAccountId); Account a = safellyRetrieveAccountForId(anAccountId); if (!a.isActive()) { throw ne...
291570_7
@RequiresPermissions("bankAccount:close") public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException { assertServiceState(); log.info("Closing account " + anAccountId); Account a = safellyRetrieveAccountForId(anAccountId); if (!a.isActive()) { throw ne...
291570_8
@RequiresPermissions("bankAccount:close") public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException { assertServiceState(); log.info("Closing account " + anAccountId); Account a = safellyRetrieveAccountForId(anAccountId); if (!a.isActive()) { throw ne...
291570_9
public boolean matches(String pattern, String source) { if (pattern == null) { throw new IllegalArgumentException("pattern argument cannot be null."); } Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(source); return m.matches(); }
293812_0
@Override public void close() { out.close(); }
293812_1
@Override public void close() { out.close(); }
293812_2
@Override public void examples(Examples examples) { replay(); examplesTags.addAll(examples.getTags()); examplesName = examples.getName(); Range tableBodyRange; switch (examples.getRows().size()) { case 0: tableBodyRange = new Range(examples.getLineRange().getLast(), examples.getL...
293812_3
public List<Argument> getOutlineArgs() { List<Argument> result = new ArrayList<Argument>(); Pattern p = Pattern.compile("<[^<]*>"); Matcher matcher = p.matcher(getName()); while (matcher.find()) { MatchResult matchResult = matcher.toMatchResult(); result.add(new Argument(matchResult.star...
293812_4
@Override public void close() { out.close(); }
293812_5
public Map<String, Object> toMap() { Map<String, Object> map = new HashMap<String, Object>(); List<Field> mappableFields = getMappableFields(); for (Field field : mappableFields) { Object value; value = getValue(field); if (value != null && Mappable.class.isAssignableFrom(value.getCl...
293812_6
public Locale getLocale() { return locale; }
293812_7
public Locale getLocale() { return locale; }
293812_8
public Locale getLocale() { return locale; }
293812_9
public boolean evaluate(Collection<Tag> tags) { return and.isEmpty() || and.eval(tags); }
298328_0
public static String getErrorMessage(int errorCode) { int bufferSize = 160; byte data[] = new byte[bufferSize]; FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, bufferSize, null); try { return new String(data, "UTF-16LE").trim(); } catch (UnsupportedEncodingException e) { ...
298328_1
@Override public String toString() { return getEncoded().toString(); }
298328_2
@Override public void write(int data) { if (filter(data)) { ps.write(data); } }
298328_3
public static boolean test(final String text) { return text != null && text.contains(BEGIN_TOKEN); }
298328_4
public static String render(final String input) throws IllegalArgumentException { try { return render(input, new StringBuilder(input.length())).toString(); } catch (IOException e) { // Cannot happen because StringBuilder does not throw IOException throw new IllegalArgumentException(e); ...
298328_5
public static String renderCodes(final String... codes) { return render(Ansi.ansi(), codes).toString(); }
298328_6
public static String render(final String input) throws IllegalArgumentException { try { return render(input, new StringBuilder(input.length())).toString(); } catch (IOException e) { // Cannot happen because StringBuilder does not throw IOException throw new IllegalArgumentException(e); ...
298328_7
public static String render(final String input) throws IllegalArgumentException { try { return render(input, new StringBuilder(input.length())).toString(); } catch (IOException e) { // Cannot happen because StringBuilder does not throw IOException throw new IllegalArgumentException(e); ...
298328_8
public static String render(final String input) throws IllegalArgumentException { try { return render(input, new StringBuilder(input.length())).toString(); } catch (IOException e) { // Cannot happen because StringBuilder does not throw IOException throw new IllegalArgumentException(e); ...
298328_9
public static String render(final String input) throws IllegalArgumentException { try { return render(input, new StringBuilder(input.length())).toString(); } catch (IOException e) { // Cannot happen because StringBuilder does not throw IOException throw new IllegalArgumentException(e); ...
309964_0
@Override public String toString() { // 16 would be the most familiar option, but 32 is shorter return type().name() + ":" + CCNDigestHelper.printBytes(id(), 32); }
309964_1
public static ContentName fromURI(String name) throws MalformedContentNameStringException { ContentName result; if ((name == null) || (name.length() == 0)) { return ROOT; } try { if (!name.startsWith(SEPARATOR)){ if ((!name.startsWith(SCHEME + SEPARATOR)) && (!name.startsWith(ORIGINAL_SCHEME + SEPARATOR))) {...
309964_2
public ContentName parent() { ContentName result = new ContentName(); result._components = new byte[_components.length - 1][]; System.arraycopy(_components, 0, result._components, 0, _components.length-1); return result; }
309964_3
public static ContentName fromURI(String name) throws MalformedContentNameStringException { ContentName result; if ((name == null) || (name.length() == 0)) { return ROOT; } try { if (!name.startsWith(SEPARATOR)){ if ((!name.startsWith(SCHEME + SEPARATOR)) && (!name.startsWith(ORIGINAL_SCHEME + SEPARATOR))) {...
309964_4
public ContentName postfix(ContentName prefix) { if (!prefix.isPrefixOf(this)) return null; return subname(prefix._components.length, _components.length); }
309964_5
public boolean verify(Key key) throws InvalidKeyException, SignatureException, NoSuchAlgorithmException, ContentEncodingException { return verify(this, key); }
309964_6
public byte [] digest() { if (_digest == null) _digest = calcDigest(); return _digest; }
309964_7
@Override public int hashCode() { return Arrays.hashCode(this.getComponent()); }
309964_8
public static byte[] parseURI(String name) throws DotDot, URISyntaxException { byte[] decodedName = null; boolean alldots = true; // does this component contain only dots after unescaping? boolean quitEarly = false; boolean hexEncoding = false; int b1, b2; ByteBuffer result = ByteBuffer.allocate(name.length()); ...
309964_9
public static String printURI(byte [] bs) { return printURI(bs, 0, bs.length, URIEscape.MIXED); }
314299_0
@SuppressWarnings( "unchecked" ) public List<String> getAvailableVersions( String groupId, String artifactId ) throws RepositoryException { // the version supplied is arbitrary, but must not be null Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, "1.0" ); List<ArtifactVer...
314299_1
@SuppressWarnings( "unchecked" ) public List<String> getAvailableVersions( String groupId, String artifactId ) throws RepositoryException { // the version supplied is arbitrary, but must not be null Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, "1.0" ); List<ArtifactVer...
314299_2
public Project retrieveProject( String groupId, String artifactId, String version ) throws RepositoryException { // get the project from the repository Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); MavenProject mavenProject; try { mavenProject...
314299_3
public Project retrieveProject( String groupId, String artifactId, String version ) throws RepositoryException { // get the project from the repository Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); MavenProject mavenProject; try { mavenProject...
314299_4
public Project importMavenProject( String groupId, String artifactId, String version ) { Project project = repositoryService.retrieveProject( groupId, artifactId, version ); projectStore.store( project ); return project; }
314299_5
public Project importMavenProject( String groupId, String artifactId, String version ) { Project project = repositoryService.retrieveProject( groupId, artifactId, version ); projectStore.store( project ); return project; }
314299_6
public void store( Project project ) { projects.put( project.getId(), project ); }
314299_7
public void setProjects( Collection<Project> projects ) { this.projects.clear(); for ( Project p : projects ) { this.projects.put( p.getId(), p ); } }
314299_8
public BuildNumber() { String msg; try { ResourceBundle bundle = ResourceBundle.getBundle( "build" ); msg = bundle.getString( "build.message" ); buildDate = new Date( Long.valueOf( bundle.getString( "build.timestamp" ) ) ); } catch ( MissingResourceException e ) { ...
314299_9
public Collection<ExtensionModel> getExtensionModels() { return extensionModels.values(); }
315033_0
public String getNextTransactionId() { return String.valueOf(uniqueIdGen.incrementAndGet()); }
315033_1
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_2
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_3
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_4
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_5
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_6
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_7
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_8
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
315033_9
protected OpState getActualStateAfterTransition(OpState oldOpState, OpState currentOpState) { if (oldOpState == null) { if (currentOpState == null) { return null; } else { switch (currentOpState) { case UPDATE: case DELETE: throw new IllegalStateException("Can not upd...
320367_0
public static int times(int x, int y) { return new HelloWorldJNI().timesHello(x, y); }
320690_0
@Override public SourceProperty getSourceProperty( String expression ) { try { return compileAndReturnProperty( expression ); } catch( ArrayIndexOutOfBoundsException exception ) { // Unprefixed expression, just log and continue by returning null. log.warn( "Error while compiling expression {}", exception ); r...
320690_1
@Override public SourceProperty getSourceProperty( String expression ) { try { return compileAndReturnProperty( expression ); } catch( ArrayIndexOutOfBoundsException exception ) { // Unprefixed expression, just log and continue by returning null. log.warn( "Error while compiling expression {}", exception ); r...
320690_2
@Override public SourceProperty getSourceProperty( String expression ) { try { return compileAndReturnProperty( expression ); } catch( ArrayIndexOutOfBoundsException exception ) { // Unprefixed expression, just log and continue by returning null. log.warn( "Error while compiling expression {}", exception ); r...
320690_3
@Override public boolean supportsPrefix( String prefix ) { return false; }
320690_4
@Override public SourceProperty getSourceProperty( String expression ) { if ( isIdentifier( expression ) ) { return new ReflectionSourceProperty( expression ); } else { return null; } }
320690_5
@Override public SourceProperty getSourceProperty( String expression ) { if ( isIdentifier( expression ) ) { return new ReflectionSourceProperty( expression ); } else { return null; } }
320690_6
@Override public SourceProperty getSourceProperty( String expression ) { if ( isIdentifier( expression ) ) { return new ReflectionSourceProperty( expression ); } else { return null; } }
320690_7
@Override public SourceProperty getSourceProperty( String expression ) { if ( isIdentifier( expression ) ) { return new ReflectionSourceProperty( expression ); } else { return null; } }
320690_8
@Override public SourceProperty getSourceProperty( String expression ) { if ( isIdentifier( expression ) ) { return new ReflectionSourceProperty( expression ); } else { return null; } }
320690_9
@Override public Object getValue( Object source ) { Class<?> currentClass = source.getClass(); while( currentClass != null ) { Method getter = getGetter( source, currentClass ); if( getter != null ) return getValue( getter, source ); Field field = getField( source, currentClass ); if( field != null ) re...
324985_0
public boolean hasAssociatedFailures(Description d) { List<Failure> failureList = result.getFailures(); for (Failure f : failureList) { if (f.getDescription().equals(d)) { return true; } if (description.isTest()) { return false; } List<Description> descriptionList = d.getChildren(); ...
327391_0
public static String escape(String string) { if (isEmpty(string)) return ""; StringBuilder sb = new StringBuilder(); char[] chars = string.toCharArray(); for (int i = 0; i < chars.length; i++) { if (i == chars.length - 1 || chars[i] != '\r' || chars[i + 1] != '\n') { sb.append(escape...
327391_1
@SuppressWarnings({"unchecked"}) public ArrayBuilder<T> add(T... elements) { if (elements == null) return this; if (array == null) { array = elements; return this; } T[] newArray = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length + elements.length); System.ar...
327391_2
public IntArrayStack() { array = new int[INITIAL_CAPACITY]; top = -1; }
327391_3
private ImmutableLinkedList() { head = null; tail = null; }
327391_4
public static List<Class<?>> getTypeArguments(Class<?> base, Class<?> implementation) { checkArgNotNull(base, "base"); checkArgNotNull(implementation, "implementation"); Map<Type, Type> resolvedTypes = new HashMap<Type, Type>(); // first we need to resolve all supertypes up to the required base class or...
327391_5
public static String humanize(long value) { if (value < 0) { return '-' + humanize(-value); } else if (value > 1000000000000000000L) { return Double.toString( (value + 500000000000000L) / 1000000000000000L * 1000000000000000L / 1000000000000000000.0) + 'E'; } else if (value >...
327391_6
public MutableInputBuffer(InputBuffer buffer) { this.buffer = buffer; }
327391_7
public String extract(int start, int end) { return origBuffer.extract(map(start), map(end)); }
327391_8
public String extract(int start, int end) { return origBuffer.extract(map(start), map(end)); }
327391_9
public String extract(int start, int end) { return origBuffer.extract(map(start), map(end)); }
327472_0
@Override public int complete(String buf, final int cursor, @SuppressWarnings("rawtypes") final List candidates) { for (final Command activeCommand: commands) { int complementCursorPosition = 0; boolean commandAccepted = false; if (activeCommand.getF...
327472_1
@Override public int complete(String buf, final int cursor, @SuppressWarnings("rawtypes") final List candidates) { for (final Command activeCommand: commands) { int complementCursorPosition = 0; boolean commandAccepted = false; if (activeCommand.getF...
327472_2
@Override public int complete(String buf, final int cursor, @SuppressWarnings("rawtypes") final List candidates) { for (final Command activeCommand: commands) { int complementCursorPosition = 0; boolean commandAccepted = false; if (activeCommand.getF...
327472_3
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
327472_4
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
327472_5
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
327472_6
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
327472_7
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
327472_8
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
327472_9
@Override public boolean accept(final ConsoleState state) { Assertions.checkNotNull("state", state); if (state.getActiveCommand() == null && state.getInput().trim().equals("clear")) { return true; } return false; }
331792_0
@Override protected Object convertToObject(final String text) throws Exception { for (DateFormat format : formats) { try { return format.parse(text); } catch (ParseException e) { // ignore } } return complexParse(text); }
331792_1
@Override protected Object convertToObject(final String text) throws Exception { for (DateFormat format : formats) { try { return format.parse(text); } catch (ParseException e) { // ignore } } return complexParse(text); }
331792_2
@Override protected Object convertToObject(final String text) throws Exception { for (Enum n : (Enum[]) getType().getEnumConstants()) { if (n.name().equalsIgnoreCase(text)) { return n; } } // Else try an index int index = Integer.parseInt(text); Method method = getType().getMethod("values"); O...
331792_3
public Node find(final String name) { checkNotNull(name); NodePath path = new NodePath(name); Node node = this; String[] elements = path.split(); for (String element : elements) { node = node.get(element); if (node == null) { break; } } // If we are looking for a group node, but given na...
331792_4
public Node find(final String name) { checkNotNull(name); NodePath path = new NodePath(name); Node node = this; String[] elements = path.split(); for (String element : elements) { node = node.get(element); if (node == null) { break; } } // If we are looking for a group node, but given na...