Input: getter for subject - gets The subject of the triple - always a URI . [CODESPLIT] public String getSubject ( ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_subject == null ) jcasType . jcas . throwFeatMissing ( "subject" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_subject ) ; }


Input: setter for subject - sets The subject of the triple - always a URI . [CODESPLIT] public void setSubject ( String v ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_subject == null ) jcasType . jcas . throwFeatMissing ( "subject" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_subject , v ) ; }


Input: getter for predicate - gets The predicate of the triple - always a URI . [CODESPLIT] public String getPredicate ( ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_predicate == null ) jcasType . jcas . throwFeatMissing ( "predicate" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_predicate ) ; }


Input: setter for predicate - sets The predicate of the triple - always a URI . [CODESPLIT] public void setPredicate ( String v ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_predicate == null ) jcasType . jcas . throwFeatMissing ( "predicate" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_predicate , v ) ; }


Input: getter for object - gets The object of the triple - may be a URI or an xml datatype ( string int etc . ) . See isObjeUri to determine if object is a URI . [CODESPLIT] public String getObject ( ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_object == null ) jcasType . jcas . throwFeatMissing ( "object" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_object ) ; }


Input: setter for object - sets The object of the triple - may be a URI or an xml datatype ( string int etc . ) . See isObjeUri to determine if object is a URI . [CODESPLIT] public void setObject ( String v ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_object == null ) jcasType . jcas . throwFeatMissing ( "object" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_object , v ) ; }


Input: getter for isObjUri - gets Boolean flag - true of object field is a URI false otherwise . [CODESPLIT] public boolean getIsObjUri ( ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_isObjUri == null ) jcasType . jcas . throwFeatMissing ( "isObjUri" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; return jcasType . ll_cas . ll_getBooleanValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_isObjUri ) ; }


Input: setter for isObjUri - sets Boolean flag - true of object field is a URI false otherwise . [CODESPLIT] public void setIsObjUri ( boolean v ) { if ( Triple_Type . featOkTst && ( ( Triple_Type ) jcasType ) . casFeat_isObjUri == null ) jcasType . jcas . throwFeatMissing ( "isObjUri" , "edu.cmu.lti.oaqa.type.kb.Triple" ) ; jcasType . ll_cas . ll_setBooleanValue ( addr , ( ( Triple_Type ) jcasType ) . casFeatCode_isObjUri , v ) ; }


Input: getter for operator - gets The operator associated with this concept . [CODESPLIT] public QueryOperator getOperator ( ) { if ( ComplexQueryConcept_Type . featOkTst && ( ( ComplexQueryConcept_Type ) jcasType ) . casFeat_operator == null ) jcasType . jcas . throwFeatMissing ( "operator" , "edu.cmu.lti.oaqa.type.retrieval.ComplexQueryConcept" ) ; return ( QueryOperator ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( ComplexQueryConcept_Type ) jcasType ) . casFeatCode_operator ) ) ) ; }


Input: setter for operator - sets The operator associated with this concept . [CODESPLIT] public void setOperator ( QueryOperator v ) { if ( ComplexQueryConcept_Type . featOkTst && ( ( ComplexQueryConcept_Type ) jcasType ) . casFeat_operator == null ) jcasType . jcas . throwFeatMissing ( "operator" , "edu.cmu.lti.oaqa.type.retrieval.ComplexQueryConcept" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( ComplexQueryConcept_Type ) jcasType ) . casFeatCode_operator , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for operatorArgs - gets The operator arguments in a complex query concept . [CODESPLIT] public FSList getOperatorArgs ( ) { if ( ComplexQueryConcept_Type . featOkTst && ( ( ComplexQueryConcept_Type ) jcasType ) . casFeat_operatorArgs == null ) jcasType . jcas . throwFeatMissing ( "operatorArgs" , "edu.cmu.lti.oaqa.type.retrieval.ComplexQueryConcept" ) ; return ( FSList ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( ComplexQueryConcept_Type ) jcasType ) . casFeatCode_operatorArgs ) ) ) ; }


Input: setter for operatorArgs - sets The operator arguments in a complex query concept . [CODESPLIT] public void setOperatorArgs ( FSList v ) { if ( ComplexQueryConcept_Type . featOkTst && ( ( ComplexQueryConcept_Type ) jcasType ) . casFeat_operatorArgs == null ) jcasType . jcas . throwFeatMissing ( "operatorArgs" , "edu.cmu.lti.oaqa.type.retrieval.ComplexQueryConcept" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( ComplexQueryConcept_Type ) jcasType ) . casFeatCode_operatorArgs , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: activate Metrics [CODESPLIT] @ GET ( ) @ Path ( ACTIVATE_METRICS_FOR_CLASS ) public String activateMetricsForClass ( @ QueryParam ( QUERY_PARAM_CLASS_FQ_NAME ) final String classFQN ) { if ( classFQN != null && ! classFQN . isEmpty ( ) ) { try { final Class < ? > aClass = Class . forName ( classFQN ) ; DI . activateMetrics ( aClass ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; return e . getMessage ( ) ; } } return OK ; }


Input: deactivate Metrics [CODESPLIT] @ GET ( ) @ Path ( DE_ACTIVATE_METRICS_FOR_CLASS ) public String deActivateMetricsForClass ( @ QueryParam ( QUERY_PARAM_CLASS_FQ_NAME ) final String classFQN ) { if ( classFQN != null && ! classFQN . isEmpty ( ) ) { try { final Class < ? > aClass = Class . forName ( classFQN ) ; DI . deActivateMetrics ( aClass ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; return e . getMessage ( ) ; } return OK ; } return NOT_OK ; }


Input: getter for concept - gets The abstract concept that the text span conveys . [CODESPLIT] public Concept getConcept ( ) { if ( ConceptMention_Type . featOkTst && ( ( ConceptMention_Type ) jcasType ) . casFeat_concept == null ) jcasType . jcas . throwFeatMissing ( "concept" , "edu.cmu.lti.oaqa.type.kb.ConceptMention" ) ; return ( Concept ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( ConceptMention_Type ) jcasType ) . casFeatCode_concept ) ) ) ; }


Input: getter for matchedName - gets A synonym of the concept that best matches the concept mention ( similar to conceptMatched in metamap ) . [CODESPLIT] public String getMatchedName ( ) { if ( ConceptMention_Type . featOkTst && ( ( ConceptMention_Type ) jcasType ) . casFeat_matchedName == null ) jcasType . jcas . throwFeatMissing ( "matchedName" , "edu.cmu.lti.oaqa.type.kb.ConceptMention" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( ConceptMention_Type ) jcasType ) . casFeatCode_matchedName ) ; }


Input: setter for matchedName - sets A synonym of the concept that best matches the concept mention ( similar to conceptMatched in metamap ) . [CODESPLIT] public void setMatchedName ( String v ) { if ( ConceptMention_Type . featOkTst && ( ( ConceptMention_Type ) jcasType ) . casFeat_matchedName == null ) jcasType . jcas . throwFeatMissing ( "matchedName" , "edu.cmu.lti.oaqa.type.kb.ConceptMention" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( ConceptMention_Type ) jcasType ) . casFeatCode_matchedName , v ) ; }


Input: getter for score - gets The confidence score that the concept mention matches the concept . [CODESPLIT] public double getScore ( ) { if ( ConceptMention_Type . featOkTst && ( ( ConceptMention_Type ) jcasType ) . casFeat_score == null ) jcasType . jcas . throwFeatMissing ( "score" , "edu.cmu.lti.oaqa.type.kb.ConceptMention" ) ; return jcasType . ll_cas . ll_getDoubleValue ( addr , ( ( ConceptMention_Type ) jcasType ) . casFeatCode_score ) ; }


Input: getter for text - gets The candidate answer string . [CODESPLIT] public String getText ( ) { if ( CandidateAnswerOccurrence_Type . featOkTst && ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeat_text == null ) jcasType . jcas . throwFeatMissing ( "text" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerOccurrence" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeatCode_text ) ; }


Input: setter for text - sets The candidate answer string . [CODESPLIT] public void setText ( String v ) { if ( CandidateAnswerOccurrence_Type . featOkTst && ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeat_text == null ) jcasType . jcas . throwFeatMissing ( "text" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerOccurrence" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeatCode_text , v ) ; }


Input: getter for mentionType - gets The manner in which covered text refers to some entity e . g . NAME NOMINAL PRONOUN [CODESPLIT] public String getMentionType ( ) { if ( CandidateAnswerOccurrence_Type . featOkTst && ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeat_mentionType == null ) jcasType . jcas . throwFeatMissing ( "mentionType" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerOccurrence" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeatCode_mentionType ) ; }


Input: setter for mentionType - sets The manner in which covered text refers to some entity e . g . NAME NOMINAL PRONOUN [CODESPLIT] public void setMentionType ( String v ) { if ( CandidateAnswerOccurrence_Type . featOkTst && ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeat_mentionType == null ) jcasType . jcas . throwFeatMissing ( "mentionType" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerOccurrence" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( CandidateAnswerOccurrence_Type ) jcasType ) . casFeatCode_mentionType , v ) ; }


Input: getter for id - gets The id of the concept type . [CODESPLIT] public String getId ( ) { if ( ConceptType_Type . featOkTst && ( ( ConceptType_Type ) jcasType ) . casFeat_id == null ) jcasType . jcas . throwFeatMissing ( "id" , "edu.cmu.lti.oaqa.type.kb.ConceptType" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( ConceptType_Type ) jcasType ) . casFeatCode_id ) ; }


Input: setter for id - sets The id of the concept type . [CODESPLIT] public void setId ( String v ) { if ( ConceptType_Type . featOkTst && ( ( ConceptType_Type ) jcasType ) . casFeat_id == null ) jcasType . jcas . throwFeatMissing ( "id" , "edu.cmu.lti.oaqa.type.kb.ConceptType" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( ConceptType_Type ) jcasType ) . casFeatCode_id , v ) ; }


Input: getter for name - gets A human readable concept label . [CODESPLIT] public String getName ( ) { if ( ConceptType_Type . featOkTst && ( ( ConceptType_Type ) jcasType ) . casFeat_name == null ) jcasType . jcas . throwFeatMissing ( "name" , "edu.cmu.lti.oaqa.type.kb.ConceptType" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( ConceptType_Type ) jcasType ) . casFeatCode_name ) ; }


Input: getter for abbreviation - gets The abbreviation of the name label . [CODESPLIT] public String getAbbreviation ( ) { if ( ConceptType_Type . featOkTst && ( ( ConceptType_Type ) jcasType ) . casFeat_abbreviation == null ) jcasType . jcas . throwFeatMissing ( "abbreviation" , "edu.cmu.lti.oaqa.type.kb.ConceptType" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( ConceptType_Type ) jcasType ) . casFeatCode_abbreviation ) ; }


Input: setter for abbreviation - sets The abbreviation of the name label . [CODESPLIT] public void setAbbreviation ( String v ) { if ( ConceptType_Type . featOkTst && ( ( ConceptType_Type ) jcasType ) . casFeat_abbreviation == null ) jcasType . jcas . throwFeatMissing ( "abbreviation" , "edu.cmu.lti.oaqa.type.kb.ConceptType" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( ConceptType_Type ) jcasType ) . casFeatCode_abbreviation , v ) ; }


Input: setter for concept - sets The relevant concept searched in the ontology . [CODESPLIT] public void setConcept ( Concept v ) { if ( ConceptSearchResult_Type . featOkTst && ( ( ConceptSearchResult_Type ) jcasType ) . casFeat_concept == null ) jcasType . jcas . throwFeatMissing ( "concept" , "edu.cmu.lti.oaqa.type.retrieval.ConceptSearchResult" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( ConceptSearchResult_Type ) jcasType ) . casFeatCode_concept , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for variants - gets List of candidate answer variants that were merged into this final answer . [CODESPLIT] public FSList getVariants ( ) { if ( Answer_Type . featOkTst && ( ( Answer_Type ) jcasType ) . casFeat_variants == null ) jcasType . jcas . throwFeatMissing ( "variants" , "edu.cmu.lti.oaqa.type.answer.Answer" ) ; return ( FSList ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( Answer_Type ) jcasType ) . casFeatCode_variants ) ) ) ; }


Input: setter for variants - sets List of candidate answer variants that were merged into this final answer . [CODESPLIT] public void setVariants ( FSList v ) { if ( Answer_Type . featOkTst && ( ( Answer_Type ) jcasType ) . casFeat_variants == null ) jcasType . jcas . throwFeatMissing ( "variants" , "edu.cmu.lti.oaqa.type.answer.Answer" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( Answer_Type ) jcasType ) . casFeatCode_variants , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for namedEntityTypes - gets List of Named Entity types associated with this concept . [CODESPLIT] public StringList getNamedEntityTypes ( ) { if ( QueryConcept_Type . featOkTst && ( ( QueryConcept_Type ) jcasType ) . casFeat_namedEntityTypes == null ) jcasType . jcas . throwFeatMissing ( "namedEntityTypes" , "edu.cmu.lti.oaqa.type.retrieval.QueryConcept" ) ; return ( StringList ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( QueryConcept_Type ) jcasType ) . casFeatCode_namedEntityTypes ) ) ) ; }


