signature:
public class AtomicQueryConcept { /** * getter for originalText - gets The lexical string in the question .
 * @ generated
 * @ return value of the feature */
public String getOriginalText ( ) { } }

implementation: 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 ) ;


signature:
public class AtomicQueryConcept { /** * setter for originalText - sets The lexical string in the question .
 * @ generated
 * @ param v value to set into the feature */
public void setOriginalText ( String v ) { } }

implementation: 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 ) ;


signature:
public class QueryOperator { /** * getter for args - gets The arguments for the operator .
 * @ generated
 * @ return value of the feature */
public StringList getArgs ( ) { } }

implementation: 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 ) ) ) ;


signature:
public class QueryOperator { /** * setter for args - sets The arguments for the operator .
 * @ generated
 * @ param v value to set into the feature */
public void setArgs ( StringList v ) { } }

implementation: 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 ) ) ;


signature:
public class SemanticRole { /** * getter for label - gets The semantic role label .
 * @ generated
 * @ return value of the feature */
public String getLabel ( ) { } }

implementation: 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 ) ;


signature:
public class SemanticRole { /** * setter for label - sets The semantic role label .
 * @ generated
 * @ param v value to set into the feature */
public void setLabel ( String v ) { } }

implementation: 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 ) ;


signature:
public class BlockLocks { /** * Find the next clear bit in the bit set .
 * @ param index
 * @ return */
public int nextClearBit ( int index ) { } }

implementation:
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 ;


signature:
public class BlockLocks { /** * Thread safe set operation that will set the bit if and only if the bit was
 * not previously set .
 * @ param index
 * the index position to set .
 * @ return returns true if the bit was set and false if it was already set . */
public boolean set ( int index ) { } }

implementation:
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 ;


signature:
public class AbstractSqlBuilder { /** * toString */
private String selectToString ( ) { } }

implementation: 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 ( ) ;


signature:
public class DB { /** * / * Transaction */
public void batch ( Runnable transaction ) { } }

implementation:
// 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 ) ; }


signature:
public class BlockCache { /** * This code was copied form MMAPDirectory in Lucene . */
protected void freeBuffer ( final ByteBuffer buffer ) throws IOException { } }

implementation: 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 ; } }


signature:
public class Cache { /** * Creates a new instance of CacheValue , the cache capacity should be used for
 * the given file .
 * @ param directory
 * the directory .
 * @ param fileName
 * the file name .
 * @ return the new CacheValue instance . */
public CacheValue newInstance ( CacheDirectory directory , String fileName ) { } }

implementation: return newInstance ( directory , fileName , getCacheBlockSize ( directory , fileName ) ) ;


signature:
public class Table { /** * 继承给定的JavaBean , 扩展Record对象的get和set方法 。
 * @ param bean 希望被继承的JavaBean
 * @ return 返回Table自身
 * @ since 2.3 */
public Table extend ( Object bean ) { } }

implementation: 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 ;


signature:
public class Table { /** * / * Association */
private Association assoc ( String name , boolean onlyOne , boolean ancestor ) { } }

implementation: name = DB . parseKeyParameter ( name ) ; Association assoc = new Association ( relations , name , onlyOne , ancestor ) ; relations . put ( name , assoc ) ; return assoc ;


signature:
public class Table { /** * / * CRUD */
public Record create ( Object ... args ) { } }

implementation: 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 ) ; }


signature:
public class Table { /** * 根据现有的Record创建新的Record .
 * 为跨数据库之间导数据提供便捷接口 ; 同时也方便根据模板创建多条相似的纪录 。
 * @ param o Record对象
 * @ return 根据参数创建的新的Record对象 */
public Record create ( Record o ) { } }

implementation: 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 ( ) ) ;


signature:
public class Table { /** * 根据指定列 , 返回符合条件的第一条记录 .
 * @ param key 要匹配的列名
 * @ param value 要匹配的值
 * @ return 返回符合条件的第一条记录 */
public Record findA ( String key , Object value ) { } }

implementation: key = DB . parseKeyParameter ( key ) ; if ( value != null ) { return first ( key . concat ( " = ?" ) , value ) ; } else { return first ( key . concat ( " is null" ) ) ; }


signature:
public class HyperSQLDialect { /** * 判断当前数据库的名称里是否包含hsql ( 忽略大小写 ) 。
 * @ param c 数据库连接
 * @ return 如果数据库名称包含hsql , 则返回true ; 否则返回false 。 */
@ Override public boolean accept ( Connection c ) { } }

implementation:
try { DatabaseMetaData d = c . getMetaData ( ) ; String name = d . getDatabaseProductName ( ) ; // HSQL Database Engine
return name . toLowerCase ( ) . contains ( "hsql" ) ; } catch ( SQLException e ) { throw new DBOpenException ( e ) ; }


signature:
public class ReusedBufferedIndexInput { /** * Flushes the in - memory bufer to the given output , copying at most
 * < code > numBytes < / code > .
 * < b > NOTE : < / b > this method does not refill the buffer , however it does
 * advance the buffer position .
 * @ return the number of bytes actually flushed from the in - memory buffer . */
protected final int flushBuffer ( IndexOutput out , long numBytes ) throws IOException { } }

