idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
34,600
public void recolorQuery ( ) { String input = parent . getText ( ) ; resetStyles ( ) ; doc . setCharacterAttributes ( 0 , doc . getLength ( ) , plainStyle , true ) ; input = input . replaceAll ( "[Ss][Ee][Ll][Ee][Cc][Tt]" , "SELECT" ) ; int offset = 0 ; for ( int index = input . indexOf ( "SELECT" , offset ) ; index != - 1 ; index = input . indexOf ( "SELECT" , offset ) ) { doc . setCharacterAttributes ( index , index + 6 , boldStyle , true ) ; offset = index + 6 ; doc . setCharacterAttributes ( offset , offset + 1 , plainStyle , true ) ; } input = input . replaceAll ( "([Ff][Rr][Oo][Mm])" , "FROM" ) ; offset = 0 ; for ( int index = input . indexOf ( "FROM" , offset ) ; index != - 1 ; index = input . indexOf ( "FROM" , offset ) ) { doc . setCharacterAttributes ( index , index + 4 , boldStyle , false ) ; offset = index + 4 ; doc . setCharacterAttributes ( offset , offset + 1 , plainStyle , true ) ; } input = input . replaceAll ( "([Ww][hH][Ee][Rr][Ee])" , "WHERE" ) ; offset = 0 ; for ( int index = input . indexOf ( "WHERE" , offset ) ; index != - 1 ; index = input . indexOf ( "WHERE" , offset ) ) { doc . setCharacterAttributes ( index , index + 5 , boldStyle , false ) ; offset = index + 5 ; doc . setCharacterAttributes ( offset , offset + 1 , plainStyle , true ) ; } parent . revalidate ( ) ; }
Performs coloring of the text pane . This method needs to be rewritten .
34,601
protected < R > R liftRegularChildBinding ( ConstructionNode selectedChildConstructionNode , int selectedChildPosition , IQTree selectedGrandChild , ImmutableList < IQTree > children , ImmutableSet < Variable > nonLiftableVariables , Optional < ImmutableExpression > initialJoiningCondition , VariableGenerator variableGenerator , LiftConverter < R > liftConverter ) throws UnsatisfiableConditionException { ImmutableSubstitution < ImmutableTerm > selectedChildSubstitution = selectedChildConstructionNode . getSubstitution ( ) ; ImmutableSubstitution < NonFunctionalTerm > downPropagableFragment = selectedChildSubstitution . getNonFunctionalTermFragment ( ) ; ImmutableSubstitution < ImmutableFunctionalTerm > nonDownPropagableFragment = selectedChildSubstitution . getFunctionalTermFragment ( ) ; ImmutableSet < Variable > otherChildrenVariables = IntStream . range ( 0 , children . size ( ) ) . filter ( i -> i != selectedChildPosition ) . boxed ( ) . map ( children :: get ) . flatMap ( iq -> iq . getVariables ( ) . stream ( ) ) . collect ( ImmutableCollectors . toSet ( ) ) ; InjectiveVar2VarSubstitution freshRenaming = computeOtherChildrenRenaming ( nonDownPropagableFragment , otherChildrenVariables , variableGenerator ) ; ExpressionAndSubstitution expressionResults = simplifyCondition ( computeNonOptimizedCondition ( initialJoiningCondition , selectedChildSubstitution , freshRenaming ) , nonLiftableVariables ) ; Optional < ImmutableExpression > newCondition = expressionResults . optionalExpression ; ImmutableSubstitution < ImmutableTerm > ascendingSubstitution = expressionResults . substitution . composeWith ( selectedChildSubstitution ) ; ImmutableSubstitution < NonFunctionalTerm > descendingSubstitution = expressionResults . substitution . composeWith2 ( freshRenaming ) . composeWith2 ( downPropagableFragment ) ; return liftConverter . convert ( children , selectedGrandChild , selectedChildPosition , newCondition , ascendingSubstitution , descendingSubstitution ) ; }
For children of a commutative join or for the left child of a LJ
34,602
public String getRewritingRendering ( InputQuery query ) throws OntopReformulationException { InternalSparqlQuery translation = query . translate ( inputQueryTranslator ) ; try { IQ converetedIQ = preProcess ( translation ) ; IQ rewrittenIQ = rewriter . rewrite ( converetedIQ ) ; return rewrittenIQ . toString ( ) ; } catch ( EmptyQueryException e ) { e . printStackTrace ( ) ; } return "EMPTY REWRITING" ; }
Returns the final rewriting of the given query
34,603
public void createGroup ( String groupId ) throws Exception { if ( getElementPosition ( groupId ) == - 1 ) { QueryControllerGroup group = new QueryControllerGroup ( groupId ) ; entities . add ( group ) ; fireElementAdded ( group ) ; } else { throw new Exception ( "The name is already taken, either by a query group or a query item" ) ; } }
Creates a new group and adds it to the vector QueryControllerEntity
34,604
public QueryControllerGroup getGroup ( String groupId ) { int index = getElementPosition ( groupId ) ; if ( index == - 1 ) { return null ; } QueryControllerGroup group = ( QueryControllerGroup ) entities . get ( index ) ; return group ; }
Searches a group and returns the object else returns null
34,605
public List < QueryControllerGroup > getGroups ( ) { List < QueryControllerGroup > groups = new ArrayList < QueryControllerGroup > ( ) ; for ( QueryControllerEntity element : entities ) { if ( element instanceof QueryControllerGroup ) { groups . add ( ( QueryControllerGroup ) element ) ; } } return groups ; }
Returns all the groups added
34,606
public void removeGroup ( String groupId ) { for ( Iterator < QueryControllerEntity > iterator = entities . iterator ( ) ; iterator . hasNext ( ) ; ) { Object temporal = iterator . next ( ) ; if ( ! ( temporal instanceof QueryControllerGroup ) ) { continue ; } QueryControllerGroup element = ( QueryControllerGroup ) temporal ; if ( element instanceof QueryControllerGroup ) { QueryControllerGroup group = element ; if ( group . getID ( ) . equals ( groupId ) ) { entities . remove ( group ) ; fireElementRemoved ( group ) ; return ; } } } }
Removes a group from the vector QueryControllerEntity
34,607
public QueryControllerQuery addQuery ( String queryStr , String queryId ) { int position = getElementPosition ( queryId ) ; QueryControllerQuery query = new QueryControllerQuery ( queryId ) ; query . setQuery ( queryStr ) ; if ( position == - 1 ) { entities . add ( query ) ; fireElementAdded ( query ) ; } else { entities . set ( position , query ) ; fireElementChanged ( query ) ; } return query ; }
Creates a new query and adds it to the vector QueryControllerEntity .
34,608
public QueryControllerQuery addQuery ( String queryStr , String queryId , String groupId ) { int position = getElementPosition ( queryId ) ; QueryControllerQuery query = new QueryControllerQuery ( queryId ) ; query . setQuery ( queryStr ) ; QueryControllerGroup group = getGroup ( groupId ) ; if ( group == null ) { group = new QueryControllerGroup ( groupId ) ; entities . add ( group ) ; fireElementAdded ( group ) ; } if ( position == - 1 ) { group . addQuery ( query ) ; fireElementAdded ( query , group ) ; } else { group . updateQuery ( query ) ; fireElementChanged ( query , group ) ; } return query ; }
Creates a new query into a group and adds it to the vector QueryControllerEntity
34,609
public void removeAllQueriesAndGroups ( ) { List < QueryControllerEntity > elements = getElements ( ) ; for ( QueryControllerEntity treeElement : elements ) { fireElementRemoved ( treeElement ) ; } entities . clear ( ) ; }
Removes all the elements from the vector QueryControllerEntity
34,610
public void removeQuery ( String id ) { int index = getElementPosition ( id ) ; QueryControllerEntity element = entities . get ( index ) ; if ( element instanceof QueryControllerQuery ) { entities . remove ( index ) ; fireElementRemoved ( element ) ; return ; } else { QueryControllerGroup group = ( QueryControllerGroup ) element ; Vector < QueryControllerQuery > queries_ingroup = group . getQueries ( ) ; for ( QueryControllerQuery query : queries_ingroup ) { if ( query . getID ( ) . equals ( id ) ) { fireElementRemoved ( group . removeQuery ( query . getID ( ) ) , group ) ; return ; } } } }
Removes a query from the vector QueryControllerEntity
34,611
public int getElementPosition ( String element_id ) { int index = - 1 ; for ( int i = 0 ; i < entities . size ( ) ; i ++ ) { QueryControllerEntity element = entities . get ( i ) ; if ( element instanceof QueryControllerQuery ) { QueryControllerQuery query = ( QueryControllerQuery ) element ; if ( query . getID ( ) . equals ( element_id ) ) { index = i ; break ; } } if ( element instanceof QueryControllerGroup ) { QueryControllerGroup group = ( QueryControllerGroup ) element ; if ( group . getID ( ) . equals ( element_id ) ) { index = i ; break ; } else { Vector < QueryControllerQuery > queries_ingroup = group . getQueries ( ) ; for ( QueryControllerQuery query : queries_ingroup ) { if ( query . getID ( ) . equals ( element_id ) ) { index = i ; break ; } } } } } return index ; }
Returns the index of the element in the vector . If its is a query and the query is found inside a query group . The position of the group is returned instead .
34,612
public void updateQuery ( QueryControllerQuery query ) { int position = getElementPosition ( query . getID ( ) ) ; queries . set ( position , query ) ; }
Updates the existing query .
34,613
public static Properties convert ( OBDADataSource source ) { String id = source . getSourceID ( ) . toString ( ) ; String url = source . getParameter ( RDBMSourceParameterConstants . DATABASE_URL ) ; String username = source . getParameter ( RDBMSourceParameterConstants . DATABASE_USERNAME ) ; String password = source . getParameter ( RDBMSourceParameterConstants . DATABASE_PASSWORD ) ; String driver = source . getParameter ( RDBMSourceParameterConstants . DATABASE_DRIVER ) ; Properties p = new Properties ( ) ; p . put ( OntopSQLCoreSettings . JDBC_NAME , id ) ; p . put ( OntopSQLCoreSettings . JDBC_URL , url ) ; p . put ( OntopSQLCredentialSettings . JDBC_USER , username ) ; p . put ( OntopSQLCredentialSettings . JDBC_PASSWORD , password ) ; p . put ( OntopSQLCoreSettings . JDBC_DRIVER , driver ) ; return p ; }
These properties are compatible with OBDAProperties keys .
34,614
private IQTree liftBindingFromLiftedChildren ( ImmutableList < IQTree > liftedChildren , VariableGenerator variableGenerator , IQProperties currentIQProperties ) { if ( liftedChildren . stream ( ) . anyMatch ( c -> ! ( c . getRootNode ( ) instanceof ConstructionNode ) ) ) return iqFactory . createNaryIQTree ( this , liftedChildren , currentIQProperties . declareLifted ( ) ) ; ImmutableSubstitution < ImmutableTerm > mergedSubstitution = mergeChildSubstitutions ( projectedVariables , liftedChildren . stream ( ) . map ( c -> ( ConstructionNode ) c . getRootNode ( ) ) . map ( ConstructionNode :: getSubstitution ) . collect ( ImmutableCollectors . toList ( ) ) , variableGenerator ) ; if ( mergedSubstitution . isEmpty ( ) ) { return iqFactory . createNaryIQTree ( this , liftedChildren , currentIQProperties . declareLifted ( ) ) ; } ConstructionNode newRootNode = iqFactory . createConstructionNode ( projectedVariables , mergedSubstitution ) ; ImmutableSet < Variable > unionVariables = newRootNode . getChildVariables ( ) ; UnionNode newUnionNode = iqFactory . createUnionNode ( unionVariables ) ; NaryIQTree unionIQ = iqFactory . createNaryIQTree ( newUnionNode , liftedChildren . stream ( ) . map ( c -> ( UnaryIQTree ) c ) . map ( c -> updateChild ( c , mergedSubstitution , unionVariables ) ) . collect ( ImmutableCollectors . toList ( ) ) ) ; return iqFactory . createUnaryIQTree ( newRootNode , unionIQ ) ; }
Has at least two children
34,615
private IQTree projectAwayUnnecessaryVariables ( IQTree child , IQProperties currentIQProperties ) { if ( child . getRootNode ( ) instanceof ConstructionNode ) { ConstructionNode constructionNode = ( ConstructionNode ) child . getRootNode ( ) ; AscendingSubstitutionNormalization normalization = normalizeAscendingSubstitution ( constructionNode . getSubstitution ( ) , projectedVariables ) ; Optional < ConstructionNode > proposedConstructionNode = normalization . generateTopConstructionNode ( ) ; if ( proposedConstructionNode . filter ( c -> c . isSyntacticallyEquivalentTo ( constructionNode ) ) . isPresent ( ) ) return child ; IQTree grandChild = normalization . normalizeChild ( ( ( UnaryIQTree ) child ) . getChild ( ) ) ; return proposedConstructionNode . map ( c -> ( IQTree ) iqFactory . createUnaryIQTree ( c , grandChild , currentIQProperties . declareLifted ( ) ) ) . orElse ( grandChild ) ; } else return child ; }
Projects away variables only for child construction nodes
34,616
private boolean canWrite ( File outputFile ) { boolean fileIsValid = false ; if ( outputFile . exists ( ) ) { int result = JOptionPane . showConfirmDialog ( this , "File exists, overwrite?" , "Warning" , JOptionPane . YES_NO_CANCEL_OPTION ) ; switch ( result ) { case JOptionPane . YES_OPTION : fileIsValid = true ; break ; default : fileIsValid = false ; } } else { fileIsValid = true ; } return fileIsValid ; }
A utility method to check if the result should be written to the target file . Return true if the target file doesn t exist yet or the user allows overwriting .
34,617
public Optional < ImmutableSubstitution < ? extends VariableOrGroundTerm > > normalizeDescendingSubstitution ( IQTree tree , ImmutableSubstitution < ? extends VariableOrGroundTerm > descendingSubstitution ) throws UnsatisfiableDescendingSubstitutionException { ImmutableSubstitution < ? extends VariableOrGroundTerm > reducedSubstitution = descendingSubstitution . reduceDomainToIntersectionWith ( tree . getVariables ( ) ) ; if ( reducedSubstitution . isEmpty ( ) ) return Optional . empty ( ) ; if ( reducedSubstitution . getImmutableMap ( ) . values ( ) . stream ( ) . anyMatch ( value -> value . equals ( termFactory . getNullConstant ( ) ) ) ) { throw new UnsatisfiableDescendingSubstitutionException ( ) ; } return Optional . of ( reducedSubstitution ) ; }
Excludes the variables that are not projected by the IQTree
34,618
public int getStatistics ( String datasourceId , String mappingId ) { final HashMap < String , Integer > mappingStat = getStatistics ( datasourceId ) ; int triplesCount = mappingStat . get ( mappingId ) . intValue ( ) ; return triplesCount ; }
Returns one triple count from a particular mapping .
34,619
public int getTotalTriples ( ) throws Exception { int total = 0 ; for ( HashMap < String , Integer > mappingStat : statistics . values ( ) ) { for ( Integer triplesCount : mappingStat . values ( ) ) { int triples = triplesCount . intValue ( ) ; if ( triples == - 1 ) { throw new Exception ( "An error was occurred in the counting process." ) ; } total = total + triples ; } } return total ; }
Gets the total number of triples from all the data sources and mappings .
34,620
private String nameViewOrVariable ( final String prefix , final String intermediateName , final String suffix , final Collection < String > alreadyDefinedNames , boolean putQuote ) { int borderLength = prefix . length ( ) + suffix . length ( ) ; int signatureVarLength = intermediateName . length ( ) ; if ( borderLength >= ( NAME_MAX_LENGTH - NAME_NUMBER_LENGTH ) ) { throw new IllegalArgumentException ( "The prefix and the suffix are too long (their accumulated length must " + "be less than " + ( NAME_MAX_LENGTH - NAME_NUMBER_LENGTH ) + ")" ) ; } if ( signatureVarLength + borderLength <= NAME_MAX_LENGTH ) { String unquotedName = buildDefaultName ( prefix , intermediateName , suffix ) ; String name = putQuote ? sqlQuote ( unquotedName ) : unquotedName ; return name ; } String shortenIntermediateNamePrefix = intermediateName . substring ( 0 , NAME_MAX_LENGTH - borderLength - NAME_NUMBER_LENGTH ) ; for ( int i = 0 ; i < Math . pow ( 10 , NAME_NUMBER_LENGTH ) ; i ++ ) { String unquotedVarName = buildDefaultName ( prefix , shortenIntermediateNamePrefix + i , suffix ) ; String mainVarName = putQuote ? sqlQuote ( unquotedVarName ) : unquotedVarName ; if ( ! alreadyDefinedNames . contains ( mainVarName ) ) { return mainVarName ; } } throw new RuntimeException ( "Impossible to create a new variable/view " + prefix + shortenIntermediateNamePrefix + "???" + suffix + " : already " + Math . pow ( 10 , NAME_NUMBER_LENGTH ) + " of them." ) ; }
Makes sure the view or variable name never exceeds the max length supported by Oracle .
34,621
public boolean isContainedIn ( ImmutableCQ cq1 , ImmutableCQ cq2 ) { return cq2 . getAnswerVariables ( ) . equals ( cq1 . getAnswerVariables ( ) ) && ! cq2 . getAtoms ( ) . stream ( ) . anyMatch ( a -> ! cq1 . getAtoms ( ) . contains ( a ) ) ; }
Check if query cq1 is contained in cq2 syntactically . That is if the head of cq1 and cq2 are equal and each atom in cq2 is also in the body of cq1
34,622
public static void getNestedConcats ( StringBuilder stb , ImmutableTerm term1 , ImmutableTerm term2 ) { if ( term1 instanceof ImmutableFunctionalTerm ) { ImmutableFunctionalTerm f = ( ImmutableFunctionalTerm ) term1 ; getNestedConcats ( stb , f . getTerms ( ) . get ( 0 ) , f . getTerms ( ) . get ( 1 ) ) ; } else { stb . append ( appendTerms ( term1 ) ) ; } if ( term2 instanceof ImmutableFunctionalTerm ) { ImmutableFunctionalTerm f = ( ImmutableFunctionalTerm ) term2 ; getNestedConcats ( stb , f . getTerms ( ) . get ( 0 ) , f . getTerms ( ) . get ( 1 ) ) ; } else { stb . append ( appendTerms ( term2 ) ) ; } }
Appends nested concats
34,623
private static String getDisplayName ( ImmutableTerm term , PrefixManager prefixManager ) { if ( term instanceof ImmutableFunctionalTerm ) return displayFunction ( ( ImmutableFunctionalTerm ) term , prefixManager ) ; if ( term instanceof Variable ) return displayVariable ( ( Variable ) term ) ; if ( term instanceof IRIConstant ) return displayURIConstant ( ( Constant ) term , prefixManager ) ; if ( term instanceof ValueConstant ) return displayValueConstant ( ( Constant ) term ) ; if ( term instanceof BNode ) return displayBnode ( ( BNode ) term ) ; throw new UnexpectedTermException ( term ) ; }
Prints the text representation of different terms .
34,624
private static ImmutableList < DateTimeFormatter > buildDefaultDateTimeFormatter ( ) { return ImmutableList . < DateTimeFormatter > builder ( ) . add ( DateTimeFormatter . ISO_LOCAL_DATE_TIME ) . add ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss[[.SSSSSSSSS][.SSSSSSS][.SSSSSS][.SSS][.SS][.S][XXXXX][XXXX][x]" ) ) . add ( DateTimeFormatter . ISO_DATE ) . add ( new DateTimeFormatterBuilder ( ) . parseCaseInsensitive ( ) . appendPattern ( "dd-MMM-yy[ HH:mm:ss]" ) . toFormatter ( ) ) . build ( ) ; }
default possible date time format
34,625
private static ImmutableMap < System , ImmutableList < DateTimeFormatter > > buildDateTimeFormatterMap ( ) { return ImmutableMap . of ( DEFAULT , ImmutableList . < DateTimeFormatter > builder ( ) . addAll ( defaultDateTimeFormatter ) . build ( ) , ORACLE , ImmutableList . < DateTimeFormatter > builder ( ) . addAll ( defaultDateTimeFormatter ) . add ( new DateTimeFormatterBuilder ( ) . parseCaseInsensitive ( ) . appendPattern ( "dd-MMM-yy[ hh[.][:]mm[.][:]ss[.][,][n][ a][ ZZZZZ][ VV]]" ) . toFormatter ( ) ) . add ( new DateTimeFormatterBuilder ( ) . parseCaseInsensitive ( ) . appendPattern ( "dd-MMM-yy[ HH[.][:]mm[.][:]ss[.][,][n][ ZZZZZ][ VV]]" ) . toFormatter ( ) ) . build ( ) , MSSQL , ImmutableList . < DateTimeFormatter > builder ( ) . addAll ( defaultDateTimeFormatter ) . add ( new DateTimeFormatterBuilder ( ) . parseCaseInsensitive ( ) . appendPattern ( "MMM dd yyyy[ hh:mm[a]]" ) . toFormatter ( ) ) . build ( ) ) ; }
special cases on different systems
34,626
public < R extends OBDAResultSet > R execute ( InputQuery < R > inputQuery ) throws OntopConnectionException , OntopReformulationException , OntopQueryEvaluationException , OntopResultConversionException { if ( inputQuery instanceof SelectQuery ) { return ( R ) executeInThread ( ( SelectQuery ) inputQuery , this :: executeSelectQuery ) ; } else if ( inputQuery instanceof AskQuery ) { return ( R ) executeInThread ( ( AskQuery ) inputQuery , this :: executeBooleanQuery ) ; } else if ( inputQuery instanceof ConstructQuery ) { return ( R ) executeInThread ( ( ConstructQuery ) inputQuery , this :: executeConstructQuery ) ; } else if ( inputQuery instanceof DescribeQuery ) { return ( R ) executeDescribeQuery ( ( DescribeQuery ) inputQuery ) ; } else { throw new OntopUnsupportedInputQueryException ( "Unsupported query type: " + inputQuery ) ; } }
Calls the necessary tuple or graph query execution Implements describe uri or var logic Returns the result set for the given query
34,627
private < R extends OBDAResultSet , Q extends InputQuery < R > > R executeInThread ( Q inputQuery , Evaluator < R , Q > evaluator ) throws OntopReformulationException , OntopQueryEvaluationException { log . debug ( "Executing SPARQL query: \n{}" , inputQuery ) ; CountDownLatch monitor = new CountDownLatch ( 1 ) ; ExecutableQuery executableQuery = engine . reformulateIntoNativeQuery ( inputQuery ) ; QueryExecutionThread < R , Q > executionthread = new QueryExecutionThread < > ( inputQuery , executableQuery , evaluator , monitor ) ; this . executionThread = executionthread ; executionthread . start ( ) ; try { monitor . await ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } if ( executionthread . errorStatus ( ) ) { Exception ex = executionthread . getException ( ) ; if ( ex instanceof OntopReformulationException ) { throw ( OntopReformulationException ) ex ; } else if ( ex instanceof OntopQueryEvaluationException ) { throw ( OntopQueryEvaluationException ) ex ; } else { throw new OntopQueryEvaluationException ( ex ) ; } } if ( canceled ) { canceled = false ; throw new OntopQueryEvaluationException ( "Query execution was cancelled" ) ; } return executionthread . getResultSet ( ) ; }
Internal method to start a new query execution thread type defines the query type SELECT ASK CONSTRUCT or DESCRIBE
34,628
private boolean isAbsent ( QuotedID attribute ) { ImmutableSet < RelationID > occurrences = attributeOccurrences . get ( attribute ) ; return ( occurrences == null ) || occurrences . isEmpty ( ) ; }
checks if the attributeOccurrences contains the attribute
34,629
private static ImmutableSet < RelationID > attributeOccurrencesUnion ( QuotedID id , RAExpressionAttributes re1 , RAExpressionAttributes re2 ) { ImmutableSet < RelationID > s1 = re1 . attributeOccurrences . get ( id ) ; ImmutableSet < RelationID > s2 = re2 . attributeOccurrences . get ( id ) ; if ( s1 == null ) return s2 ; if ( s2 == null ) return s1 ; return ImmutableSet . < RelationID > builder ( ) . addAll ( s1 ) . addAll ( s2 ) . build ( ) ; }
treats null values as empty sets
34,630
private static void checkRelationAliasesConsistency ( RAExpressionAttributes re1 , RAExpressionAttributes re2 ) throws IllegalJoinException { ImmutableSet < RelationID > alias1 = re1 . attributes . keySet ( ) . stream ( ) . filter ( id -> id . getRelation ( ) != null ) . map ( QualifiedAttributeID :: getRelation ) . collect ( ImmutableCollectors . toSet ( ) ) ; ImmutableSet < RelationID > alias2 = re2 . attributes . keySet ( ) . stream ( ) . filter ( id -> id . getRelation ( ) != null ) . map ( QualifiedAttributeID :: getRelation ) . collect ( ImmutableCollectors . toSet ( ) ) ; if ( alias1 . stream ( ) . anyMatch ( alias2 :: contains ) ) throw new IllegalJoinException ( re1 , re2 , "Relation alias " + alias1 . stream ( ) . filter ( alias2 :: contains ) . collect ( ImmutableCollectors . toList ( ) ) + " occurs in both arguments of the JOIN" ) ; }
throw IllegalJoinException if a relation alias occurs in both arguments of the join
34,631
private ImmutableMultimap < RelationDefinition , ExtensionalDataNode > extractDataNodeMap ( IntermediateQuery query , InnerJoinNode joinNode ) { return query . getChildren ( joinNode ) . stream ( ) . filter ( c -> c instanceof ExtensionalDataNode ) . map ( c -> ( ExtensionalDataNode ) c ) . map ( c -> Maps . immutableEntry ( c . getProjectionAtom ( ) . getPredicate ( ) . getRelationDefinition ( ) , c ) ) . collect ( ImmutableCollectors . toMultimap ( ) ) ; }
Predicates not having a DatabaseRelationDefinition are ignored
34,632
private Collection < TreeWitnessGenerator > getTreeWitnessGenerators ( QueryFolding qf ) { Collection < TreeWitnessGenerator > twg = null ; log . debug ( "CHECKING WHETHER THE FOLDING {} CAN BE GENERATED: " , qf ) ; for ( TreeWitnessGenerator g : allTWgenerators ) { Intersection < ObjectPropertyExpression > subp = qf . getProperties ( ) ; if ( ! subp . subsumes ( g . getProperty ( ) ) ) { log . debug ( " NEGATIVE PROPERTY CHECK {}" , g . getProperty ( ) ) ; continue ; } else log . debug ( " POSITIVE PROPERTY CHECK {}" , g . getProperty ( ) ) ; Intersection < ClassExpression > subc = qf . getInternalRootConcepts ( ) ; if ( ! g . endPointEntailsAnyOf ( subc ) ) { log . debug ( " ENDTYPE TOO SPECIFIC: {} FOR {}" , subc , g ) ; continue ; } else log . debug ( " ENDTYPE IS FINE: TOP FOR {}" , g ) ; boolean failed = false ; for ( TreeWitness tw : qf . getInteriorTreeWitnesses ( ) ) if ( ! g . endPointEntailsAnyOf ( tw . getGeneratorSubConcepts ( ) ) ) { log . debug ( " ENDTYPE TOO SPECIFIC: {} FOR {}" , tw , g ) ; failed = true ; break ; } else log . debug ( " ENDTYPE IS FINE: {} FOR {}" , tw , g ) ; if ( failed ) continue ; if ( twg == null ) twg = new LinkedList < > ( ) ; twg . add ( g ) ; log . debug ( " OK" ) ; } return twg ; }
can return null if there are no applicable generators!
34,633
Optional < Boolean > getBoolean ( String key ) { Object value = get ( key ) ; if ( value == null ) { return Optional . empty ( ) ; } if ( value instanceof Boolean ) { return Optional . of ( ( Boolean ) value ) ; } else if ( value instanceof String ) { return Optional . of ( Boolean . parseBoolean ( ( String ) value ) ) ; } else { throw new InvalidOntopConfigurationException ( "A boolean was expected: " + value ) ; } }
Returns the boolean value of the given key .
34,634
Optional < Integer > getInteger ( String key ) { String value = ( String ) get ( key ) ; return Optional . ofNullable ( Integer . parseInt ( value ) ) ; }
Returns the integer value of the given key .
34,635
void put ( String subject , String predicate , String object ) { ArrayList < String > predicateList = subjectToPredicates . get ( subject ) ; if ( predicateList == null ) { predicateList = new ArrayList < String > ( ) ; } insert ( predicateList , predicate ) ; subjectToPredicates . put ( subject , predicateList ) ; ArrayList < String > objectList = predicateToObjects . get ( predicate + "_" + subject ) ; if ( objectList == null ) { objectList = new ArrayList < String > ( ) ; } objectList . add ( object ) ; predicateToObjects . put ( predicate + "_" + subject , objectList ) ; }
Adding the subject predicate and object components to this container .
34,636
private void insert ( ArrayList < String > list , String input ) { if ( ! list . contains ( input ) ) { if ( input . equals ( "a" ) || input . equals ( "rdf:type" ) ) { list . add ( 0 , input ) ; } else { list . add ( input ) ; } } }
Utility method to insert the predicate
34,637
String print ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( String subject : subjectToPredicates . keySet ( ) ) { sb . append ( subject ) ; sb . append ( " " ) ; boolean semiColonSeparator = false ; for ( String predicate : subjectToPredicates . get ( subject ) ) { if ( semiColonSeparator ) { sb . append ( " ; " ) ; } sb . append ( predicate ) ; sb . append ( " " ) ; semiColonSeparator = true ; boolean commaSeparator = false ; for ( String object : predicateToObjects . get ( predicate + "_" + subject ) ) { if ( commaSeparator ) { sb . append ( " , " ) ; } sb . append ( object ) ; commaSeparator = true ; } } sb . append ( " " ) ; sb . append ( "." ) ; sb . append ( " " ) ; } return sb . toString ( ) ; }
Prints the container .
34,638
protected IntermediateQuery buildQuery ( DBMetadata metadata , DistinctVariableOnlyDataAtom projectionAtom , QueryTreeComponent treeComponent ) { return new IntermediateQueryImpl ( metadata , projectionAtom , treeComponent , executorRegistry , validator , settings , iqFactory ) ; }
Can be overwritten to use another constructor
34,639
protected AscendingSubstitutionNormalization normalizeAscendingSubstitution ( ImmutableSubstitution < ImmutableTerm > ascendingSubstitution , ImmutableSet < Variable > projectedVariables ) { Var2VarSubstitution downRenamingSubstitution = substitutionFactory . getVar2VarSubstitution ( ascendingSubstitution . getImmutableMap ( ) . entrySet ( ) . stream ( ) . filter ( e -> e . getValue ( ) instanceof Variable ) . map ( e -> Maps . immutableEntry ( e . getKey ( ) , ( Variable ) e . getValue ( ) ) ) . filter ( e -> ! projectedVariables . contains ( e . getValue ( ) ) ) . collect ( ImmutableCollectors . toMap ( Map . Entry :: getValue , Map . Entry :: getKey , ( v1 , v2 ) -> v1 ) ) ) ; ImmutableSubstitution < ImmutableTerm > newAscendingSubstitution = downRenamingSubstitution . composeWith ( ascendingSubstitution ) . reduceDomainToIntersectionWith ( projectedVariables ) . normalizeValues ( ) ; return new AscendingSubstitutionNormalization ( newAscendingSubstitution , downRenamingSubstitution , projectedVariables ) ; }
Prevents creating construction nodes out of ascending substitutions
34,640
private TermType getCommonDenominator ( LanguageTag otherLanguageTag ) { return langTag . getCommonDenominator ( otherLanguageTag ) . map ( newLangTag -> newLangTag . equals ( langTag ) ? ( TermType ) this : new LangDatatype ( newLangTag , parentAncestry , typeFactory ) ) . orElseGet ( typeFactory :: getXsdStringDatatype ) ; }
Common denominator between two lang strings
34,641
public DatalogProgram translate ( IQ initialQuery ) { IQ orderLiftedQuery = liftOrderBy ( initialQuery ) ; Optional < MutableQueryModifiers > optionalModifiers = extractTopQueryModifiers ( orderLiftedQuery ) ; DatalogProgram dProgram ; if ( optionalModifiers . isPresent ( ) ) { MutableQueryModifiers mutableModifiers = optionalModifiers . get ( ) ; dProgram = datalogFactory . getDatalogProgram ( mutableModifiers ) ; } else { dProgram = datalogFactory . getDatalogProgram ( ) ; } normalizeIQ ( orderLiftedQuery ) . forEach ( q -> translate ( q , dProgram ) ) ; dProgram . getRules ( ) . forEach ( q -> unfoldJoinTrees ( q . getBody ( ) ) ) ; return dProgram ; }
Translate an intermediate query tree into a Datalog program .
34,642
private Optional < MutableQueryModifiers > extractTopQueryModifiers ( IQ query ) { IQTree tree = query . getTree ( ) ; QueryNode rootNode = tree . getRootNode ( ) ; if ( rootNode instanceof QueryModifierNode ) { Optional < SliceNode > sliceNode = Optional . of ( rootNode ) . filter ( n -> n instanceof SliceNode ) . map ( n -> ( SliceNode ) n ) ; IQTree firstNonSliceTree = sliceNode . map ( n -> ( ( UnaryIQTree ) tree ) . getChild ( ) ) . orElse ( tree ) ; Optional < DistinctNode > distinctNode = Optional . of ( firstNonSliceTree ) . map ( IQTree :: getRootNode ) . filter ( n -> n instanceof DistinctNode ) . map ( n -> ( DistinctNode ) n ) ; IQTree firstNonSliceDistinctTree = distinctNode . map ( n -> ( ( UnaryIQTree ) firstNonSliceTree ) . getChild ( ) ) . orElse ( firstNonSliceTree ) ; Optional < OrderByNode > orderByNode = Optional . of ( firstNonSliceDistinctTree ) . map ( IQTree :: getRootNode ) . filter ( n -> n instanceof OrderByNode ) . map ( n -> ( OrderByNode ) n ) ; MutableQueryModifiers mutableQueryModifiers = new MutableQueryModifiersImpl ( ) ; sliceNode . ifPresent ( n -> { n . getLimit ( ) . ifPresent ( mutableQueryModifiers :: setLimit ) ; long offset = n . getOffset ( ) ; if ( offset > 0 ) mutableQueryModifiers . setOffset ( offset ) ; } ) ; if ( distinctNode . isPresent ( ) ) mutableQueryModifiers . setDistinct ( ) ; orderByNode . ifPresent ( n -> n . getComparators ( ) . forEach ( c -> convertOrderComparator ( c , mutableQueryModifiers ) ) ) ; return Optional . of ( mutableQueryModifiers ) ; } else return Optional . empty ( ) ; }
Assumes that ORDER BY is ABOVE the first construction node and the order between these operators is respected and they appear ONE time maximum
34,643
private IQTree getFirstNonQueryModifierTree ( IQ query ) { IQTree iqTree = query . getTree ( ) ; while ( iqTree . getRootNode ( ) instanceof QueryModifierNode ) { iqTree = ( ( UnaryIQTree ) iqTree ) . getChild ( ) ; } return iqTree ; }
Assumes that ORDER BY is ABOVE the first construction node
34,644
public ImmutableList < TargetAtom > parse ( String input ) throws TargetQueryParserException { StringBuffer bf = new StringBuffer ( input . trim ( ) ) ; if ( ! bf . substring ( bf . length ( ) - 2 , bf . length ( ) ) . equals ( " ." ) ) { bf . insert ( bf . length ( ) - 1 , ' ' ) ; } if ( ! prefixes . isEmpty ( ) ) { appendDirectives ( bf ) ; } try { CharStream inputStream = CharStreams . fromString ( bf . toString ( ) ) ; TurtleOBDALexer lexer = new TurtleOBDALexer ( inputStream ) ; lexer . removeErrorListeners ( ) ; lexer . addErrorListener ( ThrowingErrorListener . INSTANCE ) ; CommonTokenStream tokenStream = new CommonTokenStream ( lexer ) ; TurtleOBDAParser parser = new TurtleOBDAParser ( tokenStream ) ; parser . removeErrorListeners ( ) ; parser . addErrorListener ( ThrowingErrorListener . INSTANCE ) ; return ( ImmutableList < TargetAtom > ) visitor . visitParse ( parser . parse ( ) ) ; } catch ( RuntimeException e ) { throw new TargetQueryParserException ( e . getMessage ( ) , e ) ; } }
Returns the CQIE object from the input string . If the input prefix manager is null then no directive header will be appended .
34,645
private void appendDirectives ( StringBuffer query ) { StringBuffer sb = new StringBuffer ( ) ; for ( String prefix : prefixes . keySet ( ) ) { sb . append ( "@PREFIX" ) ; sb . append ( " " ) ; sb . append ( prefix ) ; sb . append ( " " ) ; sb . append ( "<" ) ; sb . append ( prefixes . get ( prefix ) ) ; sb . append ( ">" ) ; sb . append ( " .\n" ) ; } sb . append ( "@PREFIX " + OntopInternal . PREFIX_XSD + " <" + XSD . PREFIX + "> .\n" ) ; sb . append ( "@PREFIX " + OntopInternal . PREFIX_OBDA + " <" + Ontop . PREFIX + "> .\n" ) ; sb . append ( "@PREFIX " + OntopInternal . PREFIX_RDF + " <" + RDF . PREFIX + "> .\n" ) ; sb . append ( "@PREFIX " + OntopInternal . PREFIX_RDFS + " <" + RDFS . PREFIX + "> .\n" ) ; sb . append ( "@PREFIX " + OntopInternal . PREFIX_OWL + " <" + OWL . PREFIX + "> .\n" ) ; query . insert ( 0 , sb ) ; }
The turtle syntax predefines the quest rdf rdfs and owl prefixes .
34,646
private List < TreeModelFilter < SQLPPTriplesMap > > parseSearchString ( String textToParse ) throws Exception { List < TreeModelFilter < SQLPPTriplesMap > > listOfFilters = null ; if ( textToParse != null ) { ANTLRStringStream inputStream = new ANTLRStringStream ( textToParse ) ; MappingFilterLexer lexer = new MappingFilterLexer ( inputStream ) ; CommonTokenStream tokenStream = new CommonTokenStream ( lexer ) ; MappingFilterParser parser = new MappingFilterParser ( tokenStream ) ; listOfFilters = parser . parse ( ) ; if ( parser . getNumberOfSyntaxErrors ( ) != 0 ) { throw new Exception ( "Syntax Error: The filter string invalid" ) ; } } return listOfFilters ; }
Parses the string in the search field .
34,647
private void applyFilters ( List < TreeModelFilter < SQLPPTriplesMap > > filters ) { FilteredModel model = ( FilteredModel ) mappingList . getModel ( ) ; model . removeAllFilters ( ) ; model . addFilters ( filters ) ; }
This function add the list of current filters to the model and then the Tree is refreshed shows the mappings after the filters have been applied .
34,648
public Builder add ( Attribute attribute ) { if ( relation != attribute . getRelation ( ) ) throw new IllegalArgumentException ( "Unique Key requires the same table in all attributes: " + relation + " " + attribute ) ; builder . add ( attribute ) ; return this ; }
adds an attribute to the UNIQUE constraint
34,649
public ImmutableSet < ImmutableSubstitution < NonVariableTerm > > getPossibleVariableDefinitions ( IQTree leftChild , IQTree rightChild ) { ImmutableSet < ImmutableSubstitution < NonVariableTerm > > leftDefs = leftChild . getPossibleVariableDefinitions ( ) ; ImmutableSet < Variable > rightSpecificVariables = Sets . difference ( rightChild . getVariables ( ) , leftChild . getVariables ( ) ) . immutableCopy ( ) ; ImmutableSet < ImmutableSubstitution < NonVariableTerm > > rightDefs = leftChild . getPossibleVariableDefinitions ( ) . stream ( ) . map ( s -> s . reduceDomainToIntersectionWith ( rightSpecificVariables ) ) . collect ( ImmutableCollectors . toSet ( ) ) ; if ( leftDefs . isEmpty ( ) ) return rightDefs ; else if ( rightDefs . isEmpty ( ) ) return leftDefs ; else return leftDefs . stream ( ) . flatMap ( l -> rightDefs . stream ( ) . map ( r -> combine ( l , r ) ) ) . collect ( ImmutableCollectors . toSet ( ) ) ; }
Returns possible definitions for left and right - specific variables .
34,650
private ImmutableSubstitution < NonFunctionalTerm > selectDownSubstitution ( ImmutableSubstitution < NonFunctionalTerm > simplificationSubstitution , ImmutableSet < Variable > rightVariables ) { ImmutableMap < Variable , NonFunctionalTerm > newMap = simplificationSubstitution . getImmutableMap ( ) . entrySet ( ) . stream ( ) . filter ( e -> rightVariables . contains ( e . getKey ( ) ) ) . collect ( ImmutableCollectors . toMap ( ) ) ; return substitutionFactory . getSubstitution ( newMap ) ; }
Selects the entries that can be applied to the right child .
34,651
private boolean containsEqualityRightSpecificVariable ( ImmutableSubstitution < ? extends VariableOrGroundTerm > descendingSubstitution , IQTree leftChild , IQTree rightChild ) { ImmutableSet < Variable > leftVariables = leftChild . getVariables ( ) ; ImmutableSet < Variable > rightVariables = rightChild . getVariables ( ) ; ImmutableSet < Variable > domain = descendingSubstitution . getDomain ( ) ; ImmutableCollection < ? extends VariableOrGroundTerm > range = descendingSubstitution . getImmutableMap ( ) . values ( ) ; return rightVariables . stream ( ) . filter ( v -> ! leftVariables . contains ( v ) ) . anyMatch ( v -> ( domain . contains ( v ) && ( ! isFreshVariable ( descendingSubstitution . get ( v ) , leftVariables , rightVariables ) ) ) || range . contains ( v ) ) ; }
Returns true when an equality between a right - specific and a term that is not a fresh variable is propagated down through a substitution .
34,652
private IQTree liftChildConstructionNode ( ConstructionNode newChildRoot , UnaryIQTree newChild , IQProperties liftedProperties ) { UnaryIQTree newOrderByTree = iqFactory . createUnaryIQTree ( applySubstitution ( newChildRoot . getSubstitution ( ) ) , newChild . getChild ( ) , liftedProperties ) ; return iqFactory . createUnaryIQTree ( newChildRoot , newOrderByTree , liftedProperties ) ; }
Lifts the construction node above and updates the order comparators
34,653
private IntermediateQuery pushAboveUnions ( IntermediateQuery query ) throws EmptyQueryException { boolean fixPointReached ; do { fixPointReached = true ; for ( QueryNode node : query . getNodesInTopDownOrder ( ) ) { if ( node instanceof UnionNode ) { Optional < PushUpBooleanExpressionProposal > proposal = makeProposalForUnionNode ( ( UnionNode ) node , query ) ; if ( proposal . isPresent ( ) ) { query = ( ( PushUpBooleanExpressionResults ) query . applyProposal ( proposal . get ( ) ) ) . getResultingQuery ( ) ; fixPointReached = false ; } } } } while ( ! fixPointReached ) ; return query ; }
Can be optimized by reducing after each iteration the set of union nodes to be reviewed
34,654
private ImmutableSet < ImmutableExpression > getExpressionsToPropagateAboveUnion ( ImmutableSet < CommutativeJoinOrFilterNode > providers ) { return providers . stream ( ) . map ( n -> n . getOptionalFilterCondition ( ) . get ( ) . flattenAND ( ) ) . reduce ( this :: computeIntersection ) . get ( ) ; }
Returns the boolean conjuncts shared by all providers .
34,655
private Optional < PushUpBooleanExpressionProposal > adjustProposal ( PushUpBooleanExpressionProposal proposal , IntermediateQuery query ) { QueryNode currentNode = proposal . getUpMostPropagatingNode ( ) ; Optional < QueryNode > optChild ; ImmutableSet . Builder < ExplicitVariableProjectionNode > removedProjectors = ImmutableSet . builder ( ) ; while ( ( optChild = query . getFirstChild ( currentNode ) ) . isPresent ( ) ) { if ( currentNode instanceof ConstructionNode || currentNode instanceof QueryModifierNode ) { if ( currentNode instanceof ConstructionNode ) { removedProjectors . add ( ( ConstructionNode ) currentNode ) ; } currentNode = optChild . get ( ) ; continue ; } break ; } if ( proposal . getProvider2NonPropagatedExpressionMap ( ) . keySet ( ) . contains ( currentNode ) ) { return Optional . empty ( ) ; } QueryNode upMostPropagatingNode = currentNode ; Optional < JoinOrFilterNode > recipient = currentNode instanceof CommutativeJoinOrFilterNode ? Optional . of ( ( JoinOrFilterNode ) currentNode ) : Optional . empty ( ) ; ImmutableSet < ExplicitVariableProjectionNode > inbetweenProjectors = computeDifference ( proposal . getInbetweenProjectors ( ) , removedProjectors . build ( ) ) ; return Optional . of ( new PushUpBooleanExpressionProposalImpl ( proposal . getPropagatedExpression ( ) , proposal . getProvider2NonPropagatedExpressionMap ( ) , upMostPropagatingNode , recipient , inbetweenProjectors ) ) ; }
If the expression was blocked by a union or the root of the query
34,656
private static void checkDuplicates ( ImmutableList < SQLPPTriplesMap > mappings ) throws DuplicateMappingException { Set < SQLPPTriplesMap > mappingSet = new HashSet < > ( mappings ) ; int duplicateCount = mappings . size ( ) - mappingSet . size ( ) ; if ( duplicateCount > 0 ) { Set < String > duplicateIds = new HashSet < > ( ) ; int remaining = duplicateCount ; for ( SQLPPTriplesMap mapping : mappings ) { if ( mappingSet . contains ( mapping ) ) { mappingSet . remove ( mapping ) ; } else { duplicateIds . add ( mapping . getId ( ) ) ; if ( -- remaining == 0 ) break ; } } throw new DuplicateMappingException ( String . format ( "Found %d duplicates in the following ids: %s" , duplicateCount , duplicateIds . toString ( ) ) ) ; } }
No mapping should be duplicate among all the data sources .
34,657
private Optional < ConcreteProposal > propose ( InnerJoinNode joinNode , ImmutableMultimap < RelationPredicate , ExtensionalDataNode > initialDataNodeMap , ImmutableList < Variable > priorityVariables , IntermediateQuery query , DBMetadata dbMetadata ) throws AtomUnificationException { ImmutableList . Builder < PredicateLevelProposal > proposalListBuilder = ImmutableList . builder ( ) ; for ( RelationPredicate predicate : initialDataNodeMap . keySet ( ) ) { ImmutableCollection < ExtensionalDataNode > initialNodes = initialDataNodeMap . get ( predicate ) ; Optional < PredicateLevelProposal > predicateProposal = proposePerPredicate ( joinNode , initialNodes , predicate , dbMetadata , priorityVariables , query ) ; predicateProposal . ifPresent ( proposalListBuilder :: add ) ; } return createConcreteProposal ( proposalListBuilder . build ( ) , priorityVariables ) ; }
Throws an AtomUnificationException when the results are guaranteed to be empty
34,658
private NodeCentricOptimizationResults < InnerJoinNode > applyOptimization ( IntermediateQuery query , QueryTreeComponent treeComponent , InnerJoinNode topJoinNode , ConcreteProposal proposal ) throws EmptyQueryException { proposal . getDataNodesToRemove ( ) . forEach ( treeComponent :: removeSubTree ) ; return updateJoinNodeAndPropagateSubstitution ( query , treeComponent , topJoinNode , proposal ) ; }
Assumes that the data atoms are leafs .
34,659
public void addValidator ( com . andreabaccega . formedittextvalidator . Validator theValidator ) throws IllegalArgumentException { editTextValidator . addValidator ( theValidator ) ; }
Add a validator to this AutoCompleteTextView . The validator will be added in the queue of the current validators .
34,660
public boolean onKeyPreIme ( int keyCode , KeyEvent event ) { if ( TextUtils . isEmpty ( getText ( ) . toString ( ) ) && keyCode == KeyEvent . KEYCODE_DEL ) return true ; else return super . onKeyPreIme ( keyCode , event ) ; }
Don t send delete key so edit text doesn t capture it and close error
34,661
private void showErrorIconHax ( Drawable icon ) { if ( icon == null ) return ; if ( android . os . Build . VERSION . SDK_INT != Build . VERSION_CODES . JELLY_BEAN && android . os . Build . VERSION . SDK_INT != Build . VERSION_CODES . JELLY_BEAN_MR1 ) return ; try { Class < ? > textview = Class . forName ( "android.widget.TextView" ) ; Field tEditor = textview . getDeclaredField ( "mEditor" ) ; tEditor . setAccessible ( true ) ; Class < ? > editor = Class . forName ( "android.widget.Editor" ) ; Method privateShowError = editor . getDeclaredMethod ( "setErrorIcon" , Drawable . class ) ; privateShowError . setAccessible ( true ) ; privateShowError . invoke ( tEditor . get ( this ) , icon ) ; } catch ( Exception e ) { } }
Use reflection to force the error icon to show . Dirty but resolves the issue in 4 . 2
34,662
private static boolean isXLargeTablet ( Context context ) { return ( context . getResources ( ) . getConfiguration ( ) . screenLayout & Configuration . SCREENLAYOUT_SIZE_MASK ) >= Configuration . SCREENLAYOUT_SIZE_XLARGE ; }
Helper method to determine if the device has an extra - large screen . For example 10 tablets are extra - large .
34,663
public static SampleFetcher fetcher ( final String pathAssistantSid , final String pathTaskSid , final String pathSid ) { return new SampleFetcher ( pathAssistantSid , pathTaskSid , pathSid ) ; }
Create a SampleFetcher to execute fetch .
34,664
public static SampleCreator creator ( final String pathAssistantSid , final String pathTaskSid , final String language , final String taggedText ) { return new SampleCreator ( pathAssistantSid , pathTaskSid , language , taggedText ) ; }
Create a SampleCreator to execute create .
34,665
public static SampleUpdater updater ( final String pathAssistantSid , final String pathTaskSid , final String pathSid ) { return new SampleUpdater ( pathAssistantSid , pathTaskSid , pathSid ) ; }
Create a SampleUpdater to execute update .
34,666
public static SampleDeleter deleter ( final String pathAssistantSid , final String pathTaskSid , final String pathSid ) { return new SampleDeleter ( pathAssistantSid , pathTaskSid , pathSid ) ; }
Create a SampleDeleter to execute delete .
34,667
public static MemberCreator creator ( final String pathServiceSid , final String pathChannelSid , final String identity ) { return new MemberCreator ( pathServiceSid , pathChannelSid , identity ) ; }
Create a MemberCreator to execute create .
34,668
public static MemberDeleter deleter ( final String pathServiceSid , final String pathChannelSid , final String pathSid ) { return new MemberDeleter ( pathServiceSid , pathChannelSid , pathSid ) ; }
Create a MemberDeleter to execute delete .
34,669
public static StreamMessageCreator creator ( final String pathServiceSid , final String pathStreamSid , final Map < String , Object > data ) { return new StreamMessageCreator ( pathServiceSid , pathStreamSid , data ) ; }
Create a StreamMessageCreator to execute create .
34,670
public static CredentialListUpdater updater ( final String pathAccountSid , final String pathSid , final String friendlyName ) { return new CredentialListUpdater ( pathAccountSid , pathSid , friendlyName ) ; }
Create a CredentialListUpdater to execute update .
34,671
public static WorkerChannelFetcher fetcher ( final String pathWorkspaceSid , final String pathWorkerSid , final String pathSid ) { return new WorkerChannelFetcher ( pathWorkspaceSid , pathWorkerSid , pathSid ) ; }
Create a WorkerChannelFetcher to execute fetch .
34,672
public static WorkerChannelUpdater updater ( final String pathWorkspaceSid , final String pathWorkerSid , final String pathSid ) { return new WorkerChannelUpdater ( pathWorkspaceSid , pathWorkerSid , pathSid ) ; }
Create a WorkerChannelUpdater to execute update .
34,673
public static MessageFetcher fetcher ( final String pathServiceSid , final String pathChannelSid , final String pathSid ) { return new MessageFetcher ( pathServiceSid , pathChannelSid , pathSid ) ; }
Create a MessageFetcher to execute fetch .
34,674
public static MessageDeleter deleter ( final String pathServiceSid , final String pathChannelSid , final String pathSid ) { return new MessageDeleter ( pathServiceSid , pathChannelSid , pathSid ) ; }
Create a MessageDeleter to execute delete .
34,675
public static FlexFlowCreator creator ( final String friendlyName , final String chatServiceSid , final FlexFlow . ChannelType channelType ) { return new FlexFlowCreator ( friendlyName , chatServiceSid , channelType ) ; }
Create a FlexFlowCreator to execute create .
34,676
public static AuthCallsCredentialListMappingCreator creator ( final String pathAccountSid , final String pathDomainSid , final String credentialListSid ) { return new AuthCallsCredentialListMappingCreator ( pathAccountSid , pathDomainSid , credentialListSid ) ; }
Create a AuthCallsCredentialListMappingCreator to execute create .
34,677
public static AuthCallsCredentialListMappingFetcher fetcher ( final String pathAccountSid , final String pathDomainSid , final String pathSid ) { return new AuthCallsCredentialListMappingFetcher ( pathAccountSid , pathDomainSid , pathSid ) ; }
Create a AuthCallsCredentialListMappingFetcher to execute fetch .
34,678
public static AuthCallsCredentialListMappingDeleter deleter ( final String pathAccountSid , final String pathDomainSid , final String pathSid ) { return new AuthCallsCredentialListMappingDeleter ( pathAccountSid , pathDomainSid , pathSid ) ; }
Create a AuthCallsCredentialListMappingDeleter to execute delete .
34,679
public static UserBindingFetcher fetcher ( final String pathServiceSid , final String pathUserSid , final String pathSid ) { return new UserBindingFetcher ( pathServiceSid , pathUserSid , pathSid ) ; }
Create a UserBindingFetcher to execute fetch .
34,680
public static UserBindingDeleter deleter ( final String pathServiceSid , final String pathUserSid , final String pathSid ) { return new UserBindingDeleter ( pathServiceSid , pathUserSid , pathSid ) ; }
Create a UserBindingDeleter to execute delete .
34,681
public static ChallengeCreator creator ( final String pathServiceSid , final String pathIdentity , final String pathFactorSid ) { return new ChallengeCreator ( pathServiceSid , pathIdentity , pathFactorSid ) ; }
Create a ChallengeCreator to execute create .
34,682
public static ChallengeDeleter deleter ( final String pathServiceSid , final String pathIdentity , final String pathFactorSid , final String pathSid ) { return new ChallengeDeleter ( pathServiceSid , pathIdentity , pathFactorSid , pathSid ) ; }
Create a ChallengeDeleter to execute delete .
34,683
public static ChallengeFetcher fetcher ( final String pathServiceSid , final String pathIdentity , final String pathFactorSid , final String pathSid ) { return new ChallengeFetcher ( pathServiceSid , pathIdentity , pathFactorSid , pathSid ) ; }
Create a ChallengeFetcher to execute fetch .
34,684
public static ChallengeUpdater updater ( final String pathServiceSid , final String pathIdentity , final String pathFactorSid , final String pathSid ) { return new ChallengeUpdater ( pathServiceSid , pathIdentity , pathFactorSid , pathSid ) ; }
Create a ChallengeUpdater to execute update .
34,685
public static FeedbackSummaryCreator creator ( final String pathAccountSid , final LocalDate startDate , final LocalDate endDate ) { return new FeedbackSummaryCreator ( pathAccountSid , startDate , endDate ) ; }
Create a FeedbackSummaryCreator to execute create .
34,686
public static InviteFetcher fetcher ( final String pathServiceSid , final String pathChannelSid , final String pathSid ) { return new InviteFetcher ( pathServiceSid , pathChannelSid , pathSid ) ; }
Create a InviteFetcher to execute fetch .
34,687
public static InviteCreator creator ( final String pathServiceSid , final String pathChannelSid , final String identity ) { return new InviteCreator ( pathServiceSid , pathChannelSid , identity ) ; }
Create a InviteCreator to execute create .
34,688
public static InviteDeleter deleter ( final String pathServiceSid , final String pathChannelSid , final String pathSid ) { return new InviteDeleter ( pathServiceSid , pathChannelSid , pathSid ) ; }
Create a InviteDeleter to execute delete .
34,689
public Page < T > nextPage ( final Page < T > page ) { return nextPage ( page , Twilio . getRestClient ( ) ) ; }
Fetch the following page of resources .
34,690
public Page < T > previousPage ( final Page < T > page ) { return previousPage ( page , Twilio . getRestClient ( ) ) ; }
Fetch the prior page of resources .
34,691
public Reader < T > limit ( final long limit ) { this . limit = limit ; if ( this . pageSize == null ) { this . pageSize = ( new Long ( this . limit ) ) . intValue ( ) ; } return this ; }
Sets the max number of records to read .
34,692
public static Map < String , String > serialize ( Map < String , Object > map , String prefix ) { if ( map == null || map . isEmpty ( ) ) { return Collections . emptyMap ( ) ; } Map < String , String > flattened = flatten ( map , new HashMap < String , String > ( ) , new ArrayList < String > ( ) ) ; Map < String , String > result = new HashMap < > ( ) ; for ( Map . Entry < String , String > entry : flattened . entrySet ( ) ) { result . put ( prefix + "." + entry . getKey ( ) , entry . getValue ( ) ) ; } return result ; }
Flatten a Map of String Object into a Map of String String where keys are . separated and prepends a key .
34,693
public static ExecutionCreator creator ( final String pathFlowSid , final com . twilio . type . PhoneNumber to , final com . twilio . type . PhoneNumber from ) { return new ExecutionCreator ( pathFlowSid , to , from ) ; }
Create a ExecutionCreator to execute create .
34,694
public String create ( List < String > sortedIncludedHeaders , HashFunction hashFunction ) { StringBuilder canonicalRequest = new StringBuilder ( ) ; canonicalRequest . append ( method ) . append ( NEW_LINE ) ; String canonicalUri = CANONICALIZE_PATH . apply ( uri ) ; canonicalRequest . append ( canonicalUri ) . append ( NEW_LINE ) ; String canonicalQuery = CANONICALIZE_QUERY . apply ( queryString ) ; canonicalRequest . append ( canonicalQuery ) . append ( NEW_LINE ) ; Header [ ] normalizedHeaders = NORMALIZE_HEADERS . apply ( headers ) ; Map < String , List < String > > combinedHeaders = COMBINE_HEADERS . apply ( normalizedHeaders ) ; for ( String header : sortedIncludedHeaders ) { String lowercase = header . toLowerCase ( ) . trim ( ) ; if ( combinedHeaders . containsKey ( lowercase ) ) { List < String > values = combinedHeaders . get ( lowercase ) ; Collections . sort ( values ) ; canonicalRequest . append ( lowercase ) . append ( ":" ) . append ( Joiner . on ( ',' ) . join ( values ) ) . append ( NEW_LINE ) ; } } canonicalRequest . append ( NEW_LINE ) ; canonicalRequest . append ( Joiner . on ( ";" ) . join ( sortedIncludedHeaders ) ) . append ( NEW_LINE ) ; if ( ! Strings . isNullOrEmpty ( requestBody ) ) { String hashedPayload = hashFunction . hashString ( requestBody , Charsets . UTF_8 ) . toString ( ) ; canonicalRequest . append ( hashedPayload ) ; } return canonicalRequest . toString ( ) ; }
Creates a canonical request string out of HTTP request components .
34,695
private static String replace ( String string , boolean replaceSlash ) { if ( Strings . isNullOrEmpty ( string ) ) { return string ; } StringBuffer buffer = new StringBuffer ( string . length ( ) ) ; Matcher matcher = TOKEN_REPLACE_PATTERN . matcher ( string ) ; while ( matcher . find ( ) ) { String replacement = matcher . group ( 0 ) ; if ( "+" . equals ( replacement ) ) { replacement = "%20" ; } else if ( "*" . equals ( replacement ) ) { replacement = "%2A" ; } else if ( "%7E" . equals ( replacement ) ) { replacement = "~" ; } else if ( replaceSlash && "%2F" . equals ( replacement ) ) { replacement = "/" ; } matcher . appendReplacement ( buffer , replacement ) ; } matcher . appendTail ( buffer ) ; return buffer . toString ( ) ; }
Replaces the special characters in the URLEncoded string with the replacement values defined by the spec .
34,696
@ SuppressWarnings ( "checkstyle:linelength" ) public Page < AvailablePhoneNumberCountry > getPage ( final String targetUrl , final TwilioRestClient client ) { this . pathAccountSid = this . pathAccountSid == null ? client . getAccountSid ( ) : this . pathAccountSid ; Request request = new Request ( HttpMethod . GET , targetUrl ) ; return pageForRequest ( client , request ) ; }
Retrieve the target page from the Twilio API .
34,697
private Page < AvailablePhoneNumberCountry > pageForRequest ( final TwilioRestClient client , final Request request ) { Response response = client . request ( request ) ; if ( response == null ) { throw new ApiConnectionException ( "AvailablePhoneNumberCountry read failed: Unable to connect to server" ) ; } else if ( ! TwilioRestClient . SUCCESS . apply ( response . getStatusCode ( ) ) ) { RestException restException = RestException . fromJson ( response . getStream ( ) , client . getObjectMapper ( ) ) ; if ( restException == null ) { throw new ApiException ( "Server Error, no content" ) ; } throw new ApiException ( restException . getMessage ( ) , restException . getCode ( ) , restException . getMoreInfo ( ) , restException . getStatus ( ) , null ) ; } return Page . fromJson ( "countries" , response . getContent ( ) , AvailablePhoneNumberCountry . class , client . getObjectMapper ( ) ) ; }
Generate a Page of AvailablePhoneNumberCountry Resources for a given request .
34,698
public String getFirstPageUrl ( String domain , String region ) { if ( firstPageUrl != null ) { return firstPageUrl ; } return urlFromUri ( domain , region , firstPageUri ) ; }
Generate first page url for a list result .
34,699
public String getNextPageUrl ( String domain , String region ) { if ( nextPageUrl != null ) { return nextPageUrl ; } return urlFromUri ( domain , region , nextPageUri ) ; }
Generate next page url for a list result .