idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
14,400 | public JsonResponse deleteBlast ( Integer blastId ) throws IOException { Blast blast = new Blast ( ) ; blast . setBlastId ( blastId ) ; return apiDelete ( blast ) ; } | Delete existing blast | 43 | 3 |
14,401 | public JsonResponse cancelBlast ( Integer blastId ) throws IOException { Blast blast = new Blast ( ) ; Date d = null ; blast . setBlastId ( blastId ) . setScheduleTime ( d ) ; return apiPost ( blast ) ; } | Cancel a scheduled Blast | 56 | 5 |
14,402 | public JsonResponse getTemplate ( String template ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Template . PARAM_TEMPLATE , template ) ; return apiGet ( ApiAction . template , data ) ; } | Get template information | 64 | 3 |
14,403 | public JsonResponse deleteTemplate ( String template ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Template . PARAM_TEMPLATE , template ) ; return apiDelete ( ApiAction . template , data ) ; } | Delete existing template | 64 | 3 |
14,404 | public JsonResponse getAlert ( String email ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Alert . PARAM_EMAIL , email ) ; return apiGet ( ApiAction . alert , data ) ; } | Retrieve a user s alert settings | 62 | 7 |
14,405 | public JsonResponse deleteAlert ( String email , String alertId ) throws IOException { Map < String , Object > data = new HashMap < String , Object > ( ) ; data . put ( Alert . PARAM_EMAIL , email ) ; data . put ( Alert . PARAM_ALERT_ID , alertId ) ; return apiDelete ( ApiAction . alert , data ) ; } | Delete existing user alert | 84 | 4 |
14,406 | public Map < String , Object > listStats ( ListStat stat ) throws IOException { return ( Map < String , Object > ) this . stats ( stat ) ; } | get list stats information | 35 | 4 |
14,407 | public Map < String , Object > blastStats ( BlastStat stat ) throws IOException { return ( Map < String , Object > ) this . stats ( stat ) ; } | get blast stats information | 35 | 4 |
14,408 | public JsonResponse getJobStatus ( String jobId ) throws IOException { Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Job . JOB_ID , jobId ) ; return apiGet ( ApiAction . job , params ) ; } | Get status of a job | 64 | 5 |
14,409 | public OSchemaHelper linkedClass ( String className ) { checkOProperty ( ) ; OClass linkedToClass = schema . getClass ( className ) ; if ( linkedToClass == null ) throw new IllegalArgumentException ( "Target OClass '" + className + "' to link to not found" ) ; if ( ! Objects . equal ( linkedToClass , lastProperty . get... | Set linked class to a current property | 109 | 7 |
14,410 | public OSchemaHelper linkedType ( OType linkedType ) { checkOProperty ( ) ; if ( ! Objects . equal ( linkedType , lastProperty . getLinkedType ( ) ) ) { lastProperty . setLinkedType ( linkedType ) ; } return this ; } | Set linked type to a current property | 59 | 7 |
14,411 | public OSchemaHelper field ( String field , Object value ) { checkODocument ( ) ; lastDocument . field ( field , value ) ; return this ; } | Sets a field value for a current document | 34 | 9 |
14,412 | public static < R > R sudo ( Function < ODatabaseDocument , R > func ) { return new DBClosure < R > ( ) { @ Override protected R execute ( ODatabaseDocument db ) { return func . apply ( db ) ; } } . execute ( ) ; } | Simplified function to execute under admin | 58 | 8 |
14,413 | public static void sudoConsumer ( Consumer < ODatabaseDocument > consumer ) { new DBClosure < Void > ( ) { @ Override protected Void execute ( ODatabaseDocument db ) { consumer . accept ( db ) ; return null ; } } . execute ( ) ; } | Simplified consumer to execute under admin | 55 | 8 |
14,414 | public static void sudoSave ( final ODocument ... docs ) { if ( docs == null || docs . length == 0 ) return ; new DBClosure < Boolean > ( ) { @ Override protected Boolean execute ( ODatabaseDocument db ) { db . begin ( ) ; for ( ODocument doc : docs ) { db . save ( doc ) ; } db . commit ( ) ; return true ; } } . execut... | Allow to save set of document under admin | 89 | 8 |
14,415 | public static void sudoSave ( final ODocumentWrapper ... dws ) { if ( dws == null || dws . length == 0 ) return ; new DBClosure < Boolean > ( ) { @ Override protected Boolean execute ( ODatabaseDocument db ) { db . begin ( ) ; for ( ODocumentWrapper dw : dws ) { dw . save ( ) ; } db . commit ( ) ; return true ; } } . e... | Allow to save set of document wrappers under admin | 96 | 10 |
14,416 | public static String buitify ( String string ) { char [ ] chars = string . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; int lastApplied = 0 ; for ( int i = 0 ; i < chars . length ; i ++ ) { char pCh = i > 0 ? chars [ i - 1 ] : 0 ; char ch = chars [ i ] ; if ( ch == ' ' || ch == ' ' || Character . isWhit... | Utility method to make source string more human readable | 406 | 10 |
14,417 | protected Object getDefaultValue ( String propName , Class < ? > returnType ) { Object ret = null ; if ( returnType . isPrimitive ( ) ) { if ( returnType . equals ( boolean . class ) ) { return false ; } else if ( returnType . equals ( char . class ) ) { return ' ' ; } else { try { Class < ? > wrapperClass = Primitives... | Method for obtaining default value of required property | 172 | 8 |
14,418 | public static boolean isAllowed ( ORule . ResourceGeneric resource , String specific , OrientPermission ... permissions ) { return OrientDbWebSession . get ( ) . getEffectiveUser ( ) . checkIfAllowed ( resource , specific , OrientPermission . combinedPermission ( permissions ) ) != null ; } | Check that all required permissions present for specified resource and specific | 64 | 11 |
14,419 | public static String getResourceSpecific ( String name ) { ORule . ResourceGeneric generic = getResourceGeneric ( name ) ; String specific = generic != null ? Strings . afterFirst ( name , ' ' ) : name ; return Strings . isEmpty ( specific ) ? null : specific ; } | Extract specific from resource string | 61 | 6 |
14,420 | public String resolveOrientDBRestApiUrl ( ) { OrientDbWebApplication app = OrientDbWebApplication . get ( ) ; OServer server = app . getServer ( ) ; if ( server != null ) { OServerNetworkListener http = server . getListenerByProtocol ( ONetworkProtocolHttpAbstract . class ) ; if ( http != null ) { return "http://" + ht... | Resolve OrientDB REST API URL to be used for OrientDb REST bridge | 100 | 15 |
14,421 | public boolean isInProgress ( RequestCycle cycle ) { Boolean inProgress = cycle . getMetaData ( IN_PROGRESS_KEY ) ; return inProgress != null ? inProgress : false ; } | Is current transaction in progress? | 43 | 6 |
14,422 | public OClass probeOClass ( int probeLimit ) { Iterator < ODocument > it = iterator ( 0 , probeLimit , null ) ; return OSchemaUtils . probeOClass ( it , probeLimit ) ; } | Probe the dataset and returns upper OClass for sample | 48 | 11 |
14,423 | public long size ( ) { if ( size == null ) { ODatabaseDocument db = OrientDbWebSession . get ( ) . getDatabase ( ) ; OSQLSynchQuery < ODocument > query = new OSQLSynchQuery < ODocument > ( queryManager . getCountSql ( ) ) ; List < ODocument > ret = db . query ( enhanceContextByVariables ( query ) , prepareParams ( ) ) ... | Get the size of the data | 158 | 6 |
14,424 | public OQueryModel < K > setSort ( String sortableParameter , SortOrder order ) { setSortableParameter ( sortableParameter ) ; setAscending ( SortOrder . ASCENDING . equals ( order ) ) ; return this ; } | Set sorting configration | 52 | 4 |
14,425 | public static String md5 ( String data ) { try { return DigestUtils . md5Hex ( data . toString ( ) . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { return DigestUtils . md5Hex ( data . toString ( ) ) ; } } | generates MD5 Hash | 71 | 5 |
14,426 | public static String arrayListToCSV ( List < String > list ) { StringBuilder csv = new StringBuilder ( ) ; for ( String str : list ) { csv . append ( str ) ; csv . append ( "," ) ; } int lastIndex = csv . length ( ) - 1 ; char last = csv . charAt ( lastIndex ) ; if ( last == ' ' ) { return csv . substring ( 0 , lastInd... | Converts String ArrayList to CSV string | 111 | 8 |
14,427 | protected Scheme getScheme ( ) { String scheme ; try { URI uri = new URI ( this . apiUrl ) ; scheme = uri . getScheme ( ) ; } catch ( URISyntaxException e ) { scheme = "http" ; } if ( scheme . equals ( "https" ) ) { return new Scheme ( scheme , DEFAULT_HTTPS_PORT , SSLSocketFactory . getSocketFactory ( ) ) ; } else { r... | Get Scheme Object | 122 | 3 |
14,428 | protected Object httpRequest ( ApiAction action , HttpRequestMethod method , Map < String , Object > data ) throws IOException { String url = this . apiUrl + "/" + action . toString ( ) . toLowerCase ( ) ; Type type = new TypeToken < Map < String , Object > > ( ) { } . getType ( ) ; String json = GSON . toJson ( data ,... | Make Http request to Sailthru API for given resource with given method and data | 145 | 17 |
14,429 | protected Object httpRequest ( HttpRequestMethod method , ApiParams apiParams ) throws IOException { ApiAction action = apiParams . getApiCall ( ) ; String url = apiUrl + "/" + action . toString ( ) . toLowerCase ( ) ; String json = GSON . toJson ( apiParams , apiParams . getType ( ) ) ; Map < String , String > params ... | Make HTTP Request to Sailthru API but with Api Params rather than generalized Map this is recommended way to make request if data structure is complex | 139 | 30 |
14,430 | private Map < String , String > buildPayload ( String jsonPayload ) { Map < String , String > params = new HashMap < String , String > ( ) ; params . put ( "api_key" , apiKey ) ; params . put ( "format" , handler . getSailthruResponseHandler ( ) . getFormat ( ) ) ; params . put ( "json" , jsonPayload ) ; params . put (... | Build HTTP Request Payload | 111 | 5 |
14,431 | protected String getSignatureHash ( Map < String , String > parameters ) { List < String > values = new ArrayList < String > ( ) ; StringBuilder data = new StringBuilder ( ) ; data . append ( this . apiSecret ) ; for ( Entry < String , String > entry : parameters . entrySet ( ) ) { values . add ( entry . getValue ( ) )... | Get Signature Hash from given Map | 124 | 6 |
14,432 | public JsonResponse apiGet ( ApiAction action , Map < String , Object > data ) throws IOException { return httpRequestJson ( action , HttpRequestMethod . GET , data ) ; } | HTTP GET Request with Map | 43 | 5 |
14,433 | public JsonResponse apiPost ( ApiAction action , Map < String , Object > data ) throws IOException { return httpRequestJson ( action , HttpRequestMethod . POST , data ) ; } | HTTP POST Request with Map | 43 | 5 |
14,434 | public JsonResponse apiPost ( ApiParams data , ApiFileParams fileParams ) throws IOException { return httpRequestJson ( HttpRequestMethod . POST , data , fileParams ) ; } | HTTP POST Request with Interface implementation of ApiParams and ApiFileParams | 47 | 17 |
14,435 | public JsonResponse apiDelete ( ApiAction action , Map < String , Object > data ) throws IOException { return httpRequestJson ( action , HttpRequestMethod . DELETE , data ) ; } | HTTP DELETE Request | 45 | 5 |
14,436 | static public int obtainNextIncrementInteger ( Connection connection , ColumnData autoIncrementIntegerColumn ) throws Exception { try { String sqlQuery = "SELECT nextval(?);" ; // Create SQL command PreparedStatement pstmt = null ; { pstmt = connection . prepareStatement ( sqlQuery ) ; // Populate prepared statement ps... | Performs a database query to find the next integer in the sequence reserved for the given column . | 252 | 19 |
14,437 | static String unescapeEntity ( String e ) { // validate if ( e == null || e . isEmpty ( ) ) { return "" ; } // if our entity is an encoded unicode point, parse it. if ( e . charAt ( 0 ) == ' ' ) { int cp ; if ( e . charAt ( 1 ) == ' ' ) { // hex encoded unicode cp = Integer . parseInt ( e . substring ( 2 ) , 16 ) ; } e... | Unescapes an XML entity encoding ; | 191 | 9 |
14,438 | private String convertLastSeqObj ( Object lastSeqObj ) throws Exception { if ( null == lastSeqObj ) { return null ; } else if ( lastSeqObj instanceof String ) { return ( String ) lastSeqObj ; } else if ( lastSeqObj instanceof Number ) { // Convert to string return "" + lastSeqObj ; } else { throw new Exception ( "Do no... | Converts the object last_seq found in the change feed to a String . In CouchDB 1 . x last_seq is an integer . In CouchDB 2 . x last_seq is a string . | 116 | 42 |
14,439 | public void renameAttachmentTo ( String newAttachmentName ) throws Exception { JSONObject doc = documentDescriptor . getJson ( ) ; JSONObject _attachments = doc . optJSONObject ( "_attachments" ) ; JSONObject nunaliit_attachments = doc . getJSONObject ( UploadConstants . KEY_DOC_ATTACHMENTS ) ; JSONObject files = nunal... | Renames an attachment . This ensures that there is no collision and that all references to this attachment are updated properly within this document . | 578 | 26 |
14,440 | static public FSEntry getPositionedFile ( String path , File file ) throws Exception { List < String > pathFrags = FSEntrySupport . interpretPath ( path ) ; // Start at leaf and work our way back int index = pathFrags . size ( ) - 1 ; FSEntry root = new FSEntryFile ( pathFrags . get ( index ) , file ) ; -- index ; whil... | Create a virtual tree hierarchy with a file supporting the leaf . | 144 | 12 |
14,441 | private String computeSelectScore ( List < String > searchFields ) throws Exception { StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; if ( 0 == searchFields . size ( ) ) { throw new Exception ( "Must supply at least one search field" ) ; } else if ( 1 == searchFields . size ( ) ) { pw... | Create a SQL fragment that can be used to compute a score based on a search . | 319 | 17 |
14,442 | private String computeWhereFragment ( List < String > searchFields ) throws Exception { StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; boolean first = true ; for ( int loop = 0 ; loop < searchFields . size ( ) ; ++ loop ) { if ( first ) { first = false ; pw . print ( " WHERE " ) ; } ... | Given a number of search fields compute the SQL fragment used to filter the searched rows | 155 | 16 |
14,443 | private JSONArray executeStatementToJson ( PreparedStatement stmt , List < SelectedColumn > selectFields ) throws Exception { //logger.info("about to execute: " + stmt.toString()); if ( stmt . execute ( ) ) { // There's a ResultSet to be had ResultSet rs = stmt . getResultSet ( ) ; JSONArray array = new JSONArray ( ) ;... | This method executes a prepared SQL statement and returns a JSON array that contains the result . | 553 | 17 |
14,444 | public JSONObject getAudioMediaFromPlaceId ( String place_id ) throws Exception { List < SelectedColumn > selectFields = new Vector < SelectedColumn > ( ) ; selectFields . add ( new SelectedColumn ( SelectedColumn . Type . INTEGER , "id" ) ) ; selectFields . add ( new SelectedColumn ( SelectedColumn . Type . INTEGER , ... | Finds and returns all audio media associated with a place id . | 280 | 13 |
14,445 | static public boolean hasDocumentBeenModified ( JSONObject targetDoc ) { JSONObject targetManifest = targetDoc . optJSONObject ( MANIFEST_KEY ) ; if ( null == targetManifest ) { // Can not verify digest on target document. Let's assume it has // been modified return true ; } String targetDigest = targetManifest . optSt... | Analyzes a document and determines if the document has been modified since the time the manifest was computed . | 735 | 20 |
14,446 | static public Integer getAttachmentPosition ( JSONObject targetDoc , String attachmentName ) { JSONObject targetAttachments = targetDoc . optJSONObject ( "_attachments" ) ; if ( null == targetAttachments ) { // No attachment on target doc return null ; } JSONObject targetAttachment = targetAttachments . optJSONObject (... | Given a JSON document and an attachment name returns the revision position associated with the attachment . | 158 | 17 |
14,447 | public static void setCompressionType ( ImageWriteParam param , BufferedImage image ) { // avoid error: first compression type is RLE, not optimal and incorrect for color images // TODO expose this choice to the user? if ( image . getType ( ) == BufferedImage . TYPE_BYTE_BINARY && image . getColorModel ( ) . getPixelSi... | Sets the ImageIO parameter compression type based on the given image . | 121 | 14 |
14,448 | static public FSEntry getPositionedResource ( String path , ClassLoader classLoader , String resourceName ) throws Exception { List < String > pathFrags = FSEntrySupport . interpretPath ( path ) ; // Start at leaf and work our way back int index = pathFrags . size ( ) - 1 ; FSEntry root = create ( pathFrags . get ( ind... | Create a virtual tree hierarchy with a resource supporting the leaf . | 149 | 12 |
14,449 | static public FSEntryResource create ( ClassLoader classLoader , String resourceName ) throws Exception { return create ( null , classLoader , resourceName ) ; } | Creates an instance of FSEntryResource to represent an entry based on the resource specified by the classLoader and resource name . | 34 | 27 |
14,450 | static public FSEntryResource create ( String name , ClassLoader classLoader , String resourceName ) throws Exception { URL url = classLoader . getResource ( resourceName ) ; if ( "jar" . equals ( url . getProtocol ( ) ) ) { String path = url . getPath ( ) ; if ( path . startsWith ( "file:" ) ) { int bangIndex = path .... | Creates an instance of FSEntryResource to represent an entry based on the resource specified by the classLoader and resource name . This resource can be a file or a directory . Furthermore this resource can be located on file system or inside a JAR file . | 433 | 53 |
14,451 | private void performAdjustCookies ( HttpServletRequest request , HttpServletResponse response ) throws Exception { boolean loggedIn = false ; User user = null ; try { Cookie cookie = getCookieFromRequest ( request ) ; if ( null != cookie ) { user = CookieAuthentication . verifyCookieString ( userRepository , cookie . g... | Adjusts the information cookie based on the authentication token | 127 | 10 |
14,452 | static public TreeRebalanceProcess . Result createTree ( List < ? extends TreeElement > elements ) throws Exception { Result results = new Result ( ) ; // Compute full interval, next cluster id and legacy nodes TimeInterval fullRegularInterval = null ; TimeInterval fullOngoingInterval = null ; results . nextClusterId =... | Creates a new cluster tree given the provided elements . If these elements were already part of a cluster then legacy cluster nodes are created to account for those elements . This is the perfect process in case the previous tree was lost . | 775 | 45 |
14,453 | synchronized public Connection getDb ( String db ) throws Exception { Connection con = null ; if ( nameToConnection . containsKey ( db ) ) { con = nameToConnection . get ( db ) ; } else { ConnectionInfo info = nameToInfo . get ( db ) ; if ( null == info ) { throw new Exception ( "No information provided for database na... | This method checks for the presence of a Connection associated with the input db parameter . It attempts to create the Connection and adds it to the connection map if it does not already exist . If the Connection exists or is created it is returned . | 249 | 47 |
14,454 | static public void captureReponseErrors ( Object response , String errorMessage ) throws Exception { if ( null == response ) { throw new Exception ( "Capturing errors from null response" ) ; } if ( false == ( response instanceof JSONObject ) ) { // Not an error return ; } JSONObject obj = ( JSONObject ) response ; if (... | Analyze a CouchDb response and raises an exception if an error was returned in the response . | 159 | 19 |
14,455 | static public File computeAtlasDir ( String name ) { File atlasDir = null ; if ( null == name ) { // Current dir atlasDir = new File ( "." ) ; } else { atlasDir = new File ( name ) ; } // Force absolute if ( false == atlasDir . isAbsolute ( ) ) { atlasDir = atlasDir . getAbsoluteFile ( ) ; } return atlasDir ; } | Computes the directory where the atlas resides given a command - line argument provided by the user . If the argument is not given then this method should be called with a null argument . | 94 | 37 |
14,456 | static public File computeInstallDir ( ) { File installDir = null ; // Try to find the path of a known resource file File knownResourceFile = null ; { URL url = Main . class . getClassLoader ( ) . getResource ( "commandResourceDummy.txt" ) ; if ( null == url ) { // Nothing we can do since the resource is not found } el... | Computes the installation directory for the command line tool . This is done by looking for a known resource in a JAR file that ships with the command - line tool . When the resource is found the location of the associated JAR file is derived . From there the root directory of the installation is deduced . If the comma... | 470 | 107 |
14,457 | static public File computeContentDir ( File installDir ) { if ( null != installDir ) { // Command-line package File contentDir = new File ( installDir , "content" ) ; if ( contentDir . exists ( ) && contentDir . isDirectory ( ) ) { return contentDir ; } // Development environment File nunaliit2Dir = computeNunaliitDir ... | Finds the content directory from the installation location and returns it . If the command - line tool is packaged and deployed then the content directory is found at the root of the installation . If the command - line tool is run from the development environment then the content directory is found in the SDK sub - pr... | 145 | 61 |
14,458 | static public File computeBinDir ( File installDir ) { if ( null != installDir ) { // Command-line package File binDir = new File ( installDir , "bin" ) ; if ( binDir . exists ( ) && binDir . isDirectory ( ) ) { return binDir ; } // Development environment File nunaliit2Dir = computeNunaliitDir ( installDir ) ; binDir ... | Finds the bin directory from the installation location and returns it . If the command - line tool is packaged and deployed then the bin directory is found at the root of the installation . If the command - line tool is run from the development environment then the bin directory is found in the SDK sub - project . | 148 | 61 |
14,459 | static public File computeSiteDesignDir ( File installDir ) { if ( null != installDir ) { // Command-line package File templatesDir = new File ( installDir , "internal/siteDesign" ) ; if ( templatesDir . exists ( ) && templatesDir . isDirectory ( ) ) { return templatesDir ; } // Development environment File nunaliit2Di... | Finds the siteDesign directory from the installation location and returns it . If the command - line tool is packaged and deployed then the siteDesign directory is found at the root of the installation . If the command - line tool is run from the development environment then the siteDesign directory is found in the SDK... | 152 | 64 |
14,460 | static public File computeNunaliitDir ( File installDir ) { while ( null != installDir ) { // The root of the nunalii2 project contains "nunaliit2-couch-command", // "nunaliit2-couch-sdk" and "nunaliit2-js" boolean commandExists = ( new File ( installDir , "nunaliit2-couch-command" ) ) . exists ( ) ; boolean sdkExists ... | Given an installation directory find the root directory for the nunaliit2 project . This makes sense only in the context that the command - line tool is run from a development environment . | 207 | 36 |
14,461 | static public Set < String > getDescendantPathNames ( File dir , boolean includeDirectories ) { Set < String > paths = new HashSet < String > ( ) ; if ( dir . exists ( ) && dir . isDirectory ( ) ) { String [ ] names = dir . list ( ) ; for ( String name : names ) { File child = new File ( dir , name ) ; getPathNames ( c... | Given a directory returns a set of strings which are the paths to all elements within the directory . This process recurses through all sub - directories . | 103 | 29 |
14,462 | static public void emptyDirectory ( File dir ) throws Exception { String [ ] fileNames = dir . list ( ) ; if ( null != fileNames ) { for ( String fileName : fileNames ) { File file = new File ( dir , fileName ) ; if ( file . isDirectory ( ) ) { emptyDirectory ( file ) ; } boolean deleted = false ; try { deleted = file ... | Given a directory removes all the content found in the directory . | 150 | 12 |
14,463 | static public MailVetterDailyNotificationTask scheduleTask ( CouchDesignDocument serverDesignDoc , MailNotification mailNotification ) { Timer timer = new Timer ( ) ; MailVetterDailyNotificationTask installedTask = new MailVetterDailyNotificationTask ( timer , serverDesignDoc , mailNotification ) ; Calendar calendar = ... | 24 hours in ms | 327 | 4 |
14,464 | public Geometry simplifyGeometryAtResolution ( Geometry geometry , double resolution ) throws Exception { double inverseRes = 1 / resolution ; double p = Math . log10 ( inverseRes ) ; double exp = Math . ceil ( p ) ; if ( exp < 0 ) exp = 0 ; double factor = Math . pow ( 10 , exp ) ; Geometry simplifiedGeometry = simpli... | Accepts a geometry and a resolution . Returns a version of the geometry which is simplified for the given resolution . If the initial geometry is already simplified enough then return null . | 94 | 34 |
14,465 | private void performQuery ( HttpServletRequest request , HttpServletResponse response ) throws Exception { User user = AuthenticationUtils . getUserFromRequest ( request ) ; String tableName = getTableNameFromRequest ( request ) ; DbTableAccess tableAccess = DbTableAccess . getAccess ( dbSecurity , tableName , new DbUs... | Perform a SQL query of a specified table that must be accessible via dbSec . | 248 | 17 |
14,466 | private void performMultiQuery ( HttpServletRequest request , HttpServletResponse response ) throws Exception { User user = AuthenticationUtils . getUserFromRequest ( request ) ; String [ ] queriesStrings = request . getParameterValues ( "queries" ) ; if ( 1 != queriesStrings . length ) { throw new Exception ( "Paramet... | Perform multiple SQL queries via dbSec . | 436 | 9 |
14,467 | private List < FieldSelector > getFieldSelectorsFromRequest ( HttpServletRequest request ) throws Exception { String [ ] fieldSelectorStrings = request . getParameterValues ( "select" ) ; if ( null == fieldSelectorStrings ) { return null ; } if ( 0 == fieldSelectorStrings . length ) { return null ; } List < FieldSelect... | Return a list of column names to be included in a select clause . | 142 | 14 |
14,468 | private List < OrderSpecifier > getOrderByList ( HttpServletRequest request ) throws Exception { String [ ] orderByStrings = request . getParameterValues ( "orderBy" ) ; if ( null == orderByStrings ) { return null ; } if ( 0 == orderByStrings . length ) { return null ; } List < OrderSpecifier > result = new Vector < Or... | Return a list of order specifiers found in request | 134 | 10 |
14,469 | public TableSchema getTableSchemaFromName ( String tableName , DbUser user ) throws Exception { List < String > tableNames = new Vector < String > ( ) ; tableNames . add ( tableName ) ; Map < String , TableSchemaImpl > nameToTableMap = getTableDataFromGroups ( user , tableNames ) ; if ( false == nameToTableMap . contai... | Computes from the database the access to a table for a given user . In this call a user is represented by the set of groups it belongs to . | 130 | 31 |
14,470 | public List < TableSchema > getAvailableTablesFromGroups ( DbUser user ) throws Exception { Map < String , TableSchemaImpl > nameToTableMap = getTableDataFromGroups ( user , null ) ; List < TableSchema > result = new Vector < TableSchema > ( ) ; result . addAll ( nameToTableMap . values ( ) ) ; return result ; } | Computes from the database the access to all tables for a given user . In this call a user is represented by the set of groups it belongs to . | 86 | 31 |
14,471 | static public List < String > breakUpCommand ( String command ) throws Exception { try { List < String > commandTokens = new Vector < String > ( ) ; StringBuilder currentToken = null ; boolean isTokenQuoted = false ; StringReader sr = new StringReader ( command ) ; int b = sr . read ( ) ; while ( b >= 0 ) { char c = ( ... | Takes a single line command as a string and breaks it up in tokens acceptable for the java . lang . ProcessBuilder . ProcessBuilder | 411 | 27 |
14,472 | private UserAndPassword executeStatementToUser ( PreparedStatement preparedStmt ) throws Exception { if ( preparedStmt . execute ( ) ) { // There's a ResultSet to be had ResultSet rs = preparedStmt . getResultSet ( ) ; ResultSetMetaData rsmd = rs . getMetaData ( ) ; int numColumns = rsmd . getColumnCount ( ) ; if ( num... | This method executes a prepared SQL statement against the user table and returns a User . | 427 | 16 |
14,473 | private void writeNumber ( PrintWriter pw , NumberFormat numFormat , Number num ) { if ( num . doubleValue ( ) == Math . round ( num . doubleValue ( ) ) ) { // Integer if ( null != numFormat ) { pw . print ( numFormat . format ( num . intValue ( ) ) ) ; } else { pw . print ( num . intValue ( ) ) ; } } else { if ( null ... | Writes a number to the print writer . If the number is an integer do not write the decimal points . | 126 | 22 |
14,474 | static public Date parseGpsTimestamp ( String gpsTimestamp ) throws Exception { try { Matcher matcherTime = patternTime . matcher ( gpsTimestamp ) ; if ( matcherTime . matches ( ) ) { int year = Integer . parseInt ( matcherTime . group ( 1 ) ) ; int month = Integer . parseInt ( matcherTime . group ( 2 ) ) ; int day = I... | Parses a GPS timestamp with a 1 second precision . | 266 | 12 |
14,475 | static public String safeSqlQueryStringValue ( String in ) throws Exception { if ( null == in ) { return "NULL" ; } if ( in . indexOf ( ' ' ) >= 0 ) { throw new Exception ( "Null character found in string value" ) ; } // All quotes should be escaped in = in . replace ( "'" , "''" ) ; // Add quotes again return "'" + in... | This method converts a string into a new one that is safe for a SQL query . It deals with strings that are expected to be string values . | 92 | 29 |
14,476 | static public String safeSqlQueryIntegerValue ( String in ) throws Exception { int intValue = Integer . parseInt ( in ) ; return "" + intValue ; } | This method converts a string into a new one that is safe for a SQL query . It deals with strings that are expected to be integer values . | 35 | 29 |
14,477 | static public String safeSqlQueryIdentifier ( String in ) throws Exception { if ( null == in ) { throw new Exception ( "Null string passed as identifier" ) ; } if ( in . indexOf ( ' ' ) >= 0 ) { throw new Exception ( "Null character found in identifier" ) ; } // All quotes should be escaped in = in . replace ( "\"" , "... | This method converts a string into a new one that is safe for a SQL query . It deals with strings that are supposed to be identifiers . | 103 | 28 |
14,478 | static public String extractStringResult ( ResultSet rs , ResultSetMetaData rsmd , int index ) throws Exception { int count = rsmd . getColumnCount ( ) ; if ( index > count || index < 1 ) { throw new Exception ( "Invalid index" ) ; } int type = rsmd . getColumnType ( index ) ; switch ( type ) { case java . sql . Types ... | This method returns a String result at a given index . | 135 | 11 |
14,479 | static public int extractIntResult ( ResultSet rs , ResultSetMetaData rsmd , int index ) throws Exception { int count = rsmd . getColumnCount ( ) ; if ( index > count || index < 1 ) { throw new Exception ( "Invalid index" ) ; } int type = rsmd . getColumnType ( index ) ; switch ( type ) { case java . sql . Types . INTE... | This method returns an int result at a given index . | 137 | 11 |
14,480 | static public void addKnownString ( String mimeType , String knownString ) { Map < String , String > map = getKnownStrings ( ) ; if ( null != mimeType && null != knownString ) { map . put ( knownString . trim ( ) , mimeType . trim ( ) ) ; } } | Adds a relation between a known string for File and a mime type . | 68 | 15 |
14,481 | private static IIOMetadataNode getOrCreateChildNode ( IIOMetadataNode parentNode , String name ) { NodeList nodeList = parentNode . getElementsByTagName ( name ) ; if ( nodeList . getLength ( ) > 0 ) { return ( IIOMetadataNode ) nodeList . item ( 0 ) ; } IIOMetadataNode childNode = new IIOMetadataNode ( name ) ; parent... | Gets the named child node or creates and attaches it . | 106 | 12 |
14,482 | private static void setDPI ( IIOMetadata metadata , int dpi , String formatName ) throws IIOInvalidTreeException { IIOMetadataNode root = ( IIOMetadataNode ) metadata . getAsTree ( MetaUtil . STANDARD_METADATA_FORMAT ) ; IIOMetadataNode dimension = getOrCreateChildNode ( root , "Dimension" ) ; // PNG writer doesn't con... | sets the DPI metadata | 255 | 5 |
14,483 | static void updateMetadata ( IIOMetadata metadata , int dpi ) throws IIOInvalidTreeException { MetaUtil . debugLogMetadata ( metadata , MetaUtil . JPEG_NATIVE_FORMAT ) ; // https://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java // http://... | Set dpi in a JPEG file | 612 | 7 |
14,484 | public String nextToken ( ) throws JSONException { char c ; char q ; StringBuilder sb = new StringBuilder ( ) ; do { c = next ( ) ; } while ( Character . isWhitespace ( c ) ) ; if ( c == ' ' || c == ' ' ) { q = c ; for ( ; ; ) { c = next ( ) ; if ( c < ' ' ) { throw syntaxError ( "Unterminated string." ) ; } if ( c == ... | Get the next token or string . This is used in parsing HTTP headers . | 175 | 15 |
14,485 | public static JSONObject toJSONObject ( java . util . Properties properties ) throws JSONException { // can't use the new constructor for Android support // JSONObject jo = new JSONObject(properties == null ? 0 : properties.size()); JSONObject jo = new JSONObject ( ) ; if ( properties != null && ! properties . isEmpty ... | Converts a property file object into a JSONObject . The property file object is a table of name value pairs . | 140 | 23 |
14,486 | private void performSubmittedInlineWork ( Work work ) throws Exception { String attachmentName = work . getAttachmentName ( ) ; FileConversionContext conversionContext = new FileConversionContextImpl ( work , documentDbDesign , mediaDir ) ; DocumentDescriptor docDescriptor = conversionContext . getDocument ( ) ; Attach... | This function is called when a media file was added on a different node such as a mobile device . In that case the media is marked as submitted_inline since the media is already attached to the document but as not yet gone through the process that the robot implements . | 395 | 53 |
14,487 | static void debugLogMetadata ( IIOMetadata metadata , String format ) { if ( ! logger . isDebugEnabled ( ) ) { return ; } // see http://docs.oracle.com/javase/7/docs/api/javax/imageio/ // metadata/doc-files/standard_metadata.html IIOMetadataNode root = ( IIOMetadataNode ) metadata . getAsTree ( format ) ; try { StringW... | logs metadata as an XML tree if debug is enabled | 267 | 11 |
14,488 | static public FSEntry getPositionedBuffer ( String path , byte [ ] content ) throws Exception { List < String > pathFrags = FSEntrySupport . interpretPath ( path ) ; // Start at leaf and work our way back int index = pathFrags . size ( ) - 1 ; FSEntry root = new FSEntryBuffer ( pathFrags . get ( index ) , content ) ; -... | Create a virtual tree hierarchy with a buffer supporting the leaf . | 146 | 12 |
14,489 | static public Result insertElements ( Tree tree , List < TreeElement > elements , NowReference now ) throws Exception { ResultImpl result = new ResultImpl ( tree ) ; TreeNodeRegular regularRootNode = tree . getRegularRootNode ( ) ; TreeNodeOngoing ongoingRootNode = tree . getOngoingRootNode ( ) ; for ( TreeElement elem... | Modifies a cluster tree as a result of adding a new elements in the tree . | 162 | 17 |
14,490 | public NunaliitGeometry getOriginalGometry ( ) throws Exception { NunaliitGeometryImpl result = null ; JSONObject jsonDoc = getJSONObject ( ) ; JSONObject nunalitt_geom = jsonDoc . optJSONObject ( CouchNunaliitConstants . DOC_KEY_GEOMETRY ) ; if ( null != nunalitt_geom ) { // By default, the wkt is the geometry String ... | Return the original geometry associated with the document . This is the geometry that was first submitted with the document . If the document does not contain a geometry then null is returned . | 559 | 34 |
14,491 | static public String getDocumentIdentifierFromSubmission ( JSONObject submissionDoc ) throws Exception { JSONObject submissionInfo = submissionDoc . getJSONObject ( "nunaliit_submission" ) ; JSONObject originalReserved = submissionInfo . optJSONObject ( "original_reserved" ) ; JSONObject submittedReserved = submissionI... | Computes the target document identifier for this submission . Returns null if it can not be found . | 157 | 19 |
14,492 | static public JSONObject getSubmittedDocumentFromSubmission ( JSONObject submissionDoc ) throws Exception { JSONObject submissionInfo = submissionDoc . getJSONObject ( "nunaliit_submission" ) ; JSONObject doc = submissionInfo . getJSONObject ( "submitted_doc" ) ; JSONObject reserved = submissionInfo . optJSONObject ( "... | Re - creates the document submitted by the client from the submission document . | 97 | 14 |
14,493 | static public JSONObject getApprovedDocumentFromSubmission ( JSONObject submissionDoc ) throws Exception { JSONObject submissionInfo = submissionDoc . getJSONObject ( "nunaliit_submission" ) ; // Check if an approved version of the document is available JSONObject doc = submissionInfo . optJSONObject ( "approved_doc" )... | Re - creates the approved document submitted by the client from the submission document . | 172 | 15 |
14,494 | static public JSONObject recreateDocumentFromDocAndReserved ( JSONObject doc , JSONObject reserved ) throws Exception { JSONObject result = JSONSupport . copyObject ( doc ) ; // Re-insert attributes that start with '_' if ( null != reserved ) { Iterator < ? > it = reserved . keys ( ) ; while ( it . hasNext ( ) ) { Obje... | Re - creates a document given the document and the reserved keys . | 134 | 13 |
14,495 | private void removeUndesiredFiles ( JSONObject doc , File dir ) throws Exception { Set < String > keysKept = new HashSet < String > ( ) ; // Loop through each child of directory File [ ] children = dir . listFiles ( ) ; for ( File child : children ) { String name = child . getName ( ) ; String extension = "" ; Matcher ... | This function scans the directory for files that are no longer needed to represent the document given in arguments . The detected files are deleted from disk . | 502 | 28 |
14,496 | synchronized static private byte [ ] getSecret ( ) throws Exception { if ( null == secret ) { Date now = new Date ( ) ; long nowValue = now . getTime ( ) ; byte [ ] nowBytes = new byte [ 8 ] ; nowBytes [ 0 ] = ( byte ) ( ( nowValue >> 0 ) & 0xff ) ; nowBytes [ 1 ] = ( byte ) ( ( nowValue >> 8 ) & 0xff ) ; nowBytes [ 2 ... | protected for testing | 267 | 3 |
14,497 | static public void sendAuthRequiredError ( HttpServletResponse response , String realm ) throws IOException { response . setHeader ( "WWW-Authenticate" , "Basic realm=\"" + realm + "\"" ) ; response . setHeader ( "Cache-Control" , "no-cache,must-revalidate" ) ; response . setDateHeader ( "Expires" , ( new Date ( ) ) . ... | Sends a response to the client stating that authorization is required . | 124 | 13 |
14,498 | static public String userToCookieString ( boolean loggedIn , User user ) throws Exception { JSONObject cookieObj = new JSONObject ( ) ; cookieObj . put ( "logged" , loggedIn ) ; JSONObject userObj = user . toJSON ( ) ; cookieObj . put ( "user" , userObj ) ; StringWriter sw = new StringWriter ( ) ; cookieObj . write ( s... | Converts an instance of User to JSON object fit for a cookie | 140 | 13 |
14,499 | static public FSEntry findDescendant ( FSEntry root , String path ) throws Exception { if ( null == root ) { throw new Exception ( "root parameter should not be null" ) ; } List < String > pathFrags = interpretPath ( path ) ; // Iterate through path fragments, navigating through // the offered children FSEntry seekedEn... | Traverses a directory structure designated by root and looks for a descendant with the provided path . If found the supporting instance of FSEntry for the path is returned . If not found null is returned . | 200 | 42 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.