implementation: int toCopy = bufferLength - bufferPosition ; if ( toCopy > numBytes ) { toCopy = ( int ) numBytes ; } if ( toCopy > 0 ) { out . writeBytes ( buffer , bufferPosition , toCopy ) ; bufferPosition += toCopy ; } return toCopy ;


signature:
public class Seq { /** * 将一系列对象组装成List 。
 * @ param < E > 元素类型 。
 * @ param args 多个同类型的元素 。
 * @ return 返回由这些元素组成的List 。 */
public static < E > List < E > list ( E ... args ) { } }

implementation: List < E > list = new ArrayList < > ( ) ; list . addAll ( Arrays . asList ( args ) ) ; return list ;


signature:
public class Seq { /** * 追加任意多个新元素到数组末尾 。
 * @ param < E > 元素的类型 。
 * @ param a 现有数组 。
 * @ param b 任意多个新元素 。
 * @ return 返回组装好的新数组 。 */
public static < E > E [ ] concat ( E [ ] a , E ... b ) { } }

implementation: return merge ( a , b ) ;


signature:
public class Seq { /** * 将数组连接成字符串 。
 * @ param delimiter 分隔符 。
 * @ param args 任意多个元素 。
 * @ return 连接后的字符串 。 */
public static String join ( String delimiter , Object ... args ) { } }

implementation: return join ( Arrays . asList ( args ) , delimiter ) ;


signature:
public class Seq { /** * 将容器里的元素连接成字符串 。
 * @ param list 包含任意多个元素的容器 。
 * @ param delimiter 分隔符 。
 * @ return 连接后的字符串 。 */
public static String join ( Collection < ? > list , String delimiter ) { } }

implementation: 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 ( ) ;


signature:
public class Seq { /** * 合并两个数组 。
 * @ param < E > 数组元素的类型 。
 * @ param a 前半部分数组 。
 * @ param b 后半部分数组 。
 * @ return 合并后的数组 。 */
public static < E > E [ ] merge ( E [ ] a , E [ ] b ) { } }

implementation: List < E > list = merge ( Arrays . asList ( a ) , Arrays . asList ( b ) ) ; return list . toArray ( a ) ;


signature:
public class Seq { /** * 合并两个List 。
 * @ param < E > List元素的类型 。
 * @ param a 前半部分List 。
 * @ param b 后半部分List 。
 * @ return 合并后的List 。 */
public static < E > List < E > merge ( List < E > a , List < E > b ) { } }

implementation: List < E > list = new ArrayList < > ( ) ; list . addAll ( a ) ; list . addAll ( b ) ; return list ;


signature:
public class Seq { /** * 从数组中删除所有与给定对象equals的元素 。
 * @ param < E > 元素类型 。
 * @ param a 给定数组 。
 * @ param e 给定对象
 * @ return 去除e之后的数组 。 */
public static < E > E [ ] remove ( E [ ] a , E e ) { } }

implementation: List < E > list = remove ( Arrays . asList ( a ) , e ) ; return ( E [ ] ) list . toArray ( ) ;


signature:
public class Seq { /** * 从List中删除所有与给定对象equals的元素 。
 * @ param < E > 元素类型 。
 * @ param a 给定List 。
 * @ param e 给定对象
 * @ return 去除e之后的List 。 */
public static < E > List < E > remove ( List < E > a , E e ) { } }

implementation: List < E > list = new ArrayList < > ( ) ; for ( E o : a ) { if ( ! o . equals ( e ) ) { list . add ( o ) ; } } return list ;


signature:
public class Seq { /** * 根据给定的下标 , 选出多个元素 , 并组成新的数组 。
 * @ param < E > 元素类型 。
 * @ param a 给定数组 。
 * @ param indexes 任意多个要获取的元素下标 。
 * @ return 根据下标获得的元素组成的新数组 。 */
public static < E > E [ ] valuesAt ( E [ ] a , int ... indexes ) { } }

implementation: List < E > list = valuesAt ( Arrays . asList ( a ) , indexes ) ; return ( E [ ] ) list . toArray ( ) ;


signature:
public class Seq { /** * 根据给定的下标 , 选出多个元素 , 并组成新的List 。
 * @ param < E > 元素类型 。
 * @ param from 给定List 。
 * @ param indexes 任意多个要获取的元素下标 。
 * @ return 根据下标获得的元素组成的新List 。 */
public static < E > List < E > valuesAt ( List < E > from , int ... indexes ) { } }

implementation: 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 ;


signature:
public class Seq { /** * 同时给int数组中多个位置同时赋值 。
 * @ param a 给定int数组 。
 * @ param indexes 待赋值的位置下标 。
 * @ param values 与下标一一对应的int值 。
 * @ return 返回赋值后的新int数组 。 */
public static int [ ] assignAt ( int [ ] a , Integer [ ] indexes , int ... values ) { } }

implementation: 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 ;


signature:
public class Seq { /** * 根据规定格式 , 对容器中的每个元素进行格式化 , 并返回格式化后的结果 。
 * @ param from 包含任意多个元素的容器 。
 * @ param format 格式化模板 , 与printf兼容 。
 * @ return 格式化后的新列表 。 */
public static List < String > map ( Collection < ? > from , String format ) { } }

