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()) {
rb = lookupResourceBundleByEnumClassAndLocale(declaringClass);
cache.put(declaringClassName, rb);
}
String keyAsStr = key.toString();
String value = rb.getString(keyAsStr);
if (value == null) {
return "No key found for " + keyAsStr;
} else {
if (args == null || args.length == 0) {
return value;
} else {
return MessageFormat.format(value, args);
}
}
}
|
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 current ClassLoader...");
}
clazz = CLASS_CL_ACCESSOR.loadClass(fqcn);
}
if (clazz == null) {
if (log.isTraceEnabled()) {
log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " +
"Trying the system/application ClassLoader...");
}
clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn);
}
if (clazz == null) {
//SHIRO-767: support for getting primitive data type,such as int,double...
clazz = primClasses.get(fqcn);
}
if (clazz == null) {
String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " +
"system/application ClassLoaders. All heuristics have been exhausted. Class could not be found.";
throw new UnknownClassException(msg);
}
return clazz;
}
|
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 current ClassLoader...");
}
clazz = CLASS_CL_ACCESSOR.loadClass(fqcn);
}
if (clazz == null) {
if (log.isTraceEnabled()) {
log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " +
"Trying the system/application ClassLoader...");
}
clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn);
}
if (clazz == null) {
//SHIRO-767: support for getting primitive data type,such as int,double...
clazz = primClasses.get(fqcn);
}
if (clazz == null) {
String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " +
"system/application ClassLoaders. All heuristics have been exhausted. Class could not be found.";
throw new UnknownClassException(msg);
}
return clazz;
}
|
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 current ClassLoader...");
}
clazz = CLASS_CL_ACCESSOR.loadClass(fqcn);
}
if (clazz == null) {
if (log.isTraceEnabled()) {
log.trace("Unable to load class named [" + fqcn + "] from the current ClassLoader. " +
"Trying the system/application ClassLoader...");
}
clazz = SYSTEM_CL_ACCESSOR.loadClass(fqcn);
}
if (clazz == null) {
//SHIRO-767: support for getting primitive data type,such as int,double...
clazz = primClasses.get(fqcn);
}
if (clazz == null) {
String msg = "Unable to load class named [" + fqcn + "] from the thread context, current, or " +
"system/application ClassLoaders. All heuristics have been exhausted. Class could not be found.";
throw new UnknownClassException(msg);
}
return clazz;
}
|
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 = safellyRetrieveAccountForId(anAccountId);
AccountTransaction tx = AccountTransaction.createWithdrawalTx(anAccountId, anAmount);
tx.setCreatedBy(getCurrentUsername());
log.debug("Created a new transaction " + tx);
a.applyTransaction(tx);
log.debug("New balance of account " + a.getId() + " after withdrawal is " + a.getBalance());
return a.getBalance();
}
|
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 = safellyRetrieveAccountForId(anAccountId);
AccountTransaction tx = AccountTransaction.createWithdrawalTx(anAccountId, anAmount);
tx.setCreatedBy(getCurrentUsername());
log.debug("Created a new transaction " + tx);
a.applyTransaction(tx);
log.debug("New balance of account " + a.getId() + " after withdrawal is " + a.getBalance());
return a.getBalance();
}
|
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 new InactiveAccountException("The account " + anAccountId + " is already closed");
}
try {
AccountTransaction tx = AccountTransaction.createWithdrawalTx(a.getId(), a.getBalance());
tx.setCreatedBy(getCurrentUsername());
log.debug("Created a new transaction " + tx);
a.applyTransaction(tx);
a.setActive(false);
log.debug("Account " + a.getId() + " is now closed and an amount of " + tx.getAmount() + " is given to the owner");
return tx.getAmount();
} catch (NotEnoughFundsException nefe) {
throw new IllegalStateException("Should never happen", nefe);
}
}
|
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 new InactiveAccountException("The account " + anAccountId + " is already closed");
}
try {
AccountTransaction tx = AccountTransaction.createWithdrawalTx(a.getId(), a.getBalance());
tx.setCreatedBy(getCurrentUsername());
log.debug("Created a new transaction " + tx);
a.applyTransaction(tx);
a.setActive(false);
log.debug("Account " + a.getId() + " is now closed and an amount of " + tx.getAmount() + " is given to the owner");
return tx.getAmount();
} catch (NotEnoughFundsException nefe) {
throw new IllegalStateException("Should never happen", nefe);
}
}
|
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 new InactiveAccountException("The account " + anAccountId + " is already closed");
}
try {
AccountTransaction tx = AccountTransaction.createWithdrawalTx(a.getId(), a.getBalance());
tx.setCreatedBy(getCurrentUsername());
log.debug("Created a new transaction " + tx);
a.applyTransaction(tx);
a.setActive(false);
log.debug("Account " + a.getId() + " is now closed and an amount of " + tx.getAmount() + " is given to the owner");
return tx.getAmount();
} catch (NotEnoughFundsException nefe) {
throw new IllegalStateException("Should never happen", nefe);
}
}
|
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 new InactiveAccountException("The account " + anAccountId + " is already closed");
}
try {
AccountTransaction tx = AccountTransaction.createWithdrawalTx(a.getId(), a.getBalance());
tx.setCreatedBy(getCurrentUsername());
log.debug("Created a new transaction " + tx);
a.applyTransaction(tx);
a.setActive(false);
log.debug("Account " + a.getId() + " is now closed and an amount of " + tx.getAmount() + " is given to the owner");
return tx.getAmount();
} catch (NotEnoughFundsException nefe) {
throw new IllegalStateException("Should never happen", nefe);
}
}
|
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.getLineRange().getLast());
break;
case 1:
tableBodyRange = new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine());
break;
default:
tableBodyRange = new Range(examples.getRows().get(1).getLine(), examples.getRows().get(examples.getRows().size() - 1).getLine());
}
examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast());
if (filter.evaluate(Collections.<Tag>emptyList(), Collections.<String>emptyList(), Collections.singletonList(tableBodyRange))) {
examples.setRows(filter.filterTableBodyRows(examples.getRows()));
}
examplesEvents = new ArrayList<BasicStatement>();
examplesEvents.add(examples);
}
|
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.start(), matchResult.group()));
}
return result;
}
|
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.getClass())) {
value = ((Mappable) value).toMap();
}
if (value != null && Collection.class.isAssignableFrom(value.getClass())) {
List<Object> mappedValue = new ArrayList<Object>();
for (Object o : (Collection) value) {
if (Mappable.class.isAssignableFrom(o.getClass())) {
mappedValue.add(((Mappable) o).toMap());
} else {
mappedValue.add(o);
}
}
value = mappedValue;
}
if (value != null && !Collections.EMPTY_LIST.equals(value) && !NO_LINE.equals(value)) {
map.put(field.getName(), value);
}
}
return map;
}
|
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) {
throw new IllegalStateException(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))) {
throw new MalformedContentNameStringException("ContentName strings must begin with " + SEPARATOR + " or " + SCHEME + SEPARATOR);
}
if (name.startsWith(SCHEME)) {
name = name.substring(SCHEME.length());
} else if (name.startsWith(ORIGINAL_SCHEME)) {
name = name.substring(ORIGINAL_SCHEME.length());
}
}
String[] parts = name.split(SEPARATOR);
if (parts.length == 0) {
// We've been asked to parse the root name.
return ROOT;
}
ArrayList<byte []> comps = new ArrayList<byte []>(parts.length -1);
// Leave off initial empty component
for (int i=1; i < parts.length; ++i) {
try {
byte[] component = Component.parseURI(parts[i]);
if (null != component) {
comps.add(component);
}
} catch (Component.DotDot c) {
// Need to strip "parent"
if (comps.isEmpty()) {
throw new MalformedContentNameStringException("ContentName string contains too many .. components: " + name);
} else {
comps.remove(comps.size()-1);
}
}
}
result = new ContentName();
result._components = comps.toArray(new byte[comps.size()][]);
return result;
} catch (URISyntaxException e) {
throw new MalformedContentNameStringException(e.getMessage());
}
}
|
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))) {
throw new MalformedContentNameStringException("ContentName strings must begin with " + SEPARATOR + " or " + SCHEME + SEPARATOR);
}
if (name.startsWith(SCHEME)) {
name = name.substring(SCHEME.length());
} else if (name.startsWith(ORIGINAL_SCHEME)) {
name = name.substring(ORIGINAL_SCHEME.length());
}
}
String[] parts = name.split(SEPARATOR);
if (parts.length == 0) {
// We've been asked to parse the root name.
return ROOT;
}
ArrayList<byte []> comps = new ArrayList<byte []>(parts.length -1);
// Leave off initial empty component
for (int i=1; i < parts.length; ++i) {
try {
byte[] component = Component.parseURI(parts[i]);
if (null != component) {
comps.add(component);
}
} catch (Component.DotDot c) {
// Need to strip "parent"
if (comps.isEmpty()) {
throw new MalformedContentNameStringException("ContentName string contains too many .. components: " + name);
} else {
comps.remove(comps.size()-1);
}
}
}
result = new ContentName();
result._components = comps.toArray(new byte[comps.size()][]);
return result;
} catch (URISyntaxException e) {
throw new MalformedContentNameStringException(e.getMessage());
}
}
|
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());
for (int i = 0; i < name.length() && !quitEarly; i++) {
char ch = name.charAt(i);
switch (ch) {
case '%':
// This is a byte string %xy where xy are hex digits
// Since the input string must be compatible with the output
// of componentPrint(), we may convert the character values directly.
if (name.length()-1 < i+2) {
throw new URISyntaxException(name, "malformed %xy byte representation: too short", i);
}
b1 = Character.digit(name.charAt(++i), 16); // consume x
b2 = Character.digit(name.charAt(++i), 16); // consume y
if (b1 < 0 || b2 < 0)
throw new URISyntaxException(name, "malformed %xy byte representation: not legal hex number: " + name.substring(i-2, i+1), i-2);
result.put((byte)((b1 * 16) + b2));
break;
// Note in C lib case 0 is handled like the two general delimiters below that terminate processing
// but that case should never arise in Java which uses real unicode characters.
case '/':
case '?':
case '#':
quitEarly = true; // early exit from containing loop
break;
case '=':
if (name.length()-1 < i+2 || ((name.length() - i) & 1) == 0) {
throw new URISyntaxException(name, "malformed =xy byte representation: too short", i);
}
hexEncoding = true;
break;
case ':': case '[': case ']': case '@':
case '!': case '$': case '&': case '\'': case '(': case ')':
case '*': case '+': case ',': case ';':
// Permit unescaped reserved characters
result.put((byte)ch);
break;
default:
if (uriReserved(ch))
throw new URISyntaxException(name, "Illegal characters in URI", i);
if (hexEncoding) {
b1 = Character.digit(ch, 16); // consume x
b2 = Character.digit(name.charAt(++i), 16); // consume y
if (b1 < 0 || b2 < 0)
throw new URISyntaxException(name, "malformed =xy byte representation: not legal hex number: " + name.substring(i-1, i), i-1);
result.put((byte)((b1 * 16) + b2));
} else {
// This character remains the same
result.put((byte)ch);
}
break;
}
if (!quitEarly && result.position() > 0 && result.get(result.position()-1) != '.') {
alldots = false;
}
}
result.flip();
if (alldots) {
if (result.limit() <= 1) {
return null;
} else if (result.limit() == 2) {
throw new DotDot();
} else {
// Remove the three '.' extra
result.limit(result.limit()-3);
}
}
decodedName = new byte[result.limit()];
System.arraycopy(result.array(), 0, decodedName, 0, result.limit());
return decodedName;
}
|
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<ArtifactVersion> versions = null;
try
{
versions =
metadataSource.retrieveAvailableVersions( artifact, localRepository,
Collections.singletonList( repository ) );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new RepositoryException( e.getMessage(), e );
}
// sort the versions as required by the spec
Collections.sort( versions );
// convert the list into one of strings to return
List<String> availableVersions = new ArrayList<String>( versions.size() );
for ( ArtifactVersion version : versions )
{
availableVersions.add( version.toString() );
}
return availableVersions;
}
|
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<ArtifactVersion> versions = null;
try
{
versions =
metadataSource.retrieveAvailableVersions( artifact, localRepository,
Collections.singletonList( repository ) );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new RepositoryException( e.getMessage(), e );
}
// sort the versions as required by the spec
Collections.sort( versions );
// convert the list into one of strings to return
List<String> availableVersions = new ArrayList<String>( versions.size() );
for ( ArtifactVersion version : versions )
{
availableVersions.add( version.toString() );
}
return availableVersions;
}
|
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 =
projectBuilder.buildFromRepository( artifact, Collections.singletonList( repository ), localRepository );
}
catch ( ProjectBuildingException e )
{
throw new RepositoryException( e.getMessage(), e );
}
// populate the Centrepoint model from the Maven project
Project project = new Project();
project.setId( MavenCoordinates.constructProjectId( groupId, artifactId ) );
project.setVersion( version );
MavenCoordinates coordinates = new MavenCoordinates();
coordinates.setGroupId( groupId );
coordinates.setArtifactId( artifactId );
project.addExtensionModel( coordinates );
project.setDescription( mavenProject.getDescription() );
project.setName( mavenProject.getName() );
if ( mavenProject.getCiManagement() != null )
{
project.setCiManagementUrl( mavenProject.getCiManagement().getUrl() );
}
if ( mavenProject.getIssueManagement() != null )
{
project.setIssueTrackerUrl( mavenProject.getIssueManagement().getUrl() );
}
if ( mavenProject.getScm() != null )
{
project.setScmUrl( mavenProject.getScm().getUrl() );
}
project.setUrl( mavenProject.getUrl() );
DistributionManagement distMgmt = mavenProject.getDistributionManagement();
if ( distMgmt != null )
{
project.setRepositoryUrl( distMgmt.getRepository().getUrl() );
project.setSnapshotRepositoryUrl( distMgmt.getSnapshotRepository().getUrl() );
}
return project;
}
|
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 =
projectBuilder.buildFromRepository( artifact, Collections.singletonList( repository ), localRepository );
}
catch ( ProjectBuildingException e )
{
throw new RepositoryException( e.getMessage(), e );
}
// populate the Centrepoint model from the Maven project
Project project = new Project();
project.setId( MavenCoordinates.constructProjectId( groupId, artifactId ) );
project.setVersion( version );
MavenCoordinates coordinates = new MavenCoordinates();
coordinates.setGroupId( groupId );
coordinates.setArtifactId( artifactId );
project.addExtensionModel( coordinates );
project.setDescription( mavenProject.getDescription() );
project.setName( mavenProject.getName() );
if ( mavenProject.getCiManagement() != null )
{
project.setCiManagementUrl( mavenProject.getCiManagement().getUrl() );
}
if ( mavenProject.getIssueManagement() != null )
{
project.setIssueTrackerUrl( mavenProject.getIssueManagement().getUrl() );
}
if ( mavenProject.getScm() != null )
{
project.setScmUrl( mavenProject.getScm().getUrl() );
}
project.setUrl( mavenProject.getUrl() );
DistributionManagement distMgmt = mavenProject.getDistributionManagement();
if ( distMgmt != null )
{
project.setRepositoryUrl( distMgmt.getRepository().getUrl() );
project.setSnapshotRepositoryUrl( distMgmt.getSnapshotRepository().getUrl() );
}
return project;
}
|
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 )
{
msg = "Unknown Build";
}
buildMessage = msg;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 update/delete a bean that does not exist");
case SAVE:
return OpState.SAVE;
}
}
}
else {
if (currentOpState == null) {
throw new IllegalStateException("Can not update/delete a bean that does not exist");
}
else {
switch (oldOpState) {
case SAVE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException(
"Constraint violation exception, a object with same id has already been saved");
case DELETE:
return null;
case UPDATE:
default:
return oldOpState;
}
}
case UPDATE: {
switch (currentOpState) {
case SAVE:
throw new IllegalStateException("Can not save an existing bean");
case DELETE:
return currentOpState;
case UPDATE:
default:
return oldOpState;
}
}
case DELETE: {
switch (currentOpState) {
case SAVE:
return OpState.UPDATE;
case UPDATE:
case DELETE:
default:
throw new IllegalStateException(
"Can not update/delete a bean that has been deleted earlier in the transaction");
}
}
}
}
}
return currentOpState;
}
|
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 );
return null;
} catch( CompileException exception ) {
// Unprefixed expression, just log and continue by returning null.
log.warn( "Error while compiling expression {}", exception );
return null;
}
}
|
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 );
return null;
} catch( CompileException exception ) {
// Unprefixed expression, just log and continue by returning null.
log.warn( "Error while compiling expression {}", exception );
return null;
}
}
|
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 );
return null;
} catch( CompileException exception ) {
// Unprefixed expression, just log and continue by returning null.
log.warn( "Error while compiling expression {}", exception );
return null;
}
}
|
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 )
return getValue( field, source );
currentClass = currentClass.getSuperclass();
}
throw new MissingSourcePropertyValueException( propertyName, source.getClass() );
}
|
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();
for (Description child : descriptionList) {
if (hasAssociatedFailures(child)) {
return true;
}
}
}
return false;
}
|
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(chars[i]));
}
}
return sb.toString();
}
|
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.arraycopy(array, 0, newArray, 0, array.length);
System.arraycopy(elements, 0, newArray, array.length, elements.length);
array = newArray;
return this;
}
|
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 interface
// and find the right Type for it
Type type;
Queue<Type> toCheck = new LinkedList<Type>();
toCheck.add(implementation);
while (true) {
// if we have checked everything and not found the base class we return an empty list
if (toCheck.isEmpty()) return ImmutableList.of();
type = toCheck.remove();
Class<?> clazz;
if (type instanceof Class) {
// there is no useful information for us in raw types, so just keep going up the inheritance chain
clazz = (Class) type;
if (base.isInterface()) {
// if we are actually looking for the type parameters to an interface we also need to
// look at all the ones implemented by the given current one
toCheck.addAll(Arrays.asList(clazz.getGenericInterfaces()));
}
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
clazz = (Class) parameterizedType.getRawType();
// for instances of ParameterizedType we extract and remember all type arguments
TypeVariable<?>[] typeParameters = clazz.getTypeParameters();
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
for (int i = 0; i < actualTypeArguments.length; i++) {
resolvedTypes.put(typeParameters[i], actualTypeArguments[i]);
}
} else {
return ImmutableList.of();
}
// we can stop if we have reached the sought for base type
if (base.equals(getClass(type))) break;
toCheck.add(clazz.getGenericSuperclass());
}
// finally, for each actual type argument provided to baseClass,
// determine (if possible) the raw class for that type argument.
Type[] actualTypeArguments;
if (type instanceof Class) {
actualTypeArguments = ((Class) type).getTypeParameters();
} else {
actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
}
List<Class<?>> typeArgumentsAsClasses = new ArrayList<Class<?>>();
// resolve types by chasing down type variables.
for (Type baseType : actualTypeArguments) {
while (resolvedTypes.containsKey(baseType)) {
baseType = resolvedTypes.get(baseType);
}
typeArgumentsAsClasses.add(getClass(baseType));
}
return typeArgumentsAsClasses;
}
|
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 > 100000000000000000L) {
return Double.toString(
(value + 50000000000000L) / 100000000000000L * 100000000000000L / 1000000000000000.0) + 'P';
} else if (value > 10000000000000000L) {
return Double
.toString((value + 5000000000000L) / 10000000000000L * 10000000000000L / 1000000000000000.0) + 'P';
} else if (value > 1000000000000000L) {
return Double
.toString((value + 500000000000L) / 1000000000000L * 1000000000000L / 1000000000000000.0) + 'P';
} else if (value > 100000000000000L) {
return Double.toString((value + 50000000000L) / 100000000000L * 100000000000L / 1000000000000.0) + 'T';
} else if (value > 10000000000000L) {
return Double.toString((value + 5000000000L) / 10000000000L * 10000000000L / 1000000000000.0) + 'T';
} else if (value > 1000000000000L) {
return Double.toString((value + 500000000) / 1000000000 * 1000000000 / 1000000000000.0) + 'T';
} else if (value > 100000000000L) {
return Double.toString((value + 50000000) / 100000000 * 100000000 / 1000000000.0) + 'G';
} else if (value > 10000000000L) {
return Double.toString((value + 5000000) / 10000000 * 10000000 / 1000000000.0) + 'G';
} else if (value > 1000000000) {
return Double.toString((value + 500000) / 1000000 * 1000000 / 1000000000.0) + 'G';
} else if (value > 100000000) {
return Double.toString((value + 50000) / 100000 * 100000 / 1000000.0) + 'M';
} else if (value > 10000000) {
return Double.toString((value + 5000) / 10000 * 10000 / 1000000.0) + 'M';
} else if (value > 1000000) {
return Double.toString((value + 500) / 1000 * 1000 / 1000000.0) + 'M';
} else if (value > 100000) {
return Double.toString((value + 50) / 100 * 100 / 1000.0) + 'K';
} else if (value > 10000) {
return Double.toString((value + 5) / 10 * 10 / 1000.0) + 'K';
} else if (value > 1000) {
return Double.toString(value / 1000.0) + 'K';
} else {
return Long.toString(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.getFileCompletionMode() == FileCompletionMode.STARTS_WITH) {
if (buf.startsWith(activeCommand.getFileCompletionCommand() + " ")) {
buf = buf.substring(activeCommand.getFileCompletionCommand().length() + 1);
complementCursorPosition = activeCommand.getFileCompletionCommand().length() + 1;
commandAccepted = true;
}
} else if (activeCommand.getFileCompletionMode() == FileCompletionMode.CONTAINS) {
if (buf.contains(activeCommand.getFileCompletionCommand() + " ")) {
int indexOfOutputDef = buf.lastIndexOf(activeCommand.getFileCompletionCommand() + " ");
buf.substring(indexOfOutputDef);
indexOfOutputDef = indexOfOutputDef + activeCommand.getFileCompletionCommand().length() + 1;
buf = buf.substring(indexOfOutputDef);
complementCursorPosition = indexOfOutputDef;
commandAccepted = true;
}
}
if (commandAccepted) { return super.complete(buf, cursor, candidates) + complementCursorPosition; }
}
return cursor;
}
|
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.getFileCompletionMode() == FileCompletionMode.STARTS_WITH) {
if (buf.startsWith(activeCommand.getFileCompletionCommand() + " ")) {
buf = buf.substring(activeCommand.getFileCompletionCommand().length() + 1);
complementCursorPosition = activeCommand.getFileCompletionCommand().length() + 1;
commandAccepted = true;
}
} else if (activeCommand.getFileCompletionMode() == FileCompletionMode.CONTAINS) {
if (buf.contains(activeCommand.getFileCompletionCommand() + " ")) {
int indexOfOutputDef = buf.lastIndexOf(activeCommand.getFileCompletionCommand() + " ");
buf.substring(indexOfOutputDef);
indexOfOutputDef = indexOfOutputDef + activeCommand.getFileCompletionCommand().length() + 1;
buf = buf.substring(indexOfOutputDef);
complementCursorPosition = indexOfOutputDef;
commandAccepted = true;
}
}
if (commandAccepted) { return super.complete(buf, cursor, candidates) + complementCursorPosition; }
}
return cursor;
}
|
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.getFileCompletionMode() == FileCompletionMode.STARTS_WITH) {
if (buf.startsWith(activeCommand.getFileCompletionCommand() + " ")) {
buf = buf.substring(activeCommand.getFileCompletionCommand().length() + 1);
complementCursorPosition = activeCommand.getFileCompletionCommand().length() + 1;
commandAccepted = true;
}
} else if (activeCommand.getFileCompletionMode() == FileCompletionMode.CONTAINS) {
if (buf.contains(activeCommand.getFileCompletionCommand() + " ")) {
int indexOfOutputDef = buf.lastIndexOf(activeCommand.getFileCompletionCommand() + " ");
buf.substring(indexOfOutputDef);
indexOfOutputDef = indexOfOutputDef + activeCommand.getFileCompletionCommand().length() + 1;
buf = buf.substring(indexOfOutputDef);
complementCursorPosition = indexOfOutputDef;
commandAccepted = true;
}
}
if (commandAccepted) { return super.complete(buf, cursor, candidates) + complementCursorPosition; }
}
return cursor;
}
|
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");
Object[] values = (Object[]) method.invoke(null);
return values[index];
}
|
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 name ends with / then return null
if (node != null && !node.isRoot() && !node.isGroup() && name.endsWith(SEPARATOR)) {
return null;
}
return node;
}
|
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 name ends with / then return null
if (node != null && !node.isRoot() && !node.isGroup() && name.endsWith(SEPARATOR)) {
return null;
}
return node;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.