id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
1206855_6 | @Override
public int compareTo(TreeType o)
{
if (this.equals(o))
return 0;
int typeResult = type.getName().compareTo(o.type.getName());
if (typeResult != 0)
return typeResult;
int sizeDiff = children.size() - o.children.size();
if (sizeDiff != 0)
return sizeDiff > 0 ? 1 : -1;
for (int i = 0, s = children.size(); i < s; i++)
{
int childCompare = children.get(i).compareTo(o.children.get(i));
if (childCompare != 0)
return childCompare;
}
return 0;
} |
1206855_7 | public static IFilter compact(ITreeFilter filter)
{
return new Filter(FilterType.COMPACT,filter);
} |
1206855_8 | public static IFilter compact(ITreeFilter filter)
{
return new Filter(FilterType.COMPACT,filter);
} |
1206855_9 | public static IFilter strip(ITreeFilter filter)
{
return new Filter(FilterType.STRIP,filter);
} |
1216286_0 | @Override
public void read(InputStream in, ReadStatementListener listener) throws IOException, SemanticIOException {
throw new NotYetImplementedException();
} |
1216286_1 | public void execute(String script) throws QueryScriptException {
try {
Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();
scope.put(ARAS_SCRIPT_ENGINE_CONTEXT, scope, arasCtx);
loadRhinoBinding(scope, cx);
cx.evaluateString(scope, script, "queryscript", 0, null);
} catch (Exception e) {
throw new QueryScriptException("Execution of query script failed.", e);
} finally {
Context.exit();
}
} |
1216286_2 | public void execute(String script) throws QueryScriptException {
try {
Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();
scope.put(ARAS_SCRIPT_ENGINE_CONTEXT, scope, arasCtx);
loadRhinoBinding(scope, cx);
cx.evaluateString(scope, script, "queryscript", 0, null);
} catch (Exception e) {
throw new QueryScriptException("Execution of query script failed.", e);
} finally {
Context.exit();
}
} |
1216286_3 | @Override
public Set<Statement> getAssociations() {
final Set<Statement> directAssocs = super.getAssociations();
final Set<ResourceNode> inheritors = getInheritors(directAssocs);
if (inheritors.isEmpty()) {
return directAssocs;
}
final Set<Statement> result = new HashSet<Statement>();
// 1st: Add all inherited - excluding revoked
final RevocationDef revocationDef = getRevocationDef();
Set<ResourceID> revokedPredicates = revocationDef.getRevokedPredicates();
Set<HalfStatement> revokedStatements = revocationDef.getRevokedStatements();
for (ResourceNode inheritor : inheritors) {
for (Statement inherited : inheritor.getAssociations()) {
HalfStatement halfStatement = HalfStatement.from(inherited);
if (revokedPredicates.contains(inherited.getPredicate())) {
continue;
}
if (revokedStatements.contains(halfStatement) ) {
continue;
}
result.add(halfStatement.toFullStatement(this, inherited.getMetaInfo().inherit()));
}
}
// 3rd: Add all own statements
result.addAll(directAssocs);
return result;
} |
1216286_4 | @Override
public Set<Statement> getAssociations() {
final Set<Statement> directAssocs = super.getAssociations();
final Set<ResourceNode> inheritors = getInheritors(directAssocs);
if (inheritors.isEmpty()) {
return directAssocs;
}
final Set<Statement> result = new HashSet<Statement>();
// 1st: Add all inherited - excluding revoked
final RevocationDef revocationDef = getRevocationDef();
Set<ResourceID> revokedPredicates = revocationDef.getRevokedPredicates();
Set<HalfStatement> revokedStatements = revocationDef.getRevokedStatements();
for (ResourceNode inheritor : inheritors) {
for (Statement inherited : inheritor.getAssociations()) {
HalfStatement halfStatement = HalfStatement.from(inherited);
if (revokedPredicates.contains(inherited.getPredicate())) {
continue;
}
if (revokedStatements.contains(halfStatement) ) {
continue;
}
result.add(halfStatement.toFullStatement(this, inherited.getMetaInfo().inherit()));
}
}
// 3rd: Add all own statements
result.addAll(directAssocs);
return result;
} |
1216286_5 | @SuppressWarnings("unchecked")
public static <T extends ResourceNode> List<T> sortResources(Collection<T> nodes) {
if (nodes.size() < 2) {
return new ArrayList<T>(nodes);
}
final ResourceNode initial = nodes.iterator().next();
ResourceNode predecessor = getPredecessor(initial);
ResourceNode successor = getSuccessor(initial);
if (predecessor == null && successor == null) {
return new ArrayList<T>(nodes);
} else if (predecessor == null) {
return (List<T>) sortBySuccessors(nodes);
} else if (successor == null) {
return (List<T>) sortByPredecessors(nodes);
} else {
final LinkedList<ResourceNode> result = new LinkedList<ResourceNode>();
result.add(initial);
while(predecessor != null) {
result.addFirst(predecessor);
predecessor = getPredecessor(predecessor);
}
while(successor != null) {
result.addLast(successor);
successor = getSuccessor(successor);
}
return (List<T>) result;
}
} |
1216286_6 | @SuppressWarnings("unchecked")
public static <T extends ResourceNode> List<T> sortResources(Collection<T> nodes) {
if (nodes.size() < 2) {
return new ArrayList<T>(nodes);
}
final ResourceNode initial = nodes.iterator().next();
ResourceNode predecessor = getPredecessor(initial);
ResourceNode successor = getSuccessor(initial);
if (predecessor == null && successor == null) {
return new ArrayList<T>(nodes);
} else if (predecessor == null) {
return (List<T>) sortBySuccessors(nodes);
} else if (successor == null) {
return (List<T>) sortByPredecessors(nodes);
} else {
final LinkedList<ResourceNode> result = new LinkedList<ResourceNode>();
result.add(initial);
while(predecessor != null) {
result.addFirst(predecessor);
predecessor = getPredecessor(predecessor);
}
while(successor != null) {
result.addLast(successor);
successor = getSuccessor(successor);
}
return (List<T>) result;
}
} |
1216286_7 | @Override
protected QueryExpression getRoot() {
return super.getRoot();
} |
121672_10 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_11 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_12 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_13 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_14 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_15 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_16 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_17 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_18 | @Override
blic String apply( Visibility visibility, Object value )
{
if( value == null )
return null;
URI uri;
if( value instanceof URI )
{
uri = (URI) value;
}
else
{
try
{
uri = URI.create( encode( value.toString() ) );
}
catch( IllegalArgumentException exception )
{
LOG.warn( "failed to parse uri: {}, message: {}", value, exception.getMessage() );
LOG.debug( "failed to parse uri: {}", value, exception );
if( Boolean.parseBoolean( System.getProperty( FAILURE_MODE_PASS_THROUGH ) ) )
{
LOG.warn( "ignoring uri sanitizer failures, returning unsanitized value, property '{}' set to true", FAILURE_MODE_PASS_THROUGH );
return value.toString();
}
// return an empty string, to avoid the leakage of sensitive information.
LOG.info( "set property: '{}', to true to return unsanitized value, returning empty string", FAILURE_MODE_PASS_THROUGH );
return "";
}
}
if( uri.isOpaque() )
{
switch( visibility )
{
case PRIVATE:
return value.toString();
case PROTECTED:
case PUBLIC:
return uri.getScheme() + ":";
}
}
StringBuilder buffer = new StringBuilder();
if( uri.getPath() != null ) // can happen according to the javadoc
buffer.append( uri.getPath() );
if( ( visibility == Visibility.PROTECTED || visibility == Visibility.PRIVATE ) && uri.getQuery() != null )
buffer.append( "?" ).append( sanitizeQuery( uri.getQuery() ) );
if( visibility == Visibility.PRIVATE )
{
String currentString = buffer.toString(); // preserve before creating a new instance
buffer = new StringBuilder();
if( uri.getScheme() != null )
buffer.append( uri.getScheme() ).append( "://" );
if( uri.getAuthority() != null )
buffer.append( uri.getAuthority() );
buffer.append( currentString );
}
return buffer.toString();
} |
121672_19 | public boolean hasPrefix( String key )
{
return ( this.get( key ) != null );
} |
121672_20 | public String getCommonPrefix()
{
StringBuffer buffer = new StringBuffer();
if( children.size() != 1 )
return buffer.toString();
buildPrefix( buffer, this );
return buffer.toString();
} |
121672_21 | @Override
blic boolean hasNext()
{
if( currentException != null )
return true;
if( isComplete )
return false;
if( hasWaiting )
return true;
try
{
getNext();
}
catch( Exception exception )
{
if( permittedExceptions.contains( exception.getClass() ) )
{
LOG.warn( "Caught permitted exception while reading {}", loggableIdentifier.get(), exception );
return false;
}
currentException = new TupleException( "unable to read from input identifier: " + loggableIdentifier.get(), exception );
return true;
}
if( !hasWaiting )
isComplete = true;
return !isComplete;
} |
121672_22 | public Tuple get( int[] pos )
{
if( pos == null || pos.length == 0 )
return new Tuple( this );
Tuple results = new Tuple( new ArrayList<>( pos.length ) );
for( int i : pos )
results.elements.add( elements.get( i ) ); // skip modifiable check
return results;
} |
121672_23 | public Tuple remove( int[] pos )
{
verifyModifiable();
// calculate offsets to apply when removing values from elements
int offset[] = new int[ pos.length ];
for( int i = 0; i < pos.length; i++ )
{
offset[ i ] = 0;
for( int j = 0; j < i; j++ )
{
if( pos[ j ] < pos[ i ] )
offset[ i ]++;
}
}
Tuple results = new Tuple();
for( int i = 0; i < pos.length; i++ )
results.add( elements.remove( pos[ i ] - offset[ i ] ) );
return results;
} |
121672_24 | public Tuple leave( int[] pos )
{
verifyModifiable();
Tuple results = remove( pos );
List<Object> temp = results.elements;
results.elements = this.elements;
this.elements = temp;
return results;
} |
121672_25 | public int compareTo( Tuple other )
{
if( other == null || other.elements == null )
return 1;
if( other.elements.size() != this.elements.size() )
return this.elements.size() - other.elements.size();
for( int i = 0; i < this.elements.size(); i++ )
{
Comparable lhs = (Comparable) this.elements.get( i );
Comparable rhs = (Comparable) other.elements.get( i );
if( lhs == null && rhs == null )
continue;
if( lhs == null )
return -1;
else if( rhs == null )
return 1;
int c = lhs.compareTo( rhs ); // guaranteed to not be null
if( c != 0 )
return c;
}
return 0;
} |
121672_26 | public int compareTo( Tuple other )
{
if( other == null || other.elements == null )
return 1;
if( other.elements.size() != this.elements.size() )
return this.elements.size() - other.elements.size();
for( int i = 0; i < this.elements.size(); i++ )
{
Comparable lhs = (Comparable) this.elements.get( i );
Comparable rhs = (Comparable) other.elements.get( i );
if( lhs == null && rhs == null )
continue;
if( lhs == null )
return -1;
else if( rhs == null )
return 1;
int c = lhs.compareTo( rhs ); // guaranteed to not be null
if( c != 0 )
return c;
}
return 0;
} |
121672_27 | public int compareTo( Tuple other )
{
if( other == null || other.elements == null )
return 1;
if( other.elements.size() != this.elements.size() )
return this.elements.size() - other.elements.size();
for( int i = 0; i < this.elements.size(); i++ )
{
Comparable lhs = (Comparable) this.elements.get( i );
Comparable rhs = (Comparable) other.elements.get( i );
if( lhs == null && rhs == null )
continue;
if( lhs == null )
return -1;
else if( rhs == null )
return 1;
int c = lhs.compareTo( rhs ); // guaranteed to not be null
if( c != 0 )
return c;
}
return 0;
} |
121672_28 | public int compareTo( Tuple other )
{
if( other == null || other.elements == null )
return 1;
if( other.elements.size() != this.elements.size() )
return this.elements.size() - other.elements.size();
for( int i = 0; i < this.elements.size(); i++ )
{
Comparable lhs = (Comparable) this.elements.get( i );
Comparable rhs = (Comparable) other.elements.get( i );
if( lhs == null && rhs == null )
continue;
if( lhs == null )
return -1;
else if( rhs == null )
return 1;
int c = lhs.compareTo( rhs ); // guaranteed to not be null
if( c != 0 )
return c;
}
return 0;
} |
121672_29 | public int compareTo( Tuple other )
{
if( other == null || other.elements == null )
return 1;
if( other.elements.size() != this.elements.size() )
return this.elements.size() - other.elements.size();
for( int i = 0; i < this.elements.size(); i++ )
{
Comparable lhs = (Comparable) this.elements.get( i );
Comparable rhs = (Comparable) other.elements.get( i );
if( lhs == null && rhs == null )
continue;
if( lhs == null )
return -1;
else if( rhs == null )
return 1;
int c = lhs.compareTo( rhs ); // guaranteed to not be null
if( c != 0 )
return c;
}
return 0;
} |
121672_30 | public void setAll( Tuple tuple )
{
verifyModifiable();
if( tuple == null )
return;
for( int i = 0; i < tuple.elements.size(); i++ )
internalSet( i, tuple.elements.get( i ) );
} |
121672_31 | public Fields append( Fields fields )
{
return appendInternal( fields, false );
} |
121672_32 | public Fields appendSelector( Fields fields )
{
return appendInternal( fields, true );
} |
121672_33 | public Fields appendSelector( Fields fields )
{
return appendInternal( fields, true );
} |
121672_34 | public Fields rename( Fields from, Fields to )
{
if( this.isSubstitution() || this.isUnknown() )
throw new TupleException( "cannot rename fields in a substitution or unknown Fields instance: " + this.print() );
if( from.size() != to.size() )
throw new TupleException( "from and to fields must be the same size" );
if( from.isSubstitution() || from.isUnknown() )
throw new TupleException( "from fields may not be a substitution or unknown" );
if( to.isSubstitution() || to.isUnknown() )
throw new TupleException( "to fields may not be a substitution or unknown" );
Comparable[] newFields = Arrays.copyOf( this.fields, this.fields.length );
int[] pos = getPos( from );
for( int i = 0; i < pos.length; i++ )
newFields[ pos[ i ] ] = to.fields[ i ];
Type[] newTypes = null;
if( this.types != null && to.types != null )
{
newTypes = copyTypes( this.types, this.size() );
for( int i = 0; i < pos.length; i++ )
newTypes[ pos[ i ] ] = to.types[ i ];
}
return new Fields( newFields, newTypes );
} |
121672_35 | public Fields subtract( Fields fields )
{
if( fields.isAll() )
return Fields.NONE;
if( fields.isNone() )
return this;
List<Comparable> list = new LinkedList<Comparable>();
Collections.addAll( list, this.get() );
int[] pos = getPos( fields, -1 );
for( int i : pos )
list.set( i, null );
Util.removeAllNulls( list );
Type[] newTypes = null;
if( this.types != null )
{
List<Type> types = new LinkedList<Type>();
Collections.addAll( types, this.types );
for( int i : pos )
types.set( i, null );
Util.removeAllNulls( types );
newTypes = types.toArray( new Type[ types.size() ] );
}
return new Fields( list.toArray( new Comparable[ list.size() ] ), newTypes );
} |
121672_36 | public Fields select( Fields selector )
{
if( !isOrdered() )
throw new TupleException( "this fields instance can only be used as a selector" );
if( selector.isAll() )
return this;
// supports -1_UNKNOWN_RETURNED
// guarantees pos arguments remain selector positions, not absolute positions
if( isUnknown() )
return asSelector( selector );
if( selector.isNone() )
return NONE;
Fields result = size( selector.size() );
for( int i = 0; i < selector.size(); i++ )
{
Comparable field = selector.get( i );
if( field instanceof String )
{
result.set( i, get( indexOf( field ) ) );
continue;
}
int pos = translatePos( (Integer) field );
if( this.get( pos ) instanceof String )
result.set( i, this.get( pos ) );
else
result.set( i, pos ); // use absolute position if no field name
}
if( this.types != null )
{
result.types = new Type[ result.size() ];
for( int i = 0; i < selector.size(); i++ )
{
Comparable field = selector.get( i );
if( field instanceof String )
result.setType( i, getType( indexOf( field ) ) );
else
result.setType( i, getType( translatePos( (Integer) field ) ) );
}
}
return result;
} |
121672_37 | public Fields selectPos( Fields selector )
{
return selectPos( selector, 0 );
} |
121672_38 | public static Fields resolve( Fields selector, Fields... fields )
{
boolean hasUnknowns = false;
int size = 0;
for( Fields field : fields )
{
if( field.isUnknown() )
hasUnknowns = true;
if( !field.isDefined() && field.isUnOrdered() )
throw new TupleException( "unable to select from field set: " + field.printVerbose() );
size += field.size();
}
if( selector.isAll() )
{
Fields result = fields[ 0 ];
for( int i = 1; i < fields.length; i++ )
result = result.append( fields[ i ] );
return result;
}
if( selector.isReplace() )
{
if( fields[ 1 ].isUnknown() )
throw new TupleException( "cannot replace fields with unknown field declaration" );
if( !fields[ 0 ].contains( fields[ 1 ] ) )
throw new TupleException( "could not find all fields to be replaced, available: " + fields[ 0 ].printVerbose() + ", declared: " + fields[ 1 ].printVerbose() );
Type[] types = fields[ 0 ].getTypes();
if( types != null )
{
for( int i = 1; i < fields.length; i++ )
{
Type[] fieldTypes = fields[ i ].getTypes();
if( fieldTypes == null )
{
fields[ 0 ] = fields[ 0 ].applyTypes( (Type[]) null );
}
else
{
for( int j = 0; j < fieldTypes.length; j++ )
fields[ 0 ] = fields[ 0 ].applyType( fields[ i ].get( j ), fieldTypes[ j ] );
}
}
}
return fields[ 0 ];
}
// we can't deal with anything but ALL
if( !selector.isDefined() )
throw new TupleException( "unable to use given selector: " + selector );
Set<String> notFound = new LinkedHashSet<String>();
Set<String> found = new HashSet<String>();
Fields result = size( selector.size() );
if( hasUnknowns )
size = -1;
Type[] types = null;
if( size != -1 )
types = new Type[ result.size() ];
int offset = 0;
for( Fields current : fields )
{
if( current.isNone() )
continue;
resolveInto( notFound, found, selector, current, result, types, offset, size );
offset += current.size();
}
if( types != null && !Util.containsNull( types ) ) // don't apply types if any are null
result = result.applyTypes( types );
notFound.removeAll( found );
if( !notFound.isEmpty() )
throw new FieldsResolverException( new Fields( join( size, fields ) ), new Fields( notFound.toArray( new Comparable[ notFound.size() ] ) ) );
if( hasUnknowns )
return selector;
return result;
} |
121672_39 | public Fields select( Fields selector )
{
if( !isOrdered() )
throw new TupleException( "this fields instance can only be used as a selector" );
if( selector.isAll() )
return this;
// supports -1_UNKNOWN_RETURNED
// guarantees pos arguments remain selector positions, not absolute positions
if( isUnknown() )
return asSelector( selector );
if( selector.isNone() )
return NONE;
Fields result = size( selector.size() );
for( int i = 0; i < selector.size(); i++ )
{
Comparable field = selector.get( i );
if( field instanceof String )
{
result.set( i, get( indexOf( field ) ) );
continue;
}
int pos = translatePos( (Integer) field );
if( this.get( pos ) instanceof String )
result.set( i, this.get( pos ) );
else
result.set( i, pos ); // use absolute position if no field name
}
if( this.types != null )
{
result.types = new Type[ result.size() ];
for( int i = 0; i < selector.size(); i++ )
{
Comparable field = selector.get( i );
if( field instanceof String )
result.setType( i, getType( indexOf( field ) ) );
else
result.setType( i, getType( translatePos( (Integer) field ) ) );
}
}
return result;
} |
121672_40 | public int[] getPos()
{
if( thisPos != null )
return thisPos; // do not clone
if( isAll() || isUnknown() )
thisPos = EMPTY_INT;
else
thisPos = makeThisPos();
return thisPos;
} |
121672_41 | public int[] getPos()
{
if( thisPos != null )
return thisPos; // do not clone
if( isAll() || isUnknown() )
thisPos = EMPTY_INT;
else
thisPos = makeThisPos();
return thisPos;
} |
121672_42 | public static Fields join( Fields... fields )
{
return join( false, fields );
} |
121672_43 | public Fields applyType( Comparable fieldName, Type type )
{
if( type == null )
throw new IllegalArgumentException( "given type must not be null" );
int pos;
try
{
pos = getPos( asFieldName( fieldName ) );
}
catch( FieldsResolverException exception )
{
throw new IllegalArgumentException( "given field name was not found: " + fieldName, exception );
}
Fields results = new Fields( fields );
results.types = this.types == null ? new Type[ size() ] : copyTypes( this.types, this.types.length );
results.types[ pos ] = type;
return results;
} |
121672_44 | public static Tuple select( Fields selector, TupleEntry... entries )
{
// todo: consider just appending tuples values and just peeking those values
Tuple result = null;
// does not do field checks
if( selector.isAll() )
{
for( TupleEntry entry : entries )
{
if( result == null )
result = entry.getTuple();
else
result = result.append( entry.getTuple() );
}
return result;
}
int size = 0;
for( TupleEntry entry : entries )
size += entry.size();
result = Tuple.size( selector.size() );
int offset = 0;
for( TupleEntry entry : entries )
{
for( int i = 0; i < selector.size(); i++ )
{
Comparable field = selector.get( i );
int pos;
if( field instanceof String )
{
pos = entry.fields.indexOfSafe( field );
if( pos == -1 )
continue;
}
else
{
pos = entry.fields.translatePos( (Integer) field, size ) - offset;
if( pos >= entry.size() || pos < 0 )
continue;
}
result.set( i, entry.getObject( pos ) ); // last in wins
}
offset += entry.size();
}
return result;
} |
121672_45 | @Override
blic boolean equals( Object object )
{
if( this == object )
return true;
if( !( object instanceof TupleEntry ) )
return false;
TupleEntry that = (TupleEntry) object;
if( fields != null ? !fields.equals( that.fields ) : that.fields != null )
return false;
// use comparators if in the this side fields instance
if( tuple != null ? fields.compare( tuple, that.tuple ) != 0 : that.tuple != null )
return false;
return true;
} |
121672_46 | public int getInteger( Comparable fieldName )
{
return (Integer) getObject( fieldName, int.class );
} |
121672_47 | public void set( TupleEntry tupleEntry )
{
this.tuple.set( fields, tupleEntry.getFields(), tupleEntry.getTuple(), tupleEntry.coercions );
} |
1228775_0 | public static PaxWicketInjector getInjector() {
String applicationName = Application.get().getApplicationKey();
PaxWicketInjector injector = null;
synchronized (instance.injectorMap) {
injector = instance.injectorMap.get(applicationName);
}
if (injector == null) {
throw new IllegalStateException(String.format("No Injector is set for application %s",
Application.get().getApplicationKey()));
}
return injector;
} |
1228775_1 | public void onInstantiation(Component component) {
toWrap.inject(component, component.getClass());
} |
1228775_2 | @Override
public Class<?> getBeanClass(Element element) {
return ApplicationDecorator.class;
} |
1228775_3 | @Override
public Class<?> getBeanClass(Element element) {
return BundleClassResolverHelperDecorator.class;
} |
1228775_4 | @Override
public Class<?> getBeanClass(Element element) {
return PageFactoryDecorator.class;
} |
1228775_5 | @Override
public Class<?> getBeanClass(Element element) {
return BundleInjectionProviderHelperDecorator.class;
} |
1228775_6 | @Override
public Class<?> getBeanClass(Element element) {
return BundleScanningMountPointProviderDecorator.class;
} |
1228775_7 | @Override
public Class<?> getBeanClass(Element element) {
return FilterFactoryDecorator.class;
} |
1229527_0 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_1 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_2 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_3 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_4 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_5 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_6 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_7 | public static Properties parseInstructions( final String query )
throws MalformedURLException
{
final Properties instructions = new Properties();
if( query != null )
{
try
{
// just ignore for the moment and try out if we have valid properties separated by "&"
final String segments[] = query.split( "&" );
for( String segment : segments )
{
// do not parse empty strings
if( segment.trim().length() > 0 )
{
final Matcher matcher = INSTRUCTIONS_PATTERN.matcher( segment );
if( matcher.matches() )
{
String key = matcher.group( 1 );
String val = matcher.group( 2 );
instructions.setProperty(
verifyKey(key),
val != null ? URLDecoder.decode( val, "UTF-8" ) : ""
);
}
else
{
throw new MalformedURLException( "Invalid syntax for instruction [" + segment
+ "]. Take a look at http://www.aqute.biz/Code/Bnd."
);
}
}
}
}
catch( UnsupportedEncodingException e )
{
// thrown by URLDecoder but it should never happen
throwAsMalformedURLException( "Could not retrieve the instructions from [" + query + "]", e );
}
}
return instructions;
} |
1229527_8 | public Map<String, String> match( final Map<String, String> entries )
{
final Map<String, String> matching = new HashMap<String, String>();
if( entries != null && !entries.isEmpty() )
{
for( Map.Entry<String, String> entry : entries.entrySet() )
{
if( m_pattern.matcher( entry.getKey() ).matches() )
{
matching.put( entry.getKey(), entry.getValue() );
}
}
}
return matching;
} |
1229527_9 | public Map<String, String> match( final Map<String, String> entries )
{
final Map<String, String> matching = new HashMap<String, String>();
if( entries != null && !entries.isEmpty() )
{
for( Map.Entry<String, String> entry : entries.entrySet() )
{
if( m_pattern.matcher( entry.getKey() ).matches() )
{
matching.put( entry.getKey(), entry.getValue() );
}
}
}
return matching;
} |
1231687_1 | public boolean isBitSet(int bit) {
long bitMask = Long.rotateLeft(1, bit);
long result = this.bitMaskValue & bitMask;
if (result != 0) {
return true;
}
return false;
} |
1231687_2 | public boolean isBitSet(int bit) {
long bitMask = Long.rotateLeft(1, bit);
long result = this.bitMaskValue & bitMask;
if (result != 0) {
return true;
}
return false;
} |
123235_10 | static String getAlgorithmForOid(String oid) throws NoSuchAlgorithmException {
if ("1.2.840.10045.2.1".equals(oid)) {
return "EC";
} else if ("1.2.840.113549.1.1.1".equals(oid)) {
return "RSA";
} else if ("1.2.840.10040.4.1".equals(oid)) {
return "DSA";
} else {
throw new NoSuchAlgorithmException("Unknown algorithm OID " + oid);
}
} |
123235_11 | static String getAlgorithmForOid(String oid) throws NoSuchAlgorithmException {
if ("1.2.840.10045.2.1".equals(oid)) {
return "EC";
} else if ("1.2.840.113549.1.1.1".equals(oid)) {
return "RSA";
} else if ("1.2.840.10040.4.1".equals(oid)) {
return "DSA";
} else {
throw new NoSuchAlgorithmException("Unknown algorithm OID " + oid);
}
} |
123235_12 | public static KeyPair recoverKeyPair(byte[] encoded) throws NoSuchAlgorithmException,
InvalidKeySpecException {
final String algo = getAlgorithmForOid(getOidFromPkcs8Encoded(encoded));
final KeySpec privKeySpec = new PKCS8EncodedKeySpec(encoded);
final KeyFactory kf = KeyFactory.getInstance(algo);
final PrivateKey priv = kf.generatePrivate(privKeySpec);
return new KeyPair(recoverPublicKey(kf, priv), priv);
} |
123235_13 | public static KeyPair recoverKeyPair(byte[] encoded) throws NoSuchAlgorithmException,
InvalidKeySpecException {
final String algo = getAlgorithmForOid(getOidFromPkcs8Encoded(encoded));
final KeySpec privKeySpec = new PKCS8EncodedKeySpec(encoded);
final KeyFactory kf = KeyFactory.getInstance(algo);
final PrivateKey priv = kf.generatePrivate(privKeySpec);
return new KeyPair(recoverPublicKey(kf, priv), priv);
} |
123235_14 | public static KeyPair recoverKeyPair(byte[] encoded) throws NoSuchAlgorithmException,
InvalidKeySpecException {
final String algo = getAlgorithmForOid(getOidFromPkcs8Encoded(encoded));
final KeySpec privKeySpec = new PKCS8EncodedKeySpec(encoded);
final KeyFactory kf = KeyFactory.getInstance(algo);
final PrivateKey priv = kf.generatePrivate(privKeySpec);
return new KeyPair(recoverPublicKey(kf, priv), priv);
} |
123235_15 | static PublicKey recoverPublicKey(KeyFactory kf, PrivateKey priv)
throws NoSuchAlgorithmException, InvalidKeySpecException {
if (priv instanceof RSAPrivateCrtKey) {
RSAPrivateCrtKey rsaPriv = (RSAPrivateCrtKey) priv;
return kf.generatePublic(new RSAPublicKeySpec(rsaPriv.getModulus(), rsaPriv
.getPublicExponent()));
} else if (priv instanceof RSAPrivateKey) {
BigInteger publicExponent = getRSAPublicExponentFromPkcs8Encoded(priv.getEncoded());
RSAPrivateKey rsaPriv = (RSAPrivateKey) priv;
return kf.generatePublic(new RSAPublicKeySpec(rsaPriv.getModulus(), publicExponent));
} else if (priv instanceof DSAPrivateKey) {
DSAPrivateKey dsaPriv = (DSAPrivateKey) priv;
DSAParams params = dsaPriv.getParams();
// Calculate public key Y
BigInteger y = params.getG().modPow(dsaPriv.getX(), params.getP());
return kf.generatePublic(new DSAPublicKeySpec(y, params.getP(), params.getQ(), params
.getG()));
} else if (priv instanceof ECPrivateKey) {
ECPrivateKey ecPriv = (ECPrivateKey) priv;
ECParameterSpec params = ecPriv.getParams();
// Calculate public key Y
ECPoint generator = params.getGenerator();
BigInteger[] wCoords = EcCore.multiplyPointA(new BigInteger[] { generator.getAffineX(),
generator.getAffineY() }, ecPriv.getS(), params);
ECPoint w = new ECPoint(wCoords[0], wCoords[1]);
return kf.generatePublic(new ECPublicKeySpec(w, params));
} else {
throw new NoSuchAlgorithmException("Key type must be RSA, DSA, or EC");
}
} |
123235_16 | static BigInteger getRSAPublicExponentFromPkcs8Encoded(byte[] encoded) throws InvalidKeySpecException {
if (encoded == null) {
throw new InvalidKeySpecException("encoded key is null");
}
try {
SimpleDERReader reader = new SimpleDERReader(encoded);
reader.resetInput(reader.readSequenceAsByteArray());
if (!reader.readInt().equals(BigInteger.ZERO)) {
throw new InvalidKeySpecException("PKCS#8 is not version 0");
}
reader.readSequenceAsByteArray(); // OID sequence
reader.resetInput(reader.readOctetString()); // RSA key bytes
reader.resetInput(reader.readSequenceAsByteArray()); // RSA key sequence
if (!reader.readInt().equals(BigInteger.ZERO)) {
throw new InvalidKeySpecException("RSA key is not version 0");
}
reader.readInt(); // modulus
return reader.readInt(); // public exponent
} catch (IOException e) {
Log.w(TAG, "Could not read public exponent", e);
throw new InvalidKeySpecException("Could not read key", e);
}
} |
1251091_0 | public List<Float> getBinned()
{
if (last == -1)
return null;
return new ImmutableList.Builder<Float>().addAll(binned).build();
} |
1251538_0 | public FSMDescription addState(final String name, final StateType type) throws FSMException {
throwIfBuilt();
if (name != null && !states.containsKey(name)) {
if (type == StateType.START) {
if (startState == null)
startState = name;
else
throw new FSMException("Could not add " + name + " as start state. State "
+ startState + " is already assigned start state");
}
states.put(name, new State(name, type));
} else {
throw new FSMException("Could not add state " + name
+ ". State with that name already exists.");
}
return this;
} |
1251538_1 | public FSMDescription addTransition(final String name, TransitionCondition condition,
final String start, final String end, Action action) throws FSMException {
throwIfBuilt();
if (this.transitions.containsKey(name))
throw new FSMException("Could not add transition " + name
+ ". A transition with the same name already exists.");
if (!this.states.containsKey(start))
throw new FSMException("Could not add transition " + name + ". Start state " + start
+ " does not exist");
if (!this.states.containsKey(end))
throw new FSMException("Could not add transition " + name + ". End state " + end
+ " does not exist");
if (getState(start).getType() == StateType.END) {
throw new FSMException("End state cannot be origin of transitions");
}
if (condition == null)
condition = TransitionCondition.ALWAYS;
if (action == null)
action = Action.NOOP;
Transition t = new Transition(name, getState(start), getState(end), condition, action);
this.transitions.put(name, t);
getState(start).addTransition(t);
return this;
} |
1251538_2 | @Override
public boolean allow(Object event, Object entity, State state) {
return !(condition.allow(event, entity, state));
} |
1251538_3 | @Override
public boolean allow(Object event, Object entity, State state) {
for (TransitionCondition condition : conditions) {
if (!condition.allow(event, entity, state))
return false;
}
return true;
} |
1251538_4 | @Override
public boolean allow(Object event, Object entity, State state) {
return (type.isInstance(event));
} |
1251538_5 | @Override
public boolean allow(Object event, Object entity, State state) {
for (TransitionCondition condition : conditions) {
if (condition.allow(event, entity, state))
return true;
}
return false;
} |
1251538_6 | @SuppressWarnings("unchecked")
@Override
public <T extends EnvironmentService> T getEnvironmentService(Class<T> type)
throws UnavailableServiceException {
// force NullPointerException if type is null
type.toString();
for (EnvironmentService s : this.globalEnvironmentServices) {
if (type.isInstance(s)) {
return (T) s;
}
}
throw new UnavailableServiceException(type);
} |
1251538_7 | @SuppressWarnings("unchecked")
@Override
public <T extends EnvironmentService> T getEnvironmentService(Class<T> type)
throws UnavailableServiceException {
// force NullPointerException if type is null
type.toString();
for (EnvironmentService s : this.globalEnvironmentServices) {
if (type.isInstance(s)) {
return (T) s;
}
}
throw new UnavailableServiceException(type);
} |
1251538_8 | @Override
public Conversation spawn() {
try {
return spawnAsInititor(new ConversationSpawnEvent());
} catch (FSMException e) {
throw new RuntimeException(e);
}
} |
1251538_9 | public Location getAgentLocation(UUID participantID) {
return (Location) this.sharedState.get("util.location", participantID);
} |
1251856_0 | public int compare(KoanMethod arg0, KoanMethod arg1) {
Class<?> declaringClass0 = arg0.getMethod().getDeclaringClass();
Class<?> declaringClass1 = arg1.getMethod().getDeclaringClass();
if(declaringClass0 != declaringClass1){
Logger.getAnonymousLogger().severe("no idea how to handle comparing the classes: " + declaringClass0 + " and: "+declaringClass1);
return 0;
}
String contentsOfOriginalJavaFile = FileCompiler.getContentsOfJavaFile(DirectoryManager.getSourceDir(), declaringClass0.getName());
String pattern = ".*\\s%s(\\(|\\s*\\))";
Integer index0 = indexOfMatch(contentsOfOriginalJavaFile, String.format(pattern, arg0.getMethod().getName()));
Integer index1 = indexOfMatch(contentsOfOriginalJavaFile, String.format(pattern, arg1.getMethod().getName()));
return index0.compareTo(index1);
} |
1251856_1 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_2 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_3 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_4 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_5 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_6 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_7 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_8 | boolean isIgnored(File file){
boolean ignore = false;
while(file != null){
String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1);
for(String pathToIgnore: ignoredPaths){
ignore = end.matches(pathToIgnore);
if(ignore){
return true;
}
}
file = file.getParentFile();
}
return ignore;
} |
1251856_9 | static ResourceBundle createResourceBundle() {
ResourceBundle temp = null;
try {
temp = new PropertyResourceBundle(new FileInputStream(
DirectoryManager.injectFileSystemSeparators(
DirectoryManager.getProjectI18nDir(),
new StringBuilder("messages_").append(
Locale.getDefault().getLanguage()).append(
".properties").toString())));
} catch(FileNotFoundException x) {
try {
Logger.getLogger(Strings.class.getName()).log(Level.INFO, "Your default language is not supported yet. "+x.getLocalizedMessage());
temp = new PropertyResourceBundle(new FileInputStream(
DirectoryManager.injectFileSystemSeparators(
DirectoryManager.getProjectI18nDir(), "messages_en.properties")));
} catch (Exception e) {
throw new RuntimeException(e);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return temp;
} |
1263661_0 | @Override
public String getWriteEnabler() {
// TODO: Figure out if the message is somehow important for security.
byte[] taggedmsg = { 't', 'h', 'i', 's', 'i', 's', 'h', 'm', 'a', 'c',
'f', 'o', 'r' };
if (this.type == CapabilityType.RW) {
byte[] tmp = Cryptoutil.hmac(taggedmsg, this.key);
byte[] tmp2 = new byte[16];
System.arraycopy(tmp, 0, tmp2, 0, tmp2.length);
return Base32.encode(tmp2);
} else {
return null;
}
} |
1263661_1 | @Override
public Capability getCapability() {
return this.capability;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.