implementation: List < String > to = new ArrayList < > ( from . size ( ) ) ; for ( Object e : from ) { to . add ( String . format ( format , e ) ) ; } return to ;


signature:
public class Seq { /** * 拆分容器 , 每份至多包含n个元素 , 将每堆元素连接成一个独立字符串 。
 * @ param from 包含任意多个元素的容器 。
 * @ param n 子元素个数 。
 * @ param delimiter 分隔符 。
 * @ return 拆分后的字符串List 。 */
public static List < String > partition ( Collection < String > from , int n , String delimiter ) { } }

implementation: 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 ;


signature:
public class SlimSet { /** * Rebuild the backing array with a different size .
 * @ param values
 * The values to put into the new array .
 * @ param newSize
 * The size of the new array .
 * @ return The new backing array . */
private static Object [ ] rehash ( final Object [ ] values , final int newSize ) { } }

implementation: Object [ ] newArray = new Object [ newSize ] ; for ( Object value : values ) { if ( value == null ) { continue ; } newArray [ predictedPosition ( newArray , value , value . hashCode ( ) ) ] = value ; } return newArray ;


signature:
public class SlimSet { /** * 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 .
 * @ param array
 * @ param object
 * @ return */
private static int predictedPosition ( final Object [ ] array , final Object object , final int hash ) { } }

implementation:
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 ;


signature:
public class Split { /** * Move { @ link # mNextSeparatorPos } to the next ( unquoted ) separator ( or the end of the { @ link CharSequence } if no
 * other separator exists in { @ link # mValue } ) . */
private void findNextSeparator ( ) { } }

implementation: mLastSeparatorPos = mNextSeparatorPos ; while ( ++ mNextSeparatorPos < mValue . length ( ) ) { char c = mValue . charAt ( mNextSeparatorPos ) ; if ( c == mSeparator ) { return ; } }


signature:
public class CsvIterator { /** * Move { @ link # mNextSeparatorPos } to the next ( unquoted ) separator ( or the end of the { @ link String } if no other
 * separator exists in { @ link # mValue } ) . */
private void findNextSeparator ( ) { } }

implementation:
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 ; } }


signature:
public class PolymerElements { /** * method to generate a valid HELM2 of this object
 * @ return valid HELM2 */
public String toHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class PolymerElements { /** * @ return PolymerElments in HELM format
 * @ throws HELM1ConverterException if one single object can not be downgraded to HELM1 - Format */
public String toHELM ( ) throws HELM1ConverterException { } }

implementation: 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 ( ) ;


signature:
public class ConnectionsParser { /** * { @ inheritDoc }
 * @ throws NotationException if connection is not valid */
@ Override public void doAction ( char cha ) throws ConnectionSectionException , NotationException { } }

implementation:
/* 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 ; } }


signature:
public class GroupingOr { /** * { @ inheritDoc } */
public String toHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class AnnotationsParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws AnnotationSectionException { } }

implementation:
/* 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 ++ ; } }


signature:
public class AnnotationsParser { /** * method to check if all open brackets are closed
 * @ return true if all open brackets are close , false otherwise */
private boolean checkBracketsParenthesis ( ) { } }

implementation: LOG . debug ( "Check of brackets in the annotation section:" ) ; if ( bracketCounterOpen == bracketCounterClose && parenthesisCounterOpen == parenthesisCounterClose && curlyBracketCounterOpen == curlyBracketCounterClose ) { return true ; } return false ;


signature:
public class ConnectionNotation { /** * method to set the details of the current connection
 * @ param method to add connection detail
 * @ throws NotationException */
private void addDetails ( String str ) throws NotationException { } }

implementation:
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 ( ) ; }


signature:
public class ConnectionNotation { /** * method to get a valid HELM2 of the connection notation
 * @ return valid HELM2 */
public String toHELM2 ( ) { } }

implementation: if ( isAnnotationTrue ( ) ) { return sourceId . getId ( ) + "," + targetId . getId ( ) + "," + sourceUnit + ":" + rGroupSource + "-" + targetUnit + ":" + rGroupTarget + "\"" + annotation + "\"" ; } else { return sourceId . getId ( ) + "," + targetId . getId ( ) + "," + sourceUnit + ":" + rGroupSource + "-" + targetUnit + ":" + rGroupTarget ; }


signature:
public class MonomerNotationGroup { /** * method to add a single element to the group
 * @ param str Monomer
 * @ param type type of current polymer
 * @ param one value of the monomer
 * @ param two value of the monomer
 * @ param interval is the value on interval
 * @ param isDefault if the value is the default one
 * @ throws NotationException if notation is not valid */
public void addElement ( String str , String type , double one , double two , boolean interval , boolean isDefault ) throws NotationException { } }

implementation: this . elements . add ( ValidationMethod . decideWhichMonomerNotationInGroup ( str , type , one , two , interval , isDefault ) ) ;


signature:
public class BetweenInlineConnectionParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws ConnectionSectionException { } }

implementation:
/* 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 ) ; }


signature:
public class RepeatingMonomerParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws SimplePolymerSectionException { } }

implementation:
/* 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 ; }


signature:
public class StartHELM2Parser { /** * main method to run a single HELM2Parser from the command line
 * @ param args console parameters
 * @ throws ParseException if parsing the command lines produces an error
 * @ throws ExceptionState an exception in a state during parsing occurs , helm notation is not valid
 * @ throws IOException if file can not be read */