Input: setter for namedEntityTypes - sets List of Named Entity types associated with this concept . [CODESPLIT] public void setNamedEntityTypes ( StringList v ) { if ( QueryConcept_Type . featOkTst && ( ( QueryConcept_Type ) jcasType ) . casFeat_namedEntityTypes == null ) jcasType . jcas . throwFeatMissing ( "namedEntityTypes" , "edu.cmu.lti.oaqa.type.retrieval.QueryConcept" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( QueryConcept_Type ) jcasType ) . casFeatCode_namedEntityTypes , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for conceptType - gets The type of this concept . [CODESPLIT] public String getConceptType ( ) { if ( QueryConcept_Type . featOkTst && ( ( QueryConcept_Type ) jcasType ) . casFeat_conceptType == null ) jcasType . jcas . throwFeatMissing ( "conceptType" , "edu.cmu.lti.oaqa.type.retrieval.QueryConcept" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( QueryConcept_Type ) jcasType ) . casFeatCode_conceptType ) ; }


Input: setter for conceptType - sets The type of this concept . [CODESPLIT] public void setConceptType ( String v ) { if ( QueryConcept_Type . featOkTst && ( ( QueryConcept_Type ) jcasType ) . casFeat_conceptType == null ) jcasType . jcas . throwFeatMissing ( "conceptType" , "edu.cmu.lti.oaqa.type.retrieval.QueryConcept" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( QueryConcept_Type ) jcasType ) . casFeatCode_conceptType , v ) ; }


Input: TODO extend for a Vaadin App Version [CODESPLIT] private static DeploymentInfo createServletDeploymentInfos ( ) { final Set < Class < ? > > typesAnnotatedWith = DI . getTypesAnnotatedWith ( WebServlet . class , true ) ; final List < ServletInfo > servletInfos = typesAnnotatedWith . stream ( ) . filter ( s -> new ReflectionUtils ( ) . checkInterface ( s , HttpServlet . class ) ) . map ( c -> { Class < HttpServlet > servletClass = ( Class < HttpServlet > ) c ; final ServletInfo servletInfo = servlet ( c . getSimpleName ( ) , servletClass , new ServletInstanceFactory <> ( servletClass ) ) ; if ( c . isAnnotationPresent ( WebInitParam . class ) ) { final WebInitParam [ ] annotationsByType = c . getAnnotationsByType ( WebInitParam . class ) ; for ( WebInitParam webInitParam : annotationsByType ) { final String value = webInitParam . value ( ) ; final String name = webInitParam . name ( ) ; servletInfo . addInitParam ( name , value ) ; } } final WebServlet annotation = c . getAnnotation ( WebServlet . class ) ; final String [ ] urlPatterns = annotation . urlPatterns ( ) ; for ( String urlPattern : urlPatterns ) { servletInfo . addMapping ( urlPattern ) ; } servletInfo . setAsyncSupported ( annotation . asyncSupported ( ) ) ; return servletInfo ; } ) . filter ( servletInfo -> ! servletInfo . getMappings ( ) . isEmpty ( ) ) . collect ( Collectors . toList ( ) ) ; final Set < Class < ? > > weblisteners = DI . getTypesAnnotatedWith ( WebListener . class ) ; final List < ListenerInfo > listenerInfos = weblisteners . stream ( ) . map ( c -> new ListenerInfo ( ( Class < ? extends EventListener > ) c ) ) . collect ( Collectors . toList ( ) ) ; final DeploymentInfo deploymentInfo = deployment ( ) . setClassLoader ( Main . class . getClassLoader ( ) ) . setContextPath ( MYAPP ) . setDeploymentName ( "ROOT" + ".war" ) . setDefaultEncoding ( "UTF-8" ) ; final Boolean shiroActive = Boolean . valueOf ( System . getProperty ( SHIRO_ACTIVE_PROPERTY , "false" ) ) ; final Boolean stagemonitorActive = Boolean . valueOf ( System . getProperty ( STAGEMONITOR_ACTIVE_PROPERTY , "false" ) ) ; if ( shiroActive ) addShiroFilter ( ) . apply ( deploymentInfo , DEFAULT_SHIRO_FILTER_NAME , DEFAULT_FILTER_MAPPING ) ; if ( stagemonitorActive ) addStagemonitor ( ) . apply ( deploymentInfo ) ; return deploymentInfo . addListeners ( listenerInfos ) . addServletContextAttribute ( WebSocketDeploymentInfo . ATTRIBUTE_NAME , new WebSocketDeploymentInfo ( ) ) . addServlets ( servletInfos ) ; }


Input: getter for occurrences - gets The occurrences of this variant . [CODESPLIT] public FSList getOccurrences ( ) { if ( CandidateAnswerVariant_Type . featOkTst && ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeat_occurrences == null ) jcasType . jcas . throwFeatMissing ( "occurrences" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerVariant" ) ; return ( FSList ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeatCode_occurrences ) ) ) ; }


Input: setter for occurrences - sets The occurrences of this variant . [CODESPLIT] public void setOccurrences ( FSList v ) { if ( CandidateAnswerVariant_Type . featOkTst && ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeat_occurrences == null ) jcasType . jcas . throwFeatMissing ( "occurrences" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerVariant" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeatCode_occurrences , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: setter for names - sets Names for a given candidate answer variant e . g . Tandy Tandy Inc . for candidate answer Variant Tandy Incorporated . [CODESPLIT] public void setNames ( StringList v ) { if ( CandidateAnswerVariant_Type . featOkTst && ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeat_names == null ) jcasType . jcas . throwFeatMissing ( "names" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerVariant" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeatCode_names , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for docId - gets The unique id of the document ( if any ) from which this candidate answer was generated . [CODESPLIT] public String getDocId ( ) { if ( CandidateAnswerVariant_Type . featOkTst && ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeat_docId == null ) jcasType . jcas . throwFeatMissing ( "docId" , "edu.cmu.lti.oaqa.type.answer.CandidateAnswerVariant" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( CandidateAnswerVariant_Type ) jcasType ) . casFeatCode_docId ) ; }


Input: getter for concepts - gets The list of query concepts that make up this abstract query . The list is ordered . [CODESPLIT] public FSList getConcepts ( ) { if ( AbstractQuery_Type . featOkTst && ( ( AbstractQuery_Type ) jcasType ) . casFeat_concepts == null ) jcasType . jcas . throwFeatMissing ( "concepts" , "edu.cmu.lti.oaqa.type.retrieval.AbstractQuery" ) ; return ( FSList ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( AbstractQuery_Type ) jcasType ) . casFeatCode_concepts ) ) ) ; }


Input: setter for concepts - sets The list of query concepts that make up this abstract query . The list is ordered . [CODESPLIT] public void setConcepts ( FSList v ) { if ( AbstractQuery_Type . featOkTst && ( ( AbstractQuery_Type ) jcasType ) . casFeat_concepts == null ) jcasType . jcas . throwFeatMissing ( "concepts" , "edu.cmu.lti.oaqa.type.retrieval.AbstractQuery" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( AbstractQuery_Type ) jcasType ) . casFeatCode_concepts , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for originalText - gets The lexical string in the question . [CODESPLIT] public String getOriginalText ( ) { if ( AtomicQueryConcept_Type . featOkTst && ( ( AtomicQueryConcept_Type ) jcasType ) . casFeat_originalText == null ) jcasType . jcas . throwFeatMissing ( "originalText" , "edu.cmu.lti.oaqa.type.retrieval.AtomicQueryConcept" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( AtomicQueryConcept_Type ) jcasType ) . casFeatCode_originalText ) ; }


Input: setter for originalText - sets The lexical string in the question . [CODESPLIT] public void setOriginalText ( String v ) { if ( AtomicQueryConcept_Type . featOkTst && ( ( AtomicQueryConcept_Type ) jcasType ) . casFeat_originalText == null ) jcasType . jcas . throwFeatMissing ( "originalText" , "edu.cmu.lti.oaqa.type.retrieval.AtomicQueryConcept" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( AtomicQueryConcept_Type ) jcasType ) . casFeatCode_originalText , v ) ; }


Input: getter for args - gets The arguments for the operator . [CODESPLIT] public StringList getArgs ( ) { if ( QueryOperator_Type . featOkTst && ( ( QueryOperator_Type ) jcasType ) . casFeat_args == null ) jcasType . jcas . throwFeatMissing ( "args" , "edu.cmu.lti.oaqa.type.retrieval.QueryOperator" ) ; return ( StringList ) ( jcasType . ll_cas . ll_getFSForRef ( jcasType . ll_cas . ll_getRefValue ( addr , ( ( QueryOperator_Type ) jcasType ) . casFeatCode_args ) ) ) ; }


Input: setter for args - sets The arguments for the operator . [CODESPLIT] public void setArgs ( StringList v ) { if ( QueryOperator_Type . featOkTst && ( ( QueryOperator_Type ) jcasType ) . casFeat_args == null ) jcasType . jcas . throwFeatMissing ( "args" , "edu.cmu.lti.oaqa.type.retrieval.QueryOperator" ) ; jcasType . ll_cas . ll_setRefValue ( addr , ( ( QueryOperator_Type ) jcasType ) . casFeatCode_args , jcasType . ll_cas . ll_getFSRef ( v ) ) ; }


Input: getter for label - gets The semantic role label . [CODESPLIT] public String getLabel ( ) { if ( SemanticRole_Type . featOkTst && ( ( SemanticRole_Type ) jcasType ) . casFeat_label == null ) jcasType . jcas . throwFeatMissing ( "label" , "edu.cmu.lti.oaqa.type.nlp.SemanticRole" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( SemanticRole_Type ) jcasType ) . casFeatCode_label ) ; }


Input: setter for label - sets The semantic role label . [CODESPLIT] public void setLabel ( String v ) { if ( SemanticRole_Type . featOkTst && ( ( SemanticRole_Type ) jcasType ) . casFeat_label == null ) jcasType . jcas . throwFeatMissing ( "label" , "edu.cmu.lti.oaqa.type.nlp.SemanticRole" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( SemanticRole_Type ) jcasType ) . casFeatCode_label , v ) ; }


