idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
17,400 | public static void uploadFile ( Session session , String localFile , String remoteFile ) throws Exception { boolean ptimestamp = true ; String command = "scp " + ( ptimestamp ? "-p" : "" ) + " -t " + remoteFile ; Channel channel = session . openChannel ( "exec" ) ; ( ( ChannelExec ) channel ) . setCommand ( command ) ;... | Upload a file to the remote host via scp . |
17,401 | public int readObjectHeaderV15 ( int [ ] data , int offset ) throws Exception { int bitPos = offset ; Integer mode = ( Integer ) DwgUtil . getBits ( data , 2 , bitPos ) ; bitPos = bitPos + 2 ; setMode ( mode . intValue ( ) ) ; Vector v = DwgUtil . getBitLong ( data , bitPos ) ; bitPos = ( ( Integer ) v . get ( 0 ) ) . ... | Reads the header of an object in a DWG file Version 15 |
17,402 | public List validateSLD ( InputSource xml ) { URL schemaURL = SLDValidator . class . getResource ( "/schemas/sld/StyledLayerDescriptor.xsd" ) ; return ResponseUtils . validate ( xml , schemaURL , false , entityResolver ) ; } | validate a . sld against the schema |
17,403 | public static void pipeMagnitude ( double [ ] magnitude , double [ ] whereDrain , IHMProgressMonitor pm ) { int count = 0 ; int length = magnitude . length ; for ( int i = 0 ; i < length ; i ++ ) { count = 0 ; magnitude [ i ] ++ ; int k = i ; while ( whereDrain [ k ] != Constants . OUT_INDEX_PIPE && count < length ) { ... | Calculate the magnitudo of the several drainage area . |
17,404 | public static boolean verifyProjectType ( SimpleFeatureType schema , IHMProgressMonitor pm ) { String searchedField = PipesTrentoP . ID . getAttributeName ( ) ; verifyFeatureKey ( findAttributeName ( schema , searchedField ) , searchedField , pm ) ; searchedField = PipesTrentoP . DRAIN_AREA . getAttributeName ( ) ; ver... | Verify the schema . |
17,405 | private static void verifyFeatureKey ( String key , String searchedField , IHMProgressMonitor pm ) { if ( key == null ) { if ( pm != null ) { pm . errorMessage ( msg . message ( "trentoP.error.featureKey" ) + searchedField ) ; } throw new IllegalArgumentException ( msg . message ( "trentoP.error.featureKey" ) + searche... | Verify if there is a key of a FeatureCollections . |
17,406 | public static ValidationMessage < Origin > message ( LineReader lineReader , Severity severity , String messageKey , Object ... params ) { return message ( lineReader . getCurrentLineNumber ( ) , severity , messageKey , params ) ; } | Creates a validation message . |
17,407 | public static void setCDSTranslationReport ( ExtendedResult < CdsFeatureTranslationCheck . TranslationReportInfo > cdsCheckResult ) { try { CdsFeatureTranslationCheck . TranslationReportInfo translationInfo = cdsCheckResult . getExtension ( ) ; StringWriter translationReportWriter = new StringWriter ( ) ; TranslationRe... | Takes all the messages in a CdsFeatureTranslationCheck ExtendedResult ValidationResult object and writes a report for the CDS translation . Uses extra information from the ExtendedResult . Have put this here as it uses Writers from the FF package and the embl - api - core package does not have access to these . |
17,408 | public void writeTemplateSpreadsheetDownloadFile ( List < TemplateTokenInfo > tokenNames , TemplateVariablesSet variablesSet , String filePath ) throws TemplateException { prepareWriter ( filePath ) ; writeDownloadSpreadsheetHeader ( tokenNames ) ; for ( int i = 1 ; i < variablesSet . getEntryCount ( ) + 1 ; i ++ ) { T... | Writes the download file for variables for spreadsheet import |
17,409 | public void writeLargeTemplateSpreadsheetDownloadFile ( List < TemplateTokenInfo > tokenNames , int entryCount , TemplateVariables constants , String filePath ) throws TemplateException { prepareWriter ( filePath ) ; writeDownloadSpreadsheetHeader ( tokenNames ) ; for ( int i = 1 ; i < entryCount + 1 ; i ++ ) { writeSp... | Used to write spreadsheets where entry number exceeds the MEGABULK size . Does not use the variables map stored in the database just writes constants . |
17,410 | public void writeDownloadSpreadsheetHeader ( List < TemplateTokenInfo > variableTokenNames ) { StringBuilder headerBuilder = new StringBuilder ( ) ; headerBuilder . append ( UPLOAD_COMMENTS ) ; headerBuilder . append ( "\n" ) ; for ( TemplateTokenInfo tokenInfo : variableTokenNames ) { if ( tokenInfo . getName ( ) . eq... | writes the header for the example download spreadsheet |
17,411 | public void process ( ) throws Exception { if ( ! concatOr ( outTca == null , doReset ) ) { return ; } checkNull ( inPit , inFlow ) ; HashMap < String , Double > regionMap = CoverageUtilities . getRegionParamsFromGridCoverage ( inPit ) ; cols = regionMap . get ( CoverageUtilities . COLS ) . intValue ( ) ; rows = region... | Calculates total contributing areas |
17,412 | public void readDwgSeqendV15 ( int [ ] data , int offset ) throws Exception { int bitPos = offset ; bitPos = readObjectHeaderV15 ( data , bitPos ) ; bitPos = readObjectTailV15 ( data , bitPos ) ; } | Read a Seqend in the DWG format Version 15 |
17,413 | public boolean isDownStreamOf ( PfafstetterNumber pfafstetterNumber ) { int lastDot = pfafstetterNumberString . lastIndexOf ( '.' ) ; String pre = pfafstetterNumberString . substring ( 0 , lastDot + 1 ) ; String lastNum = pfafstetterNumberString . substring ( lastDot + 1 , pfafstetterNumberString . length ( ) ) ; int l... | Checks if the actual pfafstetter object is downstream or not of the passed argument |
17,414 | public synchronized static boolean areConnectedUpstream ( PfafstetterNumber p1 , PfafstetterNumber p2 ) { List < Integer > p1OrdersList = p1 . getOrdersList ( ) ; List < Integer > p2OrdersList = p2 . getOrdersList ( ) ; int levelDiff = p1OrdersList . size ( ) - p2OrdersList . size ( ) ; if ( levelDiff == 0 ) { if ( p1 ... | Checks if two pfafstetter are connected upstream i . e . p1 is more downstream than p2 |
17,415 | private Number setFeatureField ( SimpleFeature pipe , String key ) { Number field = ( ( Number ) pipe . getAttribute ( key ) ) ; if ( field == null ) { pm . errorMessage ( msg . message ( "trentoP.error.number" ) + key ) ; throw new IllegalArgumentException ( msg . message ( "trentoP.error.number" ) + key ) ; } return ... | Check if there is the field in a SimpleFeature and if it s a Number . |
17,416 | public void designPipe ( double [ ] [ ] diameters , double tau , double g , double maxd , double c , StringBuilder strWarnings ) { switch ( this . pipeSectionType ) { case 1 : designCircularPipe ( diameters , tau , g , maxd , strWarnings ) ; break ; case 2 : designRectangularPipe ( tau , g , maxd , c , strWarnings ) ; ... | Calculate the dimension of the pipes . |
17,417 | private void designCircularPipe ( double [ ] [ ] diameters , double tau , double g , double maxd , StringBuilder strWarnings ) { double newtheta ; double naturalslope ; double D ; double [ ] dD = new double [ 1 ] ; double ms ; newtheta = getDiameter ( diameters , tau , g , dD , maxd , strWarnings ) ; naturalslope = MET... | Dimensiona la tubazione . |
17,418 | private double getDiameter ( double [ ] [ ] diameters , double tau , double g , double [ ] dD , double maxd , StringBuilder strWarnings ) { double B ; double thta ; double oldD ; double D = 0 ; double known ; double newtheta ; double newrh ; B = ( discharge * sqrt ( WSPECIFICWEIGHT / tau ) ) / ( CUBICMETER2LITER * getK... | Dimensiona il tubo imponendo uno sforzo tangenziale al fondo . |
17,419 | private void designTrapeziumPipe ( double tau , double g , double maxd , double c , StringBuilder strWarnings ) { double base ; double naturalSlope ; double D ; double ms ; base = getHeight2 ( tau , g , maxd , c ) ; ms = getMinimumPipeSlope ( ) ; naturalSlope = METER2CM * ( initialElevation - finalElevation ) / lenght ... | Chiama altre subroutine per dimensionare una sezione di tipo 3 ossia trapezioidale . |
17,420 | public double verifyEmptyDegree ( StringBuilder strWarnings , double q ) { double B ; double thta ; double known ; double newtheta = 0 ; B = ( q * sqrt ( WSPECIFICWEIGHT / 2.8 ) ) / ( CUBICMETER2LITER * getKs ( ) ) ; thta = 2 * acos ( 1 - 2 * 0.8 ) ; known = ( B * TWO_TENOVERTHREE ) / pow ( diameterToVerify / METER2CM ... | Verify if the empty degree is greather than the 0 . 8 . |
17,421 | public static void addGpsLogDataPoint ( Connection connection , OmsGeopaparazziProject3To4Converter . GpsPoint point , long gpslogId ) throws Exception { Date timestamp = ETimeUtilities . INSTANCE . TIME_FORMATTER_LOCAL . parse ( point . utctime ) ; String insertSQL = "INSERT INTO " + TableDescriptions . TABLE_GPSLOG_D... | Adds a new XY entry to the gps table . |
17,422 | public static List < GpsLog > getLogsList ( IHMConnection connection ) throws Exception { List < GpsLog > logsList = new ArrayList < > ( ) ; String sql = "select " + GpsLogsTableFields . COLUMN_ID . getFieldName ( ) + "," + GpsLogsTableFields . COLUMN_LOG_STARTTS . getFieldName ( ) + "," + GpsLogsTableFields . COLUMN_L... | Get the list of available logs . |
17,423 | public static void collectDataForLog ( IHMConnection connection , GpsLog log ) throws Exception { long logId = log . id ; String query = "select " + GpsLogsDataTableFields . COLUMN_DATA_LAT . getFieldName ( ) + "," + GpsLogsDataTableFields . COLUMN_DATA_LON . getFieldName ( ) + "," + GpsLogsDataTableFields . COLUMN_DAT... | Gather gps points data for a supplied log . |
17,424 | public static SshTunnelHandler openTunnel ( String remoteHost , String remoteSshUser , String remoteSshPwd , int localPort , int remotePort ) throws JSchException { int port = 22 ; JSch jsch = new JSch ( ) ; Session tunnelingSession = jsch . getSession ( remoteSshUser , remoteHost , port ) ; tunnelingSession . setPassw... | Open a tunnel to the remote host . |
17,425 | public static Vector getRawLong ( int [ ] data , int offset ) { Vector v = new Vector ( ) ; int val = 0 ; v . add ( new Integer ( offset + 32 ) ) ; v . add ( new Integer ( val ) ) ; return v ; } | Read a long value from a group of unsigned bytes |
17,426 | public static Vector getTextString ( int [ ] data , int offset ) throws Exception { int bitPos = offset ; int newBitPos = ( ( Integer ) DwgUtil . getBitShort ( data , bitPos ) . get ( 0 ) ) . intValue ( ) ; int len = ( ( Integer ) DwgUtil . getBitShort ( data , bitPos ) . get ( 1 ) ) . intValue ( ) ; bitPos = newBitPos... | Read a String from a group of unsigned bytes |
17,427 | public Iterator < Compound > toRootOrder ( final Compound c ) { return new Iterator < Compound > ( ) { Compound curr ; TreeNode n = node ( c ) ; Compound parent = c ; public boolean hasNext ( ) { return ! n . isRoot ( ) ; } public Compound next ( ) { if ( hasNext ( ) ) { curr = parent ; parent = n . parent ; n = node (... | Returns all compounds from the Compound argument to the root of the tree following the path . |
17,428 | public void println ( String value ) { print ( value ) ; out . println ( ) ; out . flush ( ) ; newLine = true ; } | Print the string as the last value on the line . The value will be quoted if needed . |
17,429 | public void println ( String [ ] values ) { for ( int i = 0 ; i < values . length ; i ++ ) { print ( values [ i ] ) ; } out . println ( ) ; out . flush ( ) ; newLine = true ; } | Print a single line of comma separated values . The values will be quoted if needed . Quotes and newLine characters will be escaped . |
17,430 | public void printlnComment ( String comment ) { if ( this . strategy . isCommentingDisabled ( ) ) { return ; } if ( ! newLine ) { out . println ( ) ; } out . print ( this . strategy . getCommentStart ( ) ) ; out . print ( ' ' ) ; for ( int i = 0 ; i < comment . length ( ) ; i ++ ) { char c = comment . charAt ( i ) ; sw... | Put a comment among the comma separated values . Comments will always begin on a new line and occupy a least one full line . The character specified to star comments and a space will be inserted at the beginning of each new line in the comment . |
17,431 | public void print ( String value ) { boolean quote = false ; if ( value . length ( ) > 0 ) { char c = value . charAt ( 0 ) ; if ( newLine && ( c < '0' || ( c > '9' && c < 'A' ) || ( c > 'Z' && c < 'a' ) || ( c > 'z' ) ) ) { quote = true ; } if ( c == ' ' || c == '\f' || c == '\t' ) { quote = true ; } for ( int i = 0 ; ... | Print the string as the next value on the line . The value will be quoted if needed . |
17,432 | private String escapeAndQuote ( String value ) { int count = 2 ; for ( int i = 0 ; i < value . length ( ) ; i ++ ) { switch ( value . charAt ( i ) ) { case '\"' : case '\n' : case '\r' : case '\\' : count ++ ; break ; default : break ; } } StringBuffer sb = new StringBuffer ( value . length ( ) + count ) ; sb . append ... | Enclose the value in quotes and escape the quote and comma characters that are inside . |
17,433 | public static double calculateSlope ( GridNode node , double flowValue ) { double value = doubleNovalue ; if ( ! isNovalue ( flowValue ) ) { int flowDir = ( int ) flowValue ; if ( flowDir != 10 ) { Direction direction = Direction . forFlow ( flowDir ) ; double distance = direction . getDistance ( node . xRes , node . y... | Calculates the slope of a given flowdirection value in currentCol and currentRow . |
17,434 | public static String [ ] getAvailablePortNames ( ) { SerialPort [ ] ports = SerialPort . getCommPorts ( ) ; String [ ] portNames = new String [ ports . length ] ; for ( int i = 0 ; i < portNames . length ; i ++ ) { String systemPortName = ports [ i ] . getSystemPortName ( ) ; portNames [ i ] = systemPortName ; } return... | Getter for the available serial ports . |
17,435 | public static boolean isThisAGpsPort ( String port ) throws Exception { SerialPort comPort = SerialPort . getCommPort ( port ) ; comPort . openPort ( ) ; comPort . setComPortTimeouts ( SerialPort . TIMEOUT_READ_SEMI_BLOCKING , 100 , 0 ) ; int waitTries = 0 ; int parseTries = 0 ; while ( true && waitTries ++ < 10 && par... | Makes a blocking check to find out if the given port supplies GPS data . |
17,436 | public InvertibleMatrix inverse ( ) throws MatrixException { InvertibleMatrix inverse = new InvertibleMatrix ( nRows ) ; IdentityMatrix identity = new IdentityMatrix ( nRows ) ; for ( int c = 0 ; c < nCols ; ++ c ) { ColumnVector col = solve ( identity . getColumn ( c ) , true ) ; inverse . setColumn ( col , c ) ; } re... | Compute the inverse of this matrix . |
17,437 | public double determinant ( ) throws MatrixException { decompose ( ) ; double determinant = ( ( exchangeCount & 1 ) == 0 ) ? 1 : - 1 ; for ( int i = 0 ; i < nRows ; ++ i ) { int pi = permutation [ i ] ; determinant *= LU . at ( pi , i ) ; } return determinant ; } | Compute the determinant . |
17,438 | public double norm ( ) { double sum = 0 ; for ( int r = 0 ; r < nRows ; ++ r ) { for ( int c = 0 ; c < nCols ; ++ c ) { double v = values [ r ] [ c ] ; sum += v * v ; } } return ( double ) Math . sqrt ( sum ) ; } | Compute the Euclidean norm of this matrix . |
17,439 | private static boolean isleap ( double gpsTime ) { boolean isLeap = false ; double [ ] leaps = getleaps ( ) ; for ( int i = 0 ; i < leaps . length ; i += 1 ) { if ( gpsTime == leaps [ i ] ) { isLeap = true ; break ; } } return isLeap ; } | Test to see if a GPS second is a leap second |
17,440 | private static int countleaps ( double gpsTime , boolean accum_leaps ) { int i , nleaps ; double [ ] leaps = getleaps ( ) ; nleaps = 0 ; if ( accum_leaps ) { for ( i = 0 ; i < leaps . length ; i += 1 ) { if ( gpsTime + i >= leaps [ i ] ) { nleaps += 1 ; } } } else { for ( i = 0 ; i < leaps . length ; i += 1 ) { if ( gp... | Count number of leap seconds that have passed |
17,441 | private static boolean isunixtimeleap ( double unixTime ) { double gpsTime = unixTime - 315964800 ; gpsTime += countleaps ( gpsTime , true ) - 1 ; return isleap ( gpsTime ) ; } | Test to see if a unixtime second is a leap second |
17,442 | public static EGpsWeekDays gpsWeekTime2WeekDay ( double gpsWeekTime ) { int seconds = ( int ) gpsWeekTime ; EGpsWeekDays day4Seconds = EGpsWeekDays . getDay4Seconds ( seconds ) ; return day4Seconds ; } | Convert GPS Week Time to the day of the week . |
17,443 | public static String gpsWeekTime2ISO8601 ( double gpsWeekTime ) { DateTime gps2unix = gpsWeekTime2DateTime ( gpsWeekTime ) ; return gps2unix . toString ( ISO8601Formatter ) ; } | Convert GPS Time to ISO8601 time string . |
17,444 | private void updateComponents ( ) { updatingComponents = true ; Font font = getFont ( ) ; fontList . setSelectedValue ( font . getName ( ) , true ) ; sizeList . setSelectedValue ( font . getSize ( ) , true ) ; boldCheckBox . setSelected ( font . isBold ( ) ) ; italicCheckBox . setSelected ( font . isItalic ( ) ) ; if (... | Updates the font in the preview component according to the selected values . |
17,445 | public void setSelectionModel ( FontSelectionModel newModel ) { FontSelectionModel oldModel = selectionModel ; selectionModel = newModel ; oldModel . removeChangeListener ( labelUpdater ) ; newModel . addChangeListener ( labelUpdater ) ; firePropertyChange ( "selectionModel" , oldModel , newModel ) ; } | Set the model containing the selected font . |
17,446 | protected void fireChangeListeners ( ) { ChangeEvent ev = new ChangeEvent ( this ) ; Object [ ] l = listeners . getListeners ( ChangeListener . class ) ; for ( Object listener : l ) { ( ( ChangeListener ) listener ) . stateChanged ( ev ) ; } } | Fires the listeners registered with this model . |
17,447 | public void process ( ) throws Exception { if ( ! concatOr ( outPit == null , doReset ) ) { return ; } checkNull ( inElev ) ; HashMap < String , Double > regionMap = CoverageUtilities . getRegionParamsFromGridCoverage ( inElev ) ; nCols = regionMap . get ( CoverageUtilities . COLS ) . intValue ( ) ; nRows = regionMap .... | The pitfiller algorithm . |
17,448 | private void flood ( ) throws Exception { pitsStackSize = ( int ) ( nCols * nRows * 0.1 ) ; pstack = pitsStackSize ; dn = new int [ pitsStackSize ] ; currentPitRows = new int [ pitsStackSize ] ; currentPitCols = new int [ pitsStackSize ] ; ipool = new int [ pstack ] ; jpool = new int [ pstack ] ; firstCol = 0 ; firstRo... | Takes the elevation matrix and calculate a matrix with pits filled using the flooding algorithm . |
17,449 | private void addPitToStack ( int row , int col ) { currentPitsCount = currentPitsCount + 1 ; if ( currentPitsCount >= pitsStackSize ) { pitsStackSize = ( int ) ( pitsStackSize + nCols * nRows * .1 ) + 2 ; currentPitRows = realloc ( currentPitRows , pitsStackSize ) ; currentPitCols = realloc ( currentPitCols , pitsStack... | Adds a pit position to the stack . |
17,450 | private int resolveFlats ( int pitsCount ) { int stillPitsCount ; currentPitsCount = pitsCount ; do { if ( pm . isCanceled ( ) ) { return - 1 ; } pitsCount = currentPitsCount ; currentPitsCount = 0 ; for ( int ip = 1 ; ip <= pitsCount ; ip ++ ) { dn [ ip ] = 0 ; } for ( int k = 1 ; k <= 8 ; k ++ ) { for ( int pitIndex ... | Try to find a drainage direction for undefinite cell . |
17,451 | private int pool ( int row , int col , int prevNPool ) { int in ; int jn ; int npool = prevNPool ; if ( apool [ col ] [ row ] <= 0 ) { if ( dir [ col ] [ row ] != - 1 ) { apool [ col ] [ row ] = pooln ; npool = npool + 1 ; if ( npool >= pstack ) { if ( pstack < nCols * nRows ) { pstack = ( int ) ( pstack + nCols * nRow... | function to compute pool recursively and at the same time determine the minimum elevation of the edge . |
17,452 | private void setDirection ( double pitValue , int row , int col , int [ ] [ ] dir , double [ ] fact ) { dir [ col ] [ row ] = 0 ; double smax = 0.0 ; for ( int k = 1 ; k <= 8 ; k ++ ) { int cn = col + DIR_WITHFLOW_EXITING_INVERTED [ k ] [ 0 ] ; int rn = row + DIR_WITHFLOW_EXITING_INVERTED [ k ] [ 1 ] ; double pitN = pi... | Calculate the drainage direction with the D8 method . |
17,453 | private double [ ] calculateDirectionFactor ( double dx , double dy ) { double [ ] fact = new double [ 9 ] ; for ( int k = 1 ; k <= 8 ; k ++ ) { fact [ k ] = 1.0 / ( Math . sqrt ( DIR_WITHFLOW_EXITING_INVERTED [ k ] [ 0 ] * dy * DIR_WITHFLOW_EXITING_INVERTED [ k ] [ 0 ] * dy + DIR_WITHFLOW_EXITING_INVERTED [ k ] [ 1 ] ... | Calculate the drainage direction factor . |
17,454 | private boolean assignFlowDirection ( GridNode current , GridNode diagonal , GridNode node1 , GridNode node2 ) { double diagonalSlope = abs ( current . getSlopeTo ( diagonal ) ) ; if ( node1 != null ) { double tmpSlope = abs ( diagonal . getSlopeTo ( node1 ) ) ; if ( diagonalSlope < tmpSlope ) { return false ; } } if (... | Checks if the path from the current to the first node is steeper than to the others . |
17,455 | private boolean nodeOk ( GridNode node ) { return node != null && ! assignedFlowsMap . isMarked ( node . col , node . row ) ; } | Checks if the node is ok . |
17,456 | public void run ( ) throws Exception { if ( ranges == null ) { throw new ModelsIllegalargumentException ( "No ranges have been defined for the parameter space." , this ) ; } createSwarm ( ) ; double [ ] previous = null ; while ( iterationStep <= maxIterations ) { updateSwarm ( ) ; if ( printStep ( ) ) { System . out . ... | Run the particle swarm engine . |
17,457 | public static boolean parametersInRange ( double [ ] parameters , double [ ] ... ranges ) { for ( int i = 0 ; i < ranges . length ; i ++ ) { if ( ! NumericsUtilities . isBetween ( parameters [ i ] , ranges [ i ] ) ) { return false ; } } return true ; } | Checks if the parameters are in the ranges . |
17,458 | public static < T > T convert ( Object from , Class < ? extends T > to , Params arg ) { if ( from == null ) { throw new NullPointerException ( "from" ) ; } if ( to == null ) { throw new NullPointerException ( "to" ) ; } if ( from . getClass ( ) == String . class && to . isArray ( ) ) { return new ArrayConverter ( ( Str... | Convert a String value into an object of a certain type |
17,459 | @ SuppressWarnings ( "unchecked" ) private static < T > Converter < Object , T > lookupConversionService ( Class from , Class to ) { for ( ConversionProvider converter : convServices ) { Converter c = converter . getConverter ( from , to ) ; if ( c != null ) { return c ; } } return null ; } | Lookup a conversion service |
17,460 | private static Class getArrayBaseType ( Class array ) { while ( array . isArray ( ) ) { array = array . getComponentType ( ) ; } return array ; } | Get the array base type |
17,461 | private static Date parse ( String date ) { for ( int i = 0 ; i < fmt . length ; i ++ ) { try { SimpleDateFormat df = new SimpleDateFormat ( fmt [ i ] ) ; return df . parse ( date ) ; } catch ( ParseException E ) { } } throw new IllegalArgumentException ( date ) ; } | parse the date using the formats above . This is thread safe . |
17,462 | public void fixRowsAndCols ( ) { rows = ( int ) Math . round ( ( n - s ) / ns_res ) ; if ( rows < 1 ) rows = 1 ; cols = ( int ) Math . round ( ( e - w ) / we_res ) ; if ( cols < 1 ) cols = 1 ; } | calculate rows and cols from the region and its resolution . Round if required . |
17,463 | public static Point2D . Double snapToNextHigherInActiveRegionResolution ( double x , double y , Window activeWindow ) { double minx = activeWindow . getRectangle ( ) . getBounds2D ( ) . getMinX ( ) ; double ewres = activeWindow . getWEResolution ( ) ; double xsnap = minx + ( Math . ceil ( ( x - minx ) / ewres ) * ewres... | Moves the point given by X and Y to be on the grid of the active region . |
17,464 | public static Window getActiveWindowFromMapset ( String mapsetPath ) { File windFile = new File ( mapsetPath + File . separator + GrassLegacyConstans . WIND ) ; if ( ! windFile . exists ( ) ) { return null ; } return new Window ( windFile . getAbsolutePath ( ) ) ; } | Get the active region window from the mapset |
17,465 | public static void writeActiveWindowToMapset ( String mapsetPath , Window window ) throws IOException { writeWindowFile ( mapsetPath + File . separator + GrassLegacyConstans . WIND , window ) ; } | Write active region window to the mapset |
17,466 | public static void writeDefaultWindowToLocation ( String locationPath , Window window ) throws IOException { writeWindowFile ( locationPath + File . separator + GrassLegacyConstans . PERMANENT_MAPSET + File . separator + GrassLegacyConstans . DEFAULT_WIND , window ) ; } | Write default region window to the PERMANENT mapset |
17,467 | public static Window adaptActiveRegionToEnvelope ( Envelope bounds , Window activeRegion ) { Point2D eastNorth = Window . snapToNextHigherInActiveRegionResolution ( bounds . getMaxX ( ) , bounds . getMaxY ( ) , activeRegion ) ; Point2D westsouth = Window . snapToNextHigherInActiveRegionResolution ( bounds . getMinX ( )... | Takes an envelope and an active region and creates a new region to match the bounds of the envelope but the resolutions of the active region . This is important if the region has to match some feature layer . The bounds are assured to contain completely the envelope . |
17,468 | public double [ ] cceua ( double s [ ] [ ] , double sf [ ] , double bl [ ] , double bu [ ] ) { int nps = s . length ; int nopt = s [ 0 ] . length ; int n = nps ; int m = nopt ; double alpha = 1.0 ; double beta = 0.5 ; double sb [ ] = new double [ nopt ] ; double sw [ ] = new double [ nopt ] ; double fb = sf [ 0 ] ; dou... | bu upper bound |
17,469 | public static boolean deleteFileOrDirOnExit ( File filehandle ) { if ( filehandle . isDirectory ( ) ) { String [ ] children = filehandle . list ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { boolean success = deleteFileOrDir ( new File ( filehandle , children [ i ] ) ) ; if ( ! success ) { return false ; } } ... | Delete file or folder recursively on exit of the program |
17,470 | public static String readInputStreamToString ( InputStream inputStream ) { try { List < Byte > bytesList = new ArrayList < Byte > ( ) ; byte b = 0 ; while ( ( b = ( byte ) inputStream . read ( ) ) != - 1 ) { bytesList . add ( b ) ; } inputStream . close ( ) ; byte [ ] bArray = new byte [ bytesList . size ( ) ] ; for ( ... | Read from an inoutstream and convert the readed stuff to a String . Usefull for text files that are available as streams . |
17,471 | public static String hexDigest ( String algorithm , File [ ] files ) { try { MessageDigest md = MessageDigest . getInstance ( algorithm ) ; byte [ ] buf = new byte [ 4096 ] ; for ( File f : files ) { FileInputStream in = new FileInputStream ( f ) ; int nread = in . read ( buf ) ; while ( nread > 0 ) { md . update ( buf... | Creates a hex encoded sha - 256 hash of all files . |
17,472 | public static boolean hasLevel ( ASpatialDb db , int levelNum ) throws Exception { String tablename = TABLENAME + levelNum ; return db . hasTable ( tablename ) ; } | Checks if the given level table exists . |
17,473 | public static List < LasLevel > getLasLevels ( ASpatialDb db , int levelNum , Envelope envelope ) throws Exception { String tableName = TABLENAME + levelNum ; List < LasLevel > lasLevels = new ArrayList < > ( ) ; String sql = "SELECT " + COLUMN_GEOM + "," + COLUMN_ID + "," + COLUMN_SOURCE_ID + "," + COLUMN_AVG_ELEV + "... | Query the las level table . |
17,474 | public static void handle ( File srcFile , AnnotationHandler ah ) throws Exception { FileInputStream fis = new FileInputStream ( srcFile ) ; FileChannel fc = fis . getChannel ( ) ; ByteBuffer bb = fc . map ( FileChannel . MapMode . READ_ONLY , 0 , fc . size ( ) ) ; CharsetDecoder cd = Charset . forName ( "8859_1" ) . n... | Handle a file with an annotation handler . |
17,475 | public static void handle ( String s , AnnotationHandler ah ) { Map < String , Map < String , String > > l = new LinkedHashMap < String , Map < String , String > > ( ) ; Matcher m = annPattern . matcher ( s ) ; while ( m . find ( ) ) { String rest = s . substring ( m . end ( 0 ) ) . trim ( ) ; String srcLine = null ; i... | Handle a string with an annotation handler |
17,476 | public static void createPropertiesTable ( ASpatialDb database ) throws Exception { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "CREATE TABLE " ) ; sb . append ( PROPERTIESTABLE ) ; sb . append ( " (" ) ; sb . append ( ID ) ; sb . append ( " INTEGER PRIMARY KEY AUTOINCREMENT, " ) ; sb . append ( NAME ) . a... | Create the properties table . |
17,477 | public static Style createDefaultPropertiesForTable ( ASpatialDb database , String spatialTableUniqueName , String spatialTableLabelField ) throws Exception { StringBuilder sbIn = new StringBuilder ( ) ; sbIn . append ( "insert into " ) . append ( PROPERTIESTABLE ) ; sbIn . append ( " ( " ) ; sbIn . append ( NAME ) . a... | Create a default properties table for a spatial table . |
17,478 | public static void updateStyle ( ASpatialDb database , Style style ) throws Exception { StringBuilder sbIn = new StringBuilder ( ) ; sbIn . append ( "update " ) . append ( PROPERTIESTABLE ) ; sbIn . append ( " set " ) ; sbIn . append ( SIZE ) . append ( "=?," ) ; sbIn . append ( FILLCOLOR ) . append ( "=?," ) ; sbIn . ... | Update a style definition . |
17,479 | private ArrayList < ArrayList < String > > parseString ( String text ) { ArrayList < ArrayList < String > > result = new ArrayList < ArrayList < String > > ( ) ; StringTokenizer linetoken = new StringTokenizer ( text , "\n" ) ; StringTokenizer token ; String current ; while ( linetoken . hasMoreTokens ( ) ) { current =... | turns the clipboard into a list of tokens each array list is a line each string in the list is a token in the line |
17,480 | private void addContents ( String text ) { int firstColSelected = table . getSelectedColumn ( ) ; int firstRowSelected = table . getSelectedRow ( ) ; int temp = firstColSelected ; if ( firstColSelected == - 1 || firstRowSelected == - 1 ) { return ; } ArrayList < ArrayList < String > > clipboard = parseString ( text ) ;... | this adds the text to the jtable |
17,481 | public void pasteClipboard ( ) { Transferable t = Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . getContents ( null ) ; try { if ( t != null && t . isDataFlavorSupported ( DataFlavor . stringFlavor ) ) { addContents ( ( String ) t . getTransferData ( DataFlavor . stringFlavor ) ) ; table . repaint ( ) ; } }... | this is the function that adds the clipboard contents to the table |
17,482 | public String getControlType ( Object control ) { if ( control == null || ! ( control instanceof ScreenAnnotation ) ) return null ; if ( showPanControls && controlPan . equals ( control ) ) return AVKey . VIEW_PAN ; else if ( showLookControls && controlLook . equals ( control ) ) return AVKey . VIEW_LOOK ; else if ( sh... | Get the control type associated with the given object or null if unknown . |
17,483 | public void highlight ( Object control ) { if ( this . currentControl == control ) return ; if ( this . currentControl != null ) { this . currentControl . getAttributes ( ) . setImageOpacity ( - 1 ) ; this . currentControl = null ; } if ( control != null && control instanceof ScreenAnnotation ) { this . currentControl ... | Specifies the control to highlight . Any currently highlighted control is un - highlighted . |
17,484 | protected Object getImageSource ( String control ) { if ( control . equals ( AVKey . VIEW_PAN ) ) return IMAGE_PAN ; else if ( control . equals ( AVKey . VIEW_LOOK ) ) return IMAGE_LOOK ; else if ( control . equals ( AVKey . VIEW_HEADING_LEFT ) ) return IMAGE_HEADING_LEFT ; else if ( control . equals ( AVKey . VIEW_HEA... | Get a control image source . |
17,485 | protected Point computeLocation ( Rectangle viewport , Rectangle controls ) { double x ; double y ; if ( this . locationCenter != null ) { x = this . locationCenter . x - controls . width / 2 ; y = this . locationCenter . y - controls . height / 2 ; } else if ( this . position . equals ( AVKey . NORTHEAST ) ) { x = vie... | Compute the screen location of the controls overall rectangle bottom right corner according to either the location center if not null or the screen position . |
17,486 | public static ValidationMessage < Origin > error ( String messageKey , Object ... params ) { return ValidationMessage . message ( Severity . ERROR , messageKey , params ) ; } | Creates a ValidationMessage - severity ERROR |
17,487 | public static ValidationMessage < Origin > warning ( String messageKey , Object ... params ) { return ValidationMessage . message ( Severity . WARNING , messageKey , params ) ; } | Creates a ValidationMessage - severity WARNING |
17,488 | public static ValidationMessage < Origin > info ( String messageKey , Object ... params ) { return ValidationMessage . message ( Severity . INFO , messageKey , params ) ; } | Creates a ValidationMessage - severity INFO |
17,489 | public void writeMessage ( Writer writer , String targetOrigin ) throws IOException { writeMessage ( writer , messageFormatter , targetOrigin ) ; } | Writes the message with an additional target origin . |
17,490 | protected void set ( double values [ ] ) { this . nRows = values . length ; this . nCols = 1 ; this . values = new double [ nRows ] [ 1 ] ; for ( int r = 0 ; r < nRows ; ++ r ) { this . values [ r ] [ 0 ] = values [ r ] ; } } | Set this column vector from an array of values . |
17,491 | public List < String > getAttributesNames ( ) { SimpleFeatureType featureType = feature . getFeatureType ( ) ; List < AttributeDescriptor > attributeDescriptors = featureType . getAttributeDescriptors ( ) ; List < String > attributeNames = new ArrayList < String > ( ) ; for ( AttributeDescriptor attributeDescriptor : a... | Getter for the list of attribute names . |
17,492 | @ SuppressWarnings ( "unchecked" ) public < T > T getAttribute ( String attrName , Class < T > adaptee ) { if ( attrName == null ) { return null ; } if ( adaptee == null ) { adaptee = ( Class < T > ) String . class ; } Object attribute = feature . getAttribute ( attrName ) ; if ( attribute == null ) { return null ; } i... | Gets an attribute from the feature table adapting to the supplied class . |
17,493 | public boolean intersects ( Geometry geometry , boolean usePrepared ) { if ( ! getEnvelope ( ) . intersects ( geometry . getEnvelopeInternal ( ) ) ) { return false ; } if ( usePrepared ) { if ( preparedGeometry == null ) { preparedGeometry = PreparedGeometryFactory . prepare ( getGeometry ( ) ) ; } return preparedGeome... | Check for intersection . |
17,494 | public boolean covers ( Geometry geometry , boolean usePrepared ) { if ( ! getEnvelope ( ) . covers ( geometry . getEnvelopeInternal ( ) ) ) { return false ; } if ( usePrepared ) { if ( preparedGeometry == null ) { preparedGeometry = PreparedGeometryFactory . prepare ( getGeometry ( ) ) ; } return preparedGeometry . co... | Check for cover . |
17,495 | private double calcAerodynamic ( double displacement , double roughness , double Zref , double windSpeed , double snowWaterEquivalent ) { double ra = 0.0 ; double d_Lower ; double K2 ; double Z0_Lower ; double tmp_wind ; tmp_wind = windSpeed ; K2 = VON_K * VON_K ; if ( displacement > Zref ) Zref = displacement + Zref +... | Calculates the aerodynamic resistance for the vegetation layer . |
17,496 | public static LinkedHashMap < String , List < String > > getTablesSorted ( List < String > allTableNames , boolean doSort ) { LinkedHashMap < String , List < String > > tablesMap = new LinkedHashMap < > ( ) ; tablesMap . put ( USERDATA , new ArrayList < String > ( ) ) ; tablesMap . put ( STYLE , new ArrayList < String ... | Sorts all supplied table names by type . |
17,497 | public static void createTables ( Connection connection ) throws IOException , SQLException { StringBuilder sB = new StringBuilder ( ) ; sB . append ( "CREATE TABLE " ) ; sB . append ( TABLE_BOOKMARKS ) ; sB . append ( " (" ) ; sB . append ( COLUMN_ID ) ; sB . append ( " INTEGER PRIMARY KEY, " ) ; sB . append ( COLUMN_... | Create bookmarks tables . |
17,498 | public static String checkCompatibilityIssues ( String sql ) { sql = sql . replaceAll ( "LONG PRIMARY KEY AUTOINCREMENT" , "INTEGER PRIMARY KEY AUTOINCREMENT" ) ; sql = sql . replaceAll ( "AUTO_INCREMENT" , "AUTOINCREMENT" ) ; return sql ; } | Check for compatibility issues with other databases . |
17,499 | void mapOut ( String out , Object comp , String comp_out ) { if ( comp == ca . getComponent ( ) ) { throw new ComponentException ( "cannot connect 'Out' with itself for " + out ) ; } ComponentAccess ac_dest = lookup ( comp ) ; FieldAccess destAccess = ( FieldAccess ) ac_dest . output ( comp_out ) ; FieldAccess srcAcces... | Map two output fields . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.