public static void main ( String [ ] args ) throws ParseException , ExceptionState , IOException { } }

implementation:
/* 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 ( ) ) ; }


signature:
public class SimplePolymersNotationParser { /** * { @ inheritDoc }
 * @ throws SimplePolymerSectionException is simple polymer section is not valid
 * @ throws NotationException if notation is not valid */
@ Override public void doAction ( char cha ) throws SimplePolymerSectionException , NotationException { } }

implementation:
/* 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 ; }


signature:
public class StateMachineParser { /** * method to validate the polymer id in the simple polymer section the id can
 * be peptide , rna , chem or blob
 * @ param polymerId ID of a polymer
 * @ return true if the ID is valid , false otherwise */
public boolean checkPolymerId ( String polymerId ) { } }

implementation: 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 ;


signature:
public class StateMachineParser { /** * 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
 * @ param polymerId ID of a polymer
 * @ return true if the ID is valid , false otherwise */
public boolean checkPolymeridConnection ( String polymerId ) { } }

implementation: 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 ;


signature:
public class StateMachineParser { /** * method to validate the details about the connections ; hydrogen bonds are
 * here included
 * @ param d connection details
 * @ return true if the connection details are valid , false otherwise */
public boolean checkDetailsConnections ( String d ) { } }

implementation: 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 ;


signature:
public class StateMachineParser { /** * method to validate the group id
 * @ param d ID of a group
 * @ return true if the connection details are valid , false otherwise */
public boolean checkGroupId ( String d ) { } }

implementation: 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 ;


signature:
public class StateMachineParser { /** * 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
 * @ param d group information
 * @ return true if the group information is valid , false otherwise */
public boolean checkDetailsGroup ( String d ) { } }

implementation: 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 ;


signature:
public class StateMachineParser { /** * method to validate the repeating section it can be a single number or a
 * range
 * @ param str repeating information
 * @ return true if the information is valid , false otherwise */
public boolean checkRepeating ( String str ) { } }

implementation: String pattern = "\\d+|\\d+-\\d+" ; if ( str . matches ( pattern ) ) { return true ; } return false ;


signature:
public class StateMachineParser { /** * method to check if the last added polymer element is a peptide or a rna
 * @ return true , if the last added polymer is a peptide or a rna , false
 * otherwise
 * @ throws SimplePolymerSectionException if list of polymers is null */
public boolean isPeptideOrRna ( ) throws SimplePolymerSectionException { } }

implementation: 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" ) ; }


signature:
public class StateMachineParser { /** * method to generate a JSON - Object from the NotationContainer
 * @ return NotationContainer in JSON - Format */
protected String toJSON ( ) { } }

implementation: ObjectMapper mapper = new ObjectMapper ( ) ; try { String jsonINString = mapper . writeValueAsString ( notationContainer ) ; jsonINString = mapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( notationContainer ) ; return jsonINString ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ;


signature:
public class InlineAnnotationsParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) { } }

implementation:
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 ) ; }


signature:
public class BetweenMonomerParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws SimplePolymerSectionException { } }

implementation:
/* 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:" ) ; }


signature:
public class MonomerNotationGroupOr { /** * { @ inheritDoc } */
@ Override public String toHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class HELM2Notation { /** * method to get the simple polymer type
 * @ param string id of polymer
 * @ return PolymerNotation with the given id */
public PolymerNotation getSimplePolymer ( String string ) { } }

implementation: for ( PolymerNotation polymer : listOfPolymers ) { if ( polymer . getPolymerID ( ) . getId ( ) . equals ( string ) ) { return polymer ; } } return null ;


signature:
public class HELM2Notation { /** * method to get the current grouping notation
 * @ return GroupingNotation */
@ JsonIgnore public GroupingNotation getCurrentGroupingNotation ( ) { } }

implementation: if ( listOfGroupings . size ( ) == 0 ) { return null ; } return listOfGroupings . get ( listOfGroupings . size ( ) - 1 ) ;


signature:
public class HELM2Notation { /** * method to generate for all sections a HELM2 string
 * @ return HELM2 */
public String toHELM2 ( ) { } }

implementation:
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 ;


