idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
5,400
protected void onDDPConnect ( DDPStateSingleton ddp ) { if ( ! ddp . isLoggedIn ( ) ) { String resumeToken = ddp . getResumeToken ( ) ; if ( resumeToken != null ) { ddp . login ( resumeToken ) ; } } }
Override this to hook into what happens when DDP connect happens Default behavior is to feed in the resume token if available
5,401
protected void onError ( String title , String msg ) { AlertDialog . Builder builder = new AlertDialog . Builder ( mActivity ) ; builder . setMessage ( msg ) . setTitle ( title ) ; builder . setPositiveButton ( "OK" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { dialog . dismiss ( ) ; } } ) ; AlertDialog dialog = builder . create ( ) ; dialog . show ( ) ; }
Override this to hook into error display Default behavior is to display the error as a dialog in your application
5,402
protected void validateFeatureDictionary ( ) { FeatureDictionary dict = getFeatureDictionary ( ) ; if ( dict != null ) { if ( dict instanceof Iterable < ? > ) { FeatureDictionary posDict = ( FeatureDictionary ) dict ; Set < String > dictTags = new HashSet < String > ( ) ; Set < String > poisoned = new HashSet < String > ( ) ; for ( WordTag wt : ( Iterable < WordTag > ) posDict ) { dictTags . add ( wt . getPostag ( ) ) ; } Set < String > modelTags = new HashSet < String > ( ) ; AbstractModel posModel = this . artifactProvider . getArtifact ( FeaturizerModel . FEATURIZER_MODEL_ENTRY_NAME ) ; for ( int i = 0 ; i < posModel . getNumOutcomes ( ) ; i ++ ) { modelTags . add ( posModel . getOutcome ( i ) ) ; } for ( String d : dictTags ) { if ( ! modelTags . contains ( d ) ) { poisoned . add ( d ) ; } } this . poisonedDictionaryTags = Collections . unmodifiableSet ( poisoned ) ; } } }
because the poisoned tags are persisted ...
5,403
static void copyProperties ( ExecutionGraphVertex standard , Set < ExecutionGraphVertex > vertices ) { for ( ExecutionGraphVertex vertex : vertices ) { if ( standard . equals ( vertex ) ) { continue ; } IExecutionGraphVertexProperties from = standard . properties ( ) ; IExecutionGraphVertexProperties to = vertex . properties ( ) ; to . setName ( from . getName ( ) ) ; to . setAlias ( from . getAlias ( ) ) ; to . setValue ( from . getValue ( ) ) ; to . setType ( from . getType ( ) ) ; to . setFormulaPtg ( from . getFormulaPtg ( ) ) ; to . setPtgs ( from . getPtgs ( ) ) ; if ( from . getFormulaString ( ) == null && to . getFormulaString ( ) != null ) { from . setFormulaString ( to . getFormulaString ( ) ) ; } else { to . setFormulaString ( from . getFormulaString ( ) ) ; } if ( from . getFormulaValues ( ) == null && to . getFormulaValues ( ) != null ) { from . setFormulaValues ( to . getFormulaValues ( ) ) ; } else { to . setFormulaValues ( from . getFormulaValues ( ) ) ; } if ( from . getFormulaPtgString ( ) == null && to . getFormulaPtgString ( ) != null ) { from . setFormulaPtgString ( to . getFormulaPtgString ( ) ) ; } else { to . setFormulaPtgString ( from . getFormulaPtgString ( ) ) ; } if ( from . getPtgString ( ) == null && to . getPtgString ( ) != null ) { from . setPtgString ( to . getPtgString ( ) ) ; } else { to . setPtgString ( from . getPtgString ( ) ) ; } to . setSourceObjectId ( from . getSourceObjectId ( ) ) ; to . setRootFormulaId ( from . getRootFormulaId ( ) ) ; } }
Does copy of all properties for every Vertex from
5,404
public static List < TypedSpan > createSpanList ( String [ ] toks , String [ ] tags ) { List < TypedSpan > phrases = new ArrayList < TypedSpan > ( toks . length ) ; String startTag = "" ; int startIndex = 0 ; boolean foundPhrase = false ; for ( int ci = 0 , cn = tags . length ; ci < cn ; ci ++ ) { String pred = tags [ ci ] ; if ( ! tags [ ci ] . startsWith ( "B-" ) && ! tags [ ci ] . startsWith ( "I-" ) ) { pred = "O" ; } if ( pred . startsWith ( "B-" ) || ( ! pred . equals ( "I-" + startTag ) && ! pred . equals ( "O" ) ) ) { if ( foundPhrase ) { phrases . add ( new TypedSpan ( startIndex , ci , startTag ) ) ; } startIndex = ci ; startTag = pred . substring ( 2 ) ; foundPhrase = true ; } else if ( pred . equals ( "I-" + startTag ) ) { } else if ( foundPhrase ) { phrases . add ( new TypedSpan ( startIndex , ci , startTag ) ) ; foundPhrase = false ; startTag = "" ; } } if ( foundPhrase ) { phrases . add ( new TypedSpan ( startIndex , tags . length , startTag ) ) ; } return phrases ; }
this is from opennlp
5,405
private void createWindowFeats ( int i , String [ ] toks , String [ ] tags , String [ ] preds , List < String > feats ) { String w_2 , w_1 , w0 , w1 , w2 ; String t_2 , t_1 , t0 , t1 , t2 ; String p_2 , p_1 ; w_2 = w_1 = w0 = w1 = w2 = null ; t_2 = t_1 = t0 = t1 = t2 = null ; p_1 = p_2 = null ; if ( i < 2 ) { w_2 = "w_2=bos" ; t_2 = "t_2=bos" ; p_2 = "p_2=bos" ; } else { w_2 = "w_2=" + toks [ i - 2 ] ; t_2 = "t_2=" + tags [ i - 2 ] ; p_2 = "p_2" + preds [ i - 2 ] ; } if ( i < 1 ) { w_1 = "w_1=bos" ; t_1 = "t_1=bos" ; p_1 = "p_1=bos" ; } else { w_1 = "w_1=" + toks [ i - 1 ] ; t_1 = "t_1=" + tags [ i - 1 ] ; p_1 = "p_1=" + preds [ i - 1 ] ; } w0 = "w0=" + toks [ i ] ; t0 = "t0=" + tags [ i ] ; if ( i + 1 >= toks . length ) { w1 = "w1=eos" ; t1 = "t1=eos" ; } else { w1 = "w1=" + toks [ i + 1 ] ; t1 = "t1=" + tags [ i + 1 ] ; } if ( i + 2 >= toks . length ) { w2 = "w2=eos" ; t2 = "t2=eos" ; } else { w2 = "w2=" + toks [ i + 2 ] ; t2 = "t2=" + tags [ i + 2 ] ; } String [ ] features = new String [ ] { w_2 , w_1 , w0 , w1 , w2 , w_1 + w0 , w0 + w1 , t_2 , t_1 , t0 , t1 , t2 , t_2 + t_1 , t_1 + t0 , t0 + t1 , t1 + t2 , t_2 + t_1 + t0 , t_1 + t0 + t1 , t0 + t1 + t2 , p_2 , p_1 , p_2 + p_1 , p_1 + t_2 , p_1 + t_1 , p_1 + t0 , p_1 + t1 , p_1 + t2 , p_1 + t_2 + t_1 , p_1 + t_1 + t0 , p_1 + t0 + t1 , p_1 + t1 + t2 , p_1 + t_2 + t_1 + t0 , p_1 + t_1 + t0 + t1 , p_1 + t0 + t1 + t2 , p_1 + w_2 , p_1 + w_1 , p_1 + w0 , p_1 + w1 , p_1 + w2 , p_1 + w_1 + w0 , p_1 + w0 + w1 } ; feats . addAll ( Arrays . asList ( features ) ) ; }
0 . 9674293472168595
5,406
private void create3WindowFeats ( int i , String [ ] toks , String [ ] tags , String [ ] preds , List < String > feats ) { String w_1 , w0 , w1 ; String t_1 , t0 , t1 ; String p_2 , p_1 ; w0 = w1 = null ; t_1 = t0 = t1 = null ; p_1 = p_2 = null ; if ( i < 2 ) { p_2 = "p_2=bos" ; } else { p_2 = "p_2" + preds [ i - 2 ] ; } if ( i < 1 ) { w_1 = "w_1=bos" ; t_1 = "t_1=bos" ; p_1 = "p_1=bos" ; } else { w_1 = "w_1=" + toks [ i - 1 ] ; t_1 = "t_1=" + tags [ i - 1 ] ; p_1 = "p_1=" + preds [ i - 1 ] ; } w0 = "w0=" + toks [ i ] ; t0 = "t0=" + tags [ i ] ; if ( i + 1 >= toks . length ) { w1 = "w1=eos" ; t1 = "t1=eos" ; } else { w1 = "w1=" + toks [ i + 1 ] ; t1 = "t1=" + tags [ i + 1 ] ; } String [ ] features = new String [ ] { w_1 , w0 , w1 , w_1 + w0 , w0 + w1 , t_1 , t0 , t1 , t_1 + t0 , t0 + t1 , t_1 + t0 + t1 , p_2 , p_1 , p_2 + p_1 , p_1 + t_1 , p_1 + t0 , p_1 + t1 , p_1 + t_1 + t0 , p_1 + t0 + t1 , p_1 + t_1 + t0 + t1 , p_1 + w_1 , p_1 + w0 , p_1 + w1 , p_1 + w_1 + w0 , p_1 + w0 + w1 } ; feats . addAll ( Arrays . asList ( features ) ) ; }
0 . 9670307770871996
5,407
static List < IA1Address > resolveCellDependencies ( IA1Address cellAddress , Sheet sheet , FormulaParsingWorkbook workbook ) { Row row = sheet . getRow ( cellAddress . row ( ) ) ; if ( row == null ) { return emptyList ( ) ; } Cell cell = row . getCell ( cellAddress . column ( ) ) ; if ( cell == null ) { return emptyList ( ) ; } if ( CELL_TYPE_FORMULA != cell . getCellType ( ) ) { return singletonList ( cellAddress ) ; } List < IA1Address > dependencies = new LinkedList < > ( ) ; for ( Ptg ptg : parse ( cell . getCellFormula ( ) , workbook , CELL , 0 ) ) { if ( ptg instanceof RefPtg ) { RefPtg ref = ( RefPtg ) ptg ; dependencies . addAll ( resolveCellDependencies ( fromRowColumn ( ref . getRow ( ) , ref . getColumn ( ) ) , sheet , workbook ) ) ; } else if ( ptg instanceof AreaPtg ) { AreaPtg area = ( AreaPtg ) ptg ; for ( int r = area . getFirstRow ( ) ; r <= area . getLastRow ( ) ; r ++ ) { for ( int c = area . getFirstColumn ( ) ; c <= area . getLastColumn ( ) ; c ++ ) { dependencies . addAll ( resolveCellDependencies ( fromRowColumn ( r , c ) , sheet , workbook ) ) ; } } } dependencies . add ( cellAddress ) ; } return dependencies ; }
For given cell address gives a list of this cell s dependencies .
5,408
public String getSentence ( ) { if ( sentence != null ) return this . sentence ; else if ( doc != null ) { return span . getCoveredText ( doc ) . toString ( ) ; } else { return null ; } }
Gets the original sentence .
5,409
public byte [ ] encrypt ( PrivateKey privateKey , byte [ ] encryptedSecretKey , String data ) throws InvalidKeyException { byte [ ] encryptedData = null ; try { byte [ ] chave = privateKey . getEncoded ( ) ; Cipher rsacf = Cipher . getInstance ( "RSA" ) ; rsacf . init ( Cipher . DECRYPT_MODE , privateKey ) ; byte [ ] secretKey = rsacf . doFinal ( encryptedSecretKey ) ; encryptedData = encrypt ( secretKey , data ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Exception encrypting data" , e ) ; } return encryptedData ; }
Encrypt data using an key encrypted with a private key .
5,410
public synchronized String encrypt ( String plaintext ) { MessageDigest md = null ; try { md = MessageDigest . getInstance ( "SHA" ) ; md . update ( plaintext . getBytes ( UTF8 ) ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Should not happen!" , e ) ; } byte raw [ ] = md . digest ( ) ; return encode ( raw ) ; }
Encrypt a string using SHA
5,411
static boolean isFunctionInFormula ( String formula , String function ) { String filteredFormula = formula . replace ( POI_FUNCTION_PREFIX , "" ) ; return filteredFormula . startsWith ( function ) && filteredFormula . replace ( function , "" ) . startsWith ( "(" ) ; }
Checks if formula string contains given function .
5,412
static boolean isFormula ( String value , EvaluationWorkbook workbook ) { try { return FormulaParser . parse ( value , ( FormulaParsingWorkbook ) workbook , 0 , 0 ) . length > 1 ; } catch ( FormulaParseException e ) { return false ; } }
Returns true if value string is formula
5,413
public String [ ] getFeatures ( String word , String pos ) { return lookup ( new WordTag ( word , pos ) ) ; }
add all features if pos == null
5,414
public void process ( CAS tcas ) { final AnnotationComboIterator comboIterator = new AnnotationComboIterator ( tcas , mSentenceType , mTokenType ) ; for ( AnnotationIteratorPair annotationIteratorPair : comboIterator ) { final List < AnnotationFS > sentenceTokenAnnotationList = new LinkedList < AnnotationFS > ( ) ; final List < String > sentenceTokenList = new LinkedList < String > ( ) ; final List < String > sentenceTagsList = new LinkedList < String > ( ) ; for ( AnnotationFS tokenAnnotation : annotationIteratorPair . getSubIterator ( ) ) { sentenceTokenAnnotationList . add ( tokenAnnotation ) ; sentenceTokenList . add ( tokenAnnotation . getFeatureValueAsString ( mLexemeFeature ) ) ; sentenceTagsList . add ( tokenAnnotation . getFeatureValueAsString ( mPosFeature ) ) ; } String [ ] toks = sentenceTokenList . toArray ( new String [ sentenceTokenList . size ( ) ] ) ; String [ ] tags = sentenceTagsList . toArray ( new String [ sentenceTagsList . size ( ) ] ) ; String [ ] featureTag = mFeaturizer . featurize ( toks , tags ) ; final Iterator < AnnotationFS > sentenceTokenIterator = sentenceTokenAnnotationList . iterator ( ) ; int index = 0 ; while ( sentenceTokenIterator . hasNext ( ) ) { final AnnotationFS tokenAnnotation = sentenceTokenIterator . next ( ) ; tokenAnnotation . setStringValue ( mFeaturizerFeature , featureTag [ index ] ) ; index ++ ; } } }
Performs featurizer on the given tcas object .
5,415
public static boolean areElementEquals ( Element element1 , Element element2 ) { for ( Mask mask1 : element1 . getMask ( ) ) { if ( ! areBooleanEquals ( element1 . isNegated ( ) , element2 . isNegated ( ) ) ) { return false ; } for ( Mask mask2 : element2 . getMask ( ) ) { if ( ! areStringEquals ( mask1 . getLexemeMask ( ) , mask2 . getLexemeMask ( ) ) ) { return false ; } else if ( ! areStringEquals ( mask1 . getPrimitiveMask ( ) , mask2 . getPrimitiveMask ( ) ) ) { return false ; } else if ( ! areTagMaskEquals ( mask1 . getTagMask ( ) , mask2 . getTagMask ( ) ) ) { return false ; } } } return true ; }
Checks if two elements are equals .
5,416
public static boolean areTagMaskEquals ( TagMask tagMask1 , TagMask tagMask2 ) { if ( ( tagMask1 == null && tagMask2 != null ) || ( tagMask1 != null && tagMask2 == null ) ) { return false ; } else if ( tagMask1 != null && tagMask2 != null ) { if ( tagMask1 . getCase ( ) != tagMask2 . getCase ( ) ) { return false ; } else if ( tagMask1 . getClazz ( ) != tagMask2 . getClazz ( ) ) { return false ; } else if ( tagMask1 . getGender ( ) != tagMask2 . getGender ( ) ) { return false ; } else if ( tagMask1 . getMood ( ) != tagMask2 . getMood ( ) ) { return false ; } else if ( tagMask1 . getNumber ( ) != tagMask2 . getNumber ( ) ) { return false ; } else if ( tagMask1 . getPerson ( ) != tagMask2 . getPerson ( ) ) { return false ; } else if ( tagMask1 . getPunctuation ( ) != tagMask2 . getPunctuation ( ) ) { return false ; } else if ( tagMask1 . getSyntacticFunction ( ) != tagMask2 . getSyntacticFunction ( ) ) { return false ; } else if ( tagMask1 . getTense ( ) != tagMask2 . getTense ( ) ) { return false ; } } return true ; }
Checks if two tag masks are equals . The tag masks can be both null one of them null or none of them null .
5,417
public static boolean areBooleanEquals ( Boolean boolean1 , Boolean boolean2 ) { if ( boolean1 != null && ! boolean1 . equals ( boolean2 ) ) { return false ; } else if ( boolean2 != null && ! boolean2 . equals ( boolean1 ) ) { return false ; } return true ; }
Checks if two Booleans are equals . The booleans can be both null one of them null or none of them null .
5,418
public static boolean areStringEquals ( String string1 , String string2 ) { if ( string1 == null && string2 == null ) { return false ; } else if ( string1 != null && ! string1 . equals ( string2 ) ) { return false ; } else if ( string2 != null && ! string2 . equals ( string1 ) ) { return false ; } return true ; }
Checks if two strings are equals . The strings can be both null one of them null or none of them null .
5,419
private static String discardBeginningHyphen ( String string ) { String noHyphenString = string ; if ( string . startsWith ( "-" ) ) { noHyphenString = string . substring ( 1 ) ; } return noHyphenString ; }
Removes the beginning hyphen from the string if any .
5,420
public void commit ( Object root ) { try { XChangesBatch xUpdateControl = ( XChangesBatch ) UnoRuntime . queryInterface ( XChangesBatch . class , root ) ; xUpdateControl . commitChanges ( ) ; } catch ( WrappedTargetException e ) { e . printStackTrace ( ) ; } }
Commit the XChangeBatch control
5,421
private static String generateName ( Locale locale ) { StringBuilder str = new StringBuilder ( ) ; str . append ( "models_" ) . append ( locale . getLanguage ( ) ) ; if ( locale . getCountry ( ) != null && ! locale . getCountry ( ) . isEmpty ( ) ) str . append ( "_" ) . append ( locale . getCountry ( ) ) ; str . append ( ".xml" ) ; return str . toString ( ) ; }
Generates the name of the file to be used according to the language chosen .
5,422
public CharSequence getCoveredText ( CharSequence text ) { if ( getEnd ( ) > text . length ( ) ) { throw new IllegalArgumentException ( "The span " + toString ( ) + " is outside the given text!" ) ; } return text . subSequence ( getStart ( ) , getEnd ( ) ) ; }
Retrieves the string covered by the current span of the specified text .
5,423
public boolean connectIfNeeded ( ) { if ( getDDP ( ) . getState ( ) == CONNSTATE . Disconnected ) { getDDP ( ) . connect ( ) ; return true ; } else if ( getDDP ( ) . getState ( ) == CONNSTATE . Closed ) { createDDPClient ( ) ; getDDP ( ) . connect ( ) ; } return false ; }
Requests DDP connect if needed
5,424
public void logout ( ) { saveResumeToken ( null ) ; mDDPState = DDPSTATE . NotLoggedIn ; mUserId = null ; broadcastConnectionState ( mDDPState ) ; }
Logs out from server and removes the resume token
5,425
public void saveResumeToken ( String token ) { SharedPreferences settings = mContext . getSharedPreferences ( PREF_DDPINFO , Context . MODE_PRIVATE ) ; SharedPreferences . Editor editor = settings . edit ( ) ; editor . putString ( PREF_RESUMETOKEN , token ) ; editor . apply ( ) ; }
Saves resume token to Android s internal app storage
5,426
public String getResumeToken ( ) { SharedPreferences settings = mContext . getSharedPreferences ( PREF_DDPINFO , Context . MODE_PRIVATE ) ; return settings . getString ( PREF_RESUMETOKEN , null ) ; }
Gets resume token from Android s internal app storage
5,427
@ SuppressWarnings ( "unchecked" ) public void handleLoginResult ( Map < String , Object > jsonFields ) { if ( jsonFields . containsKey ( "result" ) ) { Map < String , Object > result = ( Map < String , Object > ) jsonFields . get ( DdpMessageField . RESULT ) ; mResumeToken = ( String ) result . get ( "token" ) ; saveResumeToken ( mResumeToken ) ; mUserId = ( String ) result . get ( "id" ) ; mDDPState = DDPSTATE . LoggedIn ; broadcastConnectionState ( mDDPState ) ; } else if ( jsonFields . containsKey ( "error" ) ) { Map < String , Object > error = ( Map < String , Object > ) jsonFields . get ( DdpMessageField . ERROR ) ; broadcastDDPError ( ( String ) error . get ( "message" ) ) ; } }
Handles callback from login command
5,428
public void broadcastConnectionState ( DDPSTATE ddpstate ) { Intent broadcastIntent = new Intent ( ) ; broadcastIntent . setAction ( MESSAGE_CONNECTION ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_STATE , ddpstate . ordinal ( ) ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_USERID , mUserId ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_USERTOKEN , mResumeToken ) ; LocalBroadcastManager . getInstance ( mContext ) . sendBroadcast ( broadcastIntent ) ; }
Used to notify event system of connection events . Default behavior uses Android s LocalBroadcastManager . Override if you want to use a different eventbus .
5,429
public void broadcastDDPError ( String errorMsg ) { Intent broadcastIntent = new Intent ( ) ; broadcastIntent . setAction ( MESSAGE_ERROR ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_MSG , errorMsg ) ; LocalBroadcastManager . getInstance ( mContext ) . sendBroadcast ( broadcastIntent ) ; }
Used to notify event system of error events . Default behavior uses Android s LocalBroadcastManager . Override if you want to use a different eventbus .
5,430
public void broadcastSubscriptionChanged ( String subscriptionName , String changetype , String docId ) { Intent broadcastIntent = new Intent ( ) ; broadcastIntent . setAction ( MESSAGE_SUBUPDATED ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_SUBNAME , subscriptionName ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_CHANGETYPE , changetype ) ; broadcastIntent . putExtra ( MESSAGE_EXTRA_CHANGEID , docId ) ; LocalBroadcastManager . getInstance ( mContext ) . sendBroadcast ( broadcastIntent ) ; }
Used to notify event system of subscription change events . Default behavior uses Android s LocalBroadcastManager . Override if you want to use a different eventbus .
5,431
@ SuppressWarnings ( "unchecked" ) public void update ( Observable client , Object msg ) { if ( msg instanceof Map < ? , ? > ) { Map < String , Object > jsonFields = ( Map < String , Object > ) msg ; String msgtype = ( String ) jsonFields . get ( DDPClient . DdpMessageField . MSG ) ; String collName = ( String ) jsonFields . get ( DdpMessageField . COLLECTION ) ; String docId = ( String ) jsonFields . get ( DdpMessageField . ID ) ; if ( msgtype != null ) { switch ( msgtype ) { case DdpMessageType . ERROR : broadcastDDPError ( ( String ) jsonFields . get ( DdpMessageField . ERRORMSG ) ) ; break ; case DdpMessageType . CONNECTED : mDDPState = DDPSTATE . Connected ; broadcastConnectionState ( mDDPState ) ; break ; case DdpMessageType . ADDED : addDoc ( jsonFields , collName , docId ) ; broadcastSubscriptionChanged ( collName , DdpMessageType . ADDED , docId ) ; break ; case DdpMessageType . REMOVED : if ( removeDoc ( collName , docId ) ) { broadcastSubscriptionChanged ( collName , DdpMessageType . REMOVED , docId ) ; } break ; case DdpMessageType . CHANGED : if ( updateDoc ( jsonFields , collName , docId ) ) { broadcastSubscriptionChanged ( collName , DdpMessageType . CHANGED , docId ) ; } break ; case DdpMessageType . CLOSED : mDDPState = DDPSTATE . Closed ; broadcastConnectionState ( DDPSTATE . Closed ) ; break ; } } } }
handles callbacks from DDP client websocket callbacks
5,432
@ SuppressWarnings ( "unchecked" ) public boolean updateDoc ( Map < String , Object > jsonFields , String collName , String docId ) { if ( mCollections . containsKey ( collName ) ) { Map < String , Map < String , Object > > collection = mCollections . get ( collName ) ; Map < String , Object > doc = collection . get ( docId ) ; if ( doc != null ) { Map < String , Object > fields = ( Map < String , Object > ) jsonFields . get ( DdpMessageField . FIELDS ) ; if ( fields != null ) { for ( Map . Entry < String , Object > field : fields . entrySet ( ) ) { String fieldname = field . getKey ( ) ; doc . put ( fieldname , field . getValue ( ) ) ; } } List < String > clearfields = ( ( List < String > ) jsonFields . get ( DdpMessageField . CLEARED ) ) ; if ( clearfields != null ) { for ( String fieldname : clearfields ) { if ( doc . containsKey ( fieldname ) ) { doc . remove ( fieldname ) ; } } } return true ; } } else { log . warn ( "Received invalid changed msg for collection " + collName ) ; } return false ; }
Handles updating a document in a collection . Override if you want to use your own collection data store .
5,433
public boolean removeDoc ( String collName , String docId ) { if ( mCollections . containsKey ( collName ) ) { Map < String , Map < String , Object > > collection = mCollections . get ( collName ) ; if ( BuildConfig . DEBUG ) { log . debug ( "Removed doc: " + docId ) ; } collection . remove ( docId ) ; return true ; } else { log . warn ( "Received invalid removed msg for collection " + collName ) ; return false ; } }
Handles deleting a document in a collection . Override if you want to use your own collection data store .
5,434
@ SuppressWarnings ( "unchecked" ) public void addDoc ( Map < String , Object > jsonFields , String collName , String docId ) { if ( ! mCollections . containsKey ( collName ) ) { log . debug ( "Added collection " + collName ) ; mCollections . put ( collName , new ConcurrentHashMap < String , Map < String , Object > > ( ) ) ; } Map < String , Map < String , Object > > collection = mCollections . get ( collName ) ; Map < String , Object > fields ; if ( jsonFields . get ( DdpMessageField . FIELDS ) == null ) { fields = new ConcurrentHashMap < > ( ) ; } else { fields = ( Map < String , Object > ) jsonFields . get ( DdpMessageField . FIELDS ) ; } collection . put ( docId , fields ) ; if ( BuildConfig . DEBUG ) { log . debug ( "Added docid " + docId + " to collection " + collName ) ; } }
Handles adding a document to collection . Override if you want to use your own collection data store .
5,435
public Map < String , Map < String , Object > > getCollection ( String collectionName ) { return mCollections . get ( collectionName ) ; }
Gets local Meteor collection
5,436
public Map < String , Object > getDocument ( String collectionName , String docId ) { Map < String , Map < String , Object > > docs = DDPStateSingleton . getInstance ( ) . getCollection ( collectionName ) ; if ( docs != null ) { return docs . get ( docId ) ; } return null ; }
Gets a document out of a collection
5,437
public Map < String , Object > getUser ( ) { Map < String , Object > userFields = DDPStateSingleton . getInstance ( ) . getDocument ( "users" , getUserId ( ) ) ; if ( userFields != null ) { return userFields ; } return null ; }
Gets current Meteor user info
5,438
@ SuppressWarnings ( "unchecked" ) public String getUserEmail ( String userId ) { if ( userId == null ) { return null ; } Map < String , Object > user = getDocument ( "users" , userId ) ; String email = userId ; if ( user != null ) { ArrayList < Map < String , String > > emails = ( ArrayList < Map < String , String > > ) user . get ( "emails" ) ; if ( ( emails != null ) && ( emails . size ( ) > 0 ) ) { Map < String , String > emailFields = emails . get ( 0 ) ; email = emailFields . get ( "address" ) ; } } return email ; }
Gets email address for user
5,439
public int call ( String method , Object [ ] params , DDPListener resultListener ) { return getDDP ( ) . call ( method , params , resultListener ) ; }
Calls a Meteor method
5,440
public static TagMask createTagMaskFromToken ( Token token , String text ) { TagMask tm = new TagMask ( ) ; Matcher m = REPLACE_R2 . matcher ( text ) ; while ( m . find ( ) ) { String property = m . group ( 1 ) ; switch ( property ) { case "number" : tm . setNumber ( token . getMorphologicalTag ( ) . getNumberE ( ) ) ; break ; case "gender" : tm . setGender ( token . getMorphologicalTag ( ) . getGenderE ( ) ) ; break ; case "class" : tm . setClazz ( token . getMorphologicalTag ( ) . getClazzE ( ) ) ; break ; case "person" : tm . setPerson ( token . getMorphologicalTag ( ) . getPersonE ( ) ) ; break ; case "tense" : tm . setTense ( token . getMorphologicalTag ( ) . getTense ( ) ) ; break ; case "mood" : tm . setMood ( token . getMorphologicalTag ( ) . getMood ( ) ) ; break ; default : break ; } } return tm ; }
Returns a TagMask with the attributes collected from the given token .
5,441
public void validate ( ) { Validator validator = this . schema . newValidator ( ) ; InputStream in = null ; try { if ( this . xmlFile != null ) { in = this . xmlFile . openStream ( ) ; } else { in = new ByteArrayInputStream ( this . serializedRule . getBytes ( ) ) ; } validator . validate ( new StreamSource ( in ) ) ; } catch ( SAXException e ) { throw new RulesException ( "Rules file does not conform to the schema" , e ) ; } catch ( IOException e ) { if ( this . xmlFile != null ) { throw new RulesException ( "Could not read file " + this . xmlFile , e ) ; } else { throw new RulesException ( "Could not read serialized rule " + this . serializedRule , e ) ; } } finally { Closeables . closeQuietly ( in ) ; } }
Checks the xml against the xsd .
5,442
public Rule getRule ( int id ) { Rule returnRule = null ; for ( Rule rule : this . getRules ( ) . getRule ( ) ) { if ( rule . getId ( ) == id ) { returnRule = rule ; break ; } } return returnRule ; }
Gets a rule by its id .
5,443
public XTextComponent addTextField ( String content , String name , int x , int y , int width , int height ) throws Exception { Object labelModel = multiServiceFactory . createInstance ( "com.sun.star.awt.UnoControlEditModel" ) ; XPropertySet textFieldProperties = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , labelModel ) ; textFieldProperties . setPropertyValue ( "PositionX" , new Integer ( x ) ) ; textFieldProperties . setPropertyValue ( "PositionY" , new Integer ( y ) ) ; textFieldProperties . setPropertyValue ( "Width" , new Integer ( width ) ) ; textFieldProperties . setPropertyValue ( "Height" , new Integer ( height ) ) ; textFieldProperties . setPropertyValue ( "Name" , name ) ; textFieldProperties . setPropertyValue ( "TabIndex" , new Short ( ( short ) tabcount ++ ) ) ; textFieldProperties . setPropertyValue ( "MultiLine" , new Boolean ( false ) ) ; textFieldProperties . setPropertyValue ( "Text" , content ) ; this . nameContainer . insertByName ( name , labelModel ) ; XControlContainer controlContainer = ( XControlContainer ) UnoRuntime . queryInterface ( XControlContainer . class , this . oUnoDialog ) ; Object obj = controlContainer . getControl ( name ) ; XTextComponent field = ( XTextComponent ) UnoRuntime . queryInterface ( XTextComponent . class , obj ) ; return field ; }
Create a single line textfield with the given content .
5,444
public XTextComponent addPasswordField ( char [ ] password , String name , int x , int y , int width , int height ) throws Exception { Object labelModel = multiServiceFactory . createInstance ( "com.sun.star.awt.UnoControlEditModel" ) ; XPropertySet passwordFieldProperties = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , labelModel ) ; passwordFieldProperties . setPropertyValue ( "PositionX" , new Integer ( x ) ) ; passwordFieldProperties . setPropertyValue ( "PositionY" , new Integer ( y ) ) ; passwordFieldProperties . setPropertyValue ( "Width" , new Integer ( width ) ) ; passwordFieldProperties . setPropertyValue ( "Height" , new Integer ( height ) ) ; passwordFieldProperties . setPropertyValue ( "Name" , name ) ; passwordFieldProperties . setPropertyValue ( "TabIndex" , new Short ( ( short ) tabcount ++ ) ) ; passwordFieldProperties . setPropertyValue ( "MultiLine" , new Boolean ( false ) ) ; passwordFieldProperties . setPropertyValue ( "EchoChar" , new Short ( ( short ) 42 ) ) ; passwordFieldProperties . setPropertyValue ( "Text" , new String ( password ) ) ; for ( int i = 0 ; i < password . length ; i ++ ) { password [ i ] = Character . DIRECTIONALITY_WHITESPACE ; } this . nameContainer . insertByName ( name , labelModel ) ; XControlContainer controlContainer = ( XControlContainer ) UnoRuntime . queryInterface ( XControlContainer . class , this . oUnoDialog ) ; Object obj = controlContainer . getControl ( name ) ; XTextComponent field = ( XTextComponent ) UnoRuntime . queryInterface ( XTextComponent . class , obj ) ; return field ; }
Create a password field
5,445
public static String createUniqueName ( XNameAccess _xElementContainer , String _sElementName ) { boolean bElementexists = true ; int i = 1 ; String sIncSuffix = "" ; String BaseName = _sElementName ; while ( bElementexists ) { bElementexists = _xElementContainer . hasByName ( _sElementName ) ; if ( bElementexists ) { i += 1 ; _sElementName = BaseName + Integer . toString ( i ) ; } } return _sElementName ; }
makes a String unique by appending a numerical suffix
5,446
public Prep findWord ( String word ) { if ( prepsMap . containsKey ( "*" ) ) { word = "*" ; } return prepsMap . get ( word ) ; }
that should be linking them otherwise returns null
5,447
protected void collectFeatures ( String prefix , String suffix , String previous , String next , char eosChar ) { buf . append ( "x=" ) ; buf . append ( prefix ) ; collectFeats . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; if ( ! prefix . equals ( "" ) ) { collectFeats . add ( Integer . toString ( prefix . length ( ) ) ) ; if ( isFirstUpper ( prefix ) ) { collectFeats . add ( "xcap" ) ; } if ( inducedAbbreviations . contains ( prefix + eosChar ) ) { collectFeats . add ( "xabbrev" ) ; } char c = prefix . charAt ( 0 ) ; if ( prefix . length ( ) == 1 && Character . isLetter ( c ) && Character . isUpperCase ( c ) && eosChar == '.' ) { collectFeats . add ( "xnabb" ) ; } } buf . append ( "v=" ) ; buf . append ( previous ) ; collectFeats . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; if ( ! previous . equals ( "" ) ) { if ( isFirstUpper ( previous ) ) { collectFeats . add ( "vcap" ) ; } if ( inducedAbbreviations . contains ( previous ) ) { collectFeats . add ( "vabbrev" ) ; } } buf . append ( "s=" ) ; buf . append ( suffix ) ; collectFeats . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; if ( ! suffix . equals ( "" ) ) { if ( isFirstUpper ( suffix ) ) { collectFeats . add ( "scap" ) ; } if ( inducedAbbreviations . contains ( suffix ) ) { collectFeats . add ( "sabbrev" ) ; } } buf . append ( "n=" ) ; buf . append ( next ) ; collectFeats . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; if ( ! next . equals ( "" ) ) { if ( isFirstUpper ( next ) ) { collectFeats . add ( "ncap" ) ; } if ( inducedAbbreviations . contains ( next ) ) { collectFeats . add ( "nabbrev" ) ; } } }
Determines some of the features for the sentence detector and adds them to list features .
5,448
private static final int previousSpaceIndex ( CharSequence sb , int seek ) { seek -- ; while ( seek > 0 && ! StringUtil . isWhitespace ( sb . charAt ( seek ) ) ) { seek -- ; } if ( seek > 0 && StringUtil . isWhitespace ( sb . charAt ( seek ) ) ) { while ( seek > 0 && StringUtil . isWhitespace ( sb . charAt ( seek - 1 ) ) ) seek -- ; return seek ; } return 0 ; }
Finds the index of the nearest space before a specified index which is not itself preceded by a space .
5,449
private void addCharPreds ( String key , char c , List < String > preds ) { preds . add ( key + "=" + c ) ; if ( Character . isLetter ( c ) ) { preds . add ( key + "_alpha" ) ; if ( Character . isUpperCase ( c ) ) { preds . add ( key + "_caps" ) ; } } else if ( Character . isDigit ( c ) ) { preds . add ( key + "_num" ) ; } else if ( StringUtil . isWhitespace ( c ) ) { preds . add ( key + "_ws" ) ; } else { if ( c == '.' || c == '?' || c == '!' ) { preds . add ( key + "_eos" ) ; } else if ( c == ',' || c == ';' || c == ':' ) { preds . add ( key + "_reos" ) ; } else if ( c == '`' || c == '"' || c == '\'' ) { preds . add ( key + "_quote" ) ; } else if ( c == '[' || c == '{' || c == '(' ) { preds . add ( key + "_lp" ) ; } else if ( c == ']' || c == '}' || c == ')' ) { preds . add ( key + "_rp" ) ; } } }
Helper function for getContext .
5,450
private boolean getsSupposedAbbreviation ( String text , int position ) { int ini ; boolean end = false ; String word = text ; for ( ini = position ; ini >= 0 ; ini -- ) if ( Character . isWhitespace ( text . charAt ( ini ) ) || isOpenBracket ( text . charAt ( ini ) ) ) break ; for ( int i = position + 1 ; i < text . length ( ) - 1 && end == false ; i ++ ) { switch ( text . charAt ( i ) ) { case '.' : if ( Character . isWhitespace ( text . charAt ( i + 1 ) ) || isEnding ( text . charAt ( i + 1 ) ) ) { word = word . substring ( ini + 1 , i + 1 ) ; end = true ; } break ; default : break ; } } if ( end == true ) { if ( INITIALS . matcher ( word ) . find ( ) ) return true ; else if ( this . dic . contains ( new StringList ( word ) ) ) return true ; } return false ; }
Analyze a sentence and gets the word which contains the position of the error in the parameter and tells if it is an initial or if the abbreviation dictionary contains it or not .
5,451
public ValueEval evaluate ( ValueEval [ ] args , OperationEvaluationContext ec ) { log . debug ( "In evaluate() of DEFINE function. Args = {}" , Arrays . toString ( args ) ) ; return new StringEval ( DefineFunction . class . getAnnotation ( CustomFunctionMeta . class ) . value ( ) ) ; }
This function does nothing since it should never be evaluated . DEFINE function is a spreadsheet metadata and it cannot have a value .
5,452
private void writeXmi ( CAS aCas , File name , String modelFileName ) throws IOException , SAXException { FileOutputStream out = null ; try { out = new FileOutputStream ( name ) ; XmiCasSerializer ser = new XmiCasSerializer ( aCas . getTypeSystem ( ) ) ; XMLSerializer xmlSer = new XMLSerializer ( out , false ) ; ser . serialize ( aCas , xmlSer . getContentHandler ( ) ) ; } finally { if ( out != null ) { out . close ( ) ; } } }
Serialize a CAS to a file in XMI format
5,453
public String getRuleId ( ) { if ( GrammarError_Type . featOkTst && ( ( GrammarError_Type ) jcasType ) . casFeat_ruleId == null ) jcasType . jcas . throwFeatMissing ( "ruleId" , "cogroo.uima.GrammarError" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( GrammarError_Type ) jcasType ) . casFeatCode_ruleId ) ; }
getter for ruleId - gets
5,454
public void setRuleId ( String v ) { if ( GrammarError_Type . featOkTst && ( ( GrammarError_Type ) jcasType ) . casFeat_ruleId == null ) jcasType . jcas . throwFeatMissing ( "ruleId" , "cogroo.uima.GrammarError" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( GrammarError_Type ) jcasType ) . casFeatCode_ruleId , v ) ; }
setter for ruleId - sets
5,455
public void setError ( String v ) { if ( GrammarError_Type . featOkTst && ( ( GrammarError_Type ) jcasType ) . casFeat_error == null ) jcasType . jcas . throwFeatMissing ( "error" , "cogroo.uima.GrammarError" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( GrammarError_Type ) jcasType ) . casFeatCode_error , v ) ; }
setter for error - sets
5,456
public String getReplace ( ) { if ( GrammarError_Type . featOkTst && ( ( GrammarError_Type ) jcasType ) . casFeat_replace == null ) jcasType . jcas . throwFeatMissing ( "replace" , "cogroo.uima.GrammarError" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( GrammarError_Type ) jcasType ) . casFeatCode_replace ) ; }
getter for replace - gets
5,457
public ExecutionGraphVertex createVertex ( String address ) { ExecutionGraphVertex v = ExecutionGraph . createVertex ( removeSymbol ( address , '$' ) ) ; this . graph . addVertex ( v ) ; Set < ExecutionGraphVertex > vs = this . addressToVertices . getOrDefault ( address , new HashSet < > ( ) ) ; vs . add ( v ) ; if ( vs . size ( ) - 1 == 0 ) { this . addressToVertices . put ( address , vs ) ; } return v ; }
This method should be used when creating a new vertex from a cell so vertex name is a cell s address . New Vertex will be created any time this method is invoked . New vertex will be stored in address - to - set - of - vertices map .
5,458
public void runPostProcessing ( boolean multiRoot ) { for ( Set < ExecutionGraphVertex > vs : this . addressToVertices . values ( ) ) { if ( vs != null && vs . size ( ) > 1 ) { for ( ExecutionGraphVertex vertex : vs ) { if ( CELL_WITH_FORMULA == vertex . properties ( ) . getType ( ) || null != vertex . properties ( ) . getAlias ( ) ) { copyProperties ( vertex , vs ) ; break ; } } } } Map < String , AtomicInteger > adressToCount = new HashMap < > ( ) ; for ( ExecutionGraphVertex vertex : this . graph . getVertices ( ) ) { Type type = vertex . properties ( ) . getType ( ) ; if ( isCell ( type ) ) { String address = vertex . properties ( ) . getName ( ) ; adressToCount . putIfAbsent ( address , new AtomicInteger ( 0 ) ) ; if ( adressToCount . get ( address ) . incrementAndGet ( ) > 1 ) { Set < ExecutionGraphVertex > subgraphTops = new HashSet < > ( ) ; this . graph . getVertices ( ) . stream ( ) . filter ( v -> address . equals ( v . properties . getName ( ) ) ) . forEach ( v -> this . graph . getIncomingEdgesOf ( v ) . forEach ( e -> subgraphTops . add ( this . graph . getEdgeSource ( e ) ) ) ) ; for ( ExecutionGraphVertex subVertex : subgraphTops ) { if ( ! this . addressToVertices . containsKey ( address ) ) { continue ; } this . addressToVertices . get ( address ) . forEach ( v -> this . graph . addEdge ( subVertex , v ) ) ; } } } if ( RANGE == type ) { connectValuesToRange ( vertex , this ) ; } if ( IF == type ) { Collection < ExecutionGraphEdge > two = this . graph . getIncomingEdgesOf ( vertex ) ; if ( two . size ( ) != 2 ) { throw new CalculationEngineException ( "IF must have only two incoming edges." ) ; } Object ifBranchValue = null ; for ( ExecutionGraphEdge e : two ) { ExecutionGraphVertex oneOfTwo = this . graph . getEdgeSource ( e ) ; if ( ! isCompareOperand ( oneOfTwo . getName ( ) ) ) { ifBranchValue = oneOfTwo . properties ( ) . getValue ( ) ; break ; } } vertex . properties ( ) . setValue ( ifBranchValue ) ; } } if ( this . config . getDuplicatesNumberThreshold ( ) != - 1 ) { removeAllDuplicates ( this ) ; } }
Do anything you want here . After graph is completed and we are out of POI context you can add \ remove \ etc any information you want .
5,459
public String getCategory ( ) { if ( GoldenGrammarError_Type . featOkTst && ( ( GoldenGrammarError_Type ) jcasType ) . casFeat_category == null ) jcasType . jcas . throwFeatMissing ( "category" , "cogroo.uima.GoldenGrammarError" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( GoldenGrammarError_Type ) jcasType ) . casFeatCode_category ) ; }
getter for category - gets
5,460
public void setCategory ( String v ) { if ( GoldenGrammarError_Type . featOkTst && ( ( GoldenGrammarError_Type ) jcasType ) . casFeat_category == null ) jcasType . jcas . throwFeatMissing ( "category" , "cogroo.uima.GoldenGrammarError" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( GoldenGrammarError_Type ) jcasType ) . casFeatCode_category , v ) ; }
setter for category - sets
5,461
public String getError ( ) { if ( GoldenGrammarError_Type . featOkTst && ( ( GoldenGrammarError_Type ) jcasType ) . casFeat_error == null ) jcasType . jcas . throwFeatMissing ( "error" , "cogroo.uima.GoldenGrammarError" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( GoldenGrammarError_Type ) jcasType ) . casFeatCode_error ) ; }
getter for error - gets
5,462
public void setReplace ( String v ) { if ( GoldenGrammarError_Type . featOkTst && ( ( GoldenGrammarError_Type ) jcasType ) . casFeat_replace == null ) jcasType . jcas . throwFeatMissing ( "replace" , "cogroo.uima.GoldenGrammarError" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( GoldenGrammarError_Type ) jcasType ) . casFeatCode_replace , v ) ; }
setter for replace - sets
5,463
public static CellFormulaExpression copyOf ( CellFormulaExpression formula ) { if ( formula == null ) { return null ; } CellFormulaExpression copy = new CellFormulaExpression ( ) ; copy . formulaStr = formula . formulaStr ( ) . intern ( ) ; copy . formulaValues = formula . formulaValues ( ) . intern ( ) ; copy . formulaPtgStr = formula . formulaPtgStr ( ) . intern ( ) ; copy . ptgStr = formula . ptgStr ( ) . intern ( ) ; copy . iptg = formula . iptg ( ) ; copy . rootFormulaId = formula . rootFormulaId ; copy . ptgs ( formula . ptgs ) ; copy . formulaPtg ( formula . formulaPtg ( ) ) ; return copy ; }
Does copy of provided instance .
5,464
public void initialize ( String selectedText ) { LOG . finest ( ">>> initialize" ) ; try { this . theCommunityLogic = new CommunityLogic ( m_xContext , selectedText ) ; String [ ] propNames = new String [ ] { "Height" , "Moveable" , "Name" , "PositionX" , "PositionY" , "Step" , "TabIndex" , "Title" , "Width" } ; Object [ ] propValues = new Object [ ] { new Integer ( DEFAULT_DIALOG_HEIGHT ) , Boolean . TRUE , I18nLabelsLoader . ADDON_REPORT_ERROR , new Integer ( 102 ) , new Integer ( 41 ) , new Integer ( - 1 ) , new Short ( ( short ) 0 ) , I18nLabelsLoader . ADDON_REPORT_ERROR + " - CoGrOO Comunidade" , new Integer ( DEFAULT_DIALOG_WIDTH ) } ; super . initialize ( propNames , propValues ) ; this . createWindowPeer ( ) ; this . addRoadmap ( new RoadmapItemStateChangeListener ( m_xMSFDialogModel ) ) ; populateStep1 ( ) ; populateStep2 ( ) ; populateStep3 ( ) ; populateStep4 ( ) ; addButtons ( ) ; new CheckTokenAndGetCategoriesThread ( ) . start ( ) ; setCurrentStep ( STEP_LOGIN ) ; setControlsState ( ) ; LOG . finest ( "<<< initialize" ) ; } catch ( BasicErrorException e ) { LOGGER . log ( Level . SEVERE , e . getLocalizedMessage ( ) , e ) ; throw new CogrooRuntimeException ( CogrooExceptionMessages . INTERNAL_ERROR , new String [ ] { e . getLocalizedMessage ( ) } ) ; } }
Initializes the dialog with a selected text . The selected text can t be enpty or null .
5,465
private void populateStep1 ( ) { this . insertRoadmapItem ( 0 , true , I18nLabelsLoader . REPORT_STEP_LOGIN , 1 ) ; int y = 6 ; this . insertFixedTextBold ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_LOGIN , I18nLabelsLoader . REPORT_STEP_LOGIN ) ; y += 12 ; this . insertMultilineFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , 8 * 18 , STEP_LOGIN , I18nLabelsLoader . ADDON_LOGIN_INFO ) ; y += 8 * 18 ; this . insertFixedHyperlink ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_LOGIN , I18nLabelsLoader . ADDON_REPORT_FROM_BROWSER , Resources . getProperty ( "COMMUNITY_ROOT" ) + "/reports/new/" + theCommunityLogic . getEscapedText ( ) ) ; y += 18 ; this . insertFixedHyperlink ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_LOGIN , I18nLabelsLoader . ADDON_LOGIN_REGISTER , Resources . getProperty ( "COMMUNITY_ROOT" ) + "/register" ) ; y += 12 ; this . insertFixedHyperlink ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_LOGIN , I18nLabelsLoader . ADDON_LOGIN_LICENSE , I18nLabelsLoader . ADDON_LOGIN_LICENSEURL ) ; y += 12 ; this . insertFixedText ( this , DEFAULT_PosX , y + 2 , 40 , 1 , I18nLabelsLoader . ADDON_LOGIN_USER ) ; String userName = getCommunityUsername ( ) ; if ( userName == null ) { userName = "" ; } XTextListener textListener = new AuthUserPasswdTextListener ( ) ; userNameText = this . insertEditField ( textListener , this , DEFAULT_PosX + 40 , y , 60 , STEP_LOGIN , userName ) ; y += 14 ; this . insertFixedText ( this , DEFAULT_PosX , y + 2 , 40 , 1 , I18nLabelsLoader . ADDON_LOGIN_PASSWORD ) ; userPasswordText = this . insertSecretEditField ( textListener , this , DEFAULT_PosX + 40 , y , 60 , STEP_LOGIN , "" ) ; y += 14 ; authButton = this . insertButton ( new AuthLoginButtonListener ( ) , DEFAULT_PosX + 40 + 60 + 10 , y - 12 , 40 , STEP_LOGIN , I18nLabelsLoader . ADDON_LOGIN_ALLOW , ( ( short ) PushButtonType . STANDARD_value ) ) ; y += 4 ; this . insertFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_LOGIN , I18nLabelsLoader . ADDON_LOGIN_STATUS ) ; authStatusLabel = this . insertHiddenFixedStatusText ( this , DEFAULT_PosX + 40 , y , DEFAULT_WIDTH_LARGE , STEP_LOGIN , I18nLabelsLoader . ADDON_LOGIN_STATUS_NOTAUTH , false ) ; authProgressBar = this . insertProgressBar ( DEFAULT_PosX , DEFAULT_DIALOG_HEIGHT - 26 - 8 , DEFAULT_WIDTH_LARGE , 1 , 100 ) ; }
Populate the step one that we put loggin stuf
5,466
private void populateStep2 ( ) { this . insertRoadmapItem ( 1 , true , I18nLabelsLoader . REPORT_STEP_FALSE_ERRORS , 2 ) ; int y = 6 ; this . insertFixedTextBold ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , I18nLabelsLoader . REPORT_STEP_FALSE_ERRORS ) ; y += 12 ; this . insertMultilineFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , 8 * 4 , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_INFO ) ; y += 8 * 3 + 4 ; this . insertMultilineFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , 8 * 2 , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_ERRORSLIST ) ; y += 8 + 12 ; this . badIntListBox = this . insertListBox ( new BadIntListSelectonListener ( ) , DEFAULT_PosX , y , 3 * 12 , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , theCommunityLogic . getBadInterventions ( ) ) ; y += 3 * 12 + 4 ; this . insertFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_ERRORSFOUND ) ; y += 8 ; this . badIntErrorsText = this . insertMultilineEditField ( this , this , DEFAULT_PosX , y , 3 * 12 , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , "" , true ) ; y += 3 * 12 + 4 ; this . insertFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_DETAILS ) ; y += 8 ; this . badIntDetails = this . insertMultilineEditField ( this , this , DEFAULT_PosX , y , 3 * 12 , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , "" , true ) ; y += 3 * 12 + 4 ; this . insertFixedText ( this , DEFAULT_PosX , y + 2 , 40 , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_TYPE ) ; this . badIntClassificationDropBox = this . insertDropBox ( new BadIntClassificationDropBoxSelectionListener ( ) , DEFAULT_PosX + 40 , y , DEFAULT_WIDTH_LARGE - 40 , STEP_FALSE_ERRORS , theCommunityLogic . getClassifications ( ) ) ; y += 14 ; this . badIntCommentsLabel = this . insertFixedText ( this , DEFAULT_PosX , y , 40 , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_COMMENTS ) ; y += 12 ; this . badIntComments = this . insertMultilineEditField ( new BadIntCommentsTextListener ( ) , this , DEFAULT_PosX , y , 2 * 12 , DEFAULT_WIDTH_LARGE , STEP_FALSE_ERRORS , "" , false ) ; y += 2 * 12 + 4 ; this . badIntApplyButton = this . insertButton ( new BadIntApplyButtonListener ( ) , DEFAULT_PosX + DEFAULT_WIDTH_LARGE - 40 , y , 40 , STEP_FALSE_ERRORS , I18nLabelsLoader . ADDON_BADINT_APPLY , ( ( short ) PushButtonType . STANDARD_value ) ) ; setIsControlEnable ( badIntApplyButton , false ) ; }
Populate with omissions
5,467
private void populateStep4 ( ) { this . insertRoadmapItem ( 3 , true , I18nLabelsLoader . REPORT_STEP_THANKS , 4 ) ; int y = 6 ; this . insertFixedTextBold ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_THANKS , I18nLabelsLoader . REPORT_STEP_THANKS ) ; y += 12 ; this . insertMultilineFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , 8 * 5 , STEP_THANKS , I18nLabelsLoader . ADDON_THANKS_MESSAGE ) ; y += 8 * 5 + 12 ; this . insertFixedText ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_THANKS , I18nLabelsLoader . ADDON_THANKS_STATUS ) ; this . thanksStatusLabel = this . insertHiddenFixedStatusText ( this , DEFAULT_PosX + 40 , y , DEFAULT_WIDTH_LARGE , STEP_THANKS , I18nLabelsLoader . ADDON_THANKS_STATUS , false ) ; y += 12 ; this . thanksReportLink = this . insertFixedHyperlink ( this , DEFAULT_PosX , y , DEFAULT_WIDTH_LARGE , STEP_THANKS , I18nLabelsLoader . ADDON_THANKS_LINK , Resources . getProperty ( "COMMUNITY_ROOT" ) + "/reports" ) ; this . thanksProgressBar = this . insertProgressBar ( DEFAULT_PosX , DEFAULT_DIALOG_HEIGHT - 26 - 8 , DEFAULT_WIDTH_LARGE , STEP_THANKS , 100 ) ; }
Populate with thanks
5,468
private void setCurrentStep ( int nNewID ) { try { XPropertySet xDialogModelPropertySet = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , m_xMSFDialogModel ) ; int nOldStep = getCurrentStep ( ) ; if ( nNewID != nOldStep ) { xDialogModelPropertySet . setPropertyValue ( "Step" , new Integer ( nNewID ) ) ; } } catch ( com . sun . star . uno . Exception exception ) { exception . printStackTrace ( System . out ) ; } }
Moves to another step
5,469
private int getCurrentStep ( ) { int step = - 1 ; try { XPropertySet xDialogModelPropertySet = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , m_xMSFDialogModel ) ; step = ( ( Integer ) xDialogModelPropertySet . getPropertyValue ( "Step" ) ) . intValue ( ) ; } catch ( com . sun . star . uno . Exception exception ) { exception . printStackTrace ( System . out ) ; } return step ; }
Get the current step
5,470
private void setIsStepEnabled ( int step , boolean isEnabled ) { try { Object oRoadmapItem = m_xRMIndexCont . getByIndex ( step - 1 ) ; XPropertySet xRMItemPSet = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , oRoadmapItem ) ; xRMItemPSet . setPropertyValue ( "Enabled" , new Boolean ( isEnabled ) ) ; } catch ( com . sun . star . uno . Exception e ) { LOGGER . log ( Level . SEVERE , "Error in setIsStepEnabled" , e ) ; throw new CogrooRuntimeException ( e ) ; } }
Configure the steps that are enabled .
5,471
private boolean isStepEnabled ( int step ) { if ( step < 0 ) { return false ; } boolean isStepEnabled = false ; try { Object oRoadmapItem = m_xRMIndexCont . getByIndex ( step - 1 ) ; XPropertySet xRMItemPSet = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , oRoadmapItem ) ; isStepEnabled = ( ( Boolean ) xRMItemPSet . getPropertyValue ( "Enabled" ) ) . booleanValue ( ) ; } catch ( com . sun . star . uno . Exception e ) { LOGGER . log ( Level . SEVERE , "Error in isStepEnabled" , e ) ; throw new CogrooRuntimeException ( e ) ; } return isStepEnabled ; }
Checks if step is enabled .
5,472
private void setEnabledSteps ( ) { boolean isAuth = isAuthenticated ( ) ; boolean hasFalseErrors = badIntListBox . getItemCount ( ) > 0 ; int currentStep = getCurrentStep ( ) ; boolean login = true ; boolean falseErrors = false ; boolean omissions = false ; boolean thanks = false ; if ( currentStep == STEP_THANKS ) { login = falseErrors = omissions = false ; thanks = true ; } else if ( isAuth ) { if ( hasFalseErrors ) { falseErrors = true ; } login = omissions = true ; } setIsStepEnabled ( STEP_LOGIN , login ) ; setIsStepEnabled ( STEP_FALSE_ERRORS , falseErrors ) ; setIsStepEnabled ( STEP_OMISSIONS , omissions ) ; setIsStepEnabled ( STEP_THANKS , thanks ) ; }
Sets the enabled steps acording to the current state
5,473
private int getNextStep ( int currentStep ) { int nextStep = - 1 ; for ( int i = currentStep + 1 ; i <= STEP_THANKS ; i ++ ) { if ( isStepEnabled ( i ) ) { nextStep = i ; break ; } } return nextStep ; }
Get the next step given the current . Will check available steps to confirm .
5,474
private int getPreviousStep ( int currentStep ) { int prevStep = - 1 ; for ( int i = currentStep - 1 ; i >= STEP_LOGIN ; i -- ) { if ( isStepEnabled ( i ) ) { prevStep = i ; break ; } } return prevStep ; }
Get the previous step given the current . Will check available steps to confirm .
5,475
public void printRulesTree ( State rootState ) { List < State > nextStates = rootState . getNextStates ( ) ; if ( nextStates . isEmpty ( ) ) { return ; } for ( int i = 0 ; i < rootState . getNextStates ( ) . size ( ) ; i ++ ) { State currState = nextStates . get ( i ) ; String accept = "" ; if ( currState instanceof AcceptState ) { accept = Long . toString ( ( ( AcceptState ) currState ) . getRule ( ) . getId ( ) ) ; } System . out . printf ( "state[%4d], parent[%4d], rule[%4s], element[%s]\n" , Integer . valueOf ( currState . getName ( ) ) , Integer . valueOf ( rootState . getName ( ) ) , accept , RuleUtils . getPatternElementAsString ( currState . getElement ( ) ) ) ; this . printRulesTree ( nextStates . get ( i ) ) ; } }
Prints the contents of a rules tree .
5,476
public static String getElementAsString ( Element element ) { StringBuilder sb = new StringBuilder ( ) ; if ( element . isNegated ( ) != null && element . isNegated ( ) . booleanValue ( ) ) { sb . append ( "~" ) ; } int masks = element . getMask ( ) . size ( ) ; if ( masks > 1 ) { sb . append ( "(" ) ; } int maskCounter = 0 ; for ( Mask mask : element . getMask ( ) ) { if ( mask . getLexemeMask ( ) != null ) { sb . append ( "\"" ) . append ( mask . getLexemeMask ( ) ) . append ( "\"" ) ; } else if ( mask . getPrimitiveMask ( ) != null ) { sb . append ( "{" ) . append ( mask . getPrimitiveMask ( ) ) . append ( "}" ) ; } else if ( mask . getTagMask ( ) != null ) { sb . append ( getTagMaskAsString ( mask . getTagMask ( ) ) ) ; } else if ( mask . getTagReference ( ) != null ) { sb . append ( getTagReferenceAsString ( mask . getTagReference ( ) ) ) ; } if ( maskCounter < masks - 1 ) { sb . append ( "|" ) ; } maskCounter ++ ; } if ( masks > 1 ) { sb . append ( ")" ) ; } return sb . toString ( ) ; }
Gets the string representation of an element .
5,477
public List < Token > findNouns ( Sentence sentence ) { List < Token > nouns = new ArrayList < Token > ( ) ; List < SyntacticChunk > syntChunks = sentence . getSyntacticChunks ( ) ; for ( int i = 0 ; i < syntChunks . size ( ) ; i ++ ) { String tag = syntChunks . get ( i ) . getTag ( ) ; if ( tag . equals ( "PIV" ) || tag . equals ( "ACC" ) || tag . equals ( "SC" ) ) { for ( Token token : syntChunks . get ( i ) . getTokens ( ) ) { if ( token . getPOSTag ( ) . equals ( "n" ) || token . getPOSTag ( ) . equals ( "pron-pers" ) || token . getPOSTag ( ) . equals ( "prop" ) ) { nouns . add ( token ) ; } } } } return nouns ; }
Looks for a noun in the sentence s objects .
5,478
public Token findVerb ( Sentence sentence ) { List < SyntacticChunk > syntChunks = sentence . getSyntacticChunks ( ) ; for ( int i = 0 ; i < syntChunks . size ( ) ; i ++ ) { String tag = syntChunks . get ( i ) . getTag ( ) ; if ( tag . equals ( "P" ) || tag . equals ( "MV" ) || tag . equals ( "PMV" ) || tag . equals ( "AUX" ) || tag . equals ( "PAUX" ) ) return syntChunks . get ( i ) . getTokens ( ) . get ( 0 ) ; } return null ; }
Looks in a sentence for a verb .
5,479
public List < Mistake > check ( Sentence sentence ) { long start = 0 ; if ( LOGGER . isDebugEnabled ( ) ) { start = System . nanoTime ( ) ; } insertOutOfBounds ( sentence ) ; List < Mistake > mistakes = new ArrayList < Mistake > ( ) ; RulesTree rulesTree ; if ( RulesProperties . APPLY_LOCAL ) { rulesTree = this . rulesTreesProvider . getTrees ( ) . getGeneral ( ) ; for ( int i = 0 ; i < sentence . getTokens ( ) . size ( ) ; i ++ ) { List < State > nextStates = rulesTree . getRoot ( ) . getNextStates ( ) ; mistakes = this . getMistakes ( mistakes , nextStates , sentence , i , i , new ArrayList < Token > ( ) , sentence ) ; } } sentence . setTokens ( sentence . getTokens ( ) . subList ( 1 , sentence . getTokens ( ) . size ( ) - 1 ) ) ; if ( RulesProperties . APPLY_PHRASE_LOCAL ) { rulesTree = this . rulesTreesProvider . getTrees ( ) . getPhraseLocal ( ) ; List < Chunk > chunks = sentence . getChunks ( ) ; for ( int i = 0 ; i < chunks . size ( ) ; i ++ ) { for ( int j = 0 ; j < chunks . get ( i ) . getTokens ( ) . size ( ) ; j ++ ) { List < State > nextStates = rulesTree . getRoot ( ) . getNextStates ( ) ; mistakes = this . getMistakes ( mistakes , nextStates , chunks . get ( i ) , j , j , new ArrayList < Token > ( ) , sentence ) ; } } } if ( RulesProperties . APPLY_SUBJECT_VERB ) { rulesTree = this . rulesTreesProvider . getTrees ( ) . getSubjectVerb ( ) ; List < SyntacticChunk > syntacticChunks = sentence . getSyntacticChunks ( ) ; for ( int i = 0 ; i < syntacticChunks . size ( ) ; i ++ ) { List < State > nextStates = rulesTree . getRoot ( ) . getNextStates ( ) ; mistakes = this . getMistakes ( mistakes , nextStates , syntacticChunks , i , i , new ArrayList < SyntacticChunk > ( ) , sentence ) ; } } if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Rules applied in " + ( System . nanoTime ( ) - start ) / 1000 + "us" ) ; } filterIgnoredRules ( mistakes ) ; return mistakes ; }
Applies all active rules described in Rules . xml given a sentence properly tokenized tagged chunked and shallow parsed .
5,480
private List < Mistake > getMistakes ( List < Mistake > mistakes , List < State > currentStates , List < SyntacticChunk > syntacticChunks , int baseChunkIndex , int currentChunkIndex , ArrayList < SyntacticChunk > matched , Sentence sentence ) { for ( State state : currentStates ) { PatternElement patternElement = state . getElement ( ) ; SyntacticChunk sc = syntacticChunks . get ( currentChunkIndex ) ; boolean chunkAndElementMatched = this . match ( sc , patternElement , baseChunkIndex , sentence ) ; if ( chunkAndElementMatched ) { ArrayList < SyntacticChunk > matchedClone = cloneList ( matched ) ; matchedClone . add ( sc ) ; if ( state instanceof AcceptState ) { Rule rule = ( ( AcceptState ) state ) . getRule ( ) ; Boundaries b = rule . getBoundaries ( ) ; int start = matchedClone . get ( b . getLower ( ) ) . getTokens ( ) . get ( 0 ) . getSpan ( ) . getStart ( ) + sentence . getOffset ( ) ; List < Token > lastChk = matchedClone . get ( matchedClone . size ( ) - 1 + b . getUpper ( ) ) . getTokens ( ) ; int end = lastChk . get ( lastChk . size ( ) - 1 ) . getSpan ( ) . getEnd ( ) + sentence . getOffset ( ) ; String [ ] suggestions = suggestionBuilder . getSyntacticSuggestions ( sentence , matchedClone , null , rule ) ; Mistake mistake = new MistakeImpl ( ID_PREFIX + rule . getId ( ) , getPriority ( rule ) , rule . getMessage ( ) , rule . getShortMessage ( ) , suggestions , start , end , rule . getExample ( ) , sentence . getDocumentText ( ) ) ; mistakes . add ( mistake ) ; } else if ( currentChunkIndex + 1 < syntacticChunks . size ( ) ) { this . getMistakes ( mistakes , state . getNextStates ( ) , syntacticChunks , baseChunkIndex , currentChunkIndex + 1 , matchedClone , sentence ) ; } } else if ( isOptional ( patternElement ) ) { ArrayList < SyntacticChunk > matchedClone = cloneList ( matched ) ; matchedClone . add ( NullSyntacticChunk . instance ( ) ) ; this . getMistakes ( mistakes , state . getNextStates ( ) , syntacticChunks , baseChunkIndex , currentChunkIndex , matchedClone , sentence ) ; } } return mistakes ; }
A recursive method that iterates the sentence given a base chunk . Used to match subject - verb rules .
5,481
private boolean match ( Token token , Element element , int baseTokenIndex , Sentence sentence ) { boolean match ; boolean negated ; if ( element . isNegated ( ) == null ) { match = false ; negated = false ; } else { match = element . isNegated ( ) . booleanValue ( ) ; negated = element . isNegated ( ) . booleanValue ( ) ; } for ( Mask mask : element . getMask ( ) ) { if ( ! negated ) { if ( mask . getLexemeMask ( ) != null && mask . getLexemeMask ( ) . equalsIgnoreCase ( token . getLexeme ( ) ) ) { match = true ; } else if ( mask . getPrimitiveMask ( ) != null && matchLemma ( token , mask . getPrimitiveMask ( ) ) ) { match = true ; } else if ( mask . getTagMask ( ) != null && token . getMorphologicalTag ( ) != null ) { match = match | token . getMorphologicalTag ( ) . matchExact ( mask . getTagMask ( ) , false ) ; } else if ( mask . getTagReference ( ) != null && token . getMorphologicalTag ( ) != null ) { match = match | token . getMorphologicalTag ( ) . match ( RuleUtils . createTagMaskFromReference ( mask . getTagReference ( ) , sentence , baseTokenIndex ) , false ) ; } else if ( mask . getOutOfBounds ( ) != null && ( baseTokenIndex == 0 || baseTokenIndex == sentence . getTokens ( ) . size ( ) - 1 ) ) { match = false ; } } else { if ( mask . getLexemeMask ( ) != null && mask . getLexemeMask ( ) . equalsIgnoreCase ( token . getLexeme ( ) ) ) { match = false ; } else if ( mask . getPrimitiveMask ( ) != null && matchLemma ( token , mask . getPrimitiveMask ( ) ) ) { match = false ; } else if ( mask . getTagMask ( ) != null && token != null && token . getMorphologicalTag ( ) != null ) { match = match & ! token . getMorphologicalTag ( ) . matchExact ( mask . getTagMask ( ) , false ) ; } else if ( mask . getTagReference ( ) != null && token != null && token . getMorphologicalTag ( ) != null ) { match = match & ! token . getMorphologicalTag ( ) . match ( RuleUtils . createTagMaskFromReference ( mask . getTagReference ( ) , sentence , baseTokenIndex ) , false ) ; } else if ( mask . getOutOfBounds ( ) != null && ( baseTokenIndex == 0 || baseTokenIndex == sentence . getTokens ( ) . size ( ) - 1 ) ) { match = false ; } } } return match ; }
Determines if a token is matched by a rule element .
5,482
public XWindowPeer createWindowPeer ( XWindowPeer _xWindowParentPeer ) throws com . sun . star . script . BasicErrorException { try { if ( _xWindowParentPeer == null ) { XWindow xWindow = ( XWindow ) UnoRuntime . queryInterface ( XWindow . class , m_xDlgContainer ) ; xWindow . setVisible ( false ) ; Object tk = m_xMCF . createInstanceWithContext ( "com.sun.star.awt.Toolkit" , m_xContext ) ; XToolkit xToolkit = ( XToolkit ) UnoRuntime . queryInterface ( XToolkit . class , tk ) ; mxReschedule = ( XReschedule ) UnoRuntime . queryInterface ( XReschedule . class , xToolkit ) ; m_xDialogControl . createPeer ( xToolkit , _xWindowParentPeer ) ; m_xWindowPeer = m_xDialogControl . getPeer ( ) ; return m_xWindowPeer ; } } catch ( com . sun . star . uno . Exception exception ) { exception . printStackTrace ( System . out ) ; } return null ; }
create a peer for this dialog using the given peer as a parent .
5,483
public XWindowPeer getWindowPeer ( XTextDocument _xTextDocument ) { XModel xModel = ( XModel ) UnoRuntime . queryInterface ( XModel . class , _xTextDocument ) ; XFrame xFrame = xModel . getCurrentController ( ) . getFrame ( ) ; XWindow xWindow = xFrame . getContainerWindow ( ) ; XWindowPeer xWindowPeer = ( XWindowPeer ) UnoRuntime . queryInterface ( XWindowPeer . class , xWindow ) ; return xWindowPeer ; }
gets the WindowPeer of a frame
5,484
public void insertRoadmapItem ( int Index , boolean _bEnabled , String _sLabel , int _ID ) { try { Object oRoadmapItem = m_xSSFRoadmap . createInstance ( ) ; XPropertySet xRMItemPSet = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , oRoadmapItem ) ; xRMItemPSet . setPropertyValue ( "Label" , _sLabel ) ; xRMItemPSet . setPropertyValue ( "Enabled" , new Boolean ( _bEnabled ) ) ; xRMItemPSet . setPropertyValue ( "ID" , new Integer ( _ID ) ) ; m_xRMIndexCont . insertByIndex ( Index , oRoadmapItem ) ; } catch ( com . sun . star . uno . Exception exception ) { exception . printStackTrace ( System . out ) ; } }
To fully understand the example one has to be aware that the passed ???Index??? parameter refers to the position of the roadmap item in the roadmapmodel container whereas the variable ???_ID??? directyl references to a certain step of dialog .
5,485
public FSArray getGoldenGrammarErrors ( ) { if ( GoldenSentence_Type . featOkTst && ( ( GoldenSentence_Type ) jcasType ) . casFeat_goldenGrammarErrors == null ) jcasType . jcas . throwFeatMissing ( "goldenGrammarErrors" , "cogroo.uima.GoldenSentence" ) ; return ( FSArray ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( GoldenSentence_Type ) jcasType ) . casFeatCode_goldenGrammarErrors ) ) ) ; }
getter for goldenGrammarErrors - gets
5,486
public void setGoldenGrammarErrors ( FSArray v ) { if ( GoldenSentence_Type . featOkTst && ( ( GoldenSentence_Type ) jcasType ) . casFeat_goldenGrammarErrors == null ) jcasType . jcas . throwFeatMissing ( "goldenGrammarErrors" , "cogroo.uima.GoldenSentence" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( GoldenSentence_Type ) jcasType ) . casFeatCode_goldenGrammarErrors , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
setter for goldenGrammarErrors - sets
5,487
public GoldenGrammarError getGoldenGrammarErrors ( int i ) { if ( GoldenSentence_Type . featOkTst && ( ( GoldenSentence_Type ) jcasType ) . casFeat_goldenGrammarErrors == null ) jcasType . jcas . throwFeatMissing ( "goldenGrammarErrors" , "cogroo.uima.GoldenSentence" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( GoldenSentence_Type ) jcasType ) . casFeatCode_goldenGrammarErrors ) , i ) ; return ( GoldenGrammarError ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( GoldenSentence_Type ) jcasType ) . casFeatCode_goldenGrammarErrors ) , i ) ) ) ; }
indexed getter for goldenGrammarErrors - gets an indexed value -
5,488
public void setGoldenGrammarErrors ( int i , GoldenGrammarError v ) { if ( GoldenSentence_Type . featOkTst && ( ( GoldenSentence_Type ) jcasType ) . casFeat_goldenGrammarErrors == null ) jcasType . jcas . throwFeatMissing ( "goldenGrammarErrors" , "cogroo.uima.GoldenSentence" ) ; jcasType . jcas . checkArrayBounds ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( GoldenSentence_Type ) jcasType ) . casFeatCode_goldenGrammarErrors ) , i ) ; jcasType . ll_cas . ll_setRefArrayValue ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( GoldenSentence_Type ) jcasType ) . casFeatCode_goldenGrammarErrors ) , i , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }
indexed setter for goldenGrammarErrors - sets an indexed value -
5,489
static public String getFormattedDateTime ( long dt , TimeZone tz , String format ) { SimpleDateFormat df = new SimpleDateFormat ( format ) ; if ( tz != null ) df . setTimeZone ( tz ) ; return df . format ( new Date ( dt ) ) ; }
Returns the given date time formatted using the given format and timezone .
5,490
public byte getNearestOccidentalValue ( ) { if ( m_value == _NONE || m_value == _NATURAL ) return 0 ; if ( ( m_value == _DOUBLE_FLAT ) || ( m_value == _DOUBLE_SHARP ) ) return ( byte ) m_value ; if ( m_value < 0 ) return - 1 ; if ( m_value > 0 ) return 1 ; return 0 ; }
Return the nearest non microtonal semitone
5,491
public boolean add ( String name , Object value ) { if ( name == null ) throw new NullPointerException ( "name == null" ) ; add ( name ) ; add ( value . toString ( ) ) ; return true ; }
Adds the given query parameter name and value .
5,492
public void add ( byte b , Collection c ) { if ( ( c != null ) && ( c . size ( ) > 0 ) ) { String s2 = get ( b ) ; for ( Object aC : c ) { String s = ( String ) aC ; if ( s2 == null ) s2 = s ; else s2 += lineSeparator + s ; } set ( b , s2 ) ; } }
Add each element of collection c as new lines in field b
5,493
public void add ( byte b , String s ) { if ( s != null ) { String s2 = get ( b ) ; if ( s2 == null ) s2 = s ; else s2 += lineSeparator + s ; set ( b , s2 ) ; } }
Add the string s as new line to field b
5,494
public String get ( byte b ) { Object o = m_infos . get ( key ( b ) ) ; String o2 = null ; if ( m_bookInfos != null ) o2 = m_bookInfos . get ( b ) ; if ( ( o == null ) && ( o2 == null ) ) return null ; else { String ret = "" ; if ( o != null ) { ret += ( String ) o ; if ( o2 != null ) ret += lineSeparator ; } if ( o2 != null ) ret += o2 ; return ret ; } }
Returns the whole content of field b null if not defined
5,495
public Collection getAsCollection ( byte b ) { String [ ] lines = getAsStringArray ( b ) ; if ( lines == null ) return new ArrayList ( ) ; else return arrayToCollection ( lines ) ; }
Returns the content of field b as a collection each line is an element of the collection
5,496
public String [ ] getAsStringArray ( byte b ) { String s = get ( b ) ; if ( s == null ) return null ; else return s . split ( lineSeparator + "" ) ; }
Returns the content of field b as a string array each line is an element in the array
5,497
public void remove ( byte b , String s ) { Collection c = getAsCollection ( b ) ; c . remove ( s ) ; set ( b , c ) ; }
Remove the line s from the field b
5,498
public void set ( byte b , String s ) { if ( ( s != null ) && ( s . length ( ) > 0 ) ) m_infos . put ( key ( b ) , s ) ; else remove ( b ) ; }
Set the whole content of field b
5,499
public Collection < MobileApplication > list ( List < String > queryParams ) { return HTTP . GET ( "/v2/mobile_applications.json" , null , queryParams , MOBILE_APPLICATIONS ) . get ( ) ; }
Returns the set of Mobile applications with the given query parameters .