Input: Find the next clear bit in the bit set . [CODESPLIT] public int nextClearBit ( int index ) { int i = index >> 6 ; if ( i >= wlen ) return - 1 ; int subIndex = index & 0x3f ; // index within the word long word = ~ bits . get ( i ) >> subIndex ; // skip all the bits to the right of // index if ( word != 0 ) { return ( i << 6 ) + subIndex + Long . numberOfTrailingZeros ( word ) ; } while ( ++ i < wlen ) { word = ~ bits . get ( i ) ; if ( word != 0 ) { return ( i << 6 ) + Long . numberOfTrailingZeros ( word ) ; } } return - 1 ; }


Input: Thread safe set operation that will set the bit if and only if the bit was not previously set . [CODESPLIT] public boolean set ( int index ) { int wordNum = index >> 6 ; // div 64 int bit = index & 0x3f ; // mod 64 long bitmask = 1L << bit ; long word , oword ; do { word = bits . get ( wordNum ) ; // if set another thread stole the lock if ( ( word & bitmask ) != 0 ) { return false ; } oword = word ; word |= bitmask ; } while ( ! bits . compareAndSet ( wordNum , oword , word ) ) ; return true ; }


Input: toString [CODESPLIT] private String selectToString ( ) { StringBuilder sql = new StringBuilder ( "select " ) ; sql . append ( Seq . join ( fields , ", " ) ) . append ( " from " ) . append ( Seq . join ( tables , " join " ) ) ; if ( ! conditions . isEmpty ( ) ) { sql . append ( " where " ) . append ( Seq . join ( conditions , " and " ) ) ; } if ( ! groups . isEmpty ( ) ) { sql . append ( " group by " ) . append ( Seq . join ( groups , ", " ) ) ; if ( ! having . isEmpty ( ) ) { sql . append ( " having " ) . append ( Seq . join ( having , " and " ) ) ; } } if ( ! orders . isEmpty ( ) ) { sql . append ( " order by " ) . append ( Seq . join ( orders , ", " ) ) ; } if ( limit > 0 ) { sql . append ( " limit " ) . append ( Integer . toString ( limit ) ) ; } if ( offset > - 1 ) { sql . append ( " offset " ) . append ( Integer . toString ( offset ) ) ; } return sql . toString ( ) ; }


Input: / * Transaction [CODESPLIT] public void batch ( Runnable transaction ) { // TODO: 不支持嵌套事务 try ( Connection c = pool . getConnection ( ) ) { boolean commit = c . getAutoCommit ( ) ; try { c . setAutoCommit ( false ) ; } catch ( SQLException e ) { throw new TransactionException ( "transaction setAutoCommit(false)" , e ) ; } base . set ( c ) ; try { transaction . run ( ) ; } catch ( RuntimeException e ) { try { c . rollback ( ) ; c . setAutoCommit ( commit ) ; } catch ( SQLException ex ) { throw new TransactionException ( "transaction rollback: " + ex . getMessage ( ) , e ) ; } throw e ; } try { c . commit ( ) ; } catch ( SQLException e ) { throw new TransactionException ( "transaction commit" , e ) ; } c . setAutoCommit ( commit ) ; } catch ( SQLException e ) { throw new DBOpenException ( e ) ; } finally { base . set ( null ) ; } }


Input: This code was copied form MMAPDirectory in Lucene . [CODESPLIT] protected void freeBuffer ( final ByteBuffer buffer ) throws IOException { if ( buffer == null ) { return ; } if ( UNMAP_SUPPORTED ) { try { AccessController . doPrivileged ( new PrivilegedExceptionAction < Void > ( ) { @ Override public Void run ( ) throws Exception { final Method getCleanerMethod = buffer . getClass ( ) . getMethod ( "cleaner" ) ; getCleanerMethod . setAccessible ( true ) ; final Object cleaner = getCleanerMethod . invoke ( buffer ) ; if ( cleaner != null ) { cleaner . getClass ( ) . getMethod ( "clean" ) . invoke ( cleaner ) ; } return null ; } } ) ; } catch ( PrivilegedActionException e ) { final IOException ioe = new IOException ( "unable to unmap the mapped buffer" ) ; ioe . initCause ( e . getCause ( ) ) ; throw ioe ; } } }


Input: Creates a new instance of CacheValue the cache capacity should be used for the given file . [CODESPLIT] public CacheValue newInstance ( CacheDirectory directory , String fileName ) { return newInstance ( directory , fileName , getCacheBlockSize ( directory , fileName ) ) ; }


Input: 继承给定的JavaBean，扩展Record对象的get和set方法。 [CODESPLIT] public Table extend ( Object bean ) { Class < ? > type = bean . getClass ( ) ; for ( Method method : type . getDeclaredMethods ( ) ) { Class < ? > returnType = method . getReturnType ( ) ; Class < ? > [ ] params = method . getParameterTypes ( ) ; String key = method . getName ( ) ; if ( params . length == 2 && key . length ( ) > 3 && ( key . startsWith ( "get" ) || key . startsWith ( "set" ) ) && params [ 0 ] . isAssignableFrom ( Record . class ) && params [ 1 ] . isAssignableFrom ( Object . class ) && Object . class . isAssignableFrom ( returnType ) ) { key = key . replaceAll ( "(?=[A-Z])" , "_" ) . toLowerCase ( ) ; hooks . put ( key , new Lambda ( bean , method ) ) ; } } return this ; }


Input: / * Association [CODESPLIT] private Association assoc ( String name , boolean onlyOne , boolean ancestor ) { name = DB . parseKeyParameter ( name ) ; Association assoc = new Association ( relations , name , onlyOne , ancestor ) ; relations . put ( name , assoc ) ; return assoc ; }


Input: / * CRUD [CODESPLIT] public Record create ( Object ... args ) { Map < String , Object > data = new HashMap <> ( ) ; data . putAll ( foreignKeys ) ; for ( int i = 0 ; i < args . length ; i += 2 ) { String key = DB . parseKeyParameter ( args [ i ] . toString ( ) ) ; if ( ! columns . containsKey ( key ) ) { throw new IllegalFieldNameException ( key ) ; } Object value = args [ i + 1 ] ; data . put ( key , value ) ; } String [ ] fields = new String [ data . size ( ) + 2 ] ; int [ ] types = new int [ data . size ( ) + 2 ] ; Object [ ] values = new Object [ data . size ( ) + 2 ] ; int index = 0 ; for ( Map . Entry < String , Object > e : data . entrySet ( ) ) { fields [ index ] = e . getKey ( ) ; types [ index ] = columns . get ( e . getKey ( ) ) ; values [ index ] = e . getValue ( ) ; index ++ ; } Seq . assignAt ( fields , Seq . array ( - 2 , - 1 ) , "created_at" , "updated_at" ) ; Seq . assignAt ( types , Seq . array ( - 2 , - 1 ) , Types . TIMESTAMP , Types . TIMESTAMP ) ; Seq . assignAt ( values , Seq . array ( - 2 , - 1 ) , DB . now ( ) , DB . now ( ) ) ; SqlBuilder sql = new TSqlBuilder ( ) ; sql . insert ( ) . into ( name ) . values ( fields ) ; PreparedStatement call = dbo . prepare ( sql . toString ( ) , values , types ) ; try { int id = 0 ; if ( call . executeUpdate ( ) > 0 ) { ResultSet rs = call . getGeneratedKeys ( ) ; if ( rs != null && rs . next ( ) ) { id = rs . getInt ( 1 ) ; rs . close ( ) ; } } return id > 0 ? find ( id ) : null ; } catch ( SQLException e ) { throw new SqlExecuteException ( sql . toString ( ) , e ) ; } finally { dbo . close ( call ) ; } }


Input: 根据现有的Record创建新的Record . 为跨数据库之间导数据提供便捷接口；同时也方便根据模板创建多条相似的纪录。 [CODESPLIT] public Record create ( Record o ) { List < Object > params = new LinkedList <> ( ) ; for ( String key : columns . keySet ( ) ) { if ( ! foreignKeys . containsKey ( key ) ) { params . add ( key ) ; params . add ( o . get ( key ) ) ; } } return create ( params . toArray ( ) ) ; }


Input: 根据指定列，返回符合条件的第一条记录 . [CODESPLIT] public Record findA ( String key , Object value ) { key = DB . parseKeyParameter ( key ) ; if ( value != null ) { return first ( key . concat ( " = ?" ) , value ) ; } else { return first ( key . concat ( " is null" ) ) ; } }


Input: 判断当前数据库的名称里是否包含hsql（忽略大小写）。 [CODESPLIT] @ Override public boolean accept ( Connection c ) { try { DatabaseMetaData d = c . getMetaData ( ) ; String name = d . getDatabaseProductName ( ) ; // HSQL Database Engine return name . toLowerCase ( ) . contains ( "hsql" ) ; } catch ( SQLException e ) { throw new DBOpenException ( e ) ; } }


Input: Flushes the in - memory bufer to the given output copying at most <code > numBytes< / code > . <p > <b > NOTE : < / b > this method does not refill the buffer however it does advance the buffer position . [CODESPLIT] protected final int flushBuffer ( IndexOutput out , long numBytes ) throws IOException { int toCopy = bufferLength - bufferPosition ; if ( toCopy > numBytes ) { toCopy = ( int ) numBytes ; } if ( toCopy > 0 ) { out . writeBytes ( buffer , bufferPosition , toCopy ) ; bufferPosition += toCopy ; } return toCopy ; }


Input: 将一系列对象组装成List。 [CODESPLIT] public static < E > List < E > list ( E ... args ) { List < E > list = new ArrayList <> ( ) ; list . addAll ( Arrays . asList ( args ) ) ; return list ; }


Input: 追加任意多个新元素到数组末尾。 [CODESPLIT] public static < E > E [ ] concat ( E [ ] a , E ... b ) { return merge ( a , b ) ; }


Input: 将数组连接成字符串。 [CODESPLIT] public static String join ( String delimiter , Object ... args ) { return join ( Arrays . asList ( args ) , delimiter ) ; }


Input: 将容器里的元素连接成字符串。 [CODESPLIT] public static String join ( Collection < ? > list , String delimiter ) { if ( list == null || list . isEmpty ( ) ) { return "" ; } if ( delimiter == null ) { delimiter = "" ; } StringBuilder s = new StringBuilder ( ) ; boolean first = true ; for ( Object e : list ) { if ( first ) { first = false ; } else { s . append ( delimiter ) ; } s . append ( e ) ; } return s . toString ( ) ; }


Input: 合并两个数组。 [CODESPLIT] public static < E > E [ ] merge ( E [ ] a , E [ ] b ) { List < E > list = merge ( Arrays . asList ( a ) , Arrays . asList ( b ) ) ; return list . toArray ( a ) ; }


Input: 合并两个List。 [CODESPLIT] public static < E > List < E > merge ( List < E > a , List < E > b ) { List < E > list = new ArrayList <> ( ) ; list . addAll ( a ) ; list . addAll ( b ) ; return list ; }


Input: 从数组中删除所有与给定对象equals的元素。 [CODESPLIT] public static < E > E [ ] remove ( E [ ] a , E e ) { List < E > list = remove ( Arrays . asList ( a ) , e ) ; return ( E [ ] ) list . toArray ( ) ; }


Input: 从List中删除所有与给定对象equals的元素。 [CODESPLIT] public static < E > List < E > remove ( List < E > a , E e ) { List < E > list = new ArrayList <> ( ) ; for ( E o : a ) { if ( ! o . equals ( e ) ) { list . add ( o ) ; } } return list ; }


Input: 根据给定的下标，选出多个元素，并组成新的数组。 [CODESPLIT] public static < E > E [ ] valuesAt ( E [ ] a , int ... indexes ) { List < E > list = valuesAt ( Arrays . asList ( a ) , indexes ) ; return ( E [ ] ) list . toArray ( ) ; }


Input: 根据给定的下标，选出多个元素，并组成新的List。 [CODESPLIT] public static < E > List < E > valuesAt ( List < E > from , int ... indexes ) { List < E > list = new ArrayList <> ( ) ; for ( int i : indexes ) { if ( 0 <= i && i < from . size ( ) ) { list . add ( from . get ( i ) ) ; } else if ( - from . size ( ) <= i && i < 0 ) { list . add ( from . get ( from . size ( ) + i ) ) ; } else { list . add ( null ) ; } } return list ; }


Input: 同时给int数组中多个位置同时赋值。 [CODESPLIT] public static int [ ] assignAt ( int [ ] a , Integer [ ] indexes , int ... values ) { if ( indexes . length != values . length ) { throw new IllegalArgumentException ( String . format ( "index.length(%d) != values.length(%d)" , indexes . length , values . length ) ) ; } for ( int i = 0 ; i < indexes . length ; i ++ ) { int index = indexes [ i ] ; if ( 0 <= index && index < a . length ) { a [ index ] = values [ i ] ; } else if ( - a . length <= index && index < 0 ) { a [ a . length + index ] = values [ i ] ; } else { throw new ArrayIndexOutOfBoundsException ( index ) ; } } return a ; }


Input: 根据规定格式，对容器中的每个元素进行格式化，并返回格式化后的结果。 [CODESPLIT] public static List < String > map ( Collection < ? > from , String format ) { List < String > to = new ArrayList <> ( from . size ( ) ) ; for ( Object e : from ) { to . add ( String . format ( format , e ) ) ; } return to ; }


Input: 拆分容器，每份至多包含n个元素，将每堆元素连接成一个独立字符串。 [CODESPLIT] public static List < String > partition ( Collection < String > from , int n , String delimiter ) { List < String > to = new ArrayList <> ( ) ; List < String > buffer = new ArrayList <> ( n ) ; for ( String e : from ) { buffer . add ( e ) ; if ( buffer . size ( ) >= n ) { to . add ( join ( buffer , delimiter ) ) ; buffer . clear ( ) ; } } return to ; }


Input: Rebuild the backing array with a different size . [CODESPLIT] private static Object [ ] rehash ( final Object [ ] values , final int newSize ) { Object [ ] newArray = new Object [ newSize ] ; for ( Object value : values ) { if ( value == null ) { continue ; } newArray [ predictedPosition ( newArray , value , value . hashCode ( ) ) ] = value ; } return newArray ; }


Input: Calculates the position of the given element in the given array . The value at the calculated position will be <code > null< / code > if the element doesn t exist in the array otherwise the position will point to the element . [CODESPLIT] private static int predictedPosition ( final Object [ ] array , final Object object , final int hash ) { int arraySize = array . length ; int i = Math . abs ( hash ) % arraySize ; Object element = array [ i ] ; while ( element != null ) // the load factor guarantees that there is always at least one free slot { if ( element . equals ( object ) ) { // already in the array return i ; } // the position is taken, try the next slot i = ( i + 1 ) % arraySize ; element = array [ i ] ; } return i ; }


Input: Move { [CODESPLIT] private void findNextSeparator ( ) { mLastSeparatorPos = mNextSeparatorPos ; while ( ++ mNextSeparatorPos < mValue . length ( ) ) { char c = mValue . charAt ( mNextSeparatorPos ) ; if ( c == mSeparator ) { return ; } } }


Input: Move { [CODESPLIT] private void findNextSeparator ( ) { boolean isQuoted = false ; mLastSeparatorPos = mNextSeparatorPos ; while ( ++ mNextSeparatorPos < mValue . length ( ) ) { char c = mValue . charAt ( mNextSeparatorPos ) ; if ( c == mSeparator ) { if ( ! isQuoted ) { return ; } // else: ignore quoted speparator } else if ( c == ' ' ) { isQuoted = ! isQuoted ; } } }


Input: method to generate a valid HELM2 of this object [CODESPLIT] public String toHELM2 ( ) { StringBuilder notation = new StringBuilder ( ) ; for ( int i = 0 ; i < listMonomerNotations . size ( ) ; i ++ ) { notation . append ( listMonomerNotations . get ( i ) . toHELM2 ( ) + "." ) ; } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input: @return PolymerElments in HELM format @throws HELM1ConverterException if one single object can not be downgraded to HELM1 - Format [CODESPLIT] public String toHELM ( ) throws HELM1ConverterException { StringBuilder notation = new StringBuilder ( ) ; for ( int i = 0 ; i < listMonomerNotations . size ( ) ; i ++ ) { notation . append ( listMonomerNotations . get ( i ) . toHELM ( ) + "." ) ; } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input: { @inheritDoc } [CODESPLIT] @ Override public void doAction ( char cha ) throws ConnectionSectionException , NotationException { /* list of connections is empty */ if ( cha == ' ' ) { if ( sourcepolymerid == "" && _parser . notationContainer . getListOfConnections ( ) . size ( ) == 0 ) { LOG . info ( "Connection section is empty:" ) ; LOG . info ( "Transition to group section:" ) ; _parser . setState ( new GroupingParser ( _parser ) ) ; } else { LOG . error ( "Missing target polymer ID in connection section:" ) ; throw new ConnectionSectionException ( "Missing target polymer id in connection section. Source of connection is " + sourcepolymerid ) ; } } /* target polymer ID is starting */ else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { if ( _parser . checkPolymeridConnection ( sourcepolymerid ) ) { LOG . info ( "Target polymer ID is read:" ) ; _parser . notationContainer . addConnection ( new ConnectionNotation ( sourcepolymerid ) ) ; _parser . setState ( new ConnectionsReadSecondIDParser ( _parser ) ) ; } else { LOG . error ( "Source polymer ID is not correct in the connection section: " + sourcepolymerid ) ; throw new ConnectionSectionException ( "Source polymer id is not correct in the connection section: " + sourcepolymerid ) ; } } else { sourcepolymerid += cha ; if ( cha == ' ' ) { parenthesisCounterOpen += 1 ; } if ( cha == ' ' ) { parenthesisCounterClose += 1 ; } } }


Input: { [CODESPLIT] public String toHELM2 ( ) { DecimalFormat d = new DecimalFormat ( "#.##" ) ; StringBuilder notation = new StringBuilder ( ) ; for ( int i = 0 ; i < elements . size ( ) ; i ++ ) { if ( ! ( elements . get ( i ) . isDefaultValue ( ) ) ) { String value = d . format ( elements . get ( i ) . getValue ( ) . get ( 0 ) ) . replace ( ' ' , ' ' ) ; if ( elements . get ( i ) . getValue ( ) . size ( ) > 1 ) { value += "-" + d . format ( elements . get ( i ) . getValue ( ) . get ( 1 ) ) . replace ( ' ' , ' ' ) ; } notation . append ( elements . get ( i ) . getID ( ) + ":" + value + "," ) ; } else { notation . append ( elements . get ( i ) . getID ( ) + "," ) ; } } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws AnnotationSectionException { /* list of attributes is finished */ if ( cha == ' ' ) { if ( checkBracketsParenthesis ( ) ) { LOG . info ( "Annotation section is finished:" ) ; if ( annotation != "" ) { _parser . notationContainer . addAnnotation ( new AnnotationNotation ( annotation ) ) ; } LOG . info ( "Transition to FinalState:" ) ; _parser . setState ( new FinalState ( ) ) ; } else { LOG . info ( "Annotation section is not valid: " + annotation ) ; throw new AnnotationSectionException ( "Annotation section is not valid: " + annotation ) ; } } else if ( cha == ' ' ) { if ( checkBracketsParenthesis ( ) ) { LOG . info ( " new annotation is starting" ) ; if ( annotation != "" ) { _parser . notationContainer . addAnnotation ( new AnnotationNotation ( annotation ) ) ; _parser . setState ( new AnnotationsParser ( _parser ) ) ; } else { LOG . info ( "Annotation section is not valid: " ) ; throw new AnnotationSectionException ( "Annotation section is not valid: " ) ; } } } else { annotation += cha ; if ( cha == ' ' ) { curlyBracketCounterOpen ++ ; } if ( cha == ' ' ) { curlyBracketCounterClose ++ ; } if ( cha == ' ' ) { bracketCounterOpen ++ ; } if ( cha == ' ' ) { bracketCounterClose ++ ; } if ( cha == ' ' ) { parenthesisCounterOpen ++ ; } if ( cha == ' ' ) { parenthesisCounterClose ++ ; } } }


Input: method to check if all open brackets are closed [CODESPLIT] private boolean checkBracketsParenthesis ( ) { LOG . debug ( "Check of brackets in the annotation section:" ) ; if ( bracketCounterOpen == bracketCounterClose && parenthesisCounterOpen == parenthesisCounterClose && curlyBracketCounterOpen == curlyBracketCounterClose ) { return true ; } return false ; }


Input: method to set the details of the current connection [CODESPLIT] private void addDetails ( String str ) throws NotationException { String [ ] parts = str . split ( "-" ) ; /* MonomerUnit */ sourceUnit = parts [ 0 ] . split ( ":" ) [ 0 ] . toUpperCase ( ) ; targetUnit = parts [ 1 ] . split ( ":" ) [ 0 ] . toUpperCase ( ) ; /* R-group */ rGroupSource = parts [ 0 ] . split ( ":" ) [ 1 ] ; rGroupTarget = parts [ 1 ] . split ( ":" ) [ 1 ] ; Pattern r = Pattern . compile ( "R\\d" , Pattern . CASE_INSENSITIVE ) ; Pattern pair = Pattern . compile ( "pair" , Pattern . CASE_INSENSITIVE ) ; Matcher mR = r . matcher ( rGroupSource ) ; Matcher mPair = pair . matcher ( rGroupTarget ) ; if ( mR . matches ( ) ) { rGroupSource = rGroupSource . toUpperCase ( ) ; } else { rGroupSource = rGroupSource . toLowerCase ( ) ; } if ( mPair . matches ( ) ) { rGroupTarget = rGroupTarget . toLowerCase ( ) ; } else { rGroupTarget = rGroupTarget . toUpperCase ( ) ; } }


Input: method to get a valid HELM2 of the connection notation [CODESPLIT] public String toHELM2 ( ) { if ( isAnnotationTrue ( ) ) { return sourceId . getId ( ) + "," + targetId . getId ( ) + "," + sourceUnit + ":" + rGroupSource + "-" + targetUnit + ":" + rGroupTarget + "\"" + annotation + "\"" ; } else { return sourceId . getId ( ) + "," + targetId . getId ( ) + "," + sourceUnit + ":" + rGroupSource + "-" + targetUnit + ":" + rGroupTarget ; } }


Input: method to add a single element to the group [CODESPLIT] public void addElement ( String str , String type , double one , double two , boolean interval , boolean isDefault ) throws NotationException { this . elements . add ( ValidationMethod . decideWhichMonomerNotationInGroup ( str , type , one , two , interval , isDefault ) ) ; }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws ConnectionSectionException { /* new connection is starting */ if ( cha == ' ' ) { LOG . info ( "A new connection is starting:" ) ; _parser . setState ( new ConnectionsParser ( _parser ) ) ; } /* grouping section is starting */ else if ( cha == ' ' ) { LOG . info ( "Transition to group section" ) ; LOG . info ( "Group section is starting:" ) ; _parser . setState ( new GroupingParser ( _parser ) ) ; } /* invalid character */ else { LOG . error ( "Invalid character after inline annotation in connection section: " + cha ) ; throw new ConnectionSectionException ( "Invalid character after inline annotation in connection section: " + cha ) ; } }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws SimplePolymerSectionException { /* repeating information is finished */ if ( cha == ' ' ) { if ( _parser . checkRepeating ( repeating ) ) { String [ ] range = repeating . split ( "-" ) ; int first = Integer . parseInt ( range [ 0 ] ) ; if ( range . length > 1 ) { int second = Integer . parseInt ( range [ 1 ] ) ; /* range is wrong */ if ( second - first <= 0 ) { LOG . error ( "Information about repeating is wrong: " + repeating ) ; throw new SimplePolymerSectionException ( "Information about repeating is wrong: " + repeating ) ; } else { LOG . info ( "Monomer unit is repeated:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . getCurrentMonomerNotation ( ) . setCount ( repeating ) ; _parser . setState ( new BetweenMonomerParser ( _parser ) ) ; } } else { LOG . info ( "Monomer unit is repeated:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . getCurrentMonomerNotation ( ) . setCount ( repeating ) ; _parser . setState ( new BetweenMonomerParser ( _parser ) ) ; } } else { LOG . error ( "Information about repeating is wrong: " + repeating ) ; throw new SimplePolymerSectionException ( "Information about repeating is wrong: " + repeating ) ; } } /* add characters to repeating information */ else { repeating += cha ; } }


Input: main method to run a single HELM2Parser from the command line [CODESPLIT] public static void main ( String [ ] args ) throws ParseException , ExceptionState , IOException { /* options for the program */ Options options = new Options ( ) ; /* add helm string */ options . addOption ( "inputHELM" , true , "HELM1 or HELM2 string in a file" ) ; /* add output option */ options . addOption ( "output" , true , "output can be in JSON- or HELM2-format" ) ; /* add translate option */ options . addOption ( "translate" , false , "translate HELM1 to HELM2" ) ; CommandLineParser parameter = new DefaultParser ( ) ; try { CommandLine cmd = parameter . parse ( options , args ) ; String filename = cmd . getOptionValue ( "inputHELM" ) ; ParserHELM2 parser = new ParserHELM2 ( ) ; FileReader in = new FileReader ( filename ) ; BufferedReader br = new BufferedReader ( in ) ; String line ; String helm ; try { while ( ( line = br . readLine ( ) ) != null ) { helm = line ; /* HELM1 notation has to be translated into HELM2 */ if ( cmd . hasOption ( "translate" ) ) { ConverterHELM1ToHELM2 converter = new ConverterHELM1ToHELM2 ( ) ; helm = converter . doConvert ( helm ) ; LOG . info ( "HELM1 is translated to HELM2" ) ; } parser . parse ( helm ) ; /* There are two different output options */ String output = "" ; if ( cmd . getOptionValue ( "output" ) . equals ( "HELM2" ) ) { output = parser . getHELM2Notation ( ) . toHELM2 ( ) ; } else if ( cmd . getOptionValue ( "output" ) . equals ( "JSON" ) ) { output = parser . getJSON ( ) ; } System . out . println ( output ) ; } } finally { br . close ( ) ; } } catch ( NullPointerException e ) { System . out . println ( "Please call the program with the following arguments: " + "\n" + "-inputHELM  <" + options . getOption ( "inputHELM" ) . getDescription ( ) + ">\n" + "-output <" + options . getOption ( "output" ) . getDescription ( ) + ">\n-translate(optional) <" + options . getOption ( "translate" ) . getDescription ( ) + ">" ) ; } catch ( ParseException exp ) { System . out . println ( "Unexpected exception: " + exp . getMessage ( ) ) ; } }


Input:
{ [CODESPLIT] @ Override public void doAction ( char cha ) throws SimplePolymerSectionException , NotationException { /* simple polymer notation is finished; can also be empty */ if ( cha == ' ' && checkBracketsParenthesis ( ) ) { // initialize object - normal monomer type
 if ( ! ( monomer . equals ( "" ) ) ) { LOG . info ( "Monomer unit is read:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new BetweenParser ( _parser ) ) ; } else { throw new SimplePolymerSectionException ( "Monomer unit is missing: " ) ; } } else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { /*
       * a new monomer unit is starting. This is only valid for peptide and rna
       * not for chem and blob
       */ if ( monomer != "" ) { if ( _parser . isPeptideOrRna ( ) ) { LOG . info ( "Monomer unit is read: " + monomer ) ; LOG . info ( "New monomer unit is starting:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new SimplePolymersNotationParser ( _parser ) ) ; } else { LOG . error ( "Only one monomer unit is allowed: " + monomer ) ; throw new SimplePolymerSectionException ( "Only one monomer unit is allowed: " + monomer ) ; } } else { LOG . error ( "Monomer unit is missing: " + monomer ) ; throw new SimplePolymerSectionException ( "Monomer unit is missing: " + monomer ) ; } } /* an additional annotation is given */ else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { if ( monomer != "" ) { LOG . info ( "Monomer unit is read: " + monomer ) ; LOG . info ( "Annotation for monomer unit is starting:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new InlineAnnotationsParser ( _parser , 11 ) ) ; } else { LOG . error ( "Monomer unit is missing:" ) ; throw new SimplePolymerSectionException ( "Monomer unit is missing:" ) ; } } else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { /*
       * the monomer unit is being repeated. This is only valid for peptide and
       * rna not for chem and blob
       */ if ( monomer != "" ) { if ( _parser . isPeptideOrRna ( ) ) { LOG . info ( "Monomer unit is read: " + monomer ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new RepeatingMonomerParser ( _parser ) ) ; } else { LOG . error ( "Monomer unit shall be not repeated: " ) ; throw new SimplePolymerSectionException ( "Monomer unit shall be not repeated: " ) ; } } else { LOG . error ( "Monomer unit is missing" ) ; throw new SimplePolymerSectionException ( "Monomer unit is missing" ) ; } } /* check all brackets */ else if ( cha == ' ' || cha == ' ' || cha == ' ' || cha == ' ' ) { monomer += cha ; if ( cha == ' ' ) { bracketCounterOpen += 1 ; } else if ( cha == ' ' ) { bracketCounterClose += 1 ; } else if ( cha == ' ' ) { parenthesisCounterOpen += 1 ; } else { parenthesisCounterClose += 1 ; } } /* add characters */ else { monomer += cha ; } }


Input: method to validate the polymer id in the simple polymer section the id can be peptide rna chem or blob [CODESPLIT] public boolean checkPolymerId ( String polymerId ) { LOG . debug ( "Validation of polymerID: " + polymerId ) ; String pattern = "PEPTIDE[1-9][0-9]*|RNA[1-9][0-9]*|CHEM[1-9][0-9]*|BLOB[1-9][0-9]*" ; Pattern p = Pattern . compile ( pattern , Pattern . CASE_INSENSITIVE ) ; Matcher m = p . matcher ( polymerId ) ; if ( m . matches ( ) ) { LOG . debug ( "PolymerID is valid: " + polymerId ) ; return true ; } LOG . debug ( "PolymerID is not valid: " + polymerId ) ; return false ; }


Input: method to validate the polymer id in the connection section the id can be peptide rna chem or blob the ratio + range was also included the ambiguity is also proven [CODESPLIT] public boolean checkPolymeridConnection ( String polymerId ) { LOG . debug ( "Validation of polymerID in the connection section:" ) ; String ratio = "(:[1-9][0-9]*(\\.[0-9]+)?)?" ; String id = "(PEPTIDE[1-9][0-9]*|RNA[1-9][0-9]*|CHEM[1-9][0-9]*|BLOB[1-9][0-9]*|G[1-9][0-9]*)" ; String pattern = "(\\(" + id + ratio + "(," + id + ratio + ")+\\)" + ratio + "|" + id + ratio + ")" ; Pattern p = Pattern . compile ( pattern , Pattern . CASE_INSENSITIVE ) ; Matcher m = p . matcher ( polymerId ) ; if ( m . matches ( ) ) { LOG . debug ( "PolymerID in the connection section is valid:" ) ; return true ; } LOG . debug ( "PolymerID in the connection section is not valid: " + polymerId ) ; return false ; }


Input: method to validate the details about the connections ; hydrogen bonds are here included [CODESPLIT] public boolean checkDetailsConnections ( String d ) { LOG . debug ( "Validation of connection's details:" ) ; String group = "\\((\\D|\\d)((,|\\+)(\\D|\\d))+\\)" ; String partOne = "([1-9][0-9]*|\\D|\\?|" + group + ")" ; String partTwo = "(R[1-9][0-9]*+|\\?)" ; String element = partOne + ":" + partTwo ; String patternConnection = element + "-" + element ; String hydrogenBondPartner = partOne + ":pair" ; String hydrogenBondPattern = hydrogenBondPartner + "-" + hydrogenBondPartner ; Pattern pConnection = Pattern . compile ( patternConnection , Pattern . CASE_INSENSITIVE ) ; Matcher mConnection = pConnection . matcher ( d ) ; Pattern pHydrogen = Pattern . compile ( hydrogenBondPattern , Pattern . CASE_INSENSITIVE ) ; Matcher mHydrogen = pHydrogen . matcher ( d ) ; if ( mConnection . matches ( ) || mHydrogen . matches ( ) ) { LOG . debug ( "Connection's details are valid:" ) ; return true ; } LOG . debug ( "Connection's details are not valid: " + d ) ; return false ; }


Input: method to validate the group id [CODESPLIT] public boolean checkGroupId ( String d ) { Pattern p = Pattern . compile ( "G[1-9][0-9]*" , Pattern . CASE_INSENSITIVE ) ; Matcher m = p . matcher ( d ) ; LOG . debug ( "Validation of groupID:" ) ; if ( m . matches ( ) ) { LOG . debug ( "GroupID is valid:" ) ; return true ; } LOG . debug ( "GroupID is not valid:" ) ; return false ; }


Input: method to validate the details about the group information ; this part can be separated after + to get the id for each single group element : to get the ratio for each single group element [CODESPLIT] public boolean checkDetailsGroup ( String d ) { LOG . debug ( "Validation of group's details:" ) ; String id = "(PEPTIDE[1-9][0-9]*+|RNA[1-9][0-9]*|CHEM[1-9][0-9]*|BLOB[1-9][0-9]*|G[1-9][0-9]*)" ; String number = "[1-9][0-9]*(\\.[0-9]+)?" ; String ratio = number + "(-" + number + ")?" ; String pattern = id + "(:" + ratio + ")?((\\+|,)" + id + "(:" + ratio + ")?)+" ; Pattern p = Pattern . compile ( pattern , Pattern . CASE_INSENSITIVE ) ; Matcher m = p . matcher ( d ) ; if ( m . matches ( ) ) { LOG . debug ( "Group's details are valid:" ) ; return true ; } LOG . debug ( "Group's details are not valid: " + d ) ; return false ; }


Input: method to validate the repeating section it can be a single number or a range [CODESPLIT] public boolean checkRepeating ( String str ) { String pattern = "\\d+|\\d+-\\d+" ; if ( str . matches ( pattern ) ) { return true ; } return false ; }


Input: method to check if the last added polymer element is a peptide or a rna [CODESPLIT] public boolean isPeptideOrRna ( ) throws SimplePolymerSectionException { if ( polymerElements . size ( ) >= 1 ) { if ( polymerElements . get ( polymerElements . size ( ) - 1 ) . matches ( "(PEPTIDE[1-9][0-9]*+|RNA[1-9][0-9]*)" ) ) { return true ; } return false ; } else { throw new SimplePolymerSectionException ( "No Polymer Id is found" ) ; } }


Input: method to generate a JSON - Object from the NotationContainer [CODESPLIT] protected String toJSON ( ) { ObjectMapper mapper = new ObjectMapper ( ) ; try { String jsonINString = mapper . writeValueAsString ( notationContainer ) ; jsonINString = mapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( notationContainer ) ; return jsonINString ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) { if ( cha == ' ' ) { /* annotation for first section:simple polymer section */ if ( sectionCounter == 1 ) { LOG . info ( "Add annotation to simple polymer:" ) ; PolymerNotation current = _parser . notationContainer . getCurrentPolymer ( ) ; _parser . notationContainer . changeLastPolymerNotation ( new PolymerNotation ( current . getPolymerID ( ) , current . getPolymerElements ( ) , comment ) ) ; _parser . setState ( new BetweenParser ( _parser ) ) ; } /* annotation for second section:connection section */ else if ( sectionCounter == 2 ) { LOG . info ( "Add annotation to connection section:" ) ; ConnectionNotation current = _parser . notationContainer . getCurrentConnection ( ) ; _parser . notationContainer . changeConnectionNotation ( new ConnectionNotation ( current . getSourceId ( ) , current . getTargetId ( ) , current . getSourceUnit ( ) , current . getTargetUnit ( ) , current . getrGroupSource ( ) , current . getrGroupTarget ( ) , comment ) ) ; _parser . setState ( new BetweenInlineConnectionParser ( _parser ) ) ; } /* annotation for a single monomer in the first section */ else if ( sectionCounter == 11 ) { LOG . info ( "Add annotation to a single monomer:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . getCurrentMonomerNotation ( ) . setAnnotation ( comment ) ; _parser . setState ( new BetweenInlineMonomerParser ( _parser ) ) ; } } else { comment += ( cha ) ; } }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws SimplePolymerSectionException { /* a new monomer section starts */ if ( cha == ' ' ) { LOG . info ( "new monomer unit is starting:" ) ; _parser . setState ( new SimplePolymersNotationParser ( _parser ) ) ; } /* polymer is finished */ else if ( cha == ' ' ) { LOG . info ( "simple polymer is read:" ) ; _parser . setState ( new BetweenParser ( _parser ) ) ; } /* inline annotation */ else if ( cha == ' ' ) { LOG . info ( "annotation for simple polymer is starting:" ) ; _parser . setState ( new InlineAnnotationsParser ( _parser , 11 ) ) ; } else { LOG . error ( "Error in the simple polymers notation section:" ) ; throw new SimplePolymerSectionException ( "Error in the simple polymers notation section:" ) ; } }


Input: { [CODESPLIT] @ Override public String toHELM2 ( ) { StringBuilder notation = new StringBuilder ( ) ; DecimalFormat d = new DecimalFormat ( "#.##" ) ; notation . append ( "(" ) ; for ( int i = 0 ; i < elements . size ( ) ; i ++ ) { String text = elements . get ( i ) . getMonomerNotation ( ) . getUnit ( ) ; if ( ! ( elements . get ( i ) . isDefaultValue ( ) ) ) { String value = d . format ( elements . get ( i ) . getValue ( ) . get ( 0 ) ) . replace ( ' ' , ' ' ) ; if ( elements . get ( i ) . isInterval ( ) ) { value += "-" + d . format ( elements . get ( i ) . getValue ( ) . get ( 1 ) ) . replace ( ' ' , ' ' ) ; } if ( value . equals ( "-1" ) ) { value = "?" ; } text += ":" + value ; } notation . append ( text + "," ) ; } notation . setLength ( notation . length ( ) - 1 ) ; notation . append ( ")" ) ; if ( ! ( isDefault ) ) { notation . append ( "'" + count + "'" ) ; } if ( isAnnotationHere ) { notation . append ( "\"" + annotation + "\"" ) ; } return notation . toString ( ) ; }


Input: method to get the simple polymer type [CODESPLIT] public PolymerNotation getSimplePolymer ( String string ) { for ( PolymerNotation polymer : listOfPolymers ) { if ( polymer . getPolymerID ( ) . getId ( ) . equals ( string ) ) { return polymer ; } } return null ; }


Input: method to get the current grouping notation [CODESPLIT] @ JsonIgnore public GroupingNotation getCurrentGroupingNotation ( ) { if ( listOfGroupings . size ( ) == 0 ) { return null ; } return listOfGroupings . get ( listOfGroupings . size ( ) - 1 ) ; }


Input: method to generate for all sections a HELM2 string [CODESPLIT] public String toHELM2 ( ) { String output = "" ; /* first section: simple polymer section */ output += polymerToHELM2 ( ) + "$" ; /* second section: connection section */ output += connectionToHELM2 ( ) + "$" ; /* third section: grouping section */ output += groupingToHELM2 ( ) + "$" ; /* fourth section: annotation section */ output += annotationToHELM2 ( ) + "$" ; /* add version number */ output += "V2.0" ; return output ; }


Input: method to generate a valid HELM2 string for the first section [CODESPLIT] public String polymerToHELM2 ( ) { StringBuilder notation = new StringBuilder ( ) ; for ( int i = 0 ; i < listOfPolymers . size ( ) ; i ++ ) { if ( listOfPolymers . get ( i ) . isAnnotationHere ( ) ) { notation . append ( listOfPolymers . get ( i ) . getPolymerID ( ) + "{" + listOfPolymers . get ( i ) . toHELM2 ( ) + "}\"" + listOfPolymers . get ( i ) . getAnnotation ( ) + "\"|" ) ; } else { notation . append ( listOfPolymers . get ( i ) . getPolymerID ( ) + "{" + listOfPolymers . get ( i ) . toHELM2 ( ) + "}" + "|" ) ; } } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input: method to generate a valid HELM2 string for the second section [CODESPLIT] public String connectionToHELM2 ( ) { if ( listOfConnections . size ( ) == 0 ) { return "" ; } StringBuilder notation = new StringBuilder ( ) ; for ( int i = 0 ; i < listOfConnections . size ( ) ; i ++ ) { notation . append ( listOfConnections . get ( i ) . toHELM2 ( ) + "|" ) ; } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input: method to generate a valid HELM2 string for the third section [CODESPLIT] public String groupingToHELM2 ( ) { if ( listOfGroupings . size ( ) == 0 ) { return "" ; } StringBuilder notation = new StringBuilder ( ) ; for ( int i = 0 ; i < listOfGroupings . size ( ) ; i ++ ) { notation . append ( listOfGroupings . get ( i ) . toHELM2 ( ) + "|" ) ; } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input: method to generate a valid HELM2 string for the fourth section [CODESPLIT] public String annotationToHELM2 ( ) { if ( ! ( annotationSection . isEmpty ( ) ) ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < annotationSection . size ( ) ; i ++ ) { sb . append ( annotationSection . get ( i ) . toHELM2 ( ) + "|" ) ; } sb . setLength ( sb . length ( ) - 1 ) ; return sb . toString ( ) ; } return "" ; }


Input: method to get the ID s from all polymers and groups [CODESPLIT] @ JsonIgnore public List < String > getPolymerAndGroupingIDs ( ) { List < String > listOfIDs = new ArrayList < String > ( ) ; for ( PolymerNotation polymer : listOfPolymers ) { listOfIDs . add ( polymer . getPolymerID ( ) . getId ( ) ) ; } for ( GroupingNotation grouping : listOfGroupings ) { listOfIDs . add ( grouping . getGroupID ( ) . getId ( ) ) ; } return listOfIDs ; }


Input: method to get the ID s from all polymers [CODESPLIT] @ JsonIgnore public List < String > getPolymerIDs ( ) { List < String > listOfIDs = new ArrayList < String > ( ) ; for ( PolymerNotation polymer : listOfPolymers ) { listOfIDs . add ( polymer . getPolymerID ( ) . getId ( ) ) ; } return listOfIDs ; }


Input: method to get the ID s from all polymers [CODESPLIT] @ JsonIgnore public List < String > getGroupIDs ( ) { List < String > listOfIDs = new ArrayList < String > ( ) ; for ( GroupingNotation grouping : listOfGroupings ) { listOfIDs . add ( grouping . getGroupID ( ) . getId ( ) ) ; } return listOfIDs ; }


Input: method to get a specific polymer by its id [CODESPLIT] @ JsonIgnore public PolymerNotation getPolymerNotation ( String id ) { for ( PolymerNotation polymer : listOfPolymers ) { if ( polymer . getPolymerID ( ) . getId ( ) . equals ( id ) ) { return polymer ; } } return null ; }


Input: method to generate the right PolymerElements in the case of Chem and Blob only one Monomer is allowed [CODESPLIT] private void setPolymerElements ( ) { if ( polymerID instanceof RNAEntity || polymerID instanceof PeptideEntity ) { this . polymerElements = new PolymerListElements ( polymerID ) ; } else { this . polymerElements = new PolymerSingleElements ( polymerID ) ; } }


Input:
{ @inheritDoc } [CODESPLIT] @ Override public void doAction ( char cha ) throws SimplePolymerSectionException , NotationException { /* list of simple polymers is finished */ if ( cha == ' ' ) { // id has to be empty
 if ( polymerId == "" ) { if ( ! ( _parser . isEmpty ( ) ) ) { LOG . info ( "Simple polymer section is finished:" ) ; LOG . info ( "Transition to connection section:" ) ; _parser . setState ( new ConnectionsParser ( _parser ) ) ; } else { LOG . error ( "Simple polymer ID has to be defined:" ) ; throw new SimplePolymerSectionException ( "A simple polymer has to be defined" ) ; } } else { LOG . error ( "Incorrect input in the simple polymer section:" ) ; throw new SimplePolymerSectionException ( "Incorrect input in the simple polymer section:" ) ; } } /* simple polymer notation is starting */ else if ( cha == ' ' ) { if ( ( _parser . checkPolymerId ( polymerId ) ) && polymerId != "" ) { LOG . info ( "Simple polymer ID is read:" ) ; _parser . notationContainer . addPolymer ( new PolymerNotation ( polymerId ) ) ; _parser . addPolymer ( polymerId ) ; _parser . setState ( new SimplePolymersNotationParser ( _parser ) ) ; } else { LOG . error ( "Polymer ID is not correct: " + polymerId ) ; throw new SimplePolymerSectionException ( "Polymer ID is not correct: " + polymerId ) ; } } /* add characters to polymer id */ else { polymerId += cha ; } }


Input: { [CODESPLIT] @ Override public String toHELM2 ( ) { DecimalFormat d = new DecimalFormat ( "#.##" ) ; StringBuilder notation = new StringBuilder ( ) ; for ( GroupingElement groupingElement : elements ) { if ( ! ( groupingElement . isDefaultValue ( ) ) ) { String value = d . format ( groupingElement . getValue ( ) . get ( 0 ) ) . replace ( ' ' , ' ' ) ; if ( groupingElement . getValue ( ) . size ( ) > 1 ) { value += "-" + d . format ( groupingElement . getValue ( ) . get ( 1 ) ) . replace ( ' ' , ' ' ) ; } notation . append ( groupingElement . getID ( ) + ":" + value + "+" ) ; } else { notation . append ( groupingElement . getID ( ) + "+" ) ; } } notation . setLength ( notation . length ( ) - 1 ) ; return notation . toString ( ) ; }


Input:
method to convert the given string into the HELM2 format [CODESPLIT] public String doConvert ( String str ) { //check for just missing V2.0
 ParserHELM2 parser = new ParserHELM2 ( ) ; try { parser . parse ( str + "V2.0" ) ; return str + "V2.0" ; } catch ( Exception e ) { /* Use String Builder */ /* simple add character -> split works then */ String helm1 = str + "f" ; StringBuilder helm2 = new StringBuilder ( ) ; String [ ] sections = helm1 . split ( "}\\$" ) ; /* Section 1 is accepted in full, no changes necessary, Section 1 has to be there */ helm2 . append ( sections [ 0 ] + "}$" ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i < sections . length ; i ++ ) { sb . append ( sections [ i ] + "}$" ) ; } helm1 = "$" + sb . toString ( ) ; sections = helm1 . split ( "\\$" ) ; /*
     * Section 2 connection section; section 3 is added to the second section,
     * Section 2 is not necessary, is this section really there
     */ if ( sections . length >= 2 ) { if ( ! ( sections [ 1 ] . isEmpty ( ) ) ) { helm2 . append ( sections [ 1 ] ) ; } } /* Add hydrogen bonds to the connection section */ if ( sections . length >= 3 ) { if ( ! ( sections [ 2 ] . isEmpty ( ) ) ) { if ( ! ( sections [ 1 ] . isEmpty ( ) ) ) { helm2 . append ( "|" + sections [ 2 ] ) ; } else { helm2 . append ( sections [ 2 ] ) ; } } /*Group section*/ helm2 . append ( "$" ) ; helm2 . append ( "$" ) ; /*Add annotation to the annotation section*/ if ( sections . length >= 4 ) { if ( ! ( sections [ 3 ] . isEmpty ( ) ) ) { helm2 . append ( sections [ 3 ] ) ; } } } /* Add version number to indicate HELM2 notation */ helm2 . append ( "$V2.0" ) ; return helm2 . toString ( ) ; } }


Input: method to add annotation to this monomer [CODESPLIT] public void setAnnotation ( String str ) { if ( str != null ) { annotation = str ; isAnnotationHere = true ; } else { annotation = null ; isAnnotationHere = false ; } }


Input: method to change the default count of one to the user - defined [CODESPLIT] public void setCount ( String str ) { isDefault = false ; if ( str . equals ( "1" ) ) { isDefault = true ; } count = str ; }


Input:
method to decide which of the MonomerNotation classes should be initialized [CODESPLIT] public static MonomerNotation decideWhichMonomerNotation ( String str , String type ) throws NotationException { MonomerNotation mon ; /* group ? */ if ( str . startsWith ( "(" ) && str . endsWith ( ")" ) ) { String str2 = str . substring ( 1 , str . length ( ) - 1 ) ; Pattern patternAND = Pattern . compile ( "\\+" ) ; Pattern patternOR = Pattern . compile ( "," ) ; /* Mixture of elements */ if ( patternAND . matcher ( str ) . find ( ) ) { mon = new MonomerNotationGroupMixture ( str2 , type ) ; } /* or - groups */ else if ( patternOR . matcher ( str ) . find ( ) ) { mon = new MonomerNotationGroupOr ( str2 , type ) ; } else { if ( str . contains ( "." ) ) { mon = new MonomerNotationList ( str2 , type ) ; } else { /* monomer unit is just in brackets */ if ( type == "RNA" ) { mon = new MonomerNotationUnitRNA ( str2 , type ) ; } else { if ( str2 . length ( ) > 1 ) { if ( ! ( str2 . startsWith ( "[" ) && str2 . endsWith ( "]" ) ) ) { throw new NotationException ( "Monomers have to be in brackets: " + str ) ; } } mon = new MonomerNotationUnit ( str2 , type ) ; } } } } else { if ( type == "RNA" ) { // if (str.startsWith("[") && str.endsWith("]")) {
 // mon = new MonomerNotationUnitRNA(str, type);
 // }
 mon = new MonomerNotationUnitRNA ( str , type ) ; } else if ( type != "BLOB" ) { if ( str . length ( ) > 1 ) { if ( ! ( str . startsWith ( "[" ) && str . endsWith ( "]" ) ) ) { throw new NotationException ( "Monomers have to be in brackets: " + str ) ; } } mon = new MonomerNotationUnit ( str , type ) ; } else { mon = new MonomerNotationUnit ( str , type ) ; } } return mon ; }


Input: method to decide which of the two Constructors of MonomerNotationGroupElement should be called [CODESPLIT] public static MonomerNotationGroupElement decideWhichMonomerNotationInGroup ( String str , String type , double one , double two , boolean interval , boolean isDefault ) throws NotationException { MonomerNotation element ; element = decideWhichMonomerNotation ( str , type ) ; if ( interval ) { return new MonomerNotationGroupElement ( element , one , two ) ; } else { return new MonomerNotationGroupElement ( element , one , isDefault ) ; } }


Input: method to decide which of the Entities classes should be initialized [CODESPLIT] public static HELMEntity decideWhichEntity ( String str ) throws NotationException { HELMEntity item ; if ( str . toUpperCase ( ) . matches ( "PEPTIDE[1-9][0-9]*" ) ) { item = new PeptideEntity ( str . toUpperCase ( ) ) ; } else if ( str . toUpperCase ( ) . matches ( "RNA[1-9][0-9]*" ) ) { item = new RNAEntity ( str . toUpperCase ( ) ) ; } else if ( str . toUpperCase ( ) . matches ( "BLOB[1-9][0-9]*" ) ) { item = new BlobEntity ( str . toUpperCase ( ) ) ; } else if ( str . toUpperCase ( ) . matches ( "CHEM[1-9][0-9]*" ) ) { item = new ChemEntity ( str . toUpperCase ( ) ) ; } else if ( str . toUpperCase ( ) . matches ( "G[1-9][0-9]*" ) ) { item = new GroupEntity ( str . toUpperCase ( ) ) ; } else { throw new NotationException ( "ID is wrong: " + str ) ; } return item ; }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws ConnectionSectionException , NotationException { /* a new connection is starting */ if ( cha == ' ' ) { if ( _parser . checkDetailsConnections ( details ) ) { LOG . info ( "A new connection is starting:" ) ; ConnectionNotation current = _parser . notationContainer . getCurrentConnection ( ) ; _parser . notationContainer . changeConnectionNotation ( new ConnectionNotation ( current . getSourceId ( ) , current . getTargetId ( ) , details ) ) ; _parser . setState ( new ConnectionsParser ( _parser ) ) ; } else { LOG . error ( "Details about the connection are not corret: " + details ) ; throw new ConnectionSectionException ( "Details about the connection are not correct: " + details ) ; } } /* connection section is finished */ else if ( cha == ' ' ) { if ( _parser . checkDetailsConnections ( details ) ) { LOG . info ( "Connection section is finished:" ) ; ConnectionNotation current = _parser . notationContainer . getCurrentConnection ( ) ; _parser . notationContainer . changeConnectionNotation ( new ConnectionNotation ( current . getSourceId ( ) , current . getTargetId ( ) , details ) ) ; LOG . info ( "Transition to group section" ) ; _parser . setState ( new GroupingParser ( _parser ) ) ; } else { throw new ConnectionSectionException ( "Details about the connection are not correct: " + details ) ; } } /* start of an annotation */ else if ( cha == ' ' ) { if ( _parser . checkDetailsConnections ( details ) ) { LOG . info ( "Add annotation to connection:" ) ; ConnectionNotation current = _parser . notationContainer . getCurrentConnection ( ) ; _parser . notationContainer . changeConnectionNotation ( new ConnectionNotation ( current . getSourceId ( ) , current . getTargetId ( ) , details ) ) ; _parser . setState ( new InlineAnnotationsParser ( _parser , 2 ) ) ; } else { LOG . error ( "Details about the connection are not corret: " + details ) ; throw new ConnectionSectionException ( "Details about the connection are not correct: " + details ) ; } } /* add characters to connection description */ else { details += cha ; } }


Input:
{ @inheritDoc } [CODESPLIT] @ Override public void doAction ( char cha ) throws GroupingSectionException , NotationException { /*
     * group section is finished: section was empty: annotation section starts
     */ if ( cha == ' ' ) { /* no details */ if ( groupId == "" && _parser . notationContainer . getListOfGroupings ( ) . size ( ) == 0 ) { LOG . info ( "Group section is empty:" ) ; LOG . info ( "Transition to annotation section:" ) ; _parser . setState ( new AnnotationsParser ( _parser ) ) ; } else { throw new GroupingSectionException ( "Missing details about the group: " + groupId ) ; } } /* detailed information about the group is starting */ else if ( cha == ' ' ) { if ( _parser . checkGroupId ( groupId ) ) { LOG . info ( "Group ID is read:" ) ; _parser . notationContainer . addGrouping ( new GroupingNotation ( groupId ) ) ; _parser . setState ( new GroupingDetailedInformationParser ( _parser ) ) ; } else { LOG . error ( "Invalid group ID: " + groupId ) ; throw new GroupingSectionException ( "Invalid group Id: " + groupId ) ; } } /* add characters to the group id */ else { groupId += cha ; } }


Input: method to get the ratio or the interval of this group in the case of an interval it returns a list of two values [CODESPLIT] public List < Double > getValue ( ) { if ( this . isInterval ) { return new ArrayList < Double > ( Arrays . asList ( numberOne , numberTwo ) ) ; } else { return new ArrayList < Double > ( Arrays . asList ( numberOne ) ) ; } }


Input: method to parse the given HELM2 string in the case of an invalid HELM2 notation exception is thrown [CODESPLIT] public void parse ( String test ) throws ExceptionState { parser = new StateMachineParser ( ) ; test = test . trim ( ) ; if ( test . substring ( test . length ( ) - 4 ) . matches ( "V2\\.0" ) || test . substring ( test . length ( ) - 4 ) . matches ( "v2\\.0" ) ) { for ( int i = 0 ; i < test . length ( ) - 4 ; i ++ ) { parser . doAction ( test . charAt ( i ) ) ; } if ( ! ( parser . getState ( ) instanceof FinalState ) ) { LOG . error ( "Invalid input: Final State was not reached:" ) ; throw new FinalStateException ( "Invalid input: Final State was not reached" ) ; } } else { LOG . error ( "Invalid input: HELM2 standard is missing:" ) ; throw new NotValidHELM2Exception ( "Invalid input: HELM2 standard is missing" ) ; } }


Input:
{ @inheritDoc } [CODESPLIT] @ Override public void doAction ( char cha ) throws GroupingSectionException , NotationException { /*
     * detailed information about the group is finished: annotation section
     * starts
     */ if ( cha == ' ' ) { if ( _parser . checkDetailsGroup ( details ) ) { LOG . info ( "Group description is finished:" ) ; LOG . info ( "Transition to annotation section:" ) ; GroupingNotation current = _parser . notationContainer . getCurrentGroupingNotation ( ) ; _parser . notationContainer . changeLastGroupingNotation ( new GroupingNotation ( current . getGroupID ( ) , details ) ) ; _parser . setState ( new BetweenGroupingParser ( _parser ) ) ; } else { LOG . error ( "Group information is wrong: " + details ) ; throw new GroupingSectionException ( "Group information is wrong: " + details ) ; } } /* add characters to the details */ else { details += cha ; } }


Input: { @inheritDoc } [CODESPLIT] @ Override public void addMonomerNotation ( String str ) throws SimplePolymerSectionException , NotationException { if ( this . listMonomerNotations . size ( ) < 1 ) { this . listMonomerNotations . add ( ValidationMethod . decideWhichMonomerNotation ( str , entity . getType ( ) ) ) ; } else { throw new SimplePolymerSectionException ( "Only one Monomer unit is allowed for CHEM and BLOB" ) ; } }


Input:
method to set for each nucleotide the sugar the base and the phosphat [CODESPLIT] private void setRNAContents ( String str ) throws NotationException { /* Nucleotide with all contents */ String [ ] list ; // if (str.contains("(")) {
 List < String > items = extractContents ( str ) ; for ( String item : items ) { if ( item . length ( ) > 1 ) { if ( ! ( item . startsWith ( "[" ) && item . endsWith ( "]" ) ) ) { throw new NotationException ( "Monomers have to be in brackets " + item ) ; } } contents . add ( new MonomerNotationUnit ( item , type ) ) ; } // } /* nucleotide contains no base, but a modified sugar or phosphat */
 // else if (str.contains("[")) {
 // if (str.startsWith("[")) {
 // str = str.replace("]", "]$");
 // } else {
 // str = str.replace("[", "$[");
 // }
 // list = str.split("\\$");
 // for (int i = 0; i < list.length; i++) {
 // contents.add(new MonomerNotationUnit(list[i], type));
 // }
 // } /* nucleotide contains only standard sugar and/or phosphat */ else {
 // for (int i = 0; i < str.length(); i++) {
 // contents.add(new MonomerNotationUnit(Character.toString(str.charAt(i)),
 // type));
 // }
 // }
 }


Input:
{ [CODESPLIT] @ Override public void doAction ( char cha ) throws ExceptionState { /*
     * third part of the connection is starting. It contains information about
     * the connection in detail
     */ if ( cha == ' ' ) { if ( _parser . checkPolymeridConnection ( targetpolymerid ) ) { LOG . info ( "Target polmyer ID is read:" ) ; ConnectionNotation current = _parser . notationContainer . getCurrentConnection ( ) ; _parser . notationContainer . changeConnectionNotation ( new ConnectionNotation ( current . getSourceId ( ) , targetpolymerid ) ) ; _parser . setState ( new ConnectionsDetailsParser ( _parser ) ) ; } else { LOG . error ( "Target polymer ID is not correct in the connection section: " + targetpolymerid ) ; throw new ConnectionSectionException ( "Target polymer ID is not correct in the connection section: " + targetpolymerid ) ; } } /* Read the id of the target polymer id */ else { targetpolymerid += cha ; } }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws SimplePolymerSectionException { /* an additional annotation is starting */ if ( cha == ' ' ) { LOG . info ( "Annotation for simple polymer is starting:" ) ; _parser . setState ( new InlineAnnotationsParser ( _parser , 1 ) ) ; } /* a new unit is starting */ else if ( cha == ' ' ) { LOG . info ( "One simple polymer is finished:" ) ; LOG . info ( "New simple polymer is starting:" ) ; _parser . setState ( new SimplePolymersParser ( _parser ) ) ; } /* a new section is starting */ else if ( cha == ' ' ) { LOG . info ( "One simple polymer is finished:" ) ; LOG . info ( "Simple polymer section is finished:" ) ; LOG . info ( "Transition to connection section:" ) ; _parser . setState ( new ConnectionsParser ( _parser ) ) ; } else { LOG . error ( "Invalid syntax in simple polymer section: " + cha ) ; throw new SimplePolymerSectionException ( "Invalid syntax in simple polymer section: " + cha ) ; } }


Input: { [CODESPLIT] @ Override public String toHELM2 ( ) { String text = unit ; if ( isDefault == false ) { if ( unit . length ( ) > 1 ) { text = "(" + unit + ")" ; } text += "'" + count + "'" ; } if ( isAnnotationHere ) { text += "\"" + annotation + "\"" ; } return text ; }


Input: { [CODESPLIT] @ Override public void doAction ( char cha ) throws GroupingSectionException { /* a new group is starting */ if ( cha == ' ' ) { LOG . info ( "A new group is starting;" ) ; _parser . setState ( new GroupingParser ( _parser ) ) ; } /* group section is finished: start of the annotation section */ else if ( cha == ' ' ) { LOG . info ( "Group section is finished:" ) ; LOG . info ( "Transition to annotation section:" ) ; _parser . setState ( new AnnotationsParser ( _parser ) ) ; } /* add characters to the grouping section */ else { LOG . error ( "Group section is not valid: " + cha ) ; throw new GroupingSectionException ( "Group section is not valid: " + cha ) ; } }


Input: This method is called from within the constructor to initialize the form . WARNING : Do NOT modify this code . The content of this method is always regenerated by the Form Editor . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) private void initComponents ( ) { jScrollPane1 = new javax . swing . JScrollPane ( ) ; input = new javax . swing . JTextArea ( ) ; inputLabel = new javax . swing . JLabel ( ) ; outputLabel = new javax . swing . JLabel ( ) ; jScrollPane2 = new javax . swing . JScrollPane ( ) ; output = new javax . swing . JTextArea ( ) ; jRadioHELM = new javax . swing . JRadioButton ( ) ; jRadioJSON = new javax . swing . JRadioButton ( ) ; jButton1 = new javax . swing . JButton ( ) ; bg = new javax . swing . ButtonGroup ( ) ; setDefaultCloseOperation ( javax . swing . WindowConstants . EXIT_ON_CLOSE ) ; setTitle ( "HELMNotationParser" ) ; input . setColumns ( 20 ) ; input . setRows ( 5 ) ; jScrollPane1 . setViewportView ( input ) ; inputLabel . setText ( "HELM-Input:" ) ; inputLabel . setFont ( new Font ( "Arial" , Font . BOLD , 20 ) ) ; inputLabel . setHorizontalAlignment ( JLabel . CENTER ) ; inputLabel . setVerticalAlignment ( JLabel . CENTER ) ; outputLabel . setText ( "Output:" ) ; outputLabel . setFont ( new Font ( "Arial" , Font . BOLD , 20 ) ) ; outputLabel . setHorizontalAlignment ( JLabel . CENTER ) ; outputLabel . setVerticalAlignment ( JLabel . CENTER ) ; output . setColumns ( 20 ) ; output . setRows ( 5 ) ; jScrollPane2 . setViewportView ( output ) ; jRadioHELM . setText ( "HELM2" ) ; jRadioHELM . addActionListener ( new java . awt . event . ActionListener ( ) { @ Override public void actionPerformed ( java . awt . event . ActionEvent evt ) { jRadioButton1ActionPerformed ( evt ) ; } } ) ; jRadioJSON . setText ( "JSON" ) ; jRadioJSON . addActionListener ( new java . awt . event . ActionListener ( ) { @ Override public void actionPerformed ( java . awt . event . ActionEvent evt ) { jRadioButton2ActionPerformed ( evt ) ; } } ) ; bg . add ( jRadioHELM ) ; bg . add ( jRadioJSON ) ; jRadioHELM . setSelected ( true ) ; jButton1 . setText ( "Translate" ) ; jButton1 . addActionListener ( new java . awt . event . ActionListener ( ) { @ Override public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton1ActionPerformed ( evt ) ; } } ) ; javax . swing . GroupLayout layout = new javax . swing . GroupLayout ( getContentPane ( ) ) ; getContentPane ( ) . setLayout ( layout ) ; layout . setHorizontalGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addGroup ( layout . createSequentialGroup ( ) . addGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING , false ) . addComponent ( inputLabel , javax . swing . GroupLayout . DEFAULT_SIZE , javax . swing . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . addComponent ( jScrollPane1 , javax . swing . GroupLayout . DEFAULT_SIZE , 438 , Short . MAX_VALUE ) ) . addGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addGroup ( layout . createSequentialGroup ( ) . addGap ( 31 , 31 , 31 ) . addGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addComponent ( jRadioHELM , javax . swing . GroupLayout . DEFAULT_SIZE , javax . swing . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . addComponent ( jButton1 ) . addComponent ( jRadioJSON , javax . swing . GroupLayout . DEFAULT_SIZE , javax . swing . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) ) . addPreferredGap ( javax . swing . LayoutStyle . ComponentPlacement . RELATED , javax . swing . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . addComponent ( jScrollPane2 , javax . swing . GroupLayout . PREFERRED_SIZE , 458 , javax . swing . GroupLayout . PREFERRED_SIZE ) ) . addGroup ( javax . swing . GroupLayout . Alignment . TRAILING , layout . createSequentialGroup ( ) . addGap ( 132 , 132 , 132 ) . addComponent ( outputLabel , javax . swing . GroupLayout . PREFERRED_SIZE , 458 , javax . swing . GroupLayout . PREFERRED_SIZE ) ) ) . addContainerGap ( ) ) ) ; layout . setVerticalGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addGroup ( layout . createSequentialGroup ( ) . addGap ( 0 , 0 , 0 ) . addGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . BASELINE ) . addComponent ( inputLabel , javax . swing . GroupLayout . PREFERRED_SIZE , 28 , javax . swing . GroupLayout . PREFERRED_SIZE ) . addComponent ( outputLabel , javax . swing . GroupLayout . DEFAULT_SIZE , javax . swing . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) ) . addPreferredGap ( javax . swing . LayoutStyle . ComponentPlacement . RELATED ) . addGroup ( layout . createParallelGroup ( javax . swing . GroupLayout . Alignment . LEADING ) . addGroup ( layout . createSequentialGroup ( ) . addGap ( 9 , 9 , 9 ) . addComponent ( jRadioHELM ) . addPreferredGap ( javax . swing . LayoutStyle . ComponentPlacement . RELATED ) . addComponent ( jRadioJSON ) . addPreferredGap ( javax . swing . LayoutStyle . ComponentPlacement . UNRELATED ) . addComponent ( jButton1 ) . addContainerGap ( 778 , Short . MAX_VALUE ) ) . addComponent ( jScrollPane1 ) . addComponent ( jScrollPane2 ) ) ) ) ; pack ( ) ; }


Input: < / editor - fold > [CODESPLIT] private void jButton1ActionPerformed ( java . awt . event . ActionEvent evt ) { String helmInput = input . getText ( ) ; if ( ! ( helmInput . contains ( "V2.0" ) ) ) { /* Translate into HELM2-format */ helmInput = converter . doConvert ( helmInput ) ; } /* read input */ try { parser . parse ( helmInput ) ; writeOutputmessage ( ) ; } catch ( ExceptionState e ) { output . setText ( "Invalid HELM-String (" + e . getMessage ( ) + ")" ) ; } }


Input: method to add ambiguity to the group [CODESPLIT] private void defineAmbiguity ( String a ) throws NotationException { Pattern patternAND = Pattern . compile ( "\\+" ) ; Matcher m = patternAND . matcher ( a ) ; /* mixture */ if ( m . find ( ) ) { setAmbiguity ( new GroupingMixture ( a ) ) ; } /* or case */ else { setAmbiguity ( new GroupingOr ( a ) ) ; } }


Input: Construct a default fraction using the default agent URL of http : // localhost : 8500 / . [CODESPLIT] @ Override public void initialize ( InitContext initContext ) { if ( initContext . projectStage ( ) . isPresent ( ) ) { try { StageConfig stageConfig = initContext . projectStage ( ) . get ( ) ; String configvalue = stageConfig . resolve ( SwarmProperties . CONSUL_URL ) . withDefault ( null ) . getValue ( ) ; this . url = configvalue != null ? new URL ( configvalue ) : DEFAULT_URL ; } catch ( MalformedURLException e ) { throw new RuntimeException ( "Faile to resolve property 'swarm.consul.url'" , e ) ; } } }


Input: This method returns an approximation of this thread s execution statistics for the entire period since the thread was started . Writes are done without memory barriers to minimize the performance impact of statistics gathering so some or all returned data may be arbitrarily stale and some fields may be far staler than others . For long - running pools however even approximate data may provide useful insights . Your mileage may vary however you have been warned ; - ) [CODESPLIT] AWorkerThreadStatistics getStatistics ( ) { return new AWorkerThreadStatistics ( getState ( ) , getId ( ) , stat_numTasksExecuted , stat_numSharedTasksExecuted , stat_numSteals , stat_numExceptions , stat_numParks , stat_numFalseAlarmUnparks , stat_numSharedQueueSwitches , stat_numLocalSubmits , localQueue . approximateSize ( ) ) ; }


Input: Add a new task to the top of the shared queue incrementing top . [CODESPLIT] @ Override public void push ( Runnable task ) { lock ( ) ; final long _base ; final long _top ; try { _base = UNSAFE . getLongVolatile ( this , OFFS_BASE ) ; _top = UNSAFE . getLongVolatile ( this , OFFS_TOP ) ; if ( _top == _base + mask ) { throw new RejectedExecutionExceptionWithoutStacktrace ( "Shared queue overflow" ) ; } // We hold a lock here, so there can be no concurrent modifications of 'top', and there is no need for CAS. We must however ensure that //  no concurrently reading thread sees the incremented 'top' without the task being present in the array, therefore the 'ordered' put. UNSAFE . putObjectVolatile ( tasks , taskOffset ( _top ) , task ) ; UNSAFE . putLongVolatile ( this , OFFS_TOP , _top + 1 ) ; } finally { unlock ( ) ; } pool . onAvailableTask ( ) ; }


Input: This is a convenience factory method that extracts the list of nodes from the edges . It assumes that every node has at least one edge going from or to it . [CODESPLIT] public static < N , E extends AEdge < N > > ADiGraph < N , E > create ( Collection < E > edges ) { final Set < N > result = new HashSet <> ( ) ; for ( E edge : edges ) { result . add ( edge . getFrom ( ) ) ; result . add ( edge . getTo ( ) ) ; } return create ( result , edges ) ; }


Input: This factory method creates a graph with the given nodes and edges . It expressly allows nodes that have no edges attached to them . [CODESPLIT] public static < N , E extends AEdge < N > > ADiGraph < N , E > create ( Collection < N > nodes , Collection < E > edges ) { final Object [ ] nodeArr = new Object [ nodes . size ( ) ] ; final AEdge [ ] edgeArr = new AEdge [ edges . size ( ) ] ; int idx = 0 ; for ( N node : nodes ) { nodeArr [ idx ] = node ; idx += 1 ; } idx = 0 ; for ( E edge : edges ) { edgeArr [ idx ] = edge ; idx += 1 ; } return new ADiGraph < N , E > ( nodeArr , edgeArr ) ; }


Input: This method does the reachability analysis in a way that is useful for many other methods . [CODESPLIT] private void initPathsInternal ( ) { synchronized ( LOCK ) { if ( _incomingPathsInternal == null ) { AMap < N , AList < AEdgePath < N , E > > > incomingPaths = AHashMap . empty ( ) ; //noinspection unchecked incomingPaths = incomingPaths . withDefaultValue ( AList . nil ) ; AMap < N , AList < AEdgePath < N , E > > > outgoingPaths = AHashMap . empty ( ) ; //noinspection unchecked outgoingPaths = outgoingPaths . withDefaultValue ( AList . nil ) ; AList < AEdgePath < N , E > > cycles = AList . nil ( ) ; for ( N curNode : nodes ( ) ) { // iterate over nodes, treat 'curNode' as a target final Iterable < E > curIncoming = incomingEdges ( curNode ) ; List < AEdgePath < N , E > > unfinishedBusiness = new ArrayList <> ( ) ; for ( E incomingEdge : curIncoming ) { unfinishedBusiness . add ( AEdgePath . create ( incomingEdge ) ) ; } AList < AEdgePath < N , E > > nonCycles = AList . nil ( ) ; while ( unfinishedBusiness . size ( ) > 0 ) { final List < AEdgePath < N , E > > curBusiness = unfinishedBusiness ; for ( AEdgePath < N , E > p : unfinishedBusiness ) { if ( ! p . hasCycle ( ) || p . isMinimalCycle ( ) ) nonCycles = nonCycles . cons ( p ) ; if ( p . isMinimalCycle ( ) ) cycles = cycles . cons ( p ) ; } unfinishedBusiness = new ArrayList <> ( ) ; for ( AEdgePath < N , E > curPath : curBusiness ) { final Iterable < E > l = incomingEdges ( curPath . getFrom ( ) ) ; for ( E newEdge : l ) { final AEdgePath < N , E > pathCandidate = curPath . prepend ( newEdge ) ; if ( ! pathCandidate . hasNonMinimalCycle ( ) ) { unfinishedBusiness . add ( pathCandidate ) ; } } } } incomingPaths = incomingPaths . updated ( curNode , nonCycles ) ; for ( AEdgePath < N , E > p : nonCycles ) { outgoingPaths = outgoingPaths . updated ( p . getFrom ( ) , outgoingPaths . getRequired ( p . getFrom ( ) ) . cons ( p ) ) ; } } _incomingPathsInternal = incomingPaths ; _outgoingPathsInternal = outgoingPaths ; _cyclesInternal = cycles ; } } }


Input: A directed graph defines a partial order through reachability and this method sorts the graph s nodes based on that partial order . [CODESPLIT] public List < N > sortedNodesByReachability ( ) throws AGraphCircularityException { if ( hasCycles ( ) ) { throw new AGraphCircularityException ( ) ; } final Object [ ] result = new Object [ nodes . length ] ; int nextIdx = 0 ; final Set < N > unprocessed = new HashSet <> ( ) ; for ( Object node : nodes ) { //noinspection unchecked unprocessed . add ( ( N ) node ) ; } //TODO Map<N,Integer> with 'remaining' incoming edges, decrement when a node is 'processed' --> JMH while ( ! unprocessed . isEmpty ( ) ) { final Set < N > nextBatch = ACollectionHelper . filter ( unprocessed , new APredicateNoThrow < N > ( ) { @ Override public boolean apply ( N n ) { for ( E e : incomingEdges ( n ) ) { if ( unprocessed . contains ( e . getFrom ( ) ) ) { return false ; } } return true ; } } ) ; unprocessed . removeAll ( nextBatch ) ; for ( N n : nextBatch ) { result [ nextIdx ] = n ; nextIdx += 1 ; } } return new ArrayIterable <> ( result ) ; }


Input: unbuffered output is with API . err . format () etc . [CODESPLIT] private static PrintStream unbuffered ( final PrintStream stream ) { try { return new PrintStream ( stream , true , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { return new PrintStream ( stream , true ) ; } }


Input: Subscribes an object method to a service name pattern . [CODESPLIT] public void subscribe ( final String pattern , final Object instance , final String methodName ) throws NoSuchMethodException { this . subscribe ( pattern , new FunctionObject9 ( instance , methodName ) ) ; }


Input: Subscribes a static method to a service name pattern . [CODESPLIT] public void subscribe ( final String pattern , final Class < ? > clazz , final String methodName ) throws NoSuchMethodException { this . subscribe ( pattern , new FunctionObject9 ( this , clazz , methodName ) ) ; }


Input: Subscribes an object method to a service name pattern . [CODESPLIT] public void subscribe ( final String pattern , final FunctionInterface9 callback ) { final String s = this . prefix + pattern ; LinkedList < FunctionInterface9 > callback_list = this . callbacks . get ( s ) ; if ( callback_list == null ) { callback_list = new LinkedList < FunctionInterface9 > ( ) ; callback_list . addLast ( callback ) ; this . callbacks . put ( s , callback_list ) ; } else { callback_list . addLast ( callback ) ; } OtpOutputStream subscribe = new OtpOutputStream ( ) ; subscribe . write ( OtpExternal . versionTag ) ; final OtpErlangObject [ ] tuple = { new OtpErlangAtom ( "subscribe" ) , new OtpErlangString ( pattern ) } ; subscribe . write_any ( new OtpErlangTuple ( tuple ) ) ; send ( subscribe ) ; }


Input: Determine how may service name pattern subscriptions have occurred . [CODESPLIT] public int subscribe_count ( final String pattern ) throws InvalidInputException , TerminateException { OtpOutputStream subscribe_count = new OtpOutputStream ( ) ; subscribe_count . write ( OtpExternal . versionTag ) ; final OtpErlangObject [ ] tuple = { new OtpErlangAtom ( "subscribe_count" ) , new OtpErlangString ( pattern ) } ; subscribe_count . write_any ( new OtpErlangTuple ( tuple ) ) ; send ( subscribe_count ) ; try { return ( Integer ) poll_request ( null , false ) ; } catch ( MessageDecodingException e ) { e . printStackTrace ( API . err ) ; return - 1 ; } }


Input: Unsubscribes from a service name pattern . [CODESPLIT] public void unsubscribe ( final String pattern ) throws InvalidInputException { final String s = this . prefix + pattern ; LinkedList < FunctionInterface9 > callback_list = this . callbacks . get ( s ) ; if ( callback_list == null ) { throw new InvalidInputException ( ) ; } else { callback_list . removeFirst ( ) ; if ( callback_list . isEmpty ( ) ) { this . callbacks . remove ( s ) ; } } OtpOutputStream unsubscribe = new OtpOutputStream ( ) ; unsubscribe . write ( OtpExternal . versionTag ) ; final OtpErlangObject [ ] tuple = { new OtpErlangAtom ( "unsubscribe" ) , new OtpErlangString ( pattern ) } ; unsubscribe . write_any ( new OtpErlangTuple ( tuple ) ) ; send ( unsubscribe ) ; }


Input: Asynchronous point - to - point communication to a service subscribed that matches the destination service <code > name< / code > . [CODESPLIT] public TransId send_async ( final String name , final byte [ ] request ) throws InvalidInputException , MessageDecodingException , TerminateException { return send_async ( name , ( "" ) . getBytes ( ) , request , this . timeout_async , this . priority_default ) ; }


Input: Synchronous point - to - point communication to a service subscribed that matches the destination service <code > name< / code > . [CODESPLIT] public Response send_sync ( final String name , final byte [ ] request ) throws InvalidInputException , MessageDecodingException , TerminateException { return send_sync ( name , ( "" ) . getBytes ( ) , request , this . timeout_sync , this . priority_default ) ; }


Input: Synchronous point - to - point communication to a service subscribed that matches the destination service <code > name< / code > . [CODESPLIT] public Response send_sync ( final String name , final byte [ ] request_info , final byte [ ] request , final Integer timeout , final Byte priority ) throws InvalidInputException , MessageDecodingException , TerminateException { try { OtpOutputStream send_sync = new OtpOutputStream ( ) ; send_sync . write ( OtpExternal . versionTag ) ; final OtpErlangObject [ ] tuple = { new OtpErlangAtom ( "send_sync" ) , new OtpErlangString ( name ) , new OtpErlangBinary ( request_info ) , new OtpErlangBinary ( request ) , new OtpErlangUInt ( timeout ) , new OtpErlangInt ( priority ) } ; send_sync . write_any ( new OtpErlangTuple ( tuple ) ) ; send ( send_sync ) ; return ( Response ) poll_request ( null , false ) ; } catch ( OtpErlangRangeException e ) { e . printStackTrace ( API . err ) ; return null ; } }