signature:
public class HELM2Notation { /** * method to generate a valid HELM2 string for the first section
 * @ return valid HELM2 string */
public String polymerToHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class HELM2Notation { /** * method to generate a valid HELM2 string for the second section
 * @ return valid HELM2 String */
public String connectionToHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class HELM2Notation { /** * method to generate a valid HELM2 string for the third section
 * @ return valid HELM2 String */
public String groupingToHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class HELM2Notation { /** * method to generate a valid HELM2 string for the fourth section
 * @ return valid HELM2 String */
public String annotationToHELM2 ( ) { } }

implementation: 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 "" ;


signature:
public class HELM2Notation { /** * method to get the ID ' s from all polymers and groups
 * @ return List of all ids from all polymers and groups */
@ JsonIgnore public List < String > getPolymerAndGroupingIDs ( ) { } }

implementation: 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 ;


signature:
public class HELM2Notation { /** * method to get the ID ' s from all polymers
 * @ return list of all polymers ids */
@ JsonIgnore public List < String > getPolymerIDs ( ) { } }

implementation: List < String > listOfIDs = new ArrayList < String > ( ) ; for ( PolymerNotation polymer : listOfPolymers ) { listOfIDs . add ( polymer . getPolymerID ( ) . getId ( ) ) ; } return listOfIDs ;


signature:
public class HELM2Notation { /** * method to get the ID ' s from all polymers
 * @ return all ids from all polymers */
@ JsonIgnore public List < String > getGroupIDs ( ) { } }

implementation: List < String > listOfIDs = new ArrayList < String > ( ) ; for ( GroupingNotation grouping : listOfGroupings ) { listOfIDs . add ( grouping . getGroupID ( ) . getId ( ) ) ; } return listOfIDs ;


signature:
public class HELM2Notation { /** * method to get a specific polymer by its id
 * @ param id polymer id
 * @ return polymer */
@ JsonIgnore public PolymerNotation getPolymerNotation ( String id ) { } }

implementation: for ( PolymerNotation polymer : listOfPolymers ) { if ( polymer . getPolymerID ( ) . getId ( ) . equals ( id ) ) { return polymer ; } } return null ;


signature:
public class PolymerNotation { /** * method to generate the right PolymerElements , in the case of Chem and Blob
 * only one Monomer is allowed */
private void setPolymerElements ( ) { } }

implementation: if ( polymerID instanceof RNAEntity || polymerID instanceof PeptideEntity ) { this . polymerElements = new PolymerListElements ( polymerID ) ; } else { this . polymerElements = new PolymerSingleElements ( polymerID ) ; }


signature:
public class SimplePolymersParser { /** * { @ inheritDoc }
 * @ throws NotationException if notation is not valid
 * @ throws SimplePolymerSectionException if simple polymer section is not valid */
@ Override public void doAction ( char cha ) throws SimplePolymerSectionException , NotationException { } }

implementation:
/* 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 ; }


signature:
public class GroupingMixture { /** * { @ inheritDoc } */
@ Override public String toHELM2 ( ) { } }

implementation: 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 ( ) ;


signature:
public class ConverterHELM1ToHELM2 { /** * method to convert the given string into the HELM2 format
 * @ param str HELM1 Notation
 * @ return HELM2 Notation */
public String doConvert ( String str ) { } }

implementation:
// 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 ( ) ; }


signature:
public class MonomerNotation { /** * method to add annotation to this monomer
 * @ param str annotation */
public void setAnnotation ( String str ) { } }

implementation: if ( str != null ) { annotation = str ; isAnnotationHere = true ; } else { annotation = null ; isAnnotationHere = false ; }


signature:
public class MonomerNotation { /** * method to change the default count of one to the user - defined
 * @ param str user - defined count */
public void setCount ( String str ) { } }

implementation: isDefault = false ; if ( str . equals ( "1" ) ) { isDefault = true ; } count = str ;


signature:
public class ValidationMethod { /** * method to decide which of the MonomerNotation classes should be
 * initialized
 * @ param str notation
 * @ param type polymer type
 * @ return MonomerNotation if monomer is not valid
 * @ throws NotationException if notation is not valid */
public static MonomerNotation decideWhichMonomerNotation ( String str , String type ) throws NotationException { } }

implementation:
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 ;


signature:
public class ValidationMethod { /** * method to decide which of the two Constructors of
 * MonomerNotationGroupElement should be called
 * @ param str
 * Monomer
 * @ param type
 * polymer type of monomer
 * @ param one
 * count of Monomer
 * @ param two
 * count of Monomer
 * @ param interval
 * Has the monomer instead of one count an interval
 * @ param isDefault
 * Is the count of the monomer default = 1
 * @ return MonomerNotationGroupElement
 * @ throws NotationException if notation is not valid */
public static MonomerNotationGroupElement decideWhichMonomerNotationInGroup ( String str , String type , double one , double two , boolean interval , boolean isDefault ) throws NotationException { } }

implementation: MonomerNotation element ; element = decideWhichMonomerNotation ( str , type ) ; if ( interval ) { return new MonomerNotationGroupElement ( element , one , two ) ; } else { return new MonomerNotationGroupElement ( element , one , isDefault ) ; }


signature:
public class ValidationMethod { /** * method to decide which of the Entities classes should be initialized
 * @ param str
 * polymer ID
 * @ return Entity
 * @ throws NotationException if the HELMEntity is not known , ID is not in the right format */
public static HELMEntity decideWhichEntity ( String str ) throws NotationException { } }

implementation: 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 ;


signature:
public class ConnectionsDetailsParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws ConnectionSectionException , NotationException { } }

implementation:
/* 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 ; }


signature:
public class GroupingParser { /** * { @ inheritDoc }
 * @ throws NotationException if notation is not valid */
@ Override public void doAction ( char cha ) throws GroupingSectionException , NotationException { } }

implementation:
/* * 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 ; }


signature:
public class MonomerNotationGroupElement { /** * method to get the ratio or the interval of this group , in the case of an
 * interval it returns a list of two values
 * @ return List of the values */
public List < Double > getValue ( ) { } }

