idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
141,400 | public static String getMacAddress ( ) { try { List < String > macAddress = new ArrayList < String > ( ) ; Enumeration < NetworkInterface > enumNetWorkInterface = NetworkInterface . getNetworkInterfaces ( ) ; while ( enumNetWorkInterface . hasMoreElements ( ) ) { NetworkInterface netWorkInterface = enumNetWorkInterface . nextElement ( ) ; byte [ ] hardwareAddress = netWorkInterface . getHardwareAddress ( ) ; if ( hardwareAddress != null && netWorkInterface . isUp ( ) && ! netWorkInterface . isVirtual ( ) ) { String displayName = netWorkInterface . getDisplayName ( ) . toLowerCase ( ) ; if ( ! displayName . contains ( "virtual" ) && ! displayName . contains ( "tunnel" ) ) { String strMac = "" ; for ( int i = 0 ; i < hardwareAddress . length ; i ++ ) { strMac += String . format ( "%02X%s" , hardwareAddress [ i ] , ( i < hardwareAddress . length - 1 ) ? "-" : "" ) ; } if ( strMac . trim ( ) . length ( ) > 0 ) { macAddress . add ( strMac ) ; } } } } return macAddress . toString ( ) . replace ( "," , ";" ) . replace ( "[" , "" ) . replace ( "]" , "" ) ; } catch ( Exception e ) { throw new JKException ( e ) ; } } | Gets the physical active mac address . | 312 | 8 |
141,401 | public static Properties getSystemInfo ( ) { logger . debug ( "getSystemInfo()" ) ; if ( MachineInfo . systemInfo == null ) { if ( ! JKIOUtil . isWindows ( ) ) { throw new IllegalStateException ( "this feature is only supported on windows" ) ; } final byte [ ] sourceFileContents = JKIOUtil . readFileAsByteArray ( "/native/jk.dll" ) ; if ( sourceFileContents . length > 0 ) { logger . debug ( "dll found" ) ; // copy the dll to the new exe file logger . debug ( "move to temp folder" ) ; final File hardDiskReaderFile = JKIOUtil . writeDataToTempFile ( sourceFileContents , ".exe" ) ; // execute the file logger . debug ( "execute process" ) ; final Process p = JKIOUtil . executeFile ( hardDiskReaderFile . getAbsolutePath ( ) ) ; String input = new String ( JKIOUtil . readStream ( p . getInputStream ( ) ) ) ; input = input . replace ( ":" , "=" ) ; logger . debug ( "input : " , input ) ; final String lines [ ] = input . split ( JK . NEW_LINE ) ; MachineInfo . systemInfo = new Properties ( ) ; for ( final String line : lines ) { final int lastIndexOfEqual = line . lastIndexOf ( ' ' ) ; if ( lastIndexOfEqual != - 1 && lastIndexOfEqual != line . length ( ) ) { String key = line . substring ( 0 , lastIndexOfEqual ) . trim ( ) . toUpperCase ( ) ; key = key . replace ( "_" , "" ) ; // remove old underscores key = key . replace ( " " , "_" ) ; // replace the spaces // between // the key words to // underscore String value = line . substring ( lastIndexOfEqual + 1 ) . trim ( ) ; value = value . replace ( "[" , "" ) ; value = value . replace ( "]" , "" ) ; value = value . trim ( ) ; String oldValue = systemInfo . getProperty ( key ) ; if ( oldValue == null ) { systemInfo . setProperty ( key , value ) ; } else { if ( ! oldValue . contains ( value ) ) { systemInfo . setProperty ( key , oldValue . concat ( ";" ) . concat ( value ) ) ; } } } } logger . debug ( "destory process" ) ; p . destroy ( ) ; logger . debug ( "delete file" ) ; hardDiskReaderFile . delete ( ) ; } } return MachineInfo . systemInfo ; } | Gets the system info . | 577 | 6 |
141,402 | public static Class < ? > getExceptionCallerClass ( final Throwable t ) { final StackTraceElement [ ] stackTrace = t . getStackTrace ( ) ; for ( final StackTraceElement stackTraceElement : stackTrace ) { logger . debug ( stackTraceElement . getClassName ( ) . concat ( "." ) . concat ( stackTraceElement . getMethodName ( ) ) ) ; } return null ; } | Gets the exception caller class . | 98 | 7 |
141,403 | public static String getMainClassName ( ) { StackTraceElement trace [ ] = Thread . currentThread ( ) . getStackTrace ( ) ; if ( trace . length > 0 ) { return trace [ trace . length - 1 ] . getClassName ( ) ; } return "Unknown" ; } | Gets the main class name . | 64 | 7 |
141,404 | public static HELM2Notation getSiRNANotation ( String senseSeq , String antiSenseSeq ) throws NotationException , FastaFormatException , HELM2HandledException , RNAUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException , CTKException , NucleotideLoadingException { return getSirnaNotation ( senseSeq , antiSenseSeq , NucleotideParser . RNA_DESIGN_NONE ) ; } | this method converts nucleotide sequences into HELM2Notation | 103 | 12 |
141,405 | public static HELM2Notation getSirnaNotation ( String senseSeq , String antiSenseSeq , String rnaDesignType ) throws NotationException , FastaFormatException , HELM2HandledException , RNAUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException , CTKException , NucleotideLoadingException { HELM2Notation helm2notation = null ; if ( senseSeq != null && senseSeq . length ( ) > 0 ) { helm2notation = SequenceConverter . readRNA ( senseSeq ) ; } if ( antiSenseSeq != null && antiSenseSeq . length ( ) > 0 ) { PolymerNotation antisense = new PolymerNotation ( "RNA2" ) ; antisense = new PolymerNotation ( antisense . getPolymerID ( ) , FastaFormat . generateElementsforRNA ( antiSenseSeq , antisense . getPolymerID ( ) ) ) ; helm2notation . addPolymer ( antisense ) ; } validateSiRNADesign ( helm2notation . getListOfPolymers ( ) . get ( 0 ) , helm2notation . getListOfPolymers ( ) . get ( 1 ) , rnaDesignType ) ; helm2notation . getListOfConnections ( ) . addAll ( hybridization ( helm2notation . getListOfPolymers ( ) . get ( 0 ) , helm2notation . getListOfPolymers ( ) . get ( 1 ) , rnaDesignType ) ) ; ChangeObjects . addAnnotation ( new AnnotationNotation ( "RNA1{ss}|RNA2{as}" ) , 0 , helm2notation ) ; return helm2notation ; } | this method converts nucleotide sequences into HELM notation based on design pattern | 372 | 14 |
141,406 | private static List < ConnectionNotation > hybridization ( PolymerNotation one , PolymerNotation two , String rnaDesignType ) throws NotationException , HELM2HandledException , RNAUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException , NucleotideLoadingException { List < ConnectionNotation > connections = new ArrayList < ConnectionNotation > ( ) ; ConnectionNotation connection ; if ( one . getPolymerElements ( ) . getListOfElements ( ) != null && one . getPolymerElements ( ) . getListOfElements ( ) . size ( ) > 0 && two . getPolymerElements ( ) . getListOfElements ( ) != null && two . getPolymerElements ( ) . getListOfElements ( ) . size ( ) > 0 ) { String analogSeqSS = RNAUtils . getNaturalAnalogSequence ( one ) . replaceAll ( "T" , "U" ) ; String analogSeqAS = new StringBuilder ( RNAUtils . getNaturalAnalogSequence ( two ) . replaceAll ( "T" , "U" ) ) . toString ( ) ; if ( NucleotideParser . RNA_DESIGN_NONE . equalsIgnoreCase ( rnaDesignType ) ) { String normalCompAS = RNAUtils . getNaturalAnalogSequence ( RNAUtils . getComplement ( two ) ) . replace ( "T" , "U" ) ; String maxMatch = RNAUtils . getMaxMatchFragment ( analogSeqSS , new StringBuilder ( normalCompAS ) . reverse ( ) . toString ( ) ) ; if ( maxMatch . length ( ) > 0 ) { int ssStart = analogSeqSS . indexOf ( maxMatch ) ; int normalCompStart = new StringBuilder ( normalCompAS ) . reverse ( ) . toString ( ) . indexOf ( maxMatch ) ; int asStart = analogSeqAS . length ( ) - maxMatch . length ( ) - normalCompStart ; for ( int i = 0 ; i < maxMatch . length ( ) ; i ++ ) { int ssPos = ( i + ssStart ) * 3 + 2 ; int asPos = ( asStart + maxMatch . length ( ) - 1 - i ) * 3 + 2 ; String details = ssPos + ":pair-" + asPos + ":pair" ; connection = new ConnectionNotation ( one . getPolymerID ( ) , two . getPolymerID ( ) , details ) ; connections . add ( connection ) ; } } } else if ( NucleotideParser . RNA_DESIGN_TUSCHL_19_PLUS_2 . equalsIgnoreCase ( rnaDesignType ) ) { int matchLength = 19 ; connections = hybridizationWithLengthFromStart ( one , two , analogSeqSS , analogSeqAS , matchLength ) ; } else if ( NucleotideParser . RNA_DESIGN_DICER_27_R . equalsIgnoreCase ( rnaDesignType ) ) { int matchLength = 25 ; connections = hybridizationWithLengthFromStart ( one , two , analogSeqSS , analogSeqAS , matchLength ) ; } else if ( NucleotideParser . RNA_DESIGN_DICER_27_L . equalsIgnoreCase ( rnaDesignType ) ) { int matchLength = 25 ; connections = hybridizationWithLengthFromStart ( one , two , analogSeqSS , analogSeqAS , matchLength ) ; } else { new RNAUtilsException ( "RNA-Design-Type " + rnaDesignType + " is unknown" ) ; } } return connections ; } | method to generate a List of ConnectionNotation according to the given two polymerNotations and the rnaDesigntype | 797 | 24 |
141,407 | private static List < ConnectionNotation > hybridizationWithLengthFromStart ( PolymerNotation one , PolymerNotation two , String senseAnalogSeq , String antisenseAnalogSeq , int lengthFromStart ) throws NotationException { List < ConnectionNotation > connections = new ArrayList < ConnectionNotation > ( ) ; ConnectionNotation connection ; for ( int i = 0 ; i < lengthFromStart ; i ++ ) { int ssPos = i * 3 + 2 ; int asPos = ( lengthFromStart - 1 - i ) * 3 + 2 ; String ssChar = String . valueOf ( senseAnalogSeq . charAt ( i ) ) ; String asChar = String . valueOf ( antisenseAnalogSeq . charAt ( lengthFromStart - 1 - i ) ) ; if ( complementMap . get ( ssChar ) . equalsIgnoreCase ( asChar ) ) { String details = ssPos + ":pair-" + asPos + ":pair" ; connection = new ConnectionNotation ( one . getPolymerID ( ) , two . getPolymerID ( ) , details ) ; connections . add ( connection ) ; } } return connections ; } | method to generate a List of ConnectionNotations given the two PolymerNotations and the sequences and the start point | 253 | 23 |
141,408 | private static boolean validateSiRNADesign ( PolymerNotation one , PolymerNotation two , String rnaDesignType ) throws RNAUtilsException , HELM2HandledException , NotationException , ChemistryException { if ( NucleotideParser . RNA_DESIGN_NONE . equalsIgnoreCase ( rnaDesignType ) ) { return true ; } if ( ! NucleotideParser . SUPPORTED_DESIGN_LIST . contains ( rnaDesignType ) ) { throw new NotationException ( "Unsupported RNA Design Type '" + rnaDesignType + "'" ) ; } List < Nucleotide > senseNucList = RNAUtils . getNucleotideList ( one ) ; List < Nucleotide > antisenseNucList = RNAUtils . getNucleotideList ( two ) ; if ( rnaDesignType . equals ( NucleotideParser . RNA_DESIGN_TUSCHL_19_PLUS_2 ) ) { if ( senseNucList . size ( ) != 21 ) { throw new NotationException ( "Sense strand for Tuschl 19+2 design must have 21 nucleotides" ) ; } if ( antisenseNucList . size ( ) != 21 ) { throw new NotationException ( "Antisense strand for Tuschl 19+2 design must have 21 nucleotides" ) ; } } else if ( rnaDesignType . equals ( NucleotideParser . RNA_DESIGN_DICER_27_R ) ) { if ( senseNucList . size ( ) != 25 ) { throw new NotationException ( "Sense strand for Dicer 27R design must have 25 nucleotides" ) ; } if ( antisenseNucList . size ( ) != 27 ) { throw new NotationException ( "Antisense strand for Dicer 27R design must have 27 nucleotides" ) ; } } else if ( rnaDesignType . equals ( NucleotideParser . RNA_DESIGN_DICER_27_L ) ) { if ( senseNucList . size ( ) != 27 ) { throw new NotationException ( "Sense strand for Dicer 27L design must have 27 nucleotides" ) ; } if ( antisenseNucList . size ( ) != 25 ) { throw new NotationException ( "Antisense strand for Dicer 27L design must have 25 nucleotides" ) ; } } return true ; } | validates the required siRNA | 525 | 6 |
141,409 | public synchronized Map < String , Map < String , Monomer > > getMonomerDB ( boolean includeNewMonomers ) { if ( includeNewMonomers ) { return monomerDB ; } else { Map < String , Map < String , Monomer > > reducedMonomerDB = new TreeMap < String , Map < String , Monomer > > ( String . CASE_INSENSITIVE_ORDER ) ; for ( String polymerType : monomerDB . keySet ( ) ) { Map < String , Monomer > monomerMap = monomerDB . get ( polymerType ) ; reducedMonomerDB . put ( polymerType , excludeNewMonomers ( monomerMap ) ) ; } return reducedMonomerDB ; } } | returns the monomer database including monomers that where temporary marked as new else without those monomers | 161 | 20 |
141,410 | public static MonomerFactory getInstance ( ) throws MonomerLoadingException , ChemistryException { if ( null == instance ) { refreshMonomerCache ( ) ; } else if ( MonomerStoreConfiguration . getInstance ( ) . isUseWebservice ( ) && MonomerStoreConfiguration . getInstance ( ) . isUpdateAutomatic ( ) ) { refreshMonomerCache ( ) ; } return instance ; } | Initialize MonomerCache and returns the singleton Factory class | 87 | 12 |
141,411 | public synchronized void addNewMonomer ( Monomer monomer ) throws IOException , MonomerException { monomer . setNewMonomer ( true ) ; addMonomer ( monomerDB , smilesMonomerDB , monomer ) ; dbChanged = true ; } | To add new monomer into monomerCache | 59 | 9 |
141,412 | public MonomerCache buildMonomerCacheFromXML ( String monomerDBXML ) throws MonomerException , IOException , JDOMException , ChemistryException , CTKException { ByteArrayInputStream bais = new ByteArrayInputStream ( monomerDBXML . getBytes ( ) ) ; return buildMonomerCacheFromXML ( bais ) ; } | Build an MonomerCache object with monomerDBXML String | 79 | 13 |
141,413 | public synchronized void merge ( MonomerCache remoteMonomerCache ) throws IOException , MonomerException { Map < Monomer , Monomer > conflicts = getConflictedMonomerMap ( remoteMonomerCache ) ; if ( conflicts . size ( ) > 0 ) { throw new MonomerException ( "Local new monomer and remote monomer database conflict found" ) ; } else { Map < String , Map < String , Monomer > > monoDB = remoteMonomerCache . getMonomerDB ( ) ; Set < String > polymerTypeSet = monoDB . keySet ( ) ; for ( Iterator i = polymerTypeSet . iterator ( ) ; i . hasNext ( ) ; ) { String polymerType = ( String ) i . next ( ) ; Map < String , Monomer > map = monoDB . get ( polymerType ) ; Set < String > monomerSet = map . keySet ( ) ; for ( Iterator it = monomerSet . iterator ( ) ; it . hasNext ( ) ; ) { String id = ( String ) it . next ( ) ; Monomer m = map . get ( id ) ; addMonomer ( monomerDB , smilesMonomerDB , m ) ; } } } dbChanged = true ; } | merge remote monomerCache with local monomerCache will throw exception if conflicts found . Client needs to resolve conflicts prior to calling merge | 269 | 27 |
141,414 | public synchronized void setMonomerCache ( MonomerCache remoteMonomerCache ) throws IOException , MonomerException { monomerDB = remoteMonomerCache . getMonomerDB ( ) ; attachmentDB = remoteMonomerCache . getAttachmentDB ( ) ; smilesMonomerDB = remoteMonomerCache . getSmilesMonomerDB ( ) ; dbChanged = true ; } | replace local cache with remote one completely may cause loss of data | 88 | 12 |
141,415 | private static Map < String , Attachment > buildAttachmentDB ( ) throws IOException { Map < String , Attachment > map = new TreeMap < String , Attachment > ( String . CASE_INSENSITIVE_ORDER ) ; if ( MonomerStoreConfiguration . getInstance ( ) . isUseExternalAttachments ( ) ) { map = AttachmentLoader . loadAttachments ( new FileInputStream ( MonomerStoreConfiguration . getInstance ( ) . getExternalAttachmentsPath ( ) ) ) ; } else { InputStream in = MonomerFactory . class . getResourceAsStream ( ATTACHMENTS_RESOURCE ) ; map = AttachmentLoader . loadAttachments ( in ) ; } return map ; } | builds attachment db from default file or external file | 151 | 10 |
141,416 | public void saveMonomerCache ( ) throws IOException , MonomerException { File f = new File ( NOTATION_DIRECTORY ) ; if ( ! f . exists ( ) ) { f . mkdir ( ) ; } MonomerCache cache = new MonomerCache ( ) ; cache . setMonomerDB ( getMonomerDB ( false ) ) ; cache . setAttachmentDB ( getAttachmentDB ( ) ) ; cache . setSmilesMonomerDB ( getSmilesMonomerDB ( false ) ) ; serializeMonomerCache ( cache , MONOMER_CACHE_FILE_PATH ) ; String monomerDbXML = buildMonomerDbXMLFromCache ( cache ) ; FileOutputStream fos = new FileOutputStream ( MONOMER_DB_FILE_PATH ) ; fos . write ( monomerDbXML . getBytes ( ) ) ; fos . close ( ) ; } | save monomerCache to disk file | 205 | 7 |
141,417 | public static void scan ( final Class < ? extends Annotation > clas , final String [ ] basePackage , final AnnotationHandler handler ) { final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider ( false ) ; scanner . setResourceLoader ( new PathMatchingResourcePatternResolver ( Thread . currentThread ( ) . getContextClassLoader ( ) ) ) ; scanner . addIncludeFilter ( new AnnotationTypeFilter ( clas ) ) ; for ( final String pck : basePackage ) { for ( final BeanDefinition bd : scanner . findCandidateComponents ( pck ) ) { handler . handleAnnotationFound ( bd . getBeanClassName ( ) ) ; } } } | Utility method to scan the given package and handler for the annotation of the given class . Its uses the Spring annotation detector | 157 | 24 |
141,418 | public static List < String > scanAsList ( final Class < ? extends Annotation > clas , final String ... basePackage ) { final List < String > classes = new ArrayList <> ( ) ; scan ( clas , basePackage , new AnnotationHandler ( ) { @ Override public void handleAnnotationFound ( String className ) { classes . add ( className ) ; } } ) ; return classes ; } | Scan as list . | 89 | 4 |
141,419 | @ Override public void refreshGuiAndShowFile ( File file ) { if ( rootNode . getChildCount ( ) > 0 ) { rootNode . removeAllChildren ( ) ; treeModel . reload ( ) ; } if ( guiMain . getAsmProjectUml ( ) . getProjectUml ( ) != null ) { addTreeNodes ( file ) ; guiMain . getMenuMain ( ) . setVisibleProjectMenu ( true ) ; } else { guiMain . getMenuMain ( ) . setVisibleProjectMenu ( false ) ; } } | refresh tree and expand to file that usually newly created | 120 | 11 |
141,420 | public static String buildToString ( Object ... params ) { StringBuffer finalMessage = new StringBuffer ( ) ; int i = 0 ; for ( Object object : params ) { if ( i ++ > 0 ) { finalMessage . append ( FIELD_SEPARATOR ) ; } if ( object instanceof List < ? > ) { finalMessage . append ( JKCollectionUtil . toString ( ( List < ? > ) object ) ) ; } else { finalMessage . append ( JKObjectUtil . toString ( object , true ) ) ; } } String fullText = finalMessage . toString ( ) ; return fullText ; } | Builds the to string . | 135 | 6 |
141,421 | public static Map toMap ( Object [ ] keys , Object [ ] values ) { Map map = new HashMap <> ( ) ; int i = 0 ; for ( Object key : keys ) { map . put ( key , values [ i ++ ] ) ; } return map ; } | To map . | 59 | 3 |
141,422 | public static void validateNull ( String name , Object object ) { if ( object == null ) { throw new IllegalStateException ( name . concat ( " cannot be null" ) ) ; } } | Validate null . | 41 | 4 |
141,423 | public static void addToSystemConfig ( String prefix , Properties prop ) { for ( Entry < Object , Object > entry : prop . entrySet ( ) ) { String key = prefix . concat ( entry . getKey ( ) . toString ( ) ) ; String value = entry . getValue ( ) . toString ( ) ; System . setProperty ( key , value ) ; } } | Adds the to system config . | 81 | 6 |
141,424 | public static char [ ] readPassword ( String msg ) { Console console = System . console ( ) ; if ( console != null ) { return console . readPassword ( ) ; } // console not available, most likely because of running inside IDE, try normal scanner = getScanner ( ) ; System . out . print ( msg ) ; return scanner . nextLine ( ) . toCharArray ( ) ; } | Read password . | 84 | 3 |
141,425 | public static void printOnce ( Object msg ) { if ( messagesCache . get ( msg . hashCode ( ) ) == null ) { JK . printBlock ( msg ) ; messagesCache . put ( msg . hashCode ( ) , msg ) ; } } | Print the message and then save it into list to avoid reporing it again it can be helpfull to debugging purposes . | 54 | 24 |
141,426 | public static String getAppName ( ) { String appName = System . getProperty ( JKContextConstants . JK_APP_NAME ) ; if ( appName == null ) { String mainClassName = JKDebugUtil . getMainClassName ( ) ; return mainClassName . substring ( 0 , mainClassName . lastIndexOf ( "." ) ) ; } return appName ; } | Gets the app name . | 87 | 6 |
141,427 | public static void dumpBeansNames ( ) { DefaultListableBeanFactory f = ( DefaultListableBeanFactory ) context . getBeanFactory ( ) ; String [ ] beanDefinitionNames = f . getBeanDefinitionNames ( ) ; for ( String name : beanDefinitionNames ) { JK . print ( name , " for class :" , f . getBean ( name ) . getClass ( ) . getName ( ) ) ; } } | Dump beans names . | 97 | 5 |
141,428 | protected static Configuration getConfig ( String path ) { if ( cfg == null ) { cfg = new Configuration ( ) ; cfg . setClassForTemplateLoading ( TemplateUtil . class , path == null ? "/templates" : path ) ; cfg . setLocale ( Locale . US ) ; cfg . setTemplateExceptionHandler ( TemplateExceptionHandler . RETHROW_HANDLER ) ; } return cfg ; } | Gets the config . | 93 | 5 |
141,429 | protected void handleClient ( final Socket client ) throws IOException { final ClientHandler handler = new ClientHandler ( client ) ; this . executorService . execute ( handler ) ; } | Handle client request this method will be called when new client connection received by the start method . | 37 | 18 |
141,430 | public synchronized void stop ( ) throws IOException { this . stopped = true ; if ( this . server != null && this . waitingClient ) { this . server . close ( ) ; this . server = null ; } } | Stop the server instance by setting the stopped flag to true the close the server instance if open . | 46 | 19 |
141,431 | private void resetConfigToDefault ( ) { isUseWebservice = true ; isUpdateAutomatic = true ; isUseExternalMonomers = false ; isUseExternalNucleotides = false ; setUseExternalAttachments ( false ) ; webserviceMonomersURL = "http://localhost:8080/HELM2MonomerService/rest" ; webserviceMonomersPath = "monomer/" ; webserviceMonomersPutPath = "monomer/" ; webserviceEditorCategorizationURL = "http://localhost:8080" ; webserviceEditorCategorizationPath = "" ; externalNucleotidesPath = "" ; externalMonomersPath = "" ; setExternalAttachmentsPath ( "" ) ; } | Resets the configuration to default values . | 164 | 8 |
141,432 | public void refresh ( ) { File configFile = new File ( CONFIG_FILE_PATH ) ; if ( ! configFile . exists ( ) ) { BufferedWriter writer = null ; BufferedReader reader = null ; try { configFile . createNewFile ( ) ; InputStream in = Chemistry . class . getResourceAsStream ( "/org/helm/notation2/resources/MonomerStoreConfig.properties" ) ; reader = new BufferedReader ( new InputStreamReader ( in ) ) ; writer = new BufferedWriter ( new FileWriter ( configFile ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { writer . write ( line + System . getProperty ( "line.separator" ) ) ; } } catch ( Exception e ) { resetConfigToDefault ( ) ; e . printStackTrace ( ) ; } finally { try { if ( writer != null ) { writer . close ( ) ; } if ( reader != null ) { reader . close ( ) ; } } catch ( IOException e ) { // TODO Auto-generated catch block e . printStackTrace ( ) ; } } } try { PropertiesConfiguration conf = new PropertiesConfiguration ( CONFIG_FILE_PATH ) ; isUseWebservice = conf . getBoolean ( USE_WEBSERVICE ) ; isUpdateAutomatic = conf . getBoolean ( UPDATE_AUTOMATIC ) ; webserviceMonomersURL = conf . getString ( WEBSERVICE_MONOMERS_URL ) ; webserviceMonomersPath = conf . getString ( WEBSERVICE_MONOMERS_PATH ) ; webserviceMonomersPutPath = conf . getString ( WEBSERVICE_MONOMERS_PUT_PATH ) ; webserviceNucleotidesURL = conf . getString ( WEBSERVICE_NUCLEOTIDES_URL ) ; webserviceNucleotidesPath = conf . getString ( WEBSERVICE_NUCLEOTIDES_PATH ) ; webserviceNucleotidesPutPath = conf . getString ( WEBSERVICE_NUCLEOTIDES_PUT_PATH ) ; webserviceEditorCategorizationURL = conf . getString ( WEBSERVICE_EDITOR_CATEGORIZATION_URL ) ; webserviceEditorCategorizationPath = conf . getString ( WEBSERVICE_EDITOR_CATEGORIZATION_PATH ) ; /* load from external xml file */ isUseExternalMonomers = conf . getBoolean ( USE_EXTERNAL_MONOMERS ) ; externalMonomersPath = conf . getString ( EXTERNAL_MONOMERS_PATH ) ; isUseExternalNucleotides = conf . getBoolean ( USE_EXTERNAL_NUCLEOTIDES ) ; externalNucleotidesPath = conf . getString ( EXTERNAL_NUCLEOTIDES_PATH ) ; isUseExternalAttachments = conf . getBoolean ( USE_EXTERNAL_ATTACHMENTS ) ; externalAttachmentsPath = conf . getString ( EXTERNAL_ATTACHMENTS_PATH ) ; } catch ( ConfigurationException | NoSuchElementException e ) { resetConfigToDefault ( ) ; e . printStackTrace ( ) ; } } | Refreshes the configuration using the local properties file . | 711 | 11 |
141,433 | private static void addEntry ( final ArrayList < String > aStringArray ) { try { final MagicMimeEntry magicEntry = new MagicMimeEntry ( aStringArray ) ; mMagicMimeEntries . add ( magicEntry ) ; } catch ( final InvalidMagicMimeEntryException e ) { } } | Adds the entry . | 66 | 4 |
141,434 | private static String getMagicMimeType ( final byte [ ] bytes ) throws IOException { final int len = mMagicMimeEntries . size ( ) ; for ( int i = 0 ; i < len ; i ++ ) { final MagicMimeEntry me = mMagicMimeEntries . get ( i ) ; final String mtype = me . getMatch ( bytes ) ; if ( mtype != null ) { return mtype ; } } return null ; } | Gets the magic mime type . | 99 | 8 |
141,435 | public static String getMimeType ( final byte [ ] data ) { String mimeType = null ; try { mimeType = MimeUtil . getMagicMimeType ( data ) ; } catch ( final Exception e ) { } finally { if ( mimeType == null ) { mimeType = UNKNOWN_MIME_TYPE ; } } return mimeType ; } | Gets the mime type . | 82 | 7 |
141,436 | private static void parse ( final Reader r ) throws IOException { final BufferedReader br = new BufferedReader ( r ) ; String line ; final ArrayList < String > sequence = new ArrayList < String > ( ) ; line = br . readLine ( ) ; while ( true ) { if ( line == null ) { break ; } line = line . trim ( ) ; if ( line . length ( ) == 0 || line . charAt ( 0 ) == ' ' ) { line = br . readLine ( ) ; continue ; } sequence . add ( line ) ; // read the following lines until a line does not begin with '>' or // EOF while ( true ) { line = br . readLine ( ) ; if ( line == null ) { addEntry ( sequence ) ; sequence . clear ( ) ; break ; } line = line . trim ( ) ; if ( line . length ( ) == 0 || line . charAt ( 0 ) == ' ' ) { continue ; } if ( line . charAt ( 0 ) != ' ' ) { addEntry ( sequence ) ; sequence . clear ( ) ; break ; } sequence . add ( line ) ; } } if ( ! sequence . isEmpty ( ) ) { addEntry ( sequence ) ; } } | Parse the magic . mime file | 265 | 8 |
141,437 | public static JKContext getCurrentContext ( ) { JKContext context = ( JKContext ) JKThreadLocal . getValue ( JKContextConstants . JK_CONTEXT ) ; if ( context == null ) { context = getInstance ( ) . createDesktopContext ( ) ; JKThreadLocal . setValue ( JKContextConstants . JK_CONTEXT , context ) ; } return context ; } | Gets the current context . | 90 | 6 |
141,438 | public static byte [ ] generateImageHELMMolecule ( HELM2Notation helm2notation ) throws BuilderMoleculeException , CTKException , IOException , ChemistryException { LOG . info ( "Image generation process of HELM molecule starts" ) ; /* get SMILES representation for the whole molecule */ String smiles = SMILES . getSMILESForAll ( helm2notation ) ; LOG . info ( "Get for the whole HELMNotation the smiles representation" ) ; AbstractMolecule molecule = Chemistry . getInstance ( ) . getManipulator ( ) . getMolecule ( smiles , null ) ; LOG . info ( "Molecule was created using the smiles generation" ) ; String molFile = Chemistry . getInstance ( ) . getManipulator ( ) . convertMolecule ( molecule , AbstractChemistryManipulator . StType . MOLFILE ) ; LOG . info ( "Generate molfile for the built molecule(s)" ) ; return Chemistry . getInstance ( ) . getManipulator ( ) . renderMol ( molFile , OutputType . PNG , PICTURE_WIDTH , PICTURE_HEIGHT , ( int ) Long . parseLong ( "D3D3D3" , 16 ) ) ; } | method to generate an image of the HELM molecule | 274 | 10 |
141,439 | public static List < String > getAminoAcidList ( String peptideSequence ) throws MonomerException , NotationException , MonomerLoadingException , ChemistryException { if ( null == peptideSequence ) { throw new NotationException ( "Peptide Sequence must be specified" ) ; } String cleanSeq = cleanup ( peptideSequence ) ; Map < String , Monomer > peptideMap = MonomerFactory . getInstance ( ) . getMonomerDB ( ) . get ( Monomer . PEPTIDE_POLYMER_TYPE ) ; Set < String > keySet = peptideMap . keySet ( ) ; // walk the sequence List < String > l = new ArrayList < String > ( ) ; int pos = 0 ; while ( pos < cleanSeq . length ( ) ) { boolean found = false ; for ( Iterator i = keySet . iterator ( ) ; i . hasNext ( ) ; ) { String symbol = ( String ) i . next ( ) ; if ( cleanSeq . startsWith ( symbol , pos ) ) { found = true ; l . add ( symbol ) ; pos = pos + symbol . length ( ) ; break ; } } if ( ! found ) { throw new NotationException ( "Sequence contains unknown amino acid starting at " + cleanSeq . substring ( pos ) ) ; } } return l ; } | This method converts peptide sequence into a List of amino acid | 295 | 12 |
141,440 | public static List < String > getAminoAcidList ( String peptideSequence , String delimiter ) throws MonomerException , NotationException , MonomerLoadingException , ChemistryException { if ( null == peptideSequence ) { throw new NotationException ( "Peptide Sequence must be specified" ) ; } if ( null == delimiter || delimiter . length ( ) == 0 ) { return getAminoAcidList ( peptideSequence ) ; } else { if ( ! isValidDelimiter ( delimiter ) ) throw new NotationException ( "Invalid sequence delimiter [" + delimiter + "], only the following are supported: [" + getValidDelimiters ( ) + "]" ) ; } List < String > blocks = new ArrayList < String > ( ) ; StringTokenizer st = new StringTokenizer ( peptideSequence , delimiter ) ; while ( st . hasMoreTokens ( ) ) { blocks . add ( st . nextToken ( ) ) ; } List < String > l = new ArrayList < String > ( ) ; for ( String block : blocks ) { List < String > tmpL = getAminoAcidList ( block ) ; l . addAll ( tmpL ) ; } return l ; } | This method converts peptide sequence into a List of amino acid with optional delimiter | 270 | 16 |
141,441 | public static String cleanup ( String sequence ) { String result = sequence . replaceAll ( "\\s" , "" ) ; // remove all white // space if ( result . equals ( result . toLowerCase ( ) ) ) { result = result . toUpperCase ( ) ; } return result ; } | remove white space and convert all lower case to upper case | 63 | 11 |
141,442 | public static void downloadFile ( final String fileUrl , final String localFile ) throws IOException { final URL url = new URL ( fileUrl ) ; final HttpURLConnection connection = ( HttpURLConnection ) url . openConnection ( ) ; final byte [ ] data = JKIOUtil . readStream ( connection . getInputStream ( ) ) ; JKIOUtil . writeBytesToFile ( data , localFile ) ; } | Download file . | 91 | 3 |
141,443 | public static File downloadFileToTemp ( final String fileUrl , final String ext ) throws IOException { final File file = File . createTempFile ( "jk-" , ext ) ; JKHttpUtil . downloadFile ( fileUrl , file . getAbsolutePath ( ) ) ; return file ; } | Download file to temp . | 65 | 5 |
141,444 | public static String requestUrl ( final String url , final String method , final Properties header , final String body ) { try { final URL siteUrl = new URL ( url ) ; final HttpURLConnection connection = ( HttpURLConnection ) siteUrl . openConnection ( ) ; connection . setRequestMethod ( method ) ; final Enumeration < ? > keys = header . keys ( ) ; while ( keys . hasMoreElements ( ) ) { final String key = ( String ) keys . nextElement ( ) ; connection . addRequestProperty ( key , header . getProperty ( key ) ) ; } connection . setDoOutput ( true ) ; final OutputStream out = connection . getOutputStream ( ) ; out . write ( body . getBytes ( ) ) ; connection . connect ( ) ; final int errorCode = connection . getResponseCode ( ) ; if ( errorCode != HttpURLConnection . HTTP_OK ) { throw new JKHttpException ( connection . getResponseMessage ( ) , errorCode ) ; } final String response = JKIOUtil . convertToString ( connection . getInputStream ( ) ) ; return response ; } catch ( IOException e ) { throw new JKHttpException ( e ) ; } } | Send http request . | 258 | 4 |
141,445 | public static String getUrlContents ( String urlString ) { HttpURLConnection con = null ; try { URL url = new URL ( urlString ) ; con = ( HttpURLConnection ) url . openConnection ( ) ; con . connect ( ) ; InputStream inputStream = con . getInputStream ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; StringBuffer contents = new StringBuffer ( ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { contents . append ( line ) ; contents . append ( JK . NEW_LINE ) ; } inputStream . close ( ) ; return contents . toString ( ) ; } catch ( Exception e ) { JKExceptionUtil . handle ( e ) ; return null ; // unreachable } finally { if ( con != null ) { con . disconnect ( ) ; } } } | Gets the url contents . | 193 | 6 |
141,446 | public static String getValueFromUrl ( String url , String preText , int length ) { String urlContents = getUrlContents ( url ) ; int indexOf = urlContents . indexOf ( preText ) ; if ( indexOf != - 1 ) { indexOf += preText . length ( ) ; String substring = urlContents . substring ( indexOf , indexOf + length ) ; return substring ; } return null ; } | Gets the value from url based on pre - text value from the response . | 91 | 16 |
141,447 | public static InputStream getUrlInputStream ( String urlString ) { URL url ; try { url = new URL ( urlString ) ; HttpURLConnection con = ( HttpURLConnection ) url . openConnection ( ) ; con . connect ( ) ; return con . getInputStream ( ) ; } catch ( Exception e ) { throw new JKException ( e ) ; } } | Gets the url input stream . | 80 | 7 |
141,448 | public static < T > T readUrlAsObject ( String url , Class < T > type ) { String contents = getUrlContents ( url ) ; ObjectMapper mapper = new ObjectMapper ( ) ; mapper . enableDefaultTyping ( ) ; try { return mapper . readValue ( contents , type ) ; } catch ( IOException e ) { JK . throww ( e ) ; return null ; } } | Read the given url contents and try to create an object from the given type . | 90 | 16 |
141,449 | public static Password createPassword ( char [ ] password ) { byte [ ] salt = JKSecurityUtil . salt ( ) ; byte [ ] hash = JKSecurityUtil . hash ( password , salt ) ; Password pass = new Password ( ) ; pass . setHash ( encodeInToBase64 ( hash ) ) ; pass . setSalt ( encodeInToBase64 ( salt ) ) ; return pass ; } | Encrypt password . | 87 | 4 |
141,450 | public Class < ? > getJavaType ( ) { if ( javaType == null ) { javaType = JKTypeMapping . getType ( getCode ( ) ) . getClass ( ) ; if ( javaType == null ) { JK . error ( "JKType cannot by null, and code not avaiable %s" , code ) ; } } return javaType ; } | Gets the java type . | 83 | 6 |
141,451 | public String getName ( ) { if ( name == null ) { name = JKMessage . get ( getJavaType ( ) . getSimpleName ( ) ) ; } return name ; } | Gets the name . | 40 | 5 |
141,452 | public JKTimeObject toTimeObject ( Date date , Date time ) { JKTimeObject fsTimeObject = new JKTimeObject ( ) ; Calendar timeInstance = Calendar . getInstance ( ) ; timeInstance . setTimeInMillis ( time . getTime ( ) ) ; fsTimeObject . setHour ( timeInstance . get ( Calendar . HOUR_OF_DAY ) ) ; fsTimeObject . setMunite ( timeInstance . get ( Calendar . MINUTE ) ) ; Calendar dateInstance = Calendar . getInstance ( ) ; dateInstance . setTime ( date ) ; fsTimeObject . setYear ( dateInstance . get ( Calendar . YEAR ) ) ; fsTimeObject . setMonth ( dateInstance . get ( Calendar . MONTH ) ) ; fsTimeObject . setDay ( dateInstance . get ( Calendar . DAY_OF_MONTH ) ) ; return fsTimeObject ; } | To time object . | 190 | 4 |
141,453 | public static RgroupStructure buildMoleculefromSinglePolymer ( final PolymerNotation polymernotation ) throws BuilderMoleculeException , HELM2HandledException , ChemistryException { LOG . info ( "Build molecule for single Polymer " + polymernotation . getPolymerID ( ) . getId ( ) ) ; /* Case 1: BLOB -> throw exception */ if ( polymernotation . getPolymerID ( ) instanceof BlobEntity ) { LOG . error ( "Molecule can't be build for BLOB" ) ; throw new BuilderMoleculeException ( "Molecule can't be build for BLOB" ) ; } /* Case 2: CHEM */ else if ( polymernotation . getPolymerID ( ) instanceof ChemEntity ) { List < Monomer > validMonomers = MethodsMonomerUtils . getListOfHandledMonomers ( polymernotation . getPolymerElements ( ) . getListOfElements ( ) ) ; return buildMoleculefromCHEM ( polymernotation . getPolymerID ( ) . getId ( ) , validMonomers ) ; } /* Case 3: RNA or PEPTIDE */ else if ( polymernotation . getPolymerID ( ) instanceof RNAEntity || polymernotation . getPolymerID ( ) instanceof PeptideEntity ) { List < Monomer > validMonomers = MethodsMonomerUtils . getListOfHandledMonomers ( polymernotation . getPolymerElements ( ) . getListOfElements ( ) ) ; return buildMoleculefromPeptideOrRNA ( polymernotation . getPolymerID ( ) . getId ( ) , validMonomers ) ; } else { LOG . error ( "Molecule can't be build for unknown polymer type" ) ; throw new BuilderMoleculeException ( "Molecule can't be build for unknown polymer type" ) ; } } | method to build a molecule for a single polymer | 411 | 9 |
141,454 | private static RgroupStructure buildMoleculefromCHEM ( final String id , final List < Monomer > validMonomers ) throws BuilderMoleculeException , ChemistryException { LOG . info ( "Build molecule for chemical component" ) ; /* a chemical molecule should only contain one monomer */ if ( validMonomers . size ( ) == 1 ) { try { Monomer monomer = validMonomers . get ( 0 ) ; String input = getInput ( monomer ) ; if ( input != null ) { /* Build monomer + Rgroup information! */ List < Attachment > listAttachments = monomer . getAttachmentList ( ) ; AttachmentList list = new AttachmentList ( ) ; for ( Attachment attachment : listAttachments ) { list . add ( new org . helm . chemtoolkit . Attachment ( attachment . getAlternateId ( ) , attachment . getLabel ( ) , attachment . getCapGroupName ( ) , attachment . getCapGroupSMILES ( ) ) ) ; } AbstractMolecule molecule = Chemistry . getInstance ( ) . getManipulator ( ) . getMolecule ( input , list ) ; RgroupStructure result = new RgroupStructure ( ) ; result . setMolecule ( molecule ) ; result . setRgroupMap ( generateRgroupMap ( id + ":" + "1" , molecule ) ) ; return result ; } else { LOG . error ( "Chemical molecule should have canonical smiles" ) ; throw new BuilderMoleculeException ( "Chemical molecule should have canoncial smiles" ) ; } } catch ( NullPointerException ex ) { throw new BuilderMoleculeException ( "Monomer is not stored in the monomer database" ) ; } catch ( IOException | CTKException e ) { LOG . error ( "Molecule can't be built " + e . getMessage ( ) ) ; throw new BuilderMoleculeException ( "Molecule can't be built " + e . getMessage ( ) ) ; } } else { LOG . error ( "Chemical molecule should contain exactly one monomer" ) ; throw new BuilderMoleculeException ( "Chemical molecule should contain exactly one monomer" ) ; } } | method to build a molecule from a chemical component | 476 | 9 |
141,455 | private static AttachmentList generateAttachmentList ( final List < Attachment > listAttachments ) { AttachmentList list = new AttachmentList ( ) ; for ( Attachment attachment : listAttachments ) { list . add ( new org . helm . chemtoolkit . Attachment ( attachment . getAlternateId ( ) , attachment . getLabel ( ) , attachment . getCapGroupName ( ) , attachment . getCapGroupSMILES ( ) ) ) ; } return list ; } | method to generate the AttachmentList given a list of attachments | 103 | 12 |
141,456 | public static AbstractMolecule mergeRgroups ( AbstractMolecule molecule ) throws BuilderMoleculeException , ChemistryException { try { boolean flag = true ; // while (flag) { // if (molecule.getAttachments().size() > 0) { for ( int i = molecule . getAttachments ( ) . size ( ) - 1 ; i > - 1 ; i -- ) { org . helm . chemtoolkit . Attachment attachment = molecule . getAttachments ( ) . get ( i ) ; int groupId = AbstractMolecule . getIdFromLabel ( attachment . getLabel ( ) ) ; AbstractMolecule rMol = Chemistry . getInstance ( ) . getManipulator ( ) . getMolecule ( attachment . getSmiles ( ) , null ) ; molecule = Chemistry . getInstance ( ) . getManipulator ( ) . merge ( molecule , molecule . getRGroupAtom ( groupId , true ) , rMol , rMol . getRGroupAtom ( groupId , true ) ) ; } return molecule ; } catch ( NullPointerException | IOException | CTKException e ) { throw new BuilderMoleculeException ( "Unused rgroups can't be merged into the molecule" + e . getMessage ( ) ) ; } } | method to merge all unused rgroups into a molecule | 277 | 10 |
141,457 | public static AbstractMolecule getMoleculeForMonomer ( final Monomer monomer ) throws BuilderMoleculeException , ChemistryException { String input = getInput ( monomer ) ; if ( input != null ) { List < Attachment > listAttachments = monomer . getAttachmentList ( ) ; AttachmentList list = new AttachmentList ( ) ; for ( Attachment attachment : listAttachments ) { list . add ( new org . helm . chemtoolkit . Attachment ( attachment . getAlternateId ( ) , attachment . getLabel ( ) , attachment . getCapGroupName ( ) , attachment . getCapGroupSMILES ( ) ) ) ; } try { return Chemistry . getInstance ( ) . getManipulator ( ) . getMolecule ( input , list ) ; } catch ( IOException | CTKException e ) { throw new BuilderMoleculeException ( "Molecule can't be built for the given monomer" ) ; } } return null ; } | method to build a molecule for a given monomer | 214 | 10 |
141,458 | void addEntry ( final String aLine ) { final String trimmed = aLine . replaceAll ( "^>*" , "" ) ; String [ ] tokens = trimmed . split ( "\t" ) ; // Now strip the empty entries final Vector < String > v = new Vector < String > ( ) ; for ( int i = 0 ; i < tokens . length ; i ++ ) { if ( ! "" . equals ( tokens [ i ] ) ) { v . add ( tokens [ i ] ) ; } } tokens = new String [ v . size ( ) ] ; tokens = v . toArray ( tokens ) ; if ( tokens . length > 0 ) { final String tok = tokens [ 0 ] . trim ( ) ; try { if ( tok . startsWith ( "0x" ) ) { this . checkBytesFrom = Integer . parseInt ( tok . substring ( 2 ) , 16 ) ; } else { this . checkBytesFrom = Integer . parseInt ( tok ) ; } } catch ( final NumberFormatException e ) { // We could have a space delinitaed entry so lets try to handle // this anyway addEntry ( trimmed . replaceAll ( " " , "\t" ) ) ; return ; } } if ( tokens . length > 1 ) { this . typeStr = tokens [ 1 ] . trim ( ) ; this . type = getType ( this . typeStr ) ; } if ( tokens . length > 2 ) { // We don't trim the content this . content = ltrim ( tokens [ 2 ] ) ; this . content = stringWithEscapeSubstitutions ( this . content ) ; } if ( tokens . length > 3 ) { this . mimeType = tokens [ 3 ] . trim ( ) ; } if ( tokens . length > 4 ) { this . mimeEnc = tokens [ 4 ] . trim ( ) ; } } | as much of the file as possible . Currently about 70 entries are incorrect | 398 | 14 |
141,459 | public String getMatch ( final byte [ ] content ) throws IOException { final ByteBuffer buf = readBuffer ( content ) ; if ( buf == null ) { return null ; } buf . position ( 0 ) ; final boolean matches = match ( buf ) ; if ( matches ) { final int subLen = this . subEntries . size ( ) ; final String myMimeType = getMimeType ( ) ; if ( subLen > 0 ) { String mtype = null ; for ( int k = 0 ; k < subLen ; k ++ ) { final MagicMimeEntry me = this . subEntries . get ( k ) ; mtype = me . getMatch ( content ) ; if ( mtype != null ) { return mtype ; } } if ( myMimeType != null ) { return myMimeType ; } } else { return myMimeType ; } } return null ; } | Gets the match . | 192 | 5 |
141,460 | private int howManyGreaterThans ( final String aLine ) { if ( aLine == null ) { return - 1 ; } int i = 0 ; final int len = aLine . length ( ) ; while ( i < len ) { if ( aLine . charAt ( i ) == ' ' ) { i ++ ; } else { break ; } } return i ; } | How many greater thans . | 80 | 6 |
141,461 | private boolean matchByte ( final ByteBuffer bbuf ) throws IOException { final byte b = bbuf . get ( 0 ) ; return b == getContent ( ) . charAt ( 0 ) ; } | Match byte . | 42 | 3 |
141,462 | private boolean matchLong ( final ByteBuffer bbuf , final ByteOrder bo , final boolean needMask , final long lMask ) throws IOException { bbuf . order ( bo ) ; long got ; final String testContent = getContent ( ) ; if ( testContent . startsWith ( "0x" ) ) { got = Long . parseLong ( testContent . substring ( 2 ) , 16 ) ; } else if ( testContent . startsWith ( "&" ) ) { got = Long . parseLong ( testContent . substring ( 3 ) , 16 ) ; } else { got = Long . parseLong ( testContent ) ; } long found = bbuf . getInt ( ) ; if ( needMask ) { found = ( short ) ( found & lMask ) ; } if ( got != found ) { return false ; } return true ; } | Match long . | 180 | 3 |
141,463 | private boolean matchShort ( final ByteBuffer bbuf , final ByteOrder bo , final boolean needMask , final short sMask ) throws IOException { bbuf . order ( bo ) ; short got ; final String testContent = getContent ( ) ; if ( testContent . startsWith ( "0x" ) ) { got = ( short ) Integer . parseInt ( testContent . substring ( 2 ) , 16 ) ; } else if ( testContent . startsWith ( "&" ) ) { got = ( short ) Integer . parseInt ( testContent . substring ( 3 ) , 16 ) ; } else { got = ( short ) Integer . parseInt ( testContent ) ; } short found = bbuf . getShort ( ) ; if ( needMask ) { found = ( short ) ( found & sMask ) ; } if ( got != found ) { return false ; } return true ; } | Match short . | 189 | 3 |
141,464 | private boolean matchString ( final ByteBuffer bbuf ) throws IOException { if ( this . isBetween ) { final String buffer = new String ( bbuf . array ( ) ) ; if ( buffer . contains ( getContent ( ) ) ) { return true ; } return false ; } final int read = getContent ( ) . length ( ) ; for ( int j = 0 ; j < read ; j ++ ) { if ( ( bbuf . get ( j ) & 0xFF ) != getContent ( ) . charAt ( j ) ) { return false ; } } return true ; } | Match string . | 124 | 3 |
141,465 | @ SuppressWarnings ( "unused" ) private ByteBuffer readBuffer ( final RandomAccessFile raf ) throws IOException { final int startPos = getCheckBytesFrom ( ) ; if ( startPos > raf . length ( ) ) { return null ; } raf . seek ( startPos ) ; ByteBuffer buf ; switch ( getType ( ) ) { case MagicMimeEntry . STRING_TYPE : { int len = 0 ; // Lets check if its a between test final int index = this . typeStr . indexOf ( ">" ) ; if ( index != - 1 ) { len = Integer . parseInt ( this . typeStr . substring ( index + 1 , this . typeStr . length ( ) - 1 ) ) ; this . isBetween = true ; } else { len = getContent ( ) . length ( ) ; } buf = ByteBuffer . allocate ( len + 1 ) ; raf . read ( buf . array ( ) , 0 , len ) ; break ; } case MagicMimeEntry . SHORT_TYPE : case MagicMimeEntry . LESHORT_TYPE : case MagicMimeEntry . BESHORT_TYPE : { buf = ByteBuffer . allocate ( 2 ) ; raf . read ( buf . array ( ) , 0 , 2 ) ; break ; } case MagicMimeEntry . LELONG_TYPE : case MagicMimeEntry . BELONG_TYPE : { buf = ByteBuffer . allocate ( 4 ) ; raf . read ( buf . array ( ) , 0 , 4 ) ; break ; } case MagicMimeEntry . BYTE_TYPE : { buf = ByteBuffer . allocate ( 1 ) ; raf . read ( buf . array ( ) , 0 , 1 ) ; } default : { buf = null ; break ; } } return buf ; } | Read buffer . | 385 | 3 |
141,466 | public void traverseAndPrint ( final String tabs ) { logger . info ( tabs + toString ( ) ) ; final int len = this . subEntries . size ( ) ; for ( int i = 0 ; i < len ; i ++ ) { final MagicMimeEntry me = this . subEntries . get ( i ) ; me . traverseAndPrint ( tabs + "\t" ) ; } } | Traverse and print . | 85 | 5 |
141,467 | public void addEmptyValue ( final JKTableColumn col ) { final JKTableColumnValue value = new JKTableColumnValue ( col ) ; this . columnsValues . add ( value ) ; } | Adds the empty value . | 43 | 5 |
141,468 | public Double getColumnValueAsDouble ( final int col , final double defaultValue ) { Double value = getColumnValueAsDouble ( col ) ; if ( value == null ) { value = defaultValue ; } return value ; } | Gets the column value as double . | 47 | 8 |
141,469 | public static String getSMILESForAll ( HELM2Notation helm2notation ) throws BuilderMoleculeException , CTKException , ChemistryException { /* Build Molecues */ LOG . debug ( "Build single molecule(s)" ) ; List < AbstractMolecule > molecules = BuilderMolecule . buildMoleculefromPolymers ( helm2notation . getListOfPolymers ( ) , HELM2NotationUtils . getAllEdgeConnections ( helm2notation . getListOfConnections ( ) ) ) ; /* get for every molecule the smiles */ LOG . debug ( "Built single molecule(s)" ) ; StringBuffer sb = new StringBuffer ( ) ; for ( AbstractMolecule molecule : molecules ) { molecule = BuilderMolecule . mergeRgroups ( molecule ) ; sb . append ( Chemistry . getInstance ( ) . getManipulator ( ) . convertMolecule ( molecule , AbstractChemistryManipulator . StType . SMILES ) + "." ) ; } sb . setLength ( sb . length ( ) - 1 ) ; LOG . debug ( "SMILES-All :" + sb . toString ( ) ) ; return sb . toString ( ) ; } | method to generate smiles for the whole HELMNotation | 265 | 11 |
141,470 | public static boolean containsGenericStructurePolymer ( List < PolymerNotation > polymers ) throws HELM2HandledException , ChemistryException , IOException , CTKException { for ( PolymerNotation polymer : polymers ) { if ( polymer . getPolymerID ( ) instanceof ChemEntity ) { Monomer monomer = MethodsMonomerUtils . getListOfHandledMonomers ( polymer . getPolymerElements ( ) . getListOfElements ( ) ) . get ( 0 ) ; if ( null == monomer . getCanSMILES ( ) || monomer . getCanSMILES ( ) . length ( ) == 0 ) { return true ; } if ( monomer . containAnyAtom ( ) ) { return true ; } } } return false ; } | method if the any of the given PolymerNotation contains generic structures | 171 | 14 |
141,471 | public static String getCanonicalSMILESForPolymer ( PolymerNotation polymer ) throws BuilderMoleculeException , HELM2HandledException , CTKSmilesException , CTKException , NotationException , ChemistryException { AbstractMolecule molecule = BuilderMolecule . buildMoleculefromSinglePolymer ( polymer ) . getMolecule ( ) ; molecule = BuilderMolecule . mergeRgroups ( molecule ) ; return Chemistry . getInstance ( ) . getManipulator ( ) . canonicalize ( Chemistry . getInstance ( ) . getManipulator ( ) . convertMolecule ( molecule , AbstractChemistryManipulator . StType . SMILES ) ) ; } | method to generate canonical smiles for one single PolymerNotation | 151 | 12 |
141,472 | public static String convertMolToSMILESWithAtomMapping ( String molfile , List < Attachment > attachments ) throws CTKException , ChemistryException { String smiles = Chemistry . getInstance ( ) . getManipulator ( ) . convertMolIntoSmilesWithAtomMapping ( molfile ) ; for ( Attachment attachment : attachments ) { int r = Integer . valueOf ( attachment . getLabel ( ) . replaceAll ( "\\D+" , "" ) ) ; smiles = smiles . replace ( "[*:" + r + "]" , "[" + attachment . getCapGroupName ( ) + ":" + r + "]" ) ; } return smiles ; } | Converts molfile with the given attachments in smiles with atom mapping | 149 | 14 |
141,473 | public static boolean isConnected ( String molfile ) throws CTKException , ChemistryException { return Chemistry . getInstance ( ) . getManipulator ( ) . isConnected ( molfile ) ; } | returns if structure is connected | 45 | 6 |
141,474 | protected static CloseableHttpResponse putResource ( String json , String fullURL ) throws ClientProtocolException , IOException , URISyntaxException { try ( CloseableHttpClient httpclient = HttpClients . createDefault ( ) ) { // There is no need to provide user credentials // HttpClient will attempt to access current user security context // through Windows platform specific methods via JNI. HttpPut httpput = new HttpPut ( new URIBuilder ( fullURL ) . build ( ) ) ; httpput . setHeader ( "Content-Type" , "application/json;charset=UTF-8" ) ; httpput . setEntity ( new StringEntity ( json , "UTF-8" ) ) ; LOG . debug ( "Executing request " + httpput . getRequestLine ( ) ) ; return httpclient . execute ( httpput ) ; } } | Calls a PUT routine with given JSON on given resource URL . | 190 | 14 |
141,475 | protected static CloseableHttpResponse getResource ( String fullURL ) throws IOException , URISyntaxException { URI uri = new URIBuilder ( fullURL ) . build ( ) ; try ( CloseableHttpClient httpclient = HttpClients . createDefault ( ) ) { /* read url */ HttpGet httpget = new HttpGet ( uri ) ; LOG . debug ( "Executing request " + httpget . getRequestLine ( ) ) ; return httpclient . execute ( httpget ) ; } } | Call a GET routine on given resource URL . | 110 | 9 |
141,476 | public static String getXHELM ( HELM2Notation helm2notation ) throws MonomerException , HELM1FormatException , IOException , JDOMException , NotationException , CTKException , ValidationException , ChemistryException { set = new HashSet < Monomer > ( ) ; Element root = new Element ( xHelmNotationExporter . XHELM_ELEMENT ) ; Document doc = new Document ( root ) ; Element helmElement = new Element ( xHelmNotationExporter . HELM_NOTATION_ELEMENT ) ; helmElement . setText ( HELM1Utils . getStandard ( helm2notation ) ) ; root . addContent ( helmElement ) ; Element monomerListElement = new Element ( xHelmNotationExporter . MONOMER_LIST_ELEMENT ) ; /* save all adhocMonomers in the set */ for ( MonomerNotation monomernotation : MethodsMonomerUtils . getListOfMonomerNotation ( helm2notation . getListOfPolymers ( ) ) ) { /* get all elements of an rna */ if ( monomernotation instanceof MonomerNotationUnitRNA ) { for ( MonomerNotationUnit unit : ( ( MonomerNotationUnitRNA ) monomernotation ) . getContents ( ) ) { addAdHocMonomer ( unit ) ; } } else { addAdHocMonomer ( monomernotation ) ; } } /* give adhoc monomer's information */ for ( Monomer distinctmonomer : set ) { Element monomerElement = MonomerParser . getMonomerElement ( distinctmonomer ) ; monomerListElement . getChildren ( ) . add ( monomerElement ) ; } root . addContent ( monomerListElement ) ; XMLOutputter xmlOutput = new XMLOutputter ( ) ; // display nice xmlOutput . setFormat ( Format . getPrettyFormat ( ) ) ; return xmlOutput . outputString ( doc ) ; } | method to get xhelm for the helm notation only if it was possible to convert the helm in the old format | 432 | 22 |
141,477 | private static void addAdHocMonomer ( MonomerNotation monomerNotation ) throws IOException , JDOMException , ChemistryException { Monomer monomer = MonomerFactory . getInstance ( ) . getMonomerStore ( ) . getMonomer ( monomerNotation . getType ( ) , monomerNotation . getUnit ( ) . replace ( "[" , "" ) . replace ( "]" , "" ) ) ; if ( monomer . isAdHocMonomer ( ) ) { set . add ( monomer ) ; } } | method to add the monomer to the database if it is an adhoc monomer | 121 | 18 |
141,478 | private List < Attachment > deserializeAttachmentList ( JsonParser parser , Map < String , Attachment > attachmentDB ) throws JsonParseException , IOException { List < Attachment > attachments = new ArrayList < Attachment > ( ) ; Attachment currentAttachment = null ; while ( ! JsonToken . END_ARRAY . equals ( parser . nextToken ( ) ) ) { String fieldName = parser . getCurrentName ( ) ; JsonToken token = parser . getCurrentToken ( ) ; if ( JsonToken . START_OBJECT . equals ( token ) ) { currentAttachment = new Attachment ( ) ; } else if ( JsonToken . END_OBJECT . equals ( token ) ) { /* * Issue 4 all attachment points have to be fully defined for * any new monomer */ if ( AttachmentLoader . validateAttachment ( currentAttachment ) ) { currentAttachment . setCapGroupSMILES ( attachmentDB . get ( currentAttachment . getAlternateId ( ) ) . getCapGroupSMILES ( ) ) ; attachments . add ( currentAttachment ) ; } } if ( fieldName != null ) { switch ( fieldName ) { case "id" : parser . nextToken ( ) ; if ( parser . getText ( ) != null ) { currentAttachment . setId ( Integer . parseInt ( parser . getText ( ) ) ) ; } break ; case "alternateId" : parser . nextToken ( ) ; currentAttachment . setAlternateId ( parser . getText ( ) ) ; break ; case "label" : parser . nextToken ( ) ; currentAttachment . setLabel ( parser . getText ( ) ) ; break ; case "capGroupName" : parser . nextToken ( ) ; currentAttachment . setCapGroupName ( parser . getText ( ) ) ; break ; case "capGroupSMILES" : parser . nextToken ( ) ; currentAttachment . setCapGroupSMILES ( parser . getText ( ) ) ; break ; default : break ; } } } return attachments ; } | Private routine to deserialize a JSON containing attachment data . This is done manually to give more freedom regarding data returned by the webservice . | 446 | 29 |
141,479 | private static List < CategorizedMonomer > deserializeEditorCategorizationConfig ( JsonParser parser ) throws JsonParseException , IOException { List < CategorizedMonomer > config = new LinkedList < CategorizedMonomer > ( ) ; CategorizedMonomer currentMonomer = null ; parser . nextToken ( ) ; while ( parser . hasCurrentToken ( ) ) { String fieldName = parser . getCurrentName ( ) ; JsonToken token = parser . getCurrentToken ( ) ; if ( JsonToken . START_OBJECT . equals ( token ) ) { currentMonomer = new CategorizedMonomer ( ) ; } else if ( JsonToken . END_OBJECT . equals ( token ) ) { config . add ( currentMonomer ) ; } if ( fieldName != null ) { switch ( fieldName ) { // id is first field case "monomerID" : parser . nextToken ( ) ; currentMonomer . setMonomerID ( parser . getText ( ) ) ; break ; case "monomerName" : parser . nextToken ( ) ; currentMonomer . setMonomerName ( parser . getText ( ) ) ; break ; case "naturalAnalogon" : parser . nextToken ( ) ; currentMonomer . setNaturalAnalogon ( parser . getText ( ) ) ; break ; case "monomerType" : parser . nextToken ( ) ; currentMonomer . setMonomerType ( parser . getText ( ) ) ; break ; case "polymerType" : parser . nextToken ( ) ; currentMonomer . setPolymerType ( parser . getText ( ) ) ; break ; case "category" : parser . nextToken ( ) ; currentMonomer . setCategory ( parser . getText ( ) ) ; break ; case "shape" : parser . nextToken ( ) ; currentMonomer . setShape ( parser . getText ( ) ) ; break ; case "fontColor" : parser . nextToken ( ) ; currentMonomer . setFontColor ( parser . getText ( ) ) ; break ; case "backgroundColor" : parser . nextToken ( ) ; currentMonomer . setBackgroundColor ( parser . getText ( ) ) ; break ; default : break ; } } parser . nextToken ( ) ; } return config ; } | Private routine to deserialize JSON containing monomer categorization data . This is done manually to give more freedom regarding data returned by the webservice . | 515 | 31 |
141,480 | public static Attachment getAttachment ( Element attachment ) { Namespace ns = attachment . getNamespace ( ) ; Attachment att = new Attachment ( ) ; att . setAlternateId ( attachment . getChildText ( ATTACHEMENT_ID_ELEMENT , ns ) ) ; att . setLabel ( attachment . getChildText ( ATTACHEMENT_LABEL_ELEMENT , ns ) ) ; att . setCapGroupName ( attachment . getChildText ( CAP_GROUP_NAME_ELEMENT , ns ) ) ; att . setCapGroupSMILES ( attachment . getChildText ( CAP_GROUP_SMILES_ELEMENT , ns ) ) ; return att ; } | Convert ATTACHMENT element to Attachment object | 149 | 10 |
141,481 | public static Element getAttachementElement ( Attachment att ) { Element attachment = new Element ( ATTACHEMENT_ELEMENT ) ; if ( null != att . getAlternateId ( ) && att . getAlternateId ( ) . length ( ) > 0 ) { Element e = new Element ( ATTACHEMENT_ID_ELEMENT ) ; e . setText ( att . getAlternateId ( ) ) ; attachment . getChildren ( ) . add ( e ) ; } if ( null != att . getLabel ( ) && att . getLabel ( ) . length ( ) > 0 ) { Element e = new Element ( ATTACHEMENT_LABEL_ELEMENT ) ; e . setText ( att . getLabel ( ) ) ; attachment . getChildren ( ) . add ( e ) ; } if ( null != att . getCapGroupName ( ) && att . getCapGroupName ( ) . length ( ) > 0 ) { Element e = new Element ( CAP_GROUP_NAME_ELEMENT ) ; e . setText ( att . getCapGroupName ( ) ) ; attachment . getChildren ( ) . add ( e ) ; } if ( null != att . getCapGroupSMILES ( ) && att . getCapGroupSMILES ( ) . length ( ) > 0 ) { Element e = new Element ( CAP_GROUP_SMILES_ELEMENT ) ; e . setText ( att . getCapGroupSMILES ( ) ) ; attachment . getChildren ( ) . add ( e ) ; } return attachment ; } | This method converts Attachment to ATTACHMENT XML element | 332 | 11 |
141,482 | public static boolean validateAttachement ( Attachment attachment ) throws MonomerException , IOException , ChemistryException { String alternateId = attachment . getAlternateId ( ) ; if ( null == alternateId ) { throw new MonomerException ( "Attachment must have unique ID" ) ; } String smiles = attachment . getCapGroupSMILES ( ) ; if ( null != smiles ) { if ( ! Chemistry . getInstance ( ) . getManipulator ( ) . validateSMILES ( smiles ) ) { throw new MonomerException ( "Attachment cap group SMILES is invalid" ) ; } List < String > labels = getAttachmentLabels ( smiles ) ; if ( null == labels || labels . size ( ) != 1 ) { throw new MonomerException ( "Attachment must have one R group in SMILES" ) ; } if ( ! ( labels . get ( 0 ) . equals ( attachment . getLabel ( ) ) ) ) { throw new MonomerException ( "R group in monomer SMILES and R group label must match" ) ; } } return true ; } | This method validates Attachment by the following rules Attachment must have unique ID cap group SMILES must be valid cap group SMILES must contain one R group R group in SMILES must match R group label | 233 | 45 |
141,483 | public static Monomer getMonomer ( Element monomer ) throws MonomerException { Monomer m = new Monomer ( ) ; Namespace ns = monomer . getNamespace ( ) ; m . setAlternateId ( monomer . getChildText ( MONOMER_ID_ELEMENT , ns ) ) ; m . setCanSMILES ( monomer . getChildText ( MONOMER_SMILES_ELEMENT , ns ) ) ; String encodedMolfile = monomer . getChildText ( MONOMER_MOL_FILE_ELEMENT , ns ) ; String molfile = null ; try { molfile = MolfileEncoder . decode ( encodedMolfile ) ; } catch ( EncoderException ex ) { throw new MonomerException ( "Invalid monomer molfile" ) ; } m . setMolfile ( molfile ) ; m . setMonomerType ( monomer . getChildText ( MONOMER_TYPE_ELEMENT , ns ) ) ; m . setPolymerType ( monomer . getChildText ( POLYMER_TYPE_ELEMENT , ns ) ) ; m . setNaturalAnalog ( monomer . getChildText ( NATURAL_ANALOG_ELEMENT , ns ) ) ; m . setName ( monomer . getChildText ( MONOMER_NAME_ELEMENT , ns ) ) ; Element attachmentElement = monomer . getChild ( ATTACHEMENTS_ELEMENT , ns ) ; if ( null != attachmentElement ) { List attachments = attachmentElement . getChildren ( ATTACHEMENT_ELEMENT , ns ) ; List < Attachment > l = new ArrayList < Attachment > ( ) ; Iterator i = attachments . iterator ( ) ; while ( i . hasNext ( ) ) { Element attachment = ( Element ) i . next ( ) ; Attachment att = getAttachment ( attachment ) ; l . add ( att ) ; } m . setAttachmentList ( l ) ; } return m ; } | Convert monomer element to Monomer object | 440 | 9 |
141,484 | public static Element getMonomerElement ( Monomer monomer ) throws MonomerException { Element element = new Element ( MONOMER_ELEMENT ) ; if ( null != monomer . getAlternateId ( ) ) { Element e = new Element ( MONOMER_ID_ELEMENT ) ; e . setText ( monomer . getAlternateId ( ) ) ; element . getChildren ( ) . add ( e ) ; } if ( null != monomer . getCanSMILES ( ) ) { Element e = new Element ( MONOMER_SMILES_ELEMENT ) ; e . setText ( monomer . getCanSMILES ( ) ) ; element . getChildren ( ) . add ( e ) ; } if ( null != monomer . getMolfile ( ) ) { Element e = new Element ( MONOMER_MOL_FILE_ELEMENT ) ; String encodedMolfile = null ; try { encodedMolfile = MolfileEncoder . encode ( monomer . getMolfile ( ) ) ; } catch ( EncoderException ex ) { throw new MonomerException ( "Invalid monomer molfile" ) ; } // CDATA cdata = new CDATA(monomer.getMolfile()); // e.setContent(cdata); e . setText ( encodedMolfile ) ; element . getChildren ( ) . add ( e ) ; } if ( null != monomer . getMonomerType ( ) ) { Element e = new Element ( MONOMER_TYPE_ELEMENT ) ; e . setText ( monomer . getMonomerType ( ) ) ; element . getChildren ( ) . add ( e ) ; } if ( null != monomer . getPolymerType ( ) ) { Element e = new Element ( POLYMER_TYPE_ELEMENT ) ; e . setText ( monomer . getPolymerType ( ) ) ; element . getChildren ( ) . add ( e ) ; } if ( null != monomer . getNaturalAnalog ( ) ) { Element e = new Element ( NATURAL_ANALOG_ELEMENT ) ; e . setText ( monomer . getNaturalAnalog ( ) ) ; element . getChildren ( ) . add ( e ) ; } if ( null != monomer . getName ( ) ) { Element e = new Element ( MONOMER_NAME_ELEMENT ) ; e . setText ( monomer . getName ( ) ) ; element . getChildren ( ) . add ( e ) ; } List < Attachment > l = monomer . getAttachmentList ( ) ; if ( null != l && l . size ( ) > 0 ) { Element attachments = new Element ( ATTACHEMENTS_ELEMENT ) ; for ( int i = 0 ; i < l . size ( ) ; i ++ ) { Attachment att = l . get ( i ) ; Element attachment = getAttachementElement ( att ) ; attachments . getChildren ( ) . add ( attachment ) ; } element . getChildren ( ) . add ( attachments ) ; } return element ; } | This method converts Monomer to MONOMER XML element | 670 | 11 |
141,485 | private static boolean areAttachmentLabelsUnique ( List < String > labels ) { Map < String , String > map = new TreeMap < String , String > ( String . CASE_INSENSITIVE_ORDER ) ; for ( int i = 0 ; i < labels . size ( ) ; i ++ ) { map . put ( labels . get ( i ) , labels . get ( i ) ) ; } if ( labels . size ( ) == map . size ( ) ) { return true ; } else { return false ; } } | This method checks if strings in a list are unique | 112 | 10 |
141,486 | public Attachment getAttachment ( String label ) { for ( Attachment attachment : attachmentList ) { if ( attachment . getLabel ( ) . equalsIgnoreCase ( label ) ) { return attachment ; } } return null ; } | get a specific attachment by passing in a label | 48 | 9 |
141,487 | public MoleculeProperty getCapMoleculeInfo ( String label ) throws CTKException , ChemistryException , IOException { for ( Attachment attachment : attachmentList ) { if ( attachment . getLabel ( ) . equalsIgnoreCase ( label ) ) { String capSmi = attachment . getCapGroupSMILES ( ) ; org . helm . chemtoolkit . MoleculeInfo info = Chemistry . getInstance ( ) . getManipulator ( ) . getMoleculeInfo ( Chemistry . getInstance ( ) . getManipulator ( ) . getMolecule ( capSmi , null ) ) ; MoleculeProperty moleculeinfo = new MoleculeProperty ( ) ; moleculeinfo . setExactMass ( info . getExactMass ( ) ) ; moleculeinfo . setMolecularFormula ( info . getMolecularFormula ( ) ) ; moleculeinfo . setMolecularWeight ( info . getMolecularWeight ( ) ) ; return moleculeinfo ; } } return null ; } | This method returns the MoleculeInfo for the input R group label of this monomer | 212 | 17 |
141,488 | public boolean addAttachment ( Attachment attachment ) { boolean isExist = false ; for ( Attachment a : attachmentList ) { if ( a . getLabel ( ) . equalsIgnoreCase ( attachment . getLabel ( ) ) ) { isExist = true ; } } if ( ! isExist ) { return attachmentList . add ( attachment ) ; } return false ; } | Try to add a new attachment to this monomer | 81 | 10 |
141,489 | public static JKCacheManager getCacheManager ( ) { if ( JKCacheFactory . defaultCacheManager == null ) { logger . debug ( "init cacheManager" ) ; defaultCacheManager = new JKDefaultCacheManager ( ) ; } return JKCacheFactory . defaultCacheManager ; } | Gets the default cache manager . | 62 | 7 |
141,490 | public JKTableColumn getTableColumn ( final int col , final boolean visibleIndex ) { int actualIndex ; if ( visibleIndex ) { actualIndex = this . visibilityManager . getActualIndexFromVisibleIndex ( col ) ; } else { actualIndex = col ; } return this . tableColumns . get ( actualIndex ) ; } | return NULL of col is out of bound . | 72 | 9 |
141,491 | public int getValueAtAsInteger ( final int row , final int col ) { final Object valueAt = getValueAt ( row , col ) ; int number = 0 ; if ( valueAt != null && ! valueAt . toString ( ) . equals ( "" ) ) { number = Integer . parseInt ( valueAt . toString ( ) . trim ( ) ) ; } return number ; } | Gets the value at as integer . | 83 | 8 |
141,492 | public boolean isEditable ( final int row , final int column ) { if ( isEditable ( column ) ) { final int actualIndex = getTableColumn ( column ) . getIndex ( ) ; final JKTableRecord record = getRecord ( row ) ; return record . isColumnEnabled ( actualIndex ) ; } return false ; } | Checks if is editable . | 71 | 7 |
141,493 | public void setEditable ( final int row , final int col , final boolean enable ) { final int actualIndex = getTableColumn ( col ) . getIndex ( ) ; getRecord ( row ) . setColumnEnabled ( actualIndex , enable ) ; } | Sets the editable . | 53 | 6 |
141,494 | public void addJKTableColumn ( String keyLabel ) { JKTableColumn col = new JKTableColumn ( ) ; col . setName ( keyLabel ) ; addJKTableColumn ( col ) ; } | Adds the JK table column . | 46 | 7 |
141,495 | public void insertConstructor ( InsertableConstructor insertableConstructor ) throws CannotCompileException , AfterBurnerImpossibleException , NotFoundException { // create or complete onViewCreated List < CtConstructor > constructorList = extractExistingConstructors ( insertableConstructor ) ; log . info ( "constructor : " + constructorList . toString ( ) ) ; if ( ! constructorList . isEmpty ( ) ) { for ( CtConstructor constructor : constructorList ) { constructor . insertBeforeBody ( insertableConstructor . getConstructorBody ( constructor . getParameterTypes ( ) ) ) ; } } else { throw new AfterBurnerImpossibleException ( "No suitable constructor was found in class " + insertableConstructor . getClassToInsertInto ( ) . getName ( ) + ". Add a constructor that is accepted by the InsertableConstructor. Don't use non static inner classes." ) ; } } | Inserts java instructions into all constructors a given class . | 196 | 12 |
141,496 | protected ValidationResult getCachedResult ( String certFingerprint ) { CachedValidationResult cvr = validationResultsCache . get ( certFingerprint ) ; if ( cvr == null ) return null ; if ( ! cachedValidationResultHasExpired ( cvr , System . currentTimeMillis ( ) ) ) { return cvr . getResult ( ) ; } validationResultsCache . remove ( certFingerprint , cvr ) ; return null ; } | Gets a validation result from the memory cache | 100 | 9 |
141,497 | public ValidationResult validate ( X509Certificate [ ] certChain ) { certChainSanityChecks ( certChain ) ; String certFingerprint = null ; try { certFingerprint = FingerprintHelper . getFingerprint ( certChain [ certChain . length - 1 ] ) ; } catch ( Throwable t ) { String errorMsg = String . format ( "Error computing fingerprint for " + "certificate: %s. Cause: %s" , CertificateUtils . format ( certChain [ 0 ] , FormatMode . COMPACT_ONE_LINE ) , t . getMessage ( ) ) ; throw new VOMSError ( errorMsg , t ) ; } ValidationResult res = getCachedResult ( certFingerprint ) ; if ( res == null ) { res = validator . validate ( certChain ) ; validationResultsCache . putIfAbsent ( certFingerprint , new CachedValidationResult ( certFingerprint , res ) ) ; } return res ; } | Validates a certificate chain using the wrapped validator caching the result for future validation calls . | 214 | 18 |
141,498 | public int minChannel ( ) { int c = 0 ; if ( getValue ( c ) > getValue ( 1 ) ) c = 1 ; if ( getValue ( c ) > getValue ( 2 ) ) c = 2 ; return c ; } | Returns the channel index with minimum value . Alpha is not considered . | 52 | 13 |
141,499 | public int maxChannel ( ) { int c = 0 ; if ( getValue ( c ) < getValue ( 1 ) ) c = 1 ; if ( getValue ( c ) < getValue ( 2 ) ) c = 2 ; return c ; } | Returns the channel index with maximum value . Alpha is not considered . | 52 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.