idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
19,100
public List < List < WF > > getSentences ( ) { return ( List < List < WF > > ) ( List < ? > ) annotationContainer . getSentences ( AnnotationType . WF ) ; }
Returns a list with all sentences . Each sentence is a list of WFs .
19,101
public List < Term > getTermsFromWFs ( List < String > wfIds ) { List < Term > terms = new ArrayList < Term > ( ) ; for ( String wfId : wfIds ) { terms . addAll ( this . wfId2Terms . get ( wfId ) ) ; } return terms ; }
Hau kendu behar da
19,102
public String createTimestamp ( ) { Date date = new Date ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ssZ" ) ; String formattedDate = sdf . format ( date ) ; return formattedDate ; }
Returns current timestamp .
19,103
static < T extends IdentifiableAnnotation > Span < T > list2Span ( List < T > list ) { Span < T > span = new Span < T > ( ) ; for ( T elem : list ) { span . addTarget ( elem ) ; } return span ; }
Converts a List into a Span
19,104
static Span < Term > targetList2Span ( List < Target > list ) { Span < Term > span = new Span < Term > ( ) ; for ( Target target : list ) { if ( target . isHead ( ) ) { span . addTarget ( target . getTerm ( ) , true ) ; } else { span . addTarget ( target . getTerm ( ) ) ; } } return span ; }
Converts a Target list into a Span of terms
19,105
static List < Target > span2TargetList ( Span < Term > span ) { List < Target > list = new ArrayList < Target > ( ) ; for ( Term t : span . getTargets ( ) ) { list . add ( KAFDocument . createTarget ( t , ( t == span . getHead ( ) ) ) ) ; } return list ; }
Converts a Span into a Target list
19,106
public static String findContentText ( final Node rootNode , final XPath xPath , final String expression ) { final Node node = findNode ( rootNode , xPath , expression ) ; if ( node == null ) { return null ; } return node . getTextContent ( ) ; }
Returns an string from a node s content .
19,107
public static Integer findContentInteger ( final Node rootNode , final XPath xPath , final String expression ) { final Node node = findNode ( rootNode , xPath , expression ) ; if ( node == null ) { return null ; } final String str = node . getTextContent ( ) ; return Integer . valueOf ( str ) ; }
Returns an integer value from a node s content .
19,108
public static Node findNode ( final Node rootNode , final XPath xPath , final String expression ) { Contract . requireArgNotNull ( "rootNode" , rootNode ) ; Contract . requireArgNotNull ( "xPath" , xPath ) ; Contract . requireArgNotNull ( "expression" , expression ) ; try { return ( Node ) xPath . compile ( expression ...
Returns a single node from a given document using xpath .
19,109
public static NodeList findNodes ( final Node rootNode , final XPath xPath , final String expression ) { Contract . requireArgNotNull ( "doc" , rootNode ) ; Contract . requireArgNotNull ( "xPath" , xPath ) ; Contract . requireArgNotNull ( "expression" , expression ) ; try { return ( NodeList ) xPath . compile ( express...
Returns a list of nodes from a given document using xpath .
19,110
public static Document parseDocument ( final DocumentBuilder builder , final InputStream inputStream ) { Contract . requireArgNotNull ( "builder" , builder ) ; Contract . requireArgNotNull ( "inputStream" , inputStream ) ; try { return builder . parse ( inputStream ) ; } catch ( final SAXException | IOException ex ) { ...
Parse the document and wraps checked exceptions into runtime exceptions .
19,111
public static XPath createXPath ( final String ... values ) { final NamespaceContext context = new NamespaceContextMap ( values ) ; final XPath xPath = XPathFactory . newInstance ( ) . newXPath ( ) ; xPath . setNamespaceContext ( context ) ; return xPath ; }
Creates a new XPath with a configured namespace context .
19,112
public static DocumentBuilder createDocumentBuilder ( ) { try { final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; return factory . newDocumentBuilder ( ) ; } catch ( final ParserConfigurationException ex ) { throw new RuntimeException ( "Couldn't cr...
Creates a namespace aware document builder .
19,113
private void reduceResults ( final List < AnalysisResultFuture > results , final Map < ComponentJob , AnalyzerResult > resultMap , final List < AnalysisResultReductionException > reductionErrors ) { if ( _hasRun . get ( ) ) { return ; } _hasRun . set ( true ) ; for ( AnalysisResultFuture result : results ) { if ( resul...
Reduces all the analyzer results of an analysis
19,114
@ SuppressWarnings ( "unchecked" ) private void reduce ( AnalyzerJob analyzerJob , Collection < AnalyzerResult > slaveResults , Map < ComponentJob , AnalyzerResult > resultMap , List < AnalysisResultReductionException > reductionErrors ) { if ( slaveResults . size ( ) == 1 ) { final AnalyzerResult firstResult = slaveRe...
Reduces result for a single analyzer
19,115
public Configuration unmarshall ( InputStream inputStream ) { try { final Unmarshaller unmarshaller = _jaxbContext . createUnmarshaller ( ) ; unmarshaller . setEventHandler ( new JaxbValidationEventHandler ( ) ) ; final Configuration configuration = ( Configuration ) unmarshaller . unmarshal ( inputStream ) ; return co...
Convenience method to get the untouched JAXB configuration object from an inputstream .
19,116
public void marshall ( Configuration configuration , OutputStream outputStream ) { try { final Marshaller marshaller = _jaxbContext . createMarshaller ( ) ; marshaller . setProperty ( Marshaller . JAXB_FORMATTED_OUTPUT , Boolean . TRUE ) ; marshaller . setEventHandler ( new JaxbValidationEventHandler ( ) ) ; marshaller...
Convenience method to marshal a JAXB configuration object into an output stream .
19,117
public static synchronized void createSource ( Java . _ClassBody clazz ) throws IOException { if ( baseDir == null ) { throw new IOException ( "Base directory for output not set, use 'setBaseDirectory'" ) ; } String pkg = clazz . getPackage ( ) ; if ( pkg == null ) { pkg = "" ; } pkg = pkg . replace ( '.' , '/' ) ; Fil...
Create the source file for a given class
19,118
private static void emitCommentIndentN ( PrintWriter fp , String text , int indent , boolean type ) { synchronized ( lock ) { String cc = type ? "/**" : "/*" ; fp . println ( cc ) ; String comment = emitCommentIndentNOnly ( fp , text , indent ) ; fp . println ( comment + "/" ) ; } }
Write a comment at some indentation level .
19,119
private static void emitFinishCommentIndentN ( PrintWriter fp , int indent ) { final String spaces = " " ; synchronized ( lock ) { String comment = spaces . substring ( 0 , indent ) + " */" ; fp . println ( comment ) ; } }
Finish a comment .
19,120
private static String emitCommentIndentNOnly ( PrintWriter fp , String text , int indent ) { synchronized ( lock ) { return ( emitCommentIndentNOnly ( fp , text , indent , true ) ) ; } }
Write a comment indent only .
19,121
public void create ( String outputdir , Program program ) { types . stream ( ) . forEach ( ( type ) -> type . createOutput ( outputdir , program ) ) ; }
Create the output .
19,122
protected boolean setConfiguredPropertyIfChanged ( final ConfiguredPropertyDescriptor configuredProperty , final Object value ) { if ( configuredProperty == null ) { throw new IllegalArgumentException ( "configuredProperty cannot be null" ) ; } final Object currentValue = configuredProperty . getValue ( _configurableBe...
Sets a configured property if it has changed .
19,123
public static < T > T deserialize ( final DeserializerRegistry registry , final SerializedData data ) { Contract . requireArgNotNull ( "registry" , registry ) ; Contract . requireArgNotNull ( "data" , data ) ; final Deserializer deserializer = registry . getDeserializer ( data . getType ( ) , data . getMimeType ( ) ) ;...
Tries to find a deserializer for the given data block .
19,124
public static EnhancedMimeType mimeType ( final SerializerRegistry registry , final List < CommonEvent > commonEvents ) { Contract . requireArgNotNull ( "registry" , registry ) ; Contract . requireArgNotNull ( "commonEvents" , commonEvents ) ; EnhancedMimeType mimeType = null ; for ( final CommonEvent commonEvent : com...
Returns the mime types shared by all events in the list .
19,125
public static boolean eventsEqual ( final List < CommonEvent > eventsA , final List < CommonEvent > eventsB ) { if ( ( eventsA == null ) && ( eventsB == null ) ) { return true ; } if ( ( eventsA == null ) && ( eventsB != null ) ) { return false ; } if ( ( eventsA != null ) && ( eventsB == null ) ) { return false ; } if...
Tests if both lists contain the same events .
19,126
public static String nodeToString ( final Node node ) { try { final Transformer t = TransformerFactory . newInstance ( ) . newTransformer ( ) ; t . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; final StringWriter sw = new StringWriter ( ) ; t . transform ( new DOMSource ( node ) , new StreamResult (...
Render a node as string .
19,127
public static JsonbDeserializer < ? > [ ] joinJsonbDeserializerArrays ( final JsonbDeserializer < ? > [ ] ... deserializerArrays ) { final List < JsonbDeserializer < ? > > all = joinArrays ( deserializerArrays ) ; return all . toArray ( new JsonbDeserializer < ? > [ all . size ( ) ] ) ; }
Creates all available JSON - B deserializers necessary for the ESC implementation .
19,128
public final CommonEvent convert ( final RecordedEvent eventData ) { final EnhancedMimeType escMetaMimeType = metaMimeType ( eventData . isJson ) ; final SerializedDataType escSerMetaType = new SerializedDataType ( EscMeta . TYPE . asBaseType ( ) ) ; final Deserializer escMetaDeserializer = deserRegistry . getDeseriali...
Converts event data into a common event .
19,129
public SortedSet < TimeInterval > getOverlappingIntervals ( boolean includeSingleTimeInstanceIntervals ) { SortedSet < TimeInterval > result = new TreeSet < TimeInterval > ( ) ; for ( TimeInterval interval1 : intervals ) { for ( TimeInterval interval2 : intervals ) { if ( interval1 != interval2 ) { TimeInterval overlap...
Gets a set of intervals representing the times where there are more than one interval overlaps .
19,130
public SortedSet < TimeInterval > getTimeGapIntervals ( ) { SortedSet < TimeInterval > flattenedIntervals = getFlattenedIntervals ( ) ; SortedSet < TimeInterval > gaps = new TreeSet < TimeInterval > ( ) ; TimeInterval previous = null ; for ( TimeInterval timeInterval : flattenedIntervals ) { if ( previous != null ) { l...
Gets a set of intervals representing the times that are NOT represented in this timeline .
19,131
public static byte [ ] decode ( char [ ] in , int iOff , int iLen ) { if ( iLen % 4 != 0 ) { throw new IllegalArgumentException ( "Length of Base64 encoded input string is not a multiple of 4." ) ; } while ( iLen > 0 && in [ iOff + iLen - 1 ] == '=' ) { iLen -- ; } int oLen = ( iLen * 3 ) / 4 ; byte [ ] out = new byte ...
Decodes a byte array from Base64 format . No blanks or line breaks are allowed within the Base64 encoded input data .
19,132
private String getPropertyKey ( ) { if ( StringUtils . isNullOrEmpty ( captureStateIdentifier ) ) { if ( lastModifiedColumn . isPhysicalColumn ( ) ) { Table table = lastModifiedColumn . getPhysicalColumn ( ) . getTable ( ) ; if ( table != null && ! StringUtils . isNullOrEmpty ( table . getName ( ) ) ) { return table . ...
Gets the key to use in the capture state file . If there is not a captureStateIdentifier available we want to avoid using a hardcoded key since the same file may be used for multiple purposes even multiple filters of the same type . Of course this is not desired configuration but may be more convenient for lazy users!
19,133
public static void addToScope ( Scriptable scope , Object object , String ... names ) { Object jsObject = Context . javaToJS ( object , scope ) ; for ( String name : names ) { name = name . replaceAll ( " " , "_" ) ; ScriptableObject . putProperty ( scope , name , jsObject ) ; } }
Adds an object to the JavaScript scope with a set of variable names
19,134
public static void addToScope ( Scriptable scope , InputRow inputRow , InputColumn < ? > [ ] columns , String arrayName ) { NativeArray values = new NativeArray ( columns . length * 2 ) ; for ( int i = 0 ; i < columns . length ; i ++ ) { InputColumn < ? > column = columns [ i ] ; Object value = inputRow . getValue ( co...
Adds the values of a row to the JavaScript scope
19,135
public final Charset getEncoding ( ) { final String parameter = getParameter ( ENCODING ) ; if ( parameter == null ) { return null ; } return Charset . forName ( parameter ) ; }
Returns the encoding from the parameters .
19,136
public final boolean matchEncoding ( final EnhancedMimeType other ) { return match ( other ) && Objects . equals ( getEncoding ( ) , other . getEncoding ( ) ) ; }
Determine if the primary sub type and encoding of this object is the same as what is in the given type .
19,137
public static EnhancedMimeType create ( final String str ) { if ( str == null ) { return null ; } try { return new EnhancedMimeType ( str ) ; } catch ( final MimeTypeParseException ex ) { throw new RuntimeException ( "Failed to create versioned mime type: " + str , ex ) ; } }
Creates an instance with all data . Exceptions are wrapped to runtime exceptions .
19,138
public static EnhancedMimeType create ( final String primary , final String sub , final Charset encoding , final String version ) { return create ( primary , sub , encoding , version , new HashMap < String , String > ( ) ) ; }
Creates an instance with primary sub type encoding and version . Exceptions are wrapped to runtime exceptions .
19,139
public static EnhancedMimeType create ( final String primary , final String sub , final Charset encoding , final String version , final Map < String , String > parameters ) { try { return new EnhancedMimeType ( primary , sub , encoding , version , parameters ) ; } catch ( final MimeTypeParseException ex ) { throw new R...
Creates an instance with all data and exceptions wrapped to runtime exceptions .
19,140
public void init ( final SerializedDataTypeRegistry typeRegistry , final DeserializerRegistry deserRegistry , final SerializerRegistry serRegistry ) { if ( initialized ) { throw new IllegalStateException ( "Instance already initialized - Don't call the init methods more than once" ) ; } this . typeRegistry = typeRegist...
Initializes the instance with necessary registries .
19,141
public void initializeAll ( InjectionManager injectionManager ) { if ( injectionManager != null ) { for ( Converter < ? > converter : _converters ) { Field [ ] fields = ReflectionUtils . getFields ( converter . getClass ( ) , Inject . class ) ; for ( Field field : fields ) { final Object value ; if ( field . getType ( ...
Initializes all converters contained with injections
19,142
public static Method [ ] getMethods ( Class < ? > clazz ) { final boolean legacyApproach = isGetMethodsLegacyApproach ( ) ; final List < Method > allMethods = new ArrayList < > ( ) ; addMethods ( allMethods , clazz , legacyApproach ) ; return allMethods . toArray ( new Method [ allMethods . size ( ) ] ) ; }
Gets all methods of a class excluding those from Object .
19,143
public static < T > String joinAnd ( final String delimiter , final String lastDelimiter , final Collection < T > objs ) { if ( objs == null || objs . isEmpty ( ) ) { return "" ; } final Iterator < T > iter = objs . iterator ( ) ; final StringBuffer buffer = new StringBuffer ( Strings . toString ( iter . next ( ) ) ) ;...
Like join but allows for a distinct final delimiter . For english sentences such as Alice Bob and Charlie use and and as the delimiters .
19,144
public final ProjectionJavaScriptBuilder type ( final String eventType ) { if ( count > 0 ) { sb . append ( "," ) ; } sb . append ( "'" + eventType + "': function(state, ev) { linkTo('" + projection + "', ev); }" ) ; count ++ ; return this ; }
Adds another type to select .
19,145
public List < CommonEvent > asCommonEvents ( final JAXBContext ctx ) { final List < CommonEvent > list = new ArrayList < CommonEvent > ( ) ; for ( final Event event : events ) { list . add ( event . asCommonEvent ( ctx ) ) ; } return list ; }
Returns this object as a list of common event objects .
19,146
public static boolean isValid ( String name ) { char [ ] nameChars = name . toCharArray ( ) ; for ( int i = 0 ; i < nameChars . length ; i ++ ) { boolean valid = i == 0 ? Character . isJavaIdentifierStart ( nameChars [ i ] ) : Character . isJavaIdentifierPart ( nameChars [ i ] ) ; if ( ! valid ) { return valid ; } } re...
Test if an identifier is valid .
19,147
List < Integer > getParaSents ( Integer para ) { List < Integer > sentList = new ArrayList < Integer > ( this . paraSentIndex . get ( para ) ) ; Collections . sort ( sentList ) ; return sentList ; }
Returns all sentences in a paragraph .
19,148
List < List < Annotation > > getSentences ( AnnotationType type , String groupID ) { List < List < Annotation > > sentences = new ArrayList < List < Annotation > > ( ) ; for ( int sent : Helper . getIndexKeys ( type , groupID , this . sentIndex ) ) { sentences . add ( this . getSentAnnotations ( sent , type ) ) ; } ret...
Return all annotations of type type classified into sentences
19,149
List < List < Annotation > > getParagraphs ( AnnotationType type , String groupID ) { List < List < Annotation > > paragraphs = new ArrayList < List < Annotation > > ( ) ; for ( int para : Helper . getIndexKeys ( type , groupID , this . paraIndex ) ) { paragraphs . add ( this . getParaAnnotations ( para , type ) ) ; } ...
Return all annotations of type type classified into paragraphs
19,150
public static String streamEntityName ( final StreamId streamId ) { if ( streamId instanceof JpaStreamId ) { final JpaStreamId jpaId = ( JpaStreamId ) streamId ; return jpaId . getEntityName ( ) ; } if ( streamId . isProjection ( ) ) { return streamId . getName ( ) ; } if ( streamId . getParameters ( ) . size ( ) == 0 ...
Returns the name of the stream entity for a given stream .
19,151
public static String nativeEventsTableName ( final StreamId streamId ) { if ( streamId instanceof JpaStreamId ) { final JpaStreamId jpaId = ( JpaStreamId ) streamId ; return jpaId . getNativeTableName ( ) ; } if ( streamId . isProjection ( ) ) { return camel2Underscore ( streamId . getName ( ) ) ; } if ( streamId . get...
Returns a native database events table name .
19,152
public static String camel2Underscore ( final String name ) { if ( name == null ) { return null ; } return name . replaceAll ( "(.)(\\p{Upper})" , "$1_$2" ) . toLowerCase ( ) ; }
Converts the given camel case name into a name with underscores .
19,153
public final CommonEvent asCommonEvent ( final JAXBContext ctx ) { final Object m ; if ( getMeta ( ) == null ) { m = null ; } else { m = getMeta ( ) . unmarshalContent ( ctx ) ; } final Object d = getData ( ) . unmarshalContent ( ctx ) ; if ( getMeta ( ) == null ) { return new SimpleCommonEvent ( getId ( ) , new TypeNa...
Returns this object as a common event object .
19,154
public static Event valueOf ( final CommonEvent selEvent ) { final Data data = Data . valueOf ( selEvent . getDataType ( ) . asBaseType ( ) , selEvent . getData ( ) ) ; if ( selEvent . getMeta ( ) == null ) { return new Event ( selEvent . getId ( ) , data ) ; } final Data meta = Data . valueOf ( "meta" , selEvent . get...
Creates an event using a common event .
19,155
public boolean isConfigured ( final boolean throwException ) throws IllegalStateException , UnconfiguredConfiguredPropertyException { if ( _datastoreConnection == null ) { if ( throwException ) { throw new IllegalStateException ( "No Datastore or DatastoreConnection set" ) ; } return false ; } if ( _sourceColumns . isE...
Used to verify whether or not the builder s configuration is valid and all properties are satisfied .
19,156
private void delete ( File file ) { if ( file . isDirectory ( ) ) { File [ ] children = file . listFiles ( ) ; for ( File child : children ) { delete ( child ) ; } } if ( ! file . delete ( ) ) { if ( ! file . isDirectory ( ) ) { logger . warn ( "Unable to clean/delete file: {}" , file ) ; } else { logger . debug ( "Una...
Recursively deletes a directory and all it s files
19,157
public static < E > List < E > refineCandidates ( final List < E > candidates , final Predicate < ? super E > predicate ) { if ( candidates . size ( ) == 1 ) { return candidates ; } List < E > newCandidates = CollectionUtils . filter ( candidates , predicate ) ; if ( newCandidates . isEmpty ( ) ) { return candidates ; ...
Refines a list of candidate objects based on a inclusion predicate . If no candidates are found the original list will be retained in the result . Therefore the result will always have 1 or more elements in it .
19,158
public static < K , V > Cache < K , V > createCache ( int maximumSize , long expiryDurationSeconds ) { Cache < K , V > cache = CacheBuilder . newBuilder ( ) . maximumSize ( maximumSize ) . expireAfterAccess ( expiryDurationSeconds , TimeUnit . SECONDS ) . build ( ) ; return cache ; }
Creates a typical Google Guava cache
19,159
public void close ( ComponentDescriptor < ? > descriptor , Object component ) { close ( descriptor , component , true ) ; }
Closes a component after user .
19,160
public void closeReferenceData ( ) { if ( _referenceDataActivationManager == null ) { return ; } final Collection < Object > referenceData = _referenceDataActivationManager . getAllReferenceData ( ) ; for ( Object object : referenceData ) { ComponentDescriptor < ? extends Object > descriptor = Descriptors . ofComponent...
Closes all reference data used in this life cycle helper
19,161
public void initializeReferenceData ( ) { if ( _referenceDataActivationManager == null ) { return ; } final Collection < Object > referenceDataCollection = _referenceDataActivationManager . getAllReferenceData ( ) ; for ( Object referenceData : referenceDataCollection ) { ComponentDescriptor < ? extends Object > descri...
Initializes all reference data used in this life cycle helper
19,162
public final String toDebugString ( ) { return new ToStringBuilder ( this ) . append ( "fromEventNumber" , fromEventNumber ) . append ( "nextEventNumber" , nextEventNumber ) . append ( "endOfStream" , endOfStream ) . append ( "events" , events ) . toString ( ) ; }
Returns a debug string representation with all data .
19,163
public static String getString ( String key , String valueIfNull ) { String value = System . getProperty ( key ) ; if ( Strings . isNullOrEmpty ( value ) ) { return valueIfNull ; } return value ; }
Gets a system property string or a replacement value if the property is null or blank .
19,164
public static long getLong ( String key , long valueIfNullOrNotParseable ) { String value = System . getProperty ( key ) ; if ( Strings . isNullOrEmpty ( value ) ) { return valueIfNullOrNotParseable ; } try { return Long . parseLong ( value ) ; } catch ( NumberFormatException e ) { return valueIfNullOrNotParseable ; } ...
Gets a system property long or a replacement value if the property is null or blank or not parseable
19,165
public static long getInt ( String key , int valueIfNullOrNotParseable ) { String value = System . getProperty ( key ) ; if ( Strings . isNullOrEmpty ( value ) ) { return valueIfNullOrNotParseable ; } try { return Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { return valueIfNullOrNotParseable ; } ...
Gets a system property int or a replacement value if the property is null or blank or not parseable
19,166
public static boolean getBoolean ( String key , boolean valueIfNull ) { String value = System . getProperty ( key ) ; if ( Strings . isNullOrEmpty ( value ) ) { return valueIfNull ; } value = value . trim ( ) . toLowerCase ( ) ; if ( "true" . equals ( value ) ) { return true ; } else if ( "false" . equals ( value ) ) {...
Gets a system property boolean or a replacement value if the property is null or blank or not parseable as a boolean .
19,167
private void restoreData ( ) { Map < String , ? > map = preferenceUtils . getAll ( ) ; Set < String > strings = map . keySet ( ) ; for ( String string : strings ) { if ( string . startsWith ( SharedPreferenceUtils . keyTestMode ) ) { preferenceUtils . restoreKey ( string ) ; } } refreshKeyValues ( ) ; }
Restore values of original keys stored .
19,168
private ArrayList < Pair < String , ? > > getKeyValues ( ) { ArrayList < Pair < String , ? > > keyValPair = new ArrayList < > ( ) ; Map < String , ? > map = preferenceUtils . getAll ( ) ; Set < String > strings = map . keySet ( ) ; Object value ; for ( String key : strings ) { if ( ! key . contains ( SharedPreferenceUt...
Get Key value pair for given shared preference files
19,169
private void storeOriginal ( Pair < String , Object > keyValue ) { String key = SharedPreferenceUtils . keyTestMode + keyValue . first ; if ( ! preferenceUtils . isValueExistForKey ( key ) ) { preferenceUtils . put ( key , keyValue . second ) ; } }
Store original value before it s changed in test mode . It will take care not to over write if original value is already stored .
19,170
public final EnhancedMimeType getDataContentType ( ) { if ( dataContentType == null ) { dataContentType = EnhancedMimeType . create ( dataContentTypeStr ) ; } return dataContentType ; }
Returns the type of the data .
19,171
public final EnhancedMimeType getMetaContentType ( ) { if ( ( metaContentType == null ) && ( metaContentTypeStr != null ) ) { metaContentType = EnhancedMimeType . create ( metaContentTypeStr ) ; } return metaContentType ; }
Returns the type of the meta data if meta data is available .
19,172
public JsonObject toJson ( ) { final JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; builder . add ( EL_DATA_TYPE , dataType ) ; builder . add ( EL_DATA_CONTENT_TYPE , dataContentTypeStr ) ; if ( meta == null ) { return builder . build ( ) ; } builder . add ( EL_META_TYPE , metaType ) ; builder . add ( EL_...
Converts the object into a JSON object .
19,173
public JsonElement callRC ( LsApiBody body ) throws LimesurveyRCException { try ( CloseableHttpClient client = HttpClientBuilder . create ( ) . build ( ) ) { HttpPost post = new HttpPost ( url ) ; post . setHeader ( "Content-type" , "application/json" ) ; String jsonBody = gson . toJson ( body ) ; LOGGER . debug ( "API...
Call Limesurvey Remote Control .
19,174
public int createIncompleteResponse ( int surveyId , String token ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; HashMap < String , String > responseData = new HashMap < > ( ) ; responseData . put ( "submitdate" , "" ) ; String date = ZonedDateTime . now ( ) . format (...
Create an incomplete response its field completed is set to N and the response doesn t have a submitdate .
19,175
public boolean completeResponse ( int surveyId , int responseId , LocalDateTime date ) throws LimesurveyRCException { Map < String , String > responseData = new HashMap < > ( ) ; responseData . put ( "submitdate" , date . format ( DateTimeFormatter . ISO_LOCAL_DATE ) + " " + date . format ( DateTimeFormatter . ISO_LOCA...
Complete a response .
19,176
public JsonElement updateResponse ( int surveyId , int responseId , Map < String , String > responseData ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; responseData . put ( "id" , String . valueOf ( responseId ) ) ; params . setResponseData ( responseData ) ; return ca...
Update a response .
19,177
public Stream < LsQuestion > getQuestions ( int surveyId ) throws LimesurveyRCException { return getGroups ( surveyId ) . flatMap ( group -> { try { return getQuestionsFromGroup ( surveyId , group . getId ( ) ) ; } catch ( LimesurveyRCException e ) { LOGGER . error ( "Unable to get questions from group " + group . getI...
Gets questions from a survey . The questions are ordered using the group_order field from the groups and then the question_order field from the questions
19,178
public LsQuestion getQuestion ( int surveyId , int questionId ) throws LimesurveyRCException { return getQuestions ( surveyId ) . filter ( question -> question . getId ( ) == questionId ) . findFirst ( ) . orElseThrow ( ( ) -> new LimesurveyRCException ( "No question found for id " + questionId + " in survey " + survey...
Gets question from a survey .
19,179
public Map < String , LsQuestionAnswer > getQuestionAnswers ( int questionId ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( ) ; params . setQuestionId ( questionId ) ; List < String > questionSettings = new ArrayList < > ( ) ; questionSettings . add ( "answeroptions" ) ; params . s...
Gets possible answers from a question .
19,180
public Stream < LsQuestionGroup > getGroups ( int surveyId ) throws LimesurveyRCException { JsonElement result = callRC ( new LsApiBody ( "list_groups" , getParamsWithKey ( surveyId ) ) ) ; List < LsQuestionGroup > questionGroups = gson . fromJson ( result , new TypeToken < List < LsQuestionGroup > > ( ) { } . getType ...
Gets groups from a survey . The groups are ordered using the group_order field .
19,181
public Stream < LsQuestion > getQuestionsFromGroup ( int surveyId , int groupId ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; params . setGroupId ( groupId ) ; JsonElement result = callRC ( new LsApiBody ( "list_questions" , params ) ) ; List < LsQuestion > questions ...
Gets questions from a group . The questions are ordered using the question_order field .
19,182
public boolean isSurveyActive ( int surveyId ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; List < String > surveySettings = new ArrayList < > ( ) ; surveySettings . add ( "active" ) ; params . setSurveySettings ( surveySettings ) ; return "Y" . equals ( callRC ( new L...
Check if a survey is active .
19,183
public Stream < LsSurvey > getSurveys ( ) throws LimesurveyRCException { JsonElement result = callRC ( new LsApiBody ( "list_surveys" , getParamsWithKey ( ) ) ) ; List < LsSurvey > surveys = gson . fromJson ( result , new TypeToken < List < LsSurvey > > ( ) { } . getType ( ) ) ; return surveys . stream ( ) ; }
Gets all surveys .
19,184
public LsSurveyLanguage getSurveyLanguageProperties ( int surveyId ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; List < String > localeSettings = new ArrayList < > ( ) ; localeSettings . add ( "surveyls_welcometext" ) ; localeSettings . add ( "surveyls_endtext" ) ; pa...
Gets language properties from a survey .
19,185
public String getSessionKey ( ) throws LimesurveyRCException { if ( ! key . isEmpty ( ) && ZonedDateTime . now ( ) . isBefore ( keyExpiration ) ) { return key ; } LsApiBody . LsApiParams params = new LsApiBody . LsApiParams ( ) ; params . setUsername ( user ) ; params . setPassword ( password ) ; JsonElement result = c...
Gets the current session key .
19,186
public Map < String , String > getParticipantProperties ( int surveyId , String token , List < String > tokenProperties ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; Map < String , String > queryProperties = new HashMap < > ( ) ; queryProperties . put ( "token" , toke...
Gets participant properties .
19,187
public Stream < LsParticipant > getAllParticipants ( int surveyId ) throws LimesurveyRCException { LsApiBody . LsApiParams params = getParamsWithKey ( surveyId ) ; params . setStart ( 0 ) ; params . setLimit ( - 1 ) ; List < LsParticipant > participants = gson . fromJson ( callRC ( new LsApiBody ( "list_participants" ,...
Gets all participants from a survey .
19,188
public static SharedPreferenceUtils initWith ( SharedPreferences sharedPreferences ) { if ( sharedPreferenceUtils == null ) { sharedPreferenceUtils = new SharedPreferenceUtils ( ) ; } sharedPreferenceUtils . sharedPreferences = sharedPreferences ; return sharedPreferenceUtils ; }
Init SharedPreferenceUtils with SharedPreferences file
19,189
public static SharedPreferenceUtils initWith ( Context context , String name ) { if ( sharedPreferenceUtils == null ) { sharedPreferenceUtils = new SharedPreferenceUtils ( ) ; } if ( isEmptyString ( name ) ) { sharedPreferenceUtils . sharedPreferences = PreferenceManager . getDefaultSharedPreferences ( context ) ; } el...
Init SharedPreferences with context and a SharedPreferences name
19,190
public static int getNumber ( CharSequence string ) { int number = 0 ; if ( ! isEmptyString ( string ) ) { if ( TextUtils . isDigitsOnly ( string ) ) { number = Integer . parseInt ( string . toString ( ) ) ; } } return number ; }
Extract number from string failsafe . If the string is not a proper number it will always return 0 ;
19,191
public static float getNumberFloat ( CharSequence string ) { float number = 0.0f ; try { if ( ! isEmptyString ( string ) ) { number = Float . parseFloat ( string . toString ( ) ) ; } } catch ( NumberFormatException e ) { e . printStackTrace ( ) ; } return number ; }
Extract number from string failsafe . If the string is not a proper number it will always return 0 . 0f ;
19,192
public static long getNumberLong ( CharSequence string ) { long number = 0l ; try { if ( ! isEmptyString ( string ) ) { if ( TextUtils . isDigitsOnly ( string ) ) { number = Long . parseLong ( string . toString ( ) ) ; } } } catch ( NumberFormatException e ) { e . printStackTrace ( ) ; } return number ; }
Extract number from string failsafe . If the string is not a proper number it will always return 0l ;
19,193
public void inflateDebugMenu ( MenuInflater inflater , Menu menu ) { inflater . inflate ( R . menu . debug , menu ) ; }
Inflate menu item for debug .
19,194
public boolean isDebugHandled ( Context context , MenuItem item ) { int id = item . getItemId ( ) ; if ( id == R . id . action_debug ) { startActivity ( context ) ; return true ; } return false ; }
Checks if debug menu item clicked or not .
19,195
public boolean isValueExistForKey ( String key ) { boolean isValueExists ; try { String string = getString ( key , "" ) ; isValueExists = ! string . equalsIgnoreCase ( "" ) ; } catch ( ClassCastException e ) { try { int anInt = getInt ( key , 0 ) ; isValueExists = anInt != 0 ; } catch ( ClassCastException e1 ) { try { ...
Check if value exists for key .
19,196
public String getString ( String key , String defaultValue ) throws ClassCastException { return sharedPreferences . getString ( key , ( defaultValue == null ) ? "" : defaultValue ) ; }
Retrieve a String value from the preferences .
19,197
public void restoreKey ( String key ) { if ( ! key . equalsIgnoreCase ( "test_mode_opened" ) ) { String originalKey = key . substring ( keyTestMode . length ( ) ) ; Object value = get ( key ) ; put ( originalKey , value ) ; clear ( key ) ; } }
Restore the original value for the key after it has been changed in test mode .
19,198
public Object get ( String key ) { try { return getString ( key , null ) ; } catch ( ClassCastException e ) { try { return getInt ( key , 0 ) ; } catch ( ClassCastException e1 ) { try { return getLong ( key , 0 ) ; } catch ( ClassCastException e2 ) { try { return getFloat ( key , 0f ) ; } catch ( ClassCastException e3 ...
Get the value of the key .
19,199
public void put ( String key , Object value ) { if ( value . getClass ( ) . equals ( String . class ) ) { putString ( key , value . toString ( ) ) ; } else if ( value . getClass ( ) . equals ( Integer . class ) ) { putInt ( key , ( Integer ) value ) ; } else if ( value . getClass ( ) . equals ( Float . class ) ) { putF...
Put the value in given shared preference