implementation: if ( this . isInterval ) { return new ArrayList < Double > ( Arrays . asList ( numberOne , numberTwo ) ) ; } else { return new ArrayList < Double > ( Arrays . asList ( numberOne ) ) ; }


signature:
public class ParserHELM2 { /** * method to parse the given HELM2 string in the case of an invalid HELM2 notation exception is thrown
 * @ param test HELM2 Notation
 * @ throws ExceptionState if error occurs in state */
public void parse ( String test ) throws ExceptionState { } }

implementation: 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" ) ; }


signature:
public class GroupingDetailedInformationParser { /** * { @ inheritDoc }
 * @ throws NotationException if notation is not valid */
@ Override public void doAction ( char cha ) throws GroupingSectionException , NotationException { } }

implementation:
/* * 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 ; }


signature:
public class PolymerSingleElements { /** * { @ inheritDoc }
 * @ throws SimplePolymerSectionException if simple polymer section is not valid
 * @ throws NotationException if not notation is not valid */
@ Override public void addMonomerNotation ( String str ) throws SimplePolymerSectionException , NotationException { } }

implementation: 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" ) ; }


signature:
public class MonomerNotationUnitRNA { /** * method to set for each nucleotide the sugar , the base and the phosphat
 * @ param str monomer notation
 * @ throws NotationException if single monomers are not in brackets */
private void setRNAContents ( String str ) throws NotationException { } }

implementation:
/* 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 ) ) ;


signature:
public class ConnectionsReadSecondIDParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws ExceptionState { } }

implementation:
/* * 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 ; }


signature:
public class BetweenParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws SimplePolymerSectionException { } }

implementation:
/* 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 ) ; }


signature:
public class MonomerNotationUnit { /** * { @ inheritDoc } */
@ Override public String toHELM2 ( ) { } }

implementation: String text = unit ; if ( isDefault == false ) { if ( unit . length ( ) > 1 ) { text = "(" + unit + ")" ; } text += "'" + count + "'" ; } if ( isAnnotationHere ) { text += "\"" + annotation + "\"" ; } return text ;


signature:
public class BetweenGroupingParser { /** * { @ inheritDoc } */
@ Override public void doAction ( char cha ) throws GroupingSectionException { } }

implementation:
/* 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 ) ; }


signature:
public class HELMNotationParserUI { /** * 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 . */
@ SuppressWarnings ( "unchecked" ) private void initComponents ( ) { } }

implementation: 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 ( ) ;


signature:
public class HELMNotationParserUI { /** * < / editor - fold > */
private void jButton1ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
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 ( ) + ")" ) ; }


signature:
public class GroupingNotation { /** * method to add ambiguity to the group
 * @ param a details about the group elements
 * @ throws NotationException if notation is not valid */
private void defineAmbiguity ( String a ) throws NotationException { } }

implementation:
Pattern patternAND = Pattern . compile ( "\\+" ) ; Matcher m = patternAND . matcher ( a ) ; /* mixture */
if ( m . find ( ) ) { setAmbiguity ( new GroupingMixture ( a ) ) ; } /* or case */
else { setAmbiguity ( new GroupingOr ( a ) ) ; }


signature:
public class ConsulTopologyFraction { /** * Construct a default fraction using the default agent URL of http : / / localhost : 8500 / . */
@ Override public void initialize ( InitContext initContext ) { } }

implementation: 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 ) ; } }


signature:
public class WorkerThread { /** * 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 ; - ) */
AWorkerThreadStatistics getStatistics ( ) { } }

implementation: return new AWorkerThreadStatistics ( getState ( ) , getId ( ) , stat_numTasksExecuted , stat_numSharedTasksExecuted , stat_numSteals , stat_numExceptions , stat_numParks , stat_numFalseAlarmUnparks , stat_numSharedQueueSwitches , stat_numLocalSubmits , localQueue . approximateSize ( ) ) ;


signature:
public class SharedQueueNonblockPushBlockPopImpl { /** * Add a new task to the top of the shared queue , incrementing ' top ' . */
@ Override public void push ( Runnable task ) { } }

implementation:
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 ( ) ;


signature:
public class ADiGraph { /** * 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 . */
public static < N , E extends AEdge < N > > ADiGraph < N , E > create ( Collection < E > edges ) { } }

implementation: final Set < N > result = new HashSet < > ( ) ; for ( E edge : edges ) { result . add ( edge . getFrom ( ) ) ; result . add ( edge . getTo ( ) ) ; } return create ( result , edges ) ;


signature:
public class ADiGraph { /** * This factory method creates a graph with the given nodes and edges . It expressly allows nodes that have no edges attached to them . */
public static < N , E extends AEdge < N > > ADiGraph < N , E > create ( Collection < N > nodes , Collection < E > edges ) { } }

implementation: 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 ) ;


signature:
public class ADiGraph { /** * This method does the reachability analysis in a way that is useful for many other methods . */
private void initPathsInternal ( ) { } }

implementation:
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 ; } }


signature:
public class ADiGraph { /** * A directed graph defines a partial order through ' reachability ' , and this method sorts the graph ' s nodes based on that
 * partial order .
 * @ return all nodes , sorted in such a way that a node is guaranteed to come before all nodes that can be reached from it .
 * @ throws AGraphCircularityException if the graph has cycles and can therefore not be sorted by reachability */
public List < N > sortedNodesByReachability ( ) throws AGraphCircularityException { } }

implementation:
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 ) ;


signature:
public class API { /** * unbuffered output is with API . err . format ( ) , etc . */
private static PrintStream unbuffered ( final PrintStream stream ) { } }

implementation: try { return new PrintStream ( stream , true , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { return new PrintStream ( stream , true ) ; }


signature:
public class API { /** * Subscribes an object method to a service name pattern .
 * @ param pattern the service name pattern
 * @ param instance the object instance
 * @ param methodName the object method to handle matching requests
 * @ throws NoSuchMethodException instance method arity is invalid */
public void subscribe ( final String pattern , final Object instance , final String methodName ) throws NoSuchMethodException { } }

implementation: this . subscribe ( pattern , new FunctionObject9 ( instance , methodName ) ) ;


signature:
public class API { /** * Subscribes a static method to a service name pattern .
 * @ param pattern the service name pattern
 * @ param clazz the class of the static method
 * @ param methodName the static method to handle matching requests
 * @ throws NoSuchMethodException instance method arity is invalid */
public void subscribe ( final String pattern , final Class < ? > clazz , final String methodName ) throws NoSuchMethodException { } }

implementation: this . subscribe ( pattern , new FunctionObject9 ( this , clazz , methodName ) ) ;


signature:
public class API { /** * Subscribes an object method to a service name pattern .
 * @ param pattern the service name pattern
 * @ param callback method reference for callback ( Java 8 or higher ) */
public void subscribe ( final String pattern , final FunctionInterface9 callback ) { } }

implementation: 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 ) ;


signature:
public class API { /** * Determine how may service name pattern subscriptions have occurred .
 * @ param pattern the service name pattern
 * @ return count of active subscriptions
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws TerminateException service execution must terminate */
public int subscribe_count ( final String pattern ) throws InvalidInputException , TerminateException { } }

implementation: 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 ; }


signature:
public class API { /** * Unsubscribes from a service name pattern .
 * @ param pattern the service name pattern
 * @ throws InvalidInputException not subscribed to service name pattern */
public void unsubscribe ( final String pattern ) throws InvalidInputException { } }

implementation: 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 ) ;


signature:
public class API { /** * Asynchronous point - to - point communication to a service
 * subscribed that matches the destination service < code > name < / code > .
 * @ param name the destination service name
 * @ param request the request data
 * @ return a transaction ID
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws MessageDecodingException service messaging failure
 * @ throws TerminateException service execution must terminate */
public TransId send_async ( final String name , final byte [ ] request ) throws InvalidInputException , MessageDecodingException , TerminateException { } }

implementation: return send_async ( name , ( "" ) . getBytes ( ) , request , this . timeout_async , this . priority_default ) ;


signature:
public class API { /** * Synchronous point - to - point communication to a service
 * subscribed that matches the destination service < code > name < / code > .
 * @ param name the destination service name
 * @ param request the request data
 * @ return the response
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws MessageDecodingException service messaging failure
 * @ throws TerminateException service execution must terminate */
public Response send_sync ( final String name , final byte [ ] request ) throws InvalidInputException , MessageDecodingException , TerminateException { } }

implementation: return send_sync ( name , ( "" ) . getBytes ( ) , request , this . timeout_sync , this . priority_default ) ;


signature:
public class API { /** * Synchronous point - to - point communication to a service
 * subscribed that matches the destination service < code > name < / code > .
 * @ param name the destination service name
 * @ param request _ info any request metadata
 * @ param request the request data
 * @ param timeout the request timeout in milliseconds
 * @ param priority the request priority
 * @ return the response
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws MessageDecodingException service messaging failure
 * @ throws TerminateException service execution must terminate */
public Response send_sync ( final String name , final byte [ ] request_info , final byte [ ] request , final Integer timeout , final Byte priority ) throws InvalidInputException , MessageDecodingException , TerminateException { } }

implementation: 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 ; }


signature:
public class API { /** * Asynchronous point - multicast communication to services
 * subscribed that matches the destination service < code > name < / code > .
 * @ param name the destination service name
 * @ param request the request data
 * @ return transaction IDs
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws MessageDecodingException service messaging failure
 * @ throws TerminateException service execution must terminate */
public ArrayList < TransId > mcast_async ( final String name , final byte [ ] request ) throws InvalidInputException , MessageDecodingException , TerminateException { } }

implementation: return mcast_async ( name , new byte [ 0 ] , request , this . timeout_async , this . priority_default ) ;


signature:
public class API { /** * Forward a message to another service
 * subscribed that matches the destination service < code > name < / code > .
 * @ param request _ type constant API . SYNC or API . ASYNC
 * @ param name the destination service name
 * @ param request _ info any request metadata
 * @ param request the request data
 * @ param timeout the request timeout in milliseconds
 * @ param priority the priority of this request
 * @ param trans _ id the transaction ID
 * @ param pid the request ' s source process ID
 * @ throws ForwardAsyncException async service request was forwarded
 * @ throws ForwardSyncException sync service request was forwarded
 * @ throws InvalidInputException invalid service request type */
public void forward_ ( final Integer request_type , final String name , final byte [ ] request_info , final byte [ ] request , final Integer timeout , final Byte priority , final byte [ ] trans_id , final OtpErlangPid pid ) throws ForwardAsyncException , ForwardSyncException , InvalidInputException { } }

implementation: if ( request_type == API . ASYNC ) forward_async ( name , request_info , request , timeout , priority , trans_id , pid ) ; else if ( request_type == API . SYNC ) forward_sync ( name , request_info , request , timeout , priority , trans_id , pid ) ; else throw new InvalidInputException ( ) ;


signature:
public class API { /** * Asynchronously forward a message to another service
 * subscribed that matches the destination service < code > name < / code > .
 * @ param name the destination service name
 * @ param request _ info any request metadata
 * @ param request the request data
 * @ param timeout the request timeout in milliseconds
 * @ param priority the priority of this request
 * @ param trans _ id the transaction ID
 * @ param pid the request ' s source process ID
 * @ throws ForwardAsyncException async service request was forwarded */
public void forward_async ( final String name , final byte [ ] request_info , final byte [ ] request , Integer timeout , final Byte priority , final byte [ ] trans_id , final OtpErlangPid pid ) throws ForwardAsyncException { } }

implementation: try { OtpOutputStream forward_async = new OtpOutputStream ( ) ; forward_async . write ( OtpExternal . versionTag ) ; final OtpErlangObject [ ] tuple = { new OtpErlangAtom ( "forward_async" ) , new OtpErlangString ( name ) , new OtpErlangBinary ( request_info ) , new OtpErlangBinary ( request ) , new OtpErlangUInt ( timeout ) , new OtpErlangInt ( priority ) , new OtpErlangBinary ( trans_id ) , pid } ; forward_async . write_any ( new OtpErlangTuple ( tuple ) ) ; send ( forward_async ) ; } catch ( OtpErlangRangeException e ) { e . printStackTrace ( API . err ) ; return ; } throw new ForwardAsyncException ( ) ;


signature:
public class API { /** * Returns a response from a service request .
 * @ param request _ type constant API . SYNC or API . SYNC
 * @ param name the service name
 * @ param pattern the service name pattern
 * @ param response _ info any response metadata
 * @ param response the response data
 * @ param timeout the request timeout in milliseconds
 * @ param trans _ id the transaction ID
 * @ param pid the request ' s source process ID
 * @ throws ReturnAsyncException async service request returned
 * @ throws ReturnSyncException sync service request returned
 * @ throws InvalidInputException invalid service request type */
public void return_ ( final Integer request_type , final String name , final String pattern , final byte [ ] response_info , final byte [ ] response , final Integer timeout , final byte [ ] trans_id , final OtpErlangPid pid ) throws ReturnAsyncException , ReturnSyncException , InvalidInputException { } }

implementation: if ( request_type == API . ASYNC ) return_async ( name , pattern , response_info , response , timeout , trans_id , pid ) ; else if ( request_type == API . SYNC ) return_sync ( name , pattern , response_info , response , timeout , trans_id , pid ) ; else throw new InvalidInputException ( ) ;


signature:
public class API { /** * Synchronously returns a response from a service request .
 * @ param name the service name
 * @ param pattern the service name pattern
 * @ param response _ info any response metadata
 * @ param response the response data
 * @ param timeout the request timeout in milliseconds
 * @ param trans _ id the transaction ID
 * @ param pid the request ' s source process ID
 * @ throws ReturnSyncException sync service request returned */
public void return_sync ( final String name , final String pattern , byte [ ] response_info , byte [ ] response , Integer timeout , final byte [ ] trans_id , final OtpErlangPid pid ) throws ReturnSyncException { } }

implementation: try { OtpOutputStream return_sync = new OtpOutputStream ( ) ; return_sync . write ( OtpExternal . versionTag ) ; final OtpErlangObject [ ] tuple = { new OtpErlangAtom ( "return_sync" ) , new OtpErlangString ( name ) , new OtpErlangString ( pattern ) , new OtpErlangBinary ( response_info ) , new OtpErlangBinary ( response ) , new OtpErlangUInt ( timeout ) , new OtpErlangBinary ( trans_id ) , pid } ; return_sync . write_any ( new OtpErlangTuple ( tuple ) ) ; send ( return_sync ) ; } catch ( OtpErlangRangeException e ) { e . printStackTrace ( API . err ) ; return ; } throw new ReturnSyncException ( ) ;


signature:
public class API { /** * Asynchronously receive a response .
 * @ param timeout the receive timeout in milliseconds
 * @ return the response
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws MessageDecodingException service messaging failure
 * @ throws TerminateException service execution must terminate */
public Response recv_async ( final Integer timeout ) throws InvalidInputException , MessageDecodingException , TerminateException { } }

implementation: return recv_async ( timeout , TransIdNull , true ) ;


signature:
public class API { /** * Asynchronously receive a response .
 * @ param trans _ id the transaction ID to receive
 * @ return the response
 * @ throws InvalidInputException invalid input to internal function call
 * @ throws MessageDecodingException service messaging failure
 * @ throws TerminateException service execution must terminate */
public Response recv_async ( final byte [ ] trans_id ) throws InvalidInputException , MessageDecodingException , TerminateException { } }

implementation: return recv_async ( this . timeout_sync , trans_id , true ) ;