signature:
public class CouchDbDesign { /** * Synchronize all design documents on desk to the database .
 * @ see # synchronizeWithDb ( DesignDocument )
 * @ see CouchDbClient # syncDesignDocsWithDb ( ) */
public void synchronizeAllWithDb ( ) { } }

implementation: List < DesignDocument > documents = getAllFromDesk ( ) ; for ( DesignDocument dd : documents ) { synchronizeWithDb ( dd ) ; }


signature:
public class CouchDbDesign { /** * Gets a design document from the database .
 * @ param id The document id
 * @ return { @ link DesignDocument } */
public DesignDocument getFromDb ( String id ) { } }

implementation: assertNotEmpty ( id , "id" ) ; final URI uri = buildUri ( dbc . getDBUri ( ) ) . path ( id ) . build ( ) ; return dbc . get ( uri , DesignDocument . class ) ;


signature:
public class CouchDbDesign { /** * Gets all design documents from desk .
 * @ see # getFromDesk ( String )
 * @ return a list of all design documents */
public List < DesignDocument > getAllFromDesk ( ) { } }

implementation: final List < DesignDocument > designDocsList = new ArrayList < DesignDocument > ( ) ; for ( String docName : listResources ( format ( "%s/" , DESIGN_DOCS_DIR ) ) ) { designDocsList . add ( getFromDesk ( docName ) ) ; } return designDocsList ;


signature:
public class CouchDbDesign { /** * Gets a design document from desk .
 * @ param id The document id to get .
 * @ return { @ link DesignDocument } */
public DesignDocument getFromDesk ( String id ) { } }

implementation:
assertNotEmpty ( id , "id" ) ; final DesignDocument dd = new DesignDocument ( ) ; final String rootPath = format ( "%s/%s/" , DESIGN_DOCS_DIR , id ) ; final List < String > elements = listResources ( rootPath ) ; if ( elements == null ) { throw new IllegalArgumentException ( "Design docs directory cannot be empty." ) ; } // Views
Map < String , MapReduce > views = null ; if ( elements . contains ( VIEWS ) ) { views = new HashMap < String , MapReduce > ( ) ; final String viewsPath = format ( "%s%s/" , rootPath , VIEWS ) ; for ( String viewDirName : listResources ( viewsPath ) ) { // views sub - dirs
final MapReduce mr = new MapReduce ( ) ; final String viewPath = format ( "%s%s/" , viewsPath , viewDirName ) ; final List < String > dirList = listResources ( viewPath ) ; for ( String fileName : dirList ) { // view files
final String def = readFile ( format ( "/%s%s" , viewPath , fileName ) ) ; if ( MAP_JS . equals ( fileName ) ) mr . setMap ( def ) ; else if ( REDUCE_JS . equals ( fileName ) ) mr . setReduce ( def ) ; } // / foreach view files
views . put ( viewDirName , mr ) ; } // / foreach views sub - dirs
} // / views
dd . setId ( DESIGN_PREFIX + id ) ; dd . setLanguage ( JAVASCRIPT ) ; dd . setViews ( views ) ; dd . setFilters ( populateMap ( rootPath , elements , FILTERS ) ) ; dd . setShows ( populateMap ( rootPath , elements , SHOWS ) ) ; dd . setLists ( populateMap ( rootPath , elements , LISTS ) ) ; dd . setUpdates ( populateMap ( rootPath , elements , UPDATES ) ) ; dd . setValidateDocUpdate ( readContent ( elements , rootPath , VALIDATE_DOC ) ) ; dd . setRewrites ( dbc . getGson ( ) . fromJson ( readContent ( elements , rootPath , REWRITES ) , JsonArray . class ) ) ; dd . setFulltext ( dbc . getGson ( ) . fromJson ( readContent ( elements , rootPath , FULLTEXT ) , JsonObject . class ) ) ; dd . setIndexes ( dbc . getGson ( ) . fromJson ( readContent ( elements , rootPath , INDEXES ) , JsonObject . class ) ) ; return dd ;


signature:
public class Replicator { /** * Adds a new document to the replicator database .
 * @ return { @ link Response } */
public Response save ( ) { } }

implementation: assertNotEmpty ( replicatorDoc . getSource ( ) , "Source" ) ; assertNotEmpty ( replicatorDoc . getTarget ( ) , "Target" ) ; if ( userCtxName != null ) { UserCtx ctx = replicatorDoc . new UserCtx ( ) ; ctx . setName ( userCtxName ) ; ctx . setRoles ( userCtxRoles ) ; replicatorDoc . setUserCtx ( ctx ) ; } return dbc . put ( dbURI , replicatorDoc , true ) ;


signature:
public class Replicator { /** * Finds a document in the replicator database .
 * @ return { @ link ReplicatorDocument } */
public ReplicatorDocument find ( ) { } }

implementation: assertNotEmpty ( replicatorDoc . getId ( ) , "Doc id" ) ; final URI uri = buildUri ( dbURI ) . path ( replicatorDoc . getId ( ) ) . query ( "rev" , replicatorDoc . getRevision ( ) ) . build ( ) ; return dbc . get ( uri , ReplicatorDocument . class ) ;


signature:
public class Replicator { /** * Finds all documents in the replicator database .
 * @ return a list of { @ link ReplicatorDocument } */
public List < ReplicatorDocument > findAll ( ) { } }

implementation:
InputStream instream = null ; try { final URI uri = buildUri ( dbURI ) . path ( "_all_docs" ) . query ( "include_docs" , "true" ) . build ( ) ; final Reader reader = new InputStreamReader ( instream = dbc . get ( uri ) , Charsets . UTF_8 ) ; final JsonArray jsonArray = new JsonParser ( ) . parse ( reader ) . getAsJsonObject ( ) . getAsJsonArray ( "rows" ) ; final List < ReplicatorDocument > list = new ArrayList < ReplicatorDocument > ( ) ; for ( JsonElement jsonElem : jsonArray ) { JsonElement elem = jsonElem . getAsJsonObject ( ) . get ( "doc" ) ; if ( ! getAsString ( elem . getAsJsonObject ( ) , "_id" ) . startsWith ( "_design" ) ) { // skip design docs
ReplicatorDocument rd = dbc . getGson ( ) . fromJson ( elem , ReplicatorDocument . class ) ; list . add ( rd ) ; } } return list ; } finally { close ( instream ) ; }


signature:
public class Replicator { /** * Removes a document from the replicator database .
 * @ return { @ link Response } */
public Response remove ( ) { } }

implementation: assertNotEmpty ( replicatorDoc . getId ( ) , "Doc id" ) ; assertNotEmpty ( replicatorDoc . getRevision ( ) , "Doc rev" ) ; final URI uri = buildUri ( dbURI ) . path ( replicatorDoc . getId ( ) ) . query ( "rev" , replicatorDoc . getRevision ( ) ) . build ( ) ; return dbc . delete ( uri ) ;


signature:
public class CouchDbClientBase { /** * Finds an Object of the specified type .
 * @ param < T > Object type .
 * @ param classType The class of type T .
 * @ param id The document id .
 * @ param params Extra parameters to append .
 * @ return An object of type T .
 * @ throws NoDocumentException If the document is not found in the database . */
public < T > T find ( Class < T > classType , String id , Params params ) { } }

implementation: assertNotEmpty ( classType , "Class" ) ; assertNotEmpty ( id , "id" ) ; final URI uri = buildUri ( getDBUri ( ) ) . pathEncoded ( id ) . query ( params ) . build ( ) ; return get ( uri , classType ) ;


signature:
public class CouchDbClientBase { /** * Finds a document and return the result as { @ link InputStream } .
 * < p > < b > Note < / b > : The stream must be closed after use to release the connection .
 * @ param id The document _ id field .
 * @ return The result as { @ link InputStream }
 * @ throws NoDocumentException If the document is not found in the database .
 * @ see # find ( String , String ) */
public InputStream find ( String id ) { } }

implementation: assertNotEmpty ( id , "id" ) ; return get ( buildUri ( getDBUri ( ) ) . path ( id ) . build ( ) ) ;


signature:
public class CouchDbClientBase { /** * Finds a document given id and revision and returns the result as { @ link InputStream } .
 * < p > < b > Note < / b > : The stream must be closed after use to release the connection .
 * @ param id The document _ id field .
 * @ param rev The document _ rev field .
 * @ return The result as { @ link InputStream }
 * @ throws NoDocumentException If the document is not found in the database . */
public InputStream find ( String id , String rev ) { } }

implementation: assertNotEmpty ( id , "id" ) ; assertNotEmpty ( rev , "rev" ) ; final URI uri = buildUri ( getDBUri ( ) ) . path ( id ) . query ( "rev" , rev ) . build ( ) ; return get ( uri ) ;


signature:
public class CouchDbClientBase { /** * Find documents using a declarative JSON querying syntax .
 * @ param < T > The class type .
 * @ param jsonQuery The JSON query string .
 * @ param classOfT The class of type T .
 * @ return The result of the query as a { @ code List < T > }
 * @ throws CouchDbException If the query failed to execute or the request is invalid . */
public < T > List < T > findDocs ( String jsonQuery , Class < T > classOfT ) { } }

implementation: assertNotEmpty ( jsonQuery , "jsonQuery" ) ; HttpResponse response = null ; try { response = post ( buildUri ( getDBUri ( ) ) . path ( "_find" ) . build ( ) , jsonQuery ) ; Reader reader = new InputStreamReader ( getStream ( response ) , Charsets . UTF_8 ) ; JsonArray jsonArray = new JsonParser ( ) . parse ( reader ) . getAsJsonObject ( ) . getAsJsonArray ( "docs" ) ; List < T > list = new ArrayList < T > ( ) ; for ( JsonElement jsonElem : jsonArray ) { JsonElement elem = jsonElem . getAsJsonObject ( ) ; T t = this . gson . fromJson ( elem , classOfT ) ; list . add ( t ) ; } return list ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Checks if a document exist in the database .
 * @ param id The document _ id field .
 * @ return true If the document is found , false otherwise . */
public boolean contains ( String id ) { } }

implementation: assertNotEmpty ( id , "id" ) ; HttpResponse response = null ; try { response = head ( buildUri ( getDBUri ( ) ) . pathEncoded ( id ) . build ( ) ) ; } catch ( NoDocumentException e ) { return false ; } finally { close ( response ) ; } return true ;


signature:
public class CouchDbClientBase { /** * Saves an object in the database using HTTP < tt > POST < / tt > request .
 * < p > The database will be responsible for generating the document id .
 * @ param object The object to save
 * @ return { @ link Response } */
public Response post ( Object object ) { } }

implementation: assertNotEmpty ( object , "object" ) ; HttpResponse response = null ; try { URI uri = buildUri ( getDBUri ( ) ) . build ( ) ; response = post ( uri , getGson ( ) . toJson ( object ) ) ; return getResponse ( response ) ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Saves a document with < tt > batch = ok < / tt > query param .
 * @ param object The object to save . */
public void batch ( Object object ) { } }

implementation: assertNotEmpty ( object , "object" ) ; HttpResponse response = null ; try { URI uri = buildUri ( getDBUri ( ) ) . query ( "batch" , "ok" ) . build ( ) ; response = post ( uri , getGson ( ) . toJson ( object ) ) ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Removes a document from the database given both a document < code > _ id < / code > and < code > _ rev < / code > values .
 * @ param id The document _ id field .
 * @ param rev The document _ rev field .
 * @ throws NoDocumentException If the document is not found in the database .
 * @ return { @ link Response } */
public Response remove ( String id , String rev ) { } }

implementation: assertNotEmpty ( id , "id" ) ; assertNotEmpty ( rev , "rev" ) ; final URI uri = buildUri ( getDBUri ( ) ) . pathEncoded ( id ) . query ( "rev" , rev ) . build ( ) ; return delete ( uri ) ;


signature:
public class CouchDbClientBase { /** * Performs bulk documents create and update request .
 * @ param objects The { @ link List } of documents objects .
 * @ param newEdits If false , prevents the database from assigning documents new revision IDs .
 * @ return { @ code List < Response > } Containing the resulted entries . */
public List < Response > bulk ( List < ? > objects , boolean newEdits ) { } }

implementation: assertNotEmpty ( objects , "objects" ) ; HttpResponse response = null ; try { final String newEditsVal = newEdits ? "\"new_edits\": true, " : "\"new_edits\": false, " ; final String json = String . format ( "{%s%s%s}" , newEditsVal , "\"docs\": " , getGson ( ) . toJson ( objects ) ) ; final URI uri = buildUri ( getDBUri ( ) ) . path ( "_bulk_docs" ) . build ( ) ; response = post ( uri , json ) ; return getResponseList ( response ) ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Saves an attachment to a new document with a generated < tt > UUID < / tt > as the document id .
 * < p > To retrieve an attachment , see { @ link # find ( String ) } .
 * @ param in The { @ link InputStream } holding the binary data .
 * @ param name The attachment name .
 * @ param contentType The attachment " Content - Type " .
 * @ return { @ link Response } */
public Response saveAttachment ( InputStream in , String name , String contentType ) { } }

implementation: assertNotEmpty ( in , "in" ) ; assertNotEmpty ( name , "name" ) ; assertNotEmpty ( contentType , "ContentType" ) ; final URI uri = buildUri ( getDBUri ( ) ) . path ( generateUUID ( ) ) . path ( "/" ) . path ( name ) . build ( ) ; return put ( uri , in , contentType ) ;


signature:
public class CouchDbClientBase { /** * Saves an attachment to an existing document given both a document id
 * and revision , or save to a new document given only the id , and rev as { @ code null } .
 * < p > To retrieve an attachment , see { @ link # find ( String ) } .
 * @ param in The { @ link InputStream } holding the binary data .
 * @ param name The attachment name .
 * @ param contentType The attachment " Content - Type " .
 * @ param docId The document id to save the attachment under , or { @ code null } to save under a new document .
 * @ param docRev The document revision to save the attachment under , or { @ code null } when saving to a new document .
 * @ return { @ link Response } */
public Response saveAttachment ( InputStream in , String name , String contentType , String docId , String docRev ) { } }

implementation: assertNotEmpty ( in , "in" ) ; assertNotEmpty ( name , "name" ) ; assertNotEmpty ( contentType , "ContentType" ) ; assertNotEmpty ( docId , "docId" ) ; final URI uri = buildUri ( getDBUri ( ) ) . pathEncoded ( docId ) . path ( "/" ) . path ( name ) . query ( "rev" , docRev ) . build ( ) ; return put ( uri , in , contentType ) ;


signature:
public class CouchDbClientBase { /** * Invokes an Update Handler .
 * < pre >
 * Params params = new Params ( )
 * . addParam ( " field " , " foo " )
 * . addParam ( " value " , " bar " ) ;
 * String output = dbClient . invokeUpdateHandler ( " designDoc / update1 " , " docId " , params ) ;
 * < / pre >
 * @ param updateHandlerUri The Update Handler URI , in the format : < code > designDoc / update1 < / code >
 * @ param docId The document id to update .
 * @ param params The query parameters as { @ link Params } .
 * @ return The output of the request . */
public String invokeUpdateHandler ( String updateHandlerUri , String docId , Params params ) { } }

implementation: assertNotEmpty ( updateHandlerUri , "uri" ) ; assertNotEmpty ( docId , "docId" ) ; final String [ ] v = updateHandlerUri . split ( "/" ) ; final String path = String . format ( "_design/%s/_update/%s/" , v [ 0 ] , v [ 1 ] ) ; final URI uri = buildUri ( getDBUri ( ) ) . path ( path ) . path ( docId ) . query ( params ) . build ( ) ; final HttpResponse response = executeRequest ( new HttpPut ( uri ) ) ; return streamToString ( getStream ( response ) ) ;


signature:
public class CouchDbClientBase { /** * Executes a HTTP request .
 * < p > < b > Note < / b > : The response must be closed after use to release the connection .
 * @ param request The HTTP request to execute .
 * @ return { @ link HttpResponse } */
public HttpResponse executeRequest ( HttpRequestBase request ) { } }

implementation: try { return httpClient . execute ( host , request , createContext ( ) ) ; } catch ( IOException e ) { request . abort ( ) ; throw new CouchDbException ( "Error executing request. " , e ) ; }


signature:
public class CouchDbClientBase { /** * Performs a HTTP GET request .
 * @ return { @ link InputStream } */
InputStream get ( HttpGet httpGet ) { } }

implementation: HttpResponse response = executeRequest ( httpGet ) ; return getStream ( response ) ;


signature:
public class CouchDbClientBase { /** * Performs a HTTP GET request .
 * @ return { @ link InputStream } */
InputStream get ( URI uri ) { } }

implementation: HttpGet get = new HttpGet ( uri ) ; get . addHeader ( "Accept" , "application/json" ) ; return get ( get ) ;


signature:
public class CouchDbClientBase { /** * Performs a HTTP GET request .
 * @ return An object of type T */
< T > T get ( URI uri , Class < T > classType ) { } }

implementation: InputStream in = null ; try { in = get ( uri ) ; return getGson ( ) . fromJson ( new InputStreamReader ( in , "UTF-8" ) , classType ) ; } catch ( UnsupportedEncodingException e ) { throw new CouchDbException ( e ) ; } finally { close ( in ) ; }


signature:
public class CouchDbClientBase { /** * Performs a HTTP PUT request , saves or updates a document .
 * @ return { @ link Response } */
Response put ( URI uri , Object object , boolean newEntity ) { } }

implementation:
assertNotEmpty ( object , "object" ) ; HttpResponse response = null ; try { final JsonObject json = getGson ( ) . toJsonTree ( object ) . getAsJsonObject ( ) ; String id = getAsString ( json , "_id" ) ; String rev = getAsString ( json , "_rev" ) ; if ( newEntity ) { // save
assertNull ( rev , "rev" ) ; id = ( id == null ) ? generateUUID ( ) : id ; } else { // update
assertNotEmpty ( id , "id" ) ; assertNotEmpty ( rev , "rev" ) ; } final HttpPut put = new HttpPut ( buildUri ( uri ) . pathEncoded ( id ) . build ( ) ) ; setEntity ( put , json . toString ( ) ) ; response = executeRequest ( put ) ; return getResponse ( response ) ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Performs a HTTP PUT request , saves an attachment .
 * @ return { @ link Response } */
Response put ( URI uri , InputStream instream , String contentType ) { } }

implementation: HttpResponse response = null ; try { final HttpPut httpPut = new HttpPut ( uri ) ; final InputStreamEntity entity = new InputStreamEntity ( instream , - 1 ) ; entity . setContentType ( contentType ) ; httpPut . setEntity ( entity ) ; response = executeRequest ( httpPut ) ; return getResponse ( response ) ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Performs a HTTP POST request .
 * @ return { @ link HttpResponse } */
HttpResponse post ( URI uri , String json ) { } }

implementation: HttpPost post = new HttpPost ( uri ) ; setEntity ( post , json ) ; return executeRequest ( post ) ;


signature:
public class CouchDbClientBase { /** * Performs a HTTP DELETE request .
 * @ return { @ link Response } */
Response delete ( URI uri ) { } }

implementation: HttpResponse response = null ; try { HttpDelete delete = new HttpDelete ( uri ) ; response = executeRequest ( delete ) ; return getResponse ( response ) ; } finally { close ( response ) ; }


signature:
public class CouchDbClientBase { /** * Validates a HTTP response ; on error cases logs status and throws relevant exceptions .
 * @ param response The HTTP response . */
void validate ( HttpResponse response ) throws IOException { } }

implementation:
final int code = response . getStatusLine ( ) . getStatusCode ( ) ; if ( code == 200 || code == 201 || code == 202 ) { // success ( ok | created | accepted )
return ; } String reason = response . getStatusLine ( ) . getReasonPhrase ( ) ; switch ( code ) { case HttpStatus . SC_NOT_FOUND : { throw new NoDocumentException ( reason ) ; } case HttpStatus . SC_CONFLICT : { throw new DocumentConflictException ( reason ) ; } default : { // other errors : 400 | 401 | 500 etc .
throw new CouchDbException ( reason += EntityUtils . toString ( response . getEntity ( ) ) ) ; } }


signature:
public class CouchDbClientBase { /** * Sets a JSON String as a request entity .
 * @ param httpRequest The request to set entity .
 * @ param json The JSON String to set . */
private void setEntity ( HttpEntityEnclosingRequestBase httpRequest , String json ) { } }

implementation: StringEntity entity = new StringEntity ( json , "UTF-8" ) ; entity . setContentType ( "application/json" ) ; httpRequest . setEntity ( entity ) ;


signature:
public class CouchDbClientBase { /** * Builds { @ link Gson } and registers any required serializer / deserializer .
 * @ return { @ link Gson } instance */
private Gson initGson ( GsonBuilder gsonBuilder ) { } }

implementation: gsonBuilder . registerTypeAdapter ( JsonObject . class , new JsonDeserializer < JsonObject > ( ) { public JsonObject deserialize ( JsonElement json , Type typeOfT , JsonDeserializationContext context ) throws JsonParseException { return json . getAsJsonObject ( ) ; } } ) ; gsonBuilder . registerTypeAdapter ( JsonObject . class , new JsonSerializer < JsonObject > ( ) { public JsonElement serialize ( JsonObject src , Type typeOfSrc , JsonSerializationContext context ) { return src . getAsJsonObject ( ) ; } } ) ; return gsonBuilder . create ( ) ;


signature:
public class Document { /** * Adds an in - line document attachment .
 * @ param name The attachment file name
 * @ param attachment The attachment instance */
public void addAttachment ( String name , Attachment attachment ) { } }

implementation: if ( attachments == null ) attachments = new HashMap < String , Attachment > ( ) ; attachments . put ( name , attachment ) ;


signature:
public class Changes { /** * Requests Change notifications of feed type continuous .
 * < p > Feed notifications are accessed in an < i > iterator < / i > style .
 * @ return { @ link Changes } */
public Changes continuousChanges ( ) { } }

implementation: final URI uri = uriBuilder . query ( "feed" , "continuous" ) . build ( ) ; httpGet = new HttpGet ( uri ) ; final InputStream in = dbc . get ( httpGet ) ; final InputStreamReader is = new InputStreamReader ( in , Charsets . UTF_8 ) ; setReader ( new BufferedReader ( is ) ) ; return this ;


signature:
public class Changes { /** * Requests Change notifications of feed type normal .
 * @ return { @ link ChangesResult } */
public ChangesResult getChanges ( ) { } }

implementation: final URI uri = uriBuilder . query ( "feed" , "normal" ) . build ( ) ; return dbc . get ( uri , ChangesResult . class ) ;


signature:
public class Changes { /** * Reads and sets the next feed in the stream . */
private boolean readNextRow ( ) { } }

implementation: boolean hasNext = false ; try { if ( ! stop ) { String row = "" ; do { row = getReader ( ) . readLine ( ) ; } while ( row . length ( ) == 0 ) ; if ( ! row . startsWith ( "{\"last_seq\":" ) ) { setNextRow ( gson . fromJson ( row , Row . class ) ) ; hasNext = true ; } } } catch ( Exception e ) { terminate ( ) ; throw new CouchDbException ( "Error reading continuous stream." , e ) ; } if ( ! hasNext ) terminate ( ) ; return hasNext ;


signature:
public class MoneyToStrApp { /** * < editor - fold defaultstate = " collapsed " desc = " Generated Code " > / / GEN - BEGIN : initComponents */
private void initComponents ( ) { } }

implementation:
jTabbedPane6 = new javax . swing . JTabbedPane ( ) ; jPanel2 = new javax . swing . JPanel ( ) ; jTabbedPane3 = new javax . swing . JTabbedPane ( ) ; jScrollPane7 = new javax . swing . JScrollPane ( ) ; jTextArea7 = new javax . swing . JTextArea ( ) ; jTabbedPane1 = new javax . swing . JTabbedPane ( ) ; jScrollPane3 = new javax . swing . JScrollPane ( ) ; jTextArea1 = new javax . swing . JTextArea ( ) ; jLabel2 = new javax . swing . JLabel ( ) ; jTabbedPane2 = new javax . swing . JTabbedPane ( ) ; jScrollPane4 = new javax . swing . JScrollPane ( ) ; jTextArea4 = new javax . swing . JTextArea ( ) ; jTabbedPane4 = new javax . swing . JTabbedPane ( ) ; jScrollPane5 = new javax . swing . JScrollPane ( ) ; jTextArea5 = new javax . swing . JTextArea ( ) ; jTabbedPane5 = new javax . swing . JTabbedPane ( ) ; jScrollPane6 = new javax . swing . JScrollPane ( ) ; jTextArea6 = new javax . swing . JTextArea ( ) ; jButton2 = new javax . swing . JButton ( ) ; jTextField1 = new HistoryComboBox ( ) ; jButton4 = new javax . swing . JButton ( ) ; jButton5 = new javax . swing . JButton ( ) ; jButton6 = new javax . swing . JButton ( ) ; jButton8 = new javax . swing . JButton ( ) ; jButton9 = new javax . swing . JButton ( ) ; jPanel1 = new javax . swing . JPanel ( ) ; jLabel1 = new javax . swing . JLabel ( ) ; jComboBox1 = new javax . swing . JComboBox ( ) ; jLabel3 = new javax . swing . JLabel ( ) ; jLabel4 = new javax . swing . JLabel ( ) ; jComboBox2 = new javax . swing . JComboBox ( ) ; jComboBox3 = new javax . swing . JComboBox ( ) ; jLabel5 = new javax . swing . JLabel ( ) ; jComboBox4 = new javax . swing . JComboBox ( ) ; jLabel6 = new javax . swing . JLabel ( ) ; jComboBox5 = new javax . swing . JComboBox ( ) ; jLabel7 = new javax . swing . JLabel ( ) ; jComboBox6 = new javax . swing . JComboBox ( ) ; jLabel12 = new javax . swing . JLabel ( ) ; jTextField5 = new javax . swing . JTextField ( ) ; jLabel10 = new javax . swing . JLabel ( ) ; jLabel9 = new javax . swing . JLabel ( ) ; jTextField3 = new javax . swing . JTextField ( ) ; jTextField2 = new javax . swing . JTextField ( ) ; jLabel11 = new javax . swing . JLabel ( ) ; jLabel8 = new javax . swing . JLabel ( ) ; jTextField4 = new javax . swing . JTextField ( ) ; jLabel13 = new javax . swing . JLabel ( ) ; jTextField7 = new javax . swing . JTextField ( ) ; jTextField6 = new javax . swing . JTextField ( ) ; jLabel14 = new javax . swing . JLabel ( ) ; jComboBox7 = new javax . swing . JComboBox ( ) ; jLabel15 = new javax . swing . JLabel ( ) ; jComboBox8 = new javax . swing . JComboBox ( ) ; jPanel3 = new javax . swing . JPanel ( ) ; jTabbedPane7 = new javax . swing . JTabbedPane ( ) ; jScrollPane1 = new javax . swing . JScrollPane ( ) ; jTextPane1 = new javax . swing . JTextPane ( ) ; jScrollPane17 = new javax . swing . JScrollPane ( ) ; jTextPane12 = new javax . swing . JTextPane ( ) ; jScrollPane16 = new javax . swing . JScrollPane ( ) ; jTextPane11 = new javax . swing . JTextPane ( ) ; jScrollPane2 = new javax . swing . JScrollPane ( ) ; jTextPane2 = new javax . swing . JTextPane ( ) ; jScrollPane15 = new javax . swing . JScrollPane ( ) ; jTextPane10 = new javax . swing . JTextPane ( ) ; jScrollPane8 = new javax . swing . JScrollPane ( ) ; jTextPane3 = new javax . swing . JTextPane ( ) ; jScrollPane9 = new javax . swing . JScrollPane ( ) ; jTextPane4 = new javax . swing . JTextPane ( ) ; jScrollPane10 = new javax . swing . JScrollPane ( ) ; jTextPane5 = new javax . swing . JTextPane ( ) ; jScrollPane11 = new javax . swing . JScrollPane ( ) ; jTextPane6 = new javax . swing . JTextPane ( ) ; jScrollPane12 = new javax . swing . JScrollPane ( ) ; jTextPane7 = new javax . swing . JTextPane ( ) ; jScrollPane13 = new javax . swing . JScrollPane ( ) ; jTextPane8 = new javax . swing . JTextPane ( ) ; jScrollPane14 = new javax . swing . JScrollPane ( ) ; jTextPane9 = new javax . swing . JTextPane ( ) ; setDefaultCloseOperation ( javax . swing . WindowConstants . EXIT_ON_CLOSE ) ; java . util . ResourceBundle bundle = java . util . ResourceBundle . getBundle ( "com/github/moneytostr/messages_ru" ) ; // NOI18N
setTitle ( bundle . getString ( "MONEYTOSTR" ) ) ; // NOI18N
jPanel2 . setBorder ( javax . swing . BorderFactory . createTitledBorder ( "" ) ) ; jPanel2 . setMaximumSize ( new java . awt . Dimension ( 610 , 444 ) ) ; jPanel2 . setPreferredSize ( new java . awt . Dimension ( 662 , 447 ) ) ; jScrollPane7 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea7 . setColumns ( 20 ) ; jTextArea7 . setRows ( 5 ) ; jScrollPane7 . setViewportView ( jTextArea7 ) ; jTabbedPane3 . addTab ( bundle . getString ( "fromCapitalLetter" ) , jScrollPane7 ) ; // NOI18N
jScrollPane3 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea1 . setColumns ( 20 ) ; jTextArea1 . setRows ( 5 ) ; jScrollPane3 . setViewportView ( jTextArea1 ) ; jTabbedPane1 . addTab ( bundle . getString ( "result" ) , jScrollPane3 ) ; // NOI18N
jLabel2 . setText ( bundle . getString ( "enterTheDigitalAmount" ) ) ; // NOI18N
jScrollPane4 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea4 . setColumns ( 20 ) ; jTextArea4 . setRows ( 5 ) ; jScrollPane4 . setViewportView ( jTextArea4 ) ; jTabbedPane2 . addTab ( bundle . getString ( "penniesByDigits" ) , jScrollPane4 ) ; // NOI18N
jScrollPane5 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea5 . setColumns ( 20 ) ; jTextArea5 . setRows ( 5 ) ; jScrollPane5 . setViewportView ( jTextArea5 ) ; jTabbedPane4 . addTab ( bundle . getString ( "withVat" ) , jScrollPane5 ) ; // NOI18N
jScrollPane6 . setVerticalScrollBarPolicy ( javax . swing . ScrollPaneConstants . VERTICAL_SCROLLBAR_NEVER ) ; jTextArea6 . setColumns ( 20 ) ; jTextArea6 . setRows ( 5 ) ; jScrollPane6 . setViewportView ( jTextArea6 ) ; jTabbedPane5 . addTab ( bundle . getString ( "withVatByString" ) , jScrollPane6 ) ; // NOI18N
jButton2 . setText ( "*" ) ; jButton2 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton2 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton2ActionPerformed ( evt ) ; } } ) ; jTextField1 . setEditable ( true ) ; jTextField1 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jTextField1ActionPerformed ( evt ) ; } } ) ; jButton4 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N
jButton4 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N
jButton4 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton4 . setFocusable ( false ) ; jButton4 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton4 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton4 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton4 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton4ActionPerformed ( evt ) ; } } ) ; jButton5 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N
jButton5 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N
jButton5 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton5 . setFocusable ( false ) ; jButton5 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton5 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton5 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton5 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton5ActionPerformed ( evt ) ; } } ) ; jButton6 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N
jButton6 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N
jButton6 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton6 . setFocusable ( false ) ; jButton6 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton6 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton6 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton6 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton6ActionPerformed ( evt ) ; } } ) ; jButton8 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N
jButton8 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N
jButton8 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton8 . setFocusable ( false ) ; jButton8 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton8 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton8 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton8 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton8ActionPerformed ( evt ) ; } } ) ; jButton9 . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/com/github/moneytostr/copy.png" ) ) ) ; // NOI18N
jButton9 . setToolTipText ( bundle . getString ( "copyToTheBuffer" ) ) ; // NOI18N
jButton9 . setBorder ( new javax . swing . border . SoftBevelBorder ( javax . swing . border . BevelBorder . RAISED ) ) ; jButton9 . setFocusable ( false ) ; jButton9 . setMaximumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton9 . setMinimumSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton9 . setPreferredSize ( new java . awt . Dimension ( 30 , 30 ) ) ; jButton9 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jButton9ActionPerformed ( evt ) ; } } ) ; org . jdesktop . layout . GroupLayout jPanel2Layout = new org . jdesktop . layout . GroupLayout ( jPanel2 ) ; jPanel2 . setLayout ( jPanel2Layout ) ; jPanel2Layout . setHorizontalGroup ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . addContainerGap ( ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . TRAILING ) . add ( jTabbedPane2 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane5 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane4 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane3 ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jPanel2Layout . createSequentialGroup ( ) . add ( jLabel2 ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jTextField1 , 0 , 636 , Short . MAX_VALUE ) ) . add ( org . jdesktop . layout . GroupLayout . LEADING , jTabbedPane1 ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jButton8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jButton2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jButton4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( jButton5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jButton6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( jButton9 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 29 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addContainerGap ( ) ) ) ; jPanel2Layout . setVerticalGroup ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . addContainerGap ( ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel2 ) . add ( jButton2 ) . add ( jTextField1 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane1 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 112 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jPanel2Layout . createSequentialGroup ( ) . add ( 23 , 23 , 23 ) . add ( jButton4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane3 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 106 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 52 , 52 , 52 ) ) ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 107 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 53 , 53 , 53 ) ) ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 112 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 57 , 57 , 57 ) ) ) . add ( jPanel2Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , 112 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jPanel2Layout . createSequentialGroup ( ) . add ( jButton9 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( 58 , 58 , 58 ) ) ) . addContainerGap ( org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) ) ) ; jTabbedPane6 . addTab ( bundle . getString ( "converter" ) , jPanel2 ) ; // NOI18N
jLabel1 . setText ( bundle . getString ( "language" ) ) ; // NOI18N
jComboBox1 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "Русский" , "Украинский" , "Английсикй" } ) ) ; jComboBox1 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox1ActionPerformed ( evt ) ; } } ) ; jLabel3 . setText ( bundle . getString ( "currency" ) ) ; // NOI18N
jLabel4 . setText ( bundle . getString ( "pennies" ) ) ; // NOI18N
jComboBox2 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "RUR" , "UAH" , "USD" , "Custom" } ) ) ; jComboBox2 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox2ActionPerformed ( evt ) ; } } ) ; jComboBox3 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "Цифрами" , "Прописью" } ) ) ; jComboBox3 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox3ActionPerformed ( evt ) ; } } ) ; jLabel5 . setText ( bundle . getString ( "toCopyToTheBuffer" ) ) ; // NOI18N
jComboBox4 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "не копировать" , "Результат" , "С заглавной буквы" , "С НДС" , "С НДС прописью" , "Копейки цифрами" } ) ) ; jComboBox4 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox4ActionPerformed ( evt ) ; } } ) ; jLabel6 . setText ( bundle . getString ( "vat" ) ) ; // NOI18N
jComboBox5 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "10%" , "12%" , "18%" , "20%" , "22%" , "25%" } ) ) ; jComboBox5 . setSelectedIndex ( 2 ) ; jComboBox5 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox5ActionPerformed ( evt ) ; } } ) ; jLabel7 . setText ( bundle . getString ( "interfaceLanguage" ) ) ; // NOI18N
jComboBox6 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "Русский" , "Украинский" } ) ) ; jComboBox6 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox6ActionPerformed ( evt ) ; } } ) ; jLabel12 . setText ( bundle . getString ( "kopTwoUnit" ) ) ; // NOI18N
jTextField5 . setText ( "евроцент" ) ; jTextField5 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField5KeyTyped ( evt ) ; } } ) ; jLabel10 . setText ( bundle . getString ( "rubFiveUnit" ) ) ; // NOI18N
jLabel9 . setText ( bundle . getString ( "rubTwoUnit" ) ) ; // NOI18N
jTextField3 . setText ( "евро" ) ; jTextField3 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField3KeyTyped ( evt ) ; } } ) ; jTextField2 . setText ( "евро" ) ; jTextField2 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField2KeyTyped ( evt ) ; } } ) ; jLabel11 . setText ( bundle . getString ( "kopOneUnit" ) ) ; // NOI18N
jLabel8 . setText ( bundle . getString ( "rubOneUnit" ) ) ; // NOI18N
jTextField4 . setText ( "евро" ) ; jTextField4 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField4KeyTyped ( evt ) ; } } ) ; jLabel13 . setText ( bundle . getString ( "kopFiveUnit" ) ) ; // NOI18N
jTextField7 . setText ( "евроцентов" ) ; jTextField7 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField7KeyTyped ( evt ) ; } } ) ; jTextField6 . setText ( "евроцента" ) ; jTextField6 . addKeyListener ( new java . awt . event . KeyAdapter ( ) { public void keyTyped ( java . awt . event . KeyEvent evt ) { jTextField6KeyTyped ( evt ) ; } } ) ; jLabel14 . setText ( bundle . getString ( "rubSex" ) ) ; // NOI18N
jComboBox7 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "M" , "F" } ) ) ; jComboBox7 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox7ActionPerformed ( evt ) ; } } ) ; jLabel15 . setText ( bundle . getString ( "kopSex" ) ) ; // NOI18N
jComboBox8 . setModel ( new javax . swing . DefaultComboBoxModel ( new String [ ] { "M" , "F" } ) ) ; jComboBox8 . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { jComboBox8ActionPerformed ( evt ) ; } } ) ; org . jdesktop . layout . GroupLayout jPanel1Layout = new org . jdesktop . layout . GroupLayout ( jPanel1 ) ; jPanel1 . setLayout ( jPanel1Layout ) ; jPanel1Layout . setHorizontalGroup ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( 23 , 23 , 23 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel1 ) . add ( jLabel3 ) . add ( jLabel4 ) . add ( jLabel5 ) . add ( jLabel6 ) . add ( jLabel7 ) ) . add ( 29 , 29 , 29 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jComboBox5 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( jComboBox2 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jComboBox3 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( org . jdesktop . layout . GroupLayout . TRAILING , jComboBox4 , 0 , 658 , Short . MAX_VALUE ) . add ( jComboBox1 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) . add ( jComboBox6 , 0 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , Short . MAX_VALUE ) ) ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel9 ) . add ( jLabel8 ) . add ( jLabel10 ) . add ( jLabel11 ) . add ( jLabel12 ) . add ( jLabel13 ) . add ( jLabel14 ) . add ( jLabel15 ) ) . add ( 25 , 25 , 25 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTextField7 ) . add ( jTextField6 ) . add ( jTextField5 ) . add ( jTextField4 ) . add ( jTextField2 ) . add ( jTextField3 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , 659 , Short . MAX_VALUE ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jComboBox8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jComboBox7 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( 0 , 0 , Short . MAX_VALUE ) ) ) ) ) . addContainerGap ( ) ) ) ; jPanel1Layout . setVerticalGroup ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jPanel1Layout . createSequentialGroup ( ) . add ( 23 , 23 , 23 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel1 ) . add ( jComboBox1 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel3 ) . add ( jComboBox2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel8 ) . add ( jTextField2 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel9 ) . add ( jTextField3 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel10 ) . add ( jTextField4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( 10 , 10 , 10 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jComboBox7 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) . add ( jLabel14 ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel11 ) . add ( jTextField5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel12 ) . add ( jTextField6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel13 ) . add ( jTextField7 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . RELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel15 ) . add ( jComboBox8 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . add ( 8 , 8 , 8 ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel4 ) . add ( jComboBox3 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jLabel5 ) . add ( jComboBox4 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel6 ) . add ( jComboBox5 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addPreferredGap ( org . jdesktop . layout . LayoutStyle . UNRELATED ) . add ( jPanel1Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . BASELINE ) . add ( jLabel7 ) . add ( jComboBox6 , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , org . jdesktop . layout . GroupLayout . PREFERRED_SIZE ) ) . addContainerGap ( 207 , Short . MAX_VALUE ) ) ) ; jTabbedPane6 . addTab ( bundle . getString ( "settings" ) , jPanel1 ) ; // NOI18N
jTabbedPane7 . setTabPlacement ( javax . swing . JTabbedPane . LEFT ) ; jScrollPane1 . setBorder ( null ) ; jTextPane1 . setEditable ( false ) ; jTextPane1 . setBorder ( null ) ; jTextPane1 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane1 . setViewportView ( jTextPane1 ) ; jTabbedPane7 . addTab ( "c#" , jScrollPane1 ) ; jScrollPane17 . setBorder ( null ) ; jTextPane12 . setEditable ( false ) ; jTextPane12 . setBorder ( null ) ; jTextPane12 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane17 . setViewportView ( jTextPane12 ) ; jTabbedPane7 . addTab ( "c++" , jScrollPane17 ) ; jScrollPane16 . setBorder ( null ) ; jTextPane11 . setEditable ( false ) ; jTextPane11 . setBorder ( null ) ; jTextPane11 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane16 . setViewportView ( jTextPane11 ) ; jTabbedPane7 . addTab ( "coffeescript" , jScrollPane16 ) ; jScrollPane2 . setBorder ( null ) ; jTextPane2 . setEditable ( false ) ; jTextPane2 . setBorder ( null ) ; jTextPane2 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane2 . setViewportView ( jTextPane2 ) ; jTabbedPane7 . addTab ( "dart" , jScrollPane2 ) ; jScrollPane15 . setBorder ( null ) ; jTextPane10 . setEditable ( false ) ; jTextPane10 . setBorder ( null ) ; jTextPane10 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane15 . setViewportView ( jTextPane10 ) ; jTabbedPane7 . addTab ( "groovy" , jScrollPane15 ) ; jScrollPane8 . setBorder ( null ) ; jTextPane3 . setEditable ( false ) ; jTextPane3 . setBorder ( null ) ; jTextPane3 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane8 . setViewportView ( jTextPane3 ) ; jTabbedPane7 . addTab ( "java" , jScrollPane8 ) ; jScrollPane9 . setBorder ( null ) ; jTextPane4 . setEditable ( false ) ; jTextPane4 . setBorder ( null ) ; jTextPane4 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane9 . setViewportView ( jTextPane4 ) ; jTabbedPane7 . addTab ( "js" , jScrollPane9 ) ; jScrollPane10 . setBorder ( null ) ; jTextPane5 . setEditable ( false ) ; jTextPane5 . setBorder ( null ) ; jTextPane5 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane10 . setViewportView ( jTextPane5 ) ; jTabbedPane7 . addTab ( "php" , jScrollPane10 ) ; jScrollPane11 . setBorder ( null ) ; jTextPane6 . setEditable ( false ) ; jTextPane6 . setBorder ( null ) ; jTextPane6 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane11 . setViewportView ( jTextPane6 ) ; jTabbedPane7 . addTab ( "python" , jScrollPane11 ) ; jScrollPane12 . setBorder ( null ) ; jTextPane7 . setEditable ( false ) ; jTextPane7 . setBorder ( null ) ; jTextPane7 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane12 . setViewportView ( jTextPane7 ) ; jTabbedPane7 . addTab ( "ruby" , jScrollPane12 ) ; jScrollPane13 . setBorder ( null ) ; jTextPane8 . setEditable ( false ) ; jTextPane8 . setBorder ( null ) ; jTextPane8 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane13 . setViewportView ( jTextPane8 ) ; jTabbedPane7 . addTab ( "scala" , jScrollPane13 ) ; jScrollPane14 . setBorder ( null ) ; jTextPane9 . setEditable ( false ) ; jTextPane9 . setBorder ( null ) ; jTextPane9 . setFont ( new java . awt . Font ( "SansSerif" , 0 , 14 ) ) ; // NOI18N
jScrollPane14 . setViewportView ( jTextPane9 ) ; jTabbedPane7 . addTab ( "typescript" , jScrollPane14 ) ; org . jdesktop . layout . GroupLayout jPanel3Layout = new org . jdesktop . layout . GroupLayout ( jPanel3 ) ; jPanel3 . setLayout ( jPanel3Layout ) ; jPanel3Layout . setHorizontalGroup ( jPanel3Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane7 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , 825 , Short . MAX_VALUE ) ) ; jPanel3Layout . setVerticalGroup ( jPanel3Layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane7 , org . jdesktop . layout . GroupLayout . DEFAULT_SIZE , 614 , Short . MAX_VALUE ) ) ; jTabbedPane6 . addTab ( bundle . getString ( "sourceCodes" ) , jPanel3 ) ; // NOI18N
org . jdesktop . layout . GroupLayout layout = new org . jdesktop . layout . GroupLayout ( getContentPane ( ) ) ; getContentPane ( ) . setLayout ( layout ) ; layout . setHorizontalGroup ( layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane6 ) ) ; layout . setVerticalGroup ( layout . createParallelGroup ( org . jdesktop . layout . GroupLayout . LEADING ) . add ( jTabbedPane6 ) ) ; pack ( ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jButton2ActionPerformed */
private void jTextField1ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jTextField1ActionPerformed
Object obj = jTextField1 . getSelectedItem ( ) ; if ( obj != null && evt . getActionCommand ( ) . equals ( "comboBoxEdited" ) ) { generateResult ( ) ; }


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jComboBox3ActionPerformed */
private void jButton4ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jButton4ActionPerformed
StringSelection ss = new StringSelection ( jTextArea1 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jButton4ActionPerformed */
private void jButton5ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jButton5ActionPerformed
StringSelection ss = new StringSelection ( jTextArea5 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jButton5ActionPerformed */
private void jButton6ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jButton6ActionPerformed
StringSelection ss = new StringSelection ( jTextArea7 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jButton6ActionPerformed */
private void jButton8ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jButton8ActionPerformed
StringSelection ss = new StringSelection ( jTextArea6 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jButton8ActionPerformed */
private void jButton9ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jButton9ActionPerformed
StringSelection ss = new StringSelection ( jTextArea4 . getText ( ) ) ; Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) . setContents ( ss , null ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jComboBox5ActionPerformed */
private void jComboBox6ActionPerformed ( java . awt . event . ActionEvent evt ) { } }

implementation:
// GEN - FIRST : event _ jComboBox6ActionPerformed
int selected = ( ( javax . swing . JComboBox ) evt . getSource ( ) ) . getSelectedIndex ( ) ; setupLanguage ( selected ) ;


signature:
public class MoneyToStrApp { /** * GEN - LAST : event _ jTextField7KeyTyped */
private void setupMoneyToStrVariables ( ) { } }

implementation: moneyToStrTxt = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . values ( ) [ jComboBox3 . getSelectedIndex ( ) ] ) ; moneyToStrNum = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . NUMBER ) ; if ( jComboBox2 . getSelectedIndex ( ) == 3 ) { String [ ] names = new String [ 8 ] ; names [ 0 ] = jTextField2 . getText ( ) ; names [ 1 ] = jTextField3 . getText ( ) ; names [ 2 ] = jTextField4 . getText ( ) ; names [ 3 ] = jComboBox7 . getModel ( ) . getSelectedItem ( ) . toString ( ) ; names [ 4 ] = jTextField5 . getText ( ) ; names [ 5 ] = jTextField6 . getText ( ) ; names [ 6 ] = jTextField7 . getText ( ) ; names [ 7 ] = jComboBox8 . getModel ( ) . getSelectedItem ( ) . toString ( ) ; moneyToStrTxt = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . values ( ) [ jComboBox3 . getSelectedIndex ( ) ] , names ) ; moneyToStrNum = new MoneyToStr ( MoneyToStr . Currency . values ( ) [ jComboBox2 . getSelectedIndex ( ) ] , MoneyToStr . Language . values ( ) [ jComboBox1 . getSelectedIndex ( ) ] , MoneyToStr . Pennies . NUMBER , names ) ; } boolean isCustomCurrency = jComboBox2 . getSelectedIndex ( ) == 3 ; jTextField2 . setEnabled ( isCustomCurrency ) ; jTextField3 . setEnabled ( isCustomCurrency ) ; jTextField4 . setEnabled ( isCustomCurrency ) ; jComboBox7 . setEnabled ( isCustomCurrency ) ; jTextField5 . setEnabled ( isCustomCurrency ) ; jTextField6 . setEnabled ( isCustomCurrency ) ; jTextField7 . setEnabled ( isCustomCurrency ) ; jComboBox8 . setEnabled ( isCustomCurrency ) ;


signature:
public class MoneyToStr { /** * Converts percent to string .
 * @ param amount the amount of percent
 * @ param lang the language ( RUS , UKR )
 * @ return the string of percent */
public static String percentToStr ( Double amount , Language lang ) { } }

implementation: return percentToStr ( amount , lang , Pennies . TEXT ) ;


signature:
public class MoneyToStr { /** * Converts percent to string .
 * @ param amount the amount of percent
 * @ param lang the language ( RUS , UKR , ENG )
 * @ param pennies the pennies ( NUMBER , TEXT )
 * @ return the string of percent */
public static String percentToStr ( Double amount , Language lang , Pennies pennies ) { } }

implementation: if ( amount == null ) { throw new IllegalArgumentException ( "amount is null" ) ; } if ( lang == null ) { throw new IllegalArgumentException ( "language is null" ) ; } if ( pennies == null ) { throw new IllegalArgumentException ( "pennies is null" ) ; } Long intPart = amount . longValue ( ) ; Long fractPart = 0L ; String result ; if ( amount . floatValue ( ) == amount . intValue ( ) ) { result = new MoneyToStr ( Currency . PER10 , lang , pennies ) . convert ( amount . longValue ( ) , 0L ) ; } else if ( Double . valueOf ( amount * NUM10 ) . floatValue ( ) == Double . valueOf ( amount * NUM10 ) . intValue ( ) ) { fractPart = Math . round ( ( amount - intPart ) * NUM10 ) ; result = new MoneyToStr ( Currency . PER10 , lang , pennies ) . convert ( intPart , fractPart ) ; } else if ( Double . valueOf ( amount * NUM100 ) . floatValue ( ) == Double . valueOf ( amount * NUM100 ) . intValue ( ) ) { fractPart = Math . round ( ( amount - intPart ) * NUM100 ) ; result = new MoneyToStr ( Currency . PER100 , lang , pennies ) . convert ( intPart , fractPart ) ; } else if ( Double . valueOf ( amount * NUM1000 ) . floatValue ( ) == Double . valueOf ( amount * NUM1000 ) . intValue ( ) ) { fractPart = Math . round ( ( amount - intPart ) * NUM1000 ) ; result = new MoneyToStr ( Currency . PER1000 , lang , pennies ) . convert ( intPart , fractPart ) ; } else { fractPart = Math . round ( ( amount - intPart ) * NUM10000 ) ; result = new MoneyToStr ( Currency . PER10000 , lang , pennies ) . convert ( intPart , fractPart ) ; } return result ;


signature:
public class MoneyToStr { /** * Converts double value to the text description .
 * @ param theMoney
 * the amount of money in format major . minor
 * @ return the string description of money value */
public String convert ( Double theMoney ) { } }

implementation: if ( theMoney == null ) { throw new IllegalArgumentException ( "theMoney is null" ) ; } Long intPart = theMoney . longValue ( ) ; Long fractPart = Math . round ( ( theMoney - intPart ) * NUM100 ) ; if ( currency == Currency . PER1000 ) { fractPart = Math . round ( ( theMoney - intPart ) * NUM1000 ) ; } return convert ( intPart , fractPart ) ;


signature:
public class MoneyToStr { /** * Converts amount to words . Usage : MoneyToStr moneyToStr =
 * new MoneyToStr ( MoneyToStr . Currency . UAH , MoneyToStr . Language . UKR , MoneyToStr . Pennies . NUMBER ) ;
 * String result = moneyToStr . convert ( 123D ) ; Expected : result = сто двадцять три гривні 00 копійок
 * @ param theMoney
 * the amount of money major currency
 * @ param theKopeiki
 * the amount of money minor currency
 * @ return the string description of money value */
public String convert ( Long theMoney , Long theKopeiki ) { } }

implementation: if ( theMoney == null ) { throw new IllegalArgumentException ( "theMoney is null" ) ; } if ( theKopeiki == null ) { throw new IllegalArgumentException ( "theKopeiki is null" ) ; } StringBuilder money2str = new StringBuilder ( ) ; Long triadNum = 0L ; Long theTriad ; Long intPart = theMoney ; if ( intPart == 0 ) { money2str . append ( messages . get ( "0" ) [ 0 ] + " " ) ; } do { theTriad = intPart % NUM1000 ; money2str . insert ( 0 , triad2Word ( theTriad , triadNum , rubSex ) ) ; if ( triadNum == 0 ) { if ( ( theTriad % NUM100 ) / NUM10 == NUM1 ) { money2str . append ( rubFiveUnit ) ; } else { switch ( Long . valueOf ( theTriad % NUM10 ) . byteValue ( ) ) { case NUM1 : money2str . append ( rubOneUnit ) ; break ; case NUM2 : case NUM3 : case NUM4 : money2str . append ( rubTwoUnit ) ; break ; default : money2str . append ( rubFiveUnit ) ; break ; } } } intPart /= NUM1000 ; triadNum ++ ; } while ( intPart > 0 ) ; if ( pennies == Pennies . TEXT ) { money2str . append ( language == Language . ENG ? " and " : " " ) . append ( theKopeiki == 0 ? messages . get ( "0" ) [ 0 ] + " " : triad2Word ( theKopeiki , 0L , kopSex ) ) ; } else { money2str . append ( " " + ( theKopeiki < 10 ? "0" + theKopeiki : theKopeiki ) + " " ) ; } if ( theKopeiki >= NUM11 && theKopeiki <= NUM14 ) { money2str . append ( kopFiveUnit ) ; } else { switch ( ( byte ) ( theKopeiki % NUM10 ) ) { case NUM1 : money2str . append ( kopOneUnit ) ; break ; case NUM2 : case NUM3 : case NUM4 : money2str . append ( kopTwoUnit ) ; break ; default : money2str . append ( kopFiveUnit ) ; break ; } } return money2str . toString ( ) . trim ( ) ;


signature:
public class LockManager { /** * Attempt to release any locks on shutdown so that other clients can obtain those locks without having to wait
 * for them to expire . */
public void shutdown ( ) { } }

implementation: try { locksExecutor . shutdown ( ) ; locksExecutor . awaitTermination ( 5 , TimeUnit . SECONDS ) ; CountDownLatch latch = new CountDownLatch ( 1 ) ; activeLocksLock . writeLock ( ) . lock ( ) ; Observable . from ( activeLocks . entrySet ( ) ) . map ( Map . Entry :: getValue ) . flatMap ( lock -> releaseLock ( lock . getName ( ) , lock . getValue ( ) ) . map ( released -> new Lock ( lock . getName ( ) , lock . getValue ( ) , lock . getExpiration ( ) , lock . getRenewalRate ( ) , ! released ) ) ) . subscribe ( lock -> { if ( lock . isLocked ( ) ) { logger . infof ( "Failed to release lock %s" , lock . getName ( ) ) ; } } , t -> { logger . info ( "There was an error while releasing locks" , t ) ; latch . countDown ( ) ; } , latch :: countDown ) ; latch . await ( ) ; logger . info ( "Shutdown complete" ) ; } catch ( InterruptedException e ) { logger . debug ( "Shutdown was interrupted. Some locks may not have been released but they will still expire." ) ; }


signature:
public class ObservableServlet { /** * Observes { @ link ServletOutputStream } .
 * This method uses Servlet 3.1 non - blocking API callback mechanisms . When the
 * container notifies that HTTP response can be written , the subscribed
 * { @ code Observer } ' s { @ link Observer # onNext onNext } method is invoked .
 * Before calling this method , a web application must put the corresponding HTTP
 * request into asynchronous mode .
 * @ param out servlet output stream
 * @ return Observable of HTTP response write ready events */
public static Observable < Void > create ( final ServletOutputStream out ) { } }

implementation: return Observable . unsafeCreate ( subscriber -> { final ServletWriteListener listener = new ServletWriteListener ( subscriber , out ) ; out . setWriteListener ( listener ) ; } ) ;


signature:
public class ObservableServlet { /** * Writes the given Observable data to ServletOutputStream .
 * This method uses Servlet 3.1 non - blocking API callback mechanisms . When the HTTP
 * request data becomes available to be read , the subscribed { @ code Observer } ' s
 * { @ link Observer # onNext onNext } method is invoked . Similarly , when all data for the
 * HTTP request has been read , the subscribed { @ code Observer } ' s
 * { @ link Observer # onCompleted onCompleted } method is invoked .
 * Before calling this method , a web application must put the corresponding HTTP request
 * into asynchronous mode .
 * @ param data
 * @ param out servlet output stream
 * @ return */
public static Observable < Void > write ( final Observable < byte [ ] > data , final ServletOutputStream out ) { } }

implementation: return Observable . create ( new Observable . OnSubscribe < Void > ( ) { @ Override public void call ( Subscriber < ? super Void > subscriber ) { Observable < Void > events = create ( out ) . onBackpressureBuffer ( ) ; Observable < Void > writeobs = Observable . zip ( data , events , ( b , aVoid ) -> { try { out . write ( b ) ; } catch ( IOException ioe ) { Exceptions . propagate ( ioe ) ; } return null ; } ) ; writeobs . subscribe ( subscriber ) ; } } ) ;


signature:
public class MetricsServiceImpl { /** * functionality into a separate class . */
@ Override public Observable < Void > addTags ( Metric < ? > metric , Map < String , String > tags ) { } }

implementation: try { checkArgument ( tags != null , "Missing tags" ) ; checkArgument ( isValidTagMap ( tags ) , "Invalid tags; tag key is required" ) ; } catch ( Exception e ) { return Observable . error ( e ) ; } return dataAccess . insertIntoMetricsTagsIndex ( metric , tags ) . concatWith ( dataAccess . addTags ( metric , tags ) ) . toList ( ) . map ( l -> null ) ;


signature:
public class MetricsServiceImpl { /** * Intended to be used at the startup of the MetricsServiceImpl to ensure we have enough tables for processing */
public void verifyAndCreateTempTables ( ) { } }

implementation: ZonedDateTime currentBlock = ZonedDateTime . ofInstant ( Instant . ofEpochMilli ( DateTimeService . now . get ( ) . getMillis ( ) ) , UTC ) . with ( DateTimeService . startOfPreviousEvenHour ( ) ) ; ZonedDateTime lastStartupBlock = currentBlock . plus ( 6 , ChronoUnit . HOURS ) ; verifyAndCreateTempTables ( currentBlock , lastStartupBlock ) . await ( ) ;


signature:
public class NamespaceListener { /** * Returns the namespace id for a particular namespace name
 * @ param namespaceName The name of the namespace
 * @ return The id of the namespace or null if the namespace does not exist */
public String getNamespaceId ( String namespaceName ) { } }

implementation: return namespaces . computeIfAbsent ( namespaceName , n -> getProjectId ( namespaceName , token ) ) ;


signature:
public class TokenAuthenticator { /** * Returns if the request is a query request , eg to perform a READ */
private boolean isQuery ( HttpServerExchange serverExchange ) { } }

implementation:
if ( serverExchange . getRequestMethod ( ) . toString ( ) . equalsIgnoreCase ( "GET" ) || serverExchange . getRequestMethod ( ) . toString ( ) . equalsIgnoreCase ( "HEAD" ) ) { // all GET requests are considered queries
return true ; } else if ( serverExchange . getRequestMethod ( ) . toString ( ) . equalsIgnoreCase ( "POST" ) ) { // some POST requests may be queries we need to check .
if ( postQuery != null && postQuery . matcher ( serverExchange . getRelativePath ( ) ) . find ( ) ) { return true ; } else { return false ; } } else { return false ; }


signature:
public class TokenAuthenticator { /** * Executed when a pooled connection is acquired . */
private void sendAuthenticationRequest ( HttpServerExchange serverExchange , PooledConnection connection ) { } }

implementation:
AuthContext context = serverExchange . getAttachment ( AUTH_CONTEXT_KEY ) ; String verb = getVerb ( serverExchange ) ; String resource ; // if we are not dealing with a query
if ( ! isQuery ( serverExchange ) ) { // is USER _ WRITE _ ACCESS is disabled , then use the legacy check .
// Otherwise check using the actual resource ( eg ' hawkular - metrics ' , ' hawkular - alerts ' , etc )
if ( USER_WRITE_ACCESS . equalsIgnoreCase ( "true" ) ) { resource = RESOURCE ; } else { resource = resourceName ; } } else { resource = RESOURCE ; } context . subjectAccessReview = generateSubjectAccessReview ( context . tenant , verb , resource ) ; ClientRequest request = buildClientRequest ( context ) ; context . clientRequestStarting ( ) ; connection . sendRequest ( request , new RequestReadyCallback ( serverExchange , connection ) ) ;


signature:
public class TokenAuthenticator { /** * Determine the verb we should apply based on the HTTP method being requested .
 * @ return the verb to use */
private String getVerb ( HttpServerExchange serverExchange ) { } }

implementation:
// if its a query type verb , then treat as a GET type call .
if ( isQuery ( serverExchange ) ) { return VERBS . get ( GET ) ; } else { String verb = VERBS . get ( serverExchange . getRequestMethod ( ) ) ; if ( verb == null ) { log . debugf ( "Unhandled http method '%s'. Checking for read access." , serverExchange . getRequestMethod ( ) ) ; verb = VERBS_DEFAULT ; } return verb ; }


signature:
public class TokenAuthenticator { /** * Generates a SubjectAccessReview object used to request if a user has a certain permission or not .
 * @ param namespace the namespace
 * @ param verb the requested permission
 * @ return JSON text representation of the SubjectAccessReview object */
private String generateSubjectAccessReview ( String namespace , String verb , String resource ) { } }

implementation: ObjectNode objectNode = objectMapper . createObjectNode ( ) ; objectNode . put ( "apiVersion" , "v1" ) ; objectNode . put ( "kind" , KIND ) ; objectNode . put ( "resource" , resource ) ; objectNode . put ( "verb" , verb ) ; objectNode . put ( "namespace" , namespace ) ; return objectNode . toString ( ) ;


signature:
public class TokenAuthenticator { /** * Called when the Kubernetes master server reponse has been inspected . */
private void onRequestResult ( HttpServerExchange serverExchange , PooledConnection connection , boolean allowed ) { } }

implementation:
connectionPools . get ( serverExchange . getIoThread ( ) ) . release ( connection ) ; // Remove attachment early to make it eligible for GC
AuthContext context = serverExchange . removeAttachment ( AUTH_CONTEXT_KEY ) ; apiLatency . update ( context . getClientResponseTime ( ) , NANOSECONDS ) ; authLatency . update ( context . getLatency ( ) , NANOSECONDS ) ; if ( allowed ) { serverExchange . dispatch ( containerHandler ) ; } else { endExchange ( serverExchange , FORBIDDEN ) ; }


signature:
public class TokenAuthenticator { /** * Called if an exception occurs at any stage in the process . */
private void onRequestFailure ( HttpServerExchange serverExchange , PooledConnection connection , IOException e , boolean retry ) { } }

implementation: log . debug ( "Client request failure" , e ) ; IoUtils . safeClose ( connection ) ; ConnectionPool connectionPool = connectionPools . get ( serverExchange . getIoThread ( ) ) ; connectionPool . release ( connection ) ; AuthContext context = serverExchange . getAttachment ( AUTH_CONTEXT_KEY ) ; if ( context . retries < MAX_RETRY && retry ) { context . retries ++ ; PooledConnectionWaiter waiter = createWaiter ( serverExchange ) ; if ( ! connectionPool . offer ( waiter ) ) { endExchange ( serverExchange , INTERNAL_SERVER_ERROR , TOO_MANY_PENDING_REQUESTS ) ; } } else { endExchange ( serverExchange , INTERNAL_SERVER_ERROR , CLIENT_REQUEST_FAILURE ) ; }


signature:
public class ConfigurationService { /** * eventually I would like service initialization async . */
public void init ( RxSession session ) { } }

implementation: this . session = session ; findConfigurationGroup = session . getSession ( ) . prepare ( "SELECT name, value FROM sys_config WHERE config_id = ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; findConfigurationValue = session . getSession ( ) . prepare ( "SELECT value FROM sys_config WHERE config_id = ? AND name= ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; updateConfigurationValue = session . getSession ( ) . prepare ( "INSERT INTO sys_config (config_id, name, value) VALUES (?, ?, ?)" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; deleteConfigurationValue = session . getSession ( ) . prepare ( "DELETE FROM sys_config WHERE config_id =? and name = ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ; deleteConfiguration = session . getSession ( ) . prepare ( "DELETE FROM sys_config WHERE config_id = ?" ) . setConsistencyLevel ( ConsistencyLevel . LOCAL_QUORUM ) ;


signature:
public class SchedulerImpl { /** * If a job is single execution then this is a no - op ; otherwise , the scheduled jobs index and jobs tables are
 * updated with the next execution time / details . If the job has missed its next execution , it will get scheduled
 * in the next available time slice . The job scheduler will actually execute the job immediately when the job falls
 * behind , but we still want to persist the scheduling update for durability . */
private Single < JobExecutionState > reschedule ( JobExecutionState executionState ) { } }

implementation: Trigger nextTrigger = executionState . currentDetails . getTrigger ( ) . nextTrigger ( ) ; if ( nextTrigger == null ) { logger . debugf ( "No more scheduled executions for %s" , executionState . currentDetails ) ; return Single . just ( executionState ) ; } JobDetailsImpl details = executionState . currentDetails ; JobDetailsImpl newDetails = new JobDetailsImpl ( details , nextTrigger ) ; if ( nextTrigger . getTriggerTime ( ) <= now . get ( ) . getMillis ( ) ) { logger . infof ( "%s missed its next execution at %d. It will be rescheduled for immediate execution." , details , nextTrigger . getTriggerTime ( ) ) ; AtomicLong nextTimeSlice = new AtomicLong ( currentMinute ( ) . getMillis ( ) ) ; Observable < Lock > scheduled = Observable . defer ( ( ) -> lockManager . acquireLock ( QUEUE_LOCK_PREFIX + nextTimeSlice . addAndGet ( 60000L ) , SCHEDULING_LOCK , SCHEDULING_LOCK_TIMEOUT_IN_SEC , false ) ) . map ( lock -> { if ( ! lock . isLocked ( ) ) { throw new RuntimeException ( ) ; } return lock ; } ) . retry ( ) ; return scheduled . map ( lock -> new JobExecutionState ( executionState . currentDetails , executionState . timeSlice , newDetails , new Date ( nextTimeSlice . get ( ) ) , executionState . activeJobs ) ) . flatMap ( state -> jobsService . insert ( state . nextTimeSlice , state . nextDetails ) . map ( updated -> state ) ) . doOnNext ( state -> logger . debugf ( "Rescheduled %s to execute in time slice %s with trigger time " + "of %s" , state . nextDetails . getJobName ( ) , state . nextTimeSlice , new Date ( state . nextDetails . getTrigger ( ) . getTriggerTime ( ) ) ) ) . toSingle ( ) ; } logger . debugf ( "Scheduling %s for next execution at %s" , newDetails , new Date ( nextTrigger . getTriggerTime ( ) ) ) ; JobExecutionState newState = new JobExecutionState ( details , executionState . timeSlice , newDetails , new Date ( nextTrigger . getTriggerTime ( ) ) , executionState . activeJobs ) ; return jobsService . insert ( newState . nextTimeSlice , newState . nextDetails ) . map ( updated -> newState ) . toSingle ( ) ;


signature:
public class JobsService { /** * This method is currently unused . */
public Observable < JobDetails > findScheduledJobs ( Date timeSlice , rx . Scheduler scheduler ) { } }

implementation: return session . executeAndFetch ( findAllScheduled . bind ( ) , scheduler ) . filter ( filterNullJobs ) . filter ( row -> row . getTimestamp ( 0 ) . compareTo ( timeSlice ) <= 0 ) . map ( row -> createJobDetails ( row . getUUID ( 1 ) , row . getString ( 2 ) , row . getString ( 3 ) , row . getMap ( 4 , String . class , String . class ) , getTrigger ( row . getUDTValue ( 5 ) ) , JobStatus . fromCode ( row . getByte ( 6 ) ) , timeSlice ) ) . collect ( HashMap :: new , ( Map < UUID , SortedSet < JobDetails > > map , JobDetails details ) -> { SortedSet < JobDetails > set = map . get ( details . getJobId ( ) ) ; if ( set == null ) { set = new TreeSet < > ( ( JobDetails d1 , JobDetails d2 ) -> Long . compare ( d1 . getTrigger ( ) . getTriggerTime ( ) , d2 . getTrigger ( ) . getTriggerTime ( ) ) ) ; } set . add ( details ) ; map . put ( details . getJobId ( ) , set ) ; } ) . flatMap ( map -> Observable . from ( map . entrySet ( ) ) ) . map ( entry -> entry . getValue ( ) . first ( ) ) ;


signature:
public class BucketPoint { /** * Converts bucket points indexed by start time into a list , ordered by start time . Blanks will be filled with
 * empty bucket points . */
public static < T extends BucketPoint > List < T > toList ( Map < Long , T > pointMap , Buckets buckets , BiFunction < Long , Long , T > emptyBucketFactory ) { } }

implementation: List < T > result = new ArrayList < > ( buckets . getCount ( ) ) ; for ( int index = 0 ; index < buckets . getCount ( ) ; index ++ ) { long from = buckets . getBucketStart ( index ) ; T bucketPoint = pointMap . get ( from ) ; if ( bucketPoint == null ) { long to = from + buckets . getStep ( ) ; bucketPoint = emptyBucketFactory . apply ( from , to ) ; } result . add ( bucketPoint ) ; } return result ;


signature:
public class JobsServiceImpl { /** * JMX management */
private void submitCompressJob ( Map < String , String > parameters ) { } }

implementation:
String jobName = String . format ( "%s_single_%s" , CompressData . JOB_NAME , parameters . get ( CompressData . TARGET_TIME ) ) ; // Blocking to ensure it is actually scheduled . .
scheduler . scheduleJob ( CompressData . JOB_NAME , jobName , parameters , new SingleExecutionTrigger . Builder ( ) . withDelay ( 1 , TimeUnit . MINUTES ) . build ( ) ) . toBlocking ( ) . value ( ) ;


signature:
public class PatternUtil { /** * Allow special cases to Pattern matching , such as " * " - > " . * " and ! indicating the match shouldn ' t
 * happen . The first ! indicates the rest of the pattern should not match .
 * @ param inputRegexp Regexp given by the user
 * @ return Pattern modified to allow special cases in the query language */
public static Pattern filterPattern ( String inputRegexp ) { } }

implementation: if ( inputRegexp . equals ( "*" ) ) { inputRegexp = ".*" ; } else if ( inputRegexp . startsWith ( "!" ) ) { inputRegexp = inputRegexp . substring ( 1 ) ; } return Pattern . compile ( inputRegexp ) ; // Catch incorrect patterns . .


signature:
public class GCGraceSecondsManager { /** * Asynchronously performs gc _ grace _ seconds updates if necessary . This method should < strong > not < / strong > be called
 * until schema updates have finished . */
public void maybeUpdateGCGraceSeconds ( ) { } }

implementation:
logger . info ( "Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated" ) ; Stopwatch stopwatch = Stopwatch . createStarted ( ) ; Map < String , String > replication = session . getCluster ( ) . getMetadata ( ) . getKeyspace ( keyspace ) . getReplication ( ) ; String replicationFactor = replication . get ( "replication_factor" ) ; Completable check ; if ( getClusterSize ( ) == 1 || replicationFactor . equals ( "1" ) ) { check = updateAllGCGraceSeconds ( 0 ) ; } else { // Need to call Completable . merge in order for subscriptions to happen correctly . See https : / / goo . gl / l15CRV
check = Completable . merge ( configurationService . load ( "org.hawkular.metrics" , "gcGraceSeconds" ) . switchIfEmpty ( Observable . just ( Integer . toString ( DEFAULT_GC_GRACE_SECONDS ) ) ) . map ( property -> { int gcGraceSeconds = Integer . parseInt ( property ) ; return updateAllGCGraceSeconds ( gcGraceSeconds ) ; } ) ) ; } check . subscribe ( ( ) -> { stopwatch . stop ( ) ; logger . info ( "Finished gc_grace_seconds updates in " + stopwatch . elapsed ( TimeUnit . MILLISECONDS ) + " ms" ) ; updatesFinished . ifPresent ( subject -> subject . onNext ( null ) ) ; } , t -> { logger . warn ( "There was an error checking and updating gc_grace_seconds" ) ; updatesFinished . ifPresent ( subject -> subject . onNext ( t ) ) ; } ) ;


signature:
public class Utils { /** * Changes the status code of the response , sets the HTTP reason phrase and ends the exchange .
 * @ param exchange the HTTP server request / response exchange
 * @ param statusCode the HTTP status code
 * @ param reasonPhrase the HTTP status message
 * @ see HttpServerExchange # setStatusCode ( int )
 * @ see HttpServerExchange # setReasonPhrase ( String )
 * @ see HttpServerExchange # endExchange ( ) */
public static void endExchange ( HttpServerExchange exchange , int statusCode , String reasonPhrase ) { } }

implementation: exchange . setStatusCode ( statusCode ) ; if ( reasonPhrase != null ) { exchange . setReasonPhrase ( reasonPhrase ) ; } exchange . endExchange ( ) ;


signature:
public class Interval { /** * Parses the string into an interval . The string must match the regular expression ( \ d + ) ( min | hr | d ) ; otherwise ,
 * an exception is thrown .
 * @ param s The string to parse
 * @ return The { @ link Interval }
 * @ throws java . lang . IllegalArgumentException if the string does not parse */
public static Interval parse ( String s ) { } }

implementation: if ( s . isEmpty ( ) ) { return NONE ; } Matcher matcher = INTERVAL_PATTERN . matcher ( s ) ; if ( ! ( matcher . matches ( ) && matcher . groupCount ( ) == 2 ) ) { throw new IllegalArgumentException ( s + " is not a valid interval. It must follow the pattern " + INTERVAL_PATTERN . pattern ( ) ) ; } return new Interval ( Integer . parseInt ( matcher . group ( 1 ) ) , Units . fromCode ( matcher . group ( 2 ) ) ) ;


signature:
public class DataAccessImpl { /** * Fetch all the data from a temporary table for the compression job . Using TokenRanges avoids fetching first
 * all the metrics ' partition keys and then requesting them .
 * Performance can be improved by using data locality and fetching with multiple threads .
 * @ param timestamp A timestamp inside the wanted bucket ( such as the previous starting row timestamp )
 * @ param pageSize How many rows to fetch each time
 * @ param maxConcurrency To how many streams should token ranges be split to
 * @ return Observable of Observables per partition key */
@ Override public Observable < Observable < Row > > findAllDataFromBucket ( long timestamp , int pageSize , int maxConcurrency ) { } }

implementation:
PreparedStatement ts = getTempStatement ( MetricType . UNDEFINED , TempStatement . SCAN_WITH_TOKEN_RANGES , timestamp ) ; // The table does not exists - case such as when starting Hawkular - Metrics for the first time just before
// compression kicks in .
if ( ts == null || prepMap . floorKey ( timestamp ) == 0L ) { return Observable . empty ( ) ; } return Observable . from ( getTokenRanges ( ) ) . map ( tr -> rxSession . executeAndFetch ( ts . bind ( ) . setToken ( 0 , tr . getStart ( ) ) . setToken ( 1 , tr . getEnd ( ) ) . setFetchSize ( pageSize ) ) ) ;


signature:
public class DataAccessImpl { /** * Applies micro - batching capabilities by taking advantage of token ranges in the Cassandra */
private Observable . Transformer < BoundStatement , Integer > applyMicroBatching ( ) { } }

implementation: return tObservable -> tObservable . groupBy ( b -> { ByteBuffer routingKey = b . getRoutingKey ( ProtocolVersion . NEWEST_SUPPORTED , codecRegistry ) ; Token token = metadata . newToken ( routingKey ) ; for ( TokenRange tokenRange : session . getCluster ( ) . getMetadata ( ) . getTokenRanges ( ) ) { if ( tokenRange . contains ( token ) ) { return tokenRange ; } } log . warn ( "Unable to find any Cassandra node to insert token " + token . toString ( ) ) ; return session . getCluster ( ) . getMetadata ( ) . getTokenRanges ( ) . iterator ( ) . next ( ) ; } ) . flatMap ( g -> g . compose ( new BoundBatchStatementTransformer ( ) ) ) . flatMap ( batch -> rxSession . execute ( batch ) . compose ( applyInsertRetryPolicy ( ) ) . map ( resultSet -> batch . size ( ) ) ) ;


signature:
public class DataAccessImpl { /** * Apply our current retry policy to the insert behavior */
private < T > Observable . Transformer < T , T > applyInsertRetryPolicy ( ) { } }

implementation: return tObservable -> tObservable . retryWhen ( errors -> { Observable < Integer > range = Observable . range ( 1 , 2 ) ; return errors . zipWith ( range , ( t , i ) -> { if ( t instanceof DriverException ) { return i ; } throw Exceptions . propagate ( t ) ; } ) . flatMap ( retryCount -> { long delay = ( long ) Math . min ( Math . pow ( 2 , retryCount ) * 1000 , 3000 ) ; log . debug ( "Retrying batch insert in " + delay + " ms" ) ; return Observable . timer ( delay , TimeUnit . MILLISECONDS ) ; } ) ; } ) ;


signature:
public class Buckets { /** * Force bucket count . This method does not guarantee that the last bucket includes the { @ code end } value .
 * @ param start start time
 * @ param end end time
 * @ param count desired number of buckets
 * @ return an instance of { @ link Buckets } , starting at { @ code start } , separated by { @ code count } intervals */
public static Buckets fromCount ( long start , long end , int count ) { } }

implementation:
checkTimeRange ( start , end ) ; checkArgument ( count > 0 , "count is not positive: %s" , count ) ; long quotient = ( end - start ) / count ; long remainder = ( end - start ) % count ; long step ; // count * quotient + remainder = end - start
// If the remainder is greater than zero , we should try with ( quotient + 1 ) , provided that this greater step
// does not make the number of buckets smaller than the expected count
if ( remainder != 0 && ( count - 1 ) * ( quotient + 1 ) < ( end - start ) ) { step = quotient + 1 ; } else { step = quotient ; } checkArgument ( step > 0 , "Computed step is equal to zero" ) ; return new Buckets ( start , step , count ) ;


signature:
public class Buckets { /** * Force bucket step .
 * @ param start start time
 * @ param end end time
 * @ param step desired step
 * @ return an instance of { @ link Buckets } , starting at { @ code start } , separated by intervals of size { @ code step } */
public static Buckets fromStep ( long start , long end , long step ) { } }

implementation: checkTimeRange ( start , end ) ; checkArgument ( step > 0 , "step is not positive: %s" , step ) ; if ( step > ( end - start ) ) { return new Buckets ( start , step , 1 ) ; } long quotient = ( end - start ) / step ; long remainder = ( end - start ) % step ; long count ; if ( remainder == 0 ) { count = quotient ; } else { count = quotient + 1 ; } checkArgument ( count <= Integer . MAX_VALUE , "Computed number of buckets is too big: %s" , count ) ; return new Buckets ( start , step , ( int ) count ) ;


signature:
public class DefaultRocketMqProducer { /** * send msg .
 * @ param msg content
 * @ return send result */
public boolean sendMsg ( Message msg ) { } }

implementation: SendResult sendResult = null ; try { sendResult = producer . send ( msg ) ; } catch ( Exception e ) { logger . error ( "send msg error" , e ) ; } return sendResult != null && sendResult . getSendStatus ( ) == SendStatus . SEND_OK ;


signature:
public class DefaultRocketMqProducer { /** * sene one way msg .
 * @ param msg msg */
public void sendOneWayMsg ( Message msg ) { } }

implementation: try { producer . sendOneway ( msg ) ; } catch ( Exception e ) { logger . error ( "send msg error" , e ) ; }


signature:
public class DefaultRocketMqProducer { /** * send delay msg .
 * @ param msg content
 * @ param delayLevel 1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
 * @ return send result */
public boolean sendDelayMsg ( String topic , String tag , Message msg , int delayLevel ) { } }

implementation: msg . setDelayTimeLevel ( delayLevel ) ; SendResult sendResult = null ; try { sendResult = producer . send ( msg ) ; } catch ( Exception e ) { logger . error ( "send msg error" , e ) ; } return sendResult != null && sendResult . getSendStatus ( ) == SendStatus . SEND_OK ;


signature:
public class MockJedis { /** * In this simple proposal , we ' re not testing complex iterations
 * of scan cursor . SCAN is simply a wrapper for KEYS , and the result
 * is given in one single response , no matter the COUNT argument . */
@ Override public ScanResult < String > scan ( String cursor , ScanParams params ) { } }

implementation:
// We need to extract the MATCH argument from the scan params
Collection < byte [ ] > rawParams = params . getParams ( ) ; // Raw collection is a list of byte [ ] , made of : key1 , value1 , key2 , value2 , etc .
boolean isKey = true ; String match = null ; boolean foundMatchKey = false ; // So , we run over the list , where any even index is a key , and the following data is its value .
for ( byte [ ] raw : rawParams ) { if ( isKey ) { String key = new String ( raw ) ; if ( key . equals ( new String ( MATCH . raw ) ) ) { // What really interests us is the MATCH key .
foundMatchKey = true ; } } // As soon as we ' ve found the MATCH key , we can stop searching .
else if ( foundMatchKey ) { match = new String ( raw ) ; break ; } isKey = ! isKey ; } // Our simple implementation of SCAN is really a plain wrapper for KEYS ,
// relying on the current mock implementation of the pattern search .
return new ScanResult < String > ( "0" , new ArrayList < String > ( keys ( match ) ) ) ;


signature:
public class WildcardMatcher { /** * Performs a wildcard matching for the text and pattern
 * provided .
 * Source : http : / / www . adarshr . com / papers / wildcard
 * @ param text the text to be tested for matches .
 * @ param pattern the pattern to be matched for .
 * This can contain the wildcard character ' * ' ( asterisk ) .
 * @ return < tt > true < / tt > if a match is found , < tt > false < / tt >
 * otherwise . */
public boolean match ( String text , final String pattern ) { } }

implementation:
// Create the cards by splitting using a RegEx . If more speed
// is desired , a simpler character based splitting can be done .
final String [ ] cards = REGEX_STAR . split ( pattern ) ; final int numCards = cards . length ; // Iterate over the cards .
for ( int i = 0 ; i < numCards ; ++ i ) { final String card = cards [ i ] ; final int idx = text . indexOf ( card ) ; // Card not detected in the text .
if ( idx == - 1 ) { return false ; } if ( idx != 0 && i == 0 ) { return false ; // test needs to start from ' card '
} // Move ahead , towards the right of the text .
text = text . substring ( idx + card . length ( ) ) ; } return true ;


signature:
public class CIEnvironment { /** * https : / / confluence . atlassian . com / bamboo / bamboo - variables - 289277087 . html */
private static CIEnvironment detectBamboo ( Map < String , String > env ) { } }

implementation: String revision = env . get ( "bamboo_planRepository_revision" ) ; String branch = env . get ( "bamboo_repository_git_branch" ) ; if ( revision == null || branch == null ) return null ; String tag = null ; String projectName = env . get ( "bamboo_planRepository_name" ) ; return new CIEnvironment ( "Bamboo" , revision , branch , tag , projectName ) ;


signature:
public class CIEnvironment { /** * https : / / docs . travis - ci . com / user / environment - variables / # Default - Environment - Variables */
private static CIEnvironment detectTravis ( Map < String , String > env ) { } }

implementation: String revision = env . get ( "TRAVIS_COMMIT" ) ; String branch = env . get ( "TRAVIS_BRANCH" ) ; if ( revision == null || branch == null ) return null ; String tag = null ; String repoSlug = env . get ( "TRAVIS_REPO_SLUG" ) ; String projectName = repoSlug . split ( "/" ) [ 1 ] ; return new CIEnvironment ( "Travis CI" , revision , branch , tag , projectName ) ;


signature:
public class Config { /** * Use by loaders */
public void setValue ( String property , Value value ) { } }

implementation: this . valueByProperty . put ( property . toLowerCase ( ) , value ) ;


signature:
public class ZipBuilder { /** * Add a file to the ZIP .
 * @ param file The file to add
 * @ param preserveExternalFileName Whether external file names are to be preserved as much as possible , or whether
 * they should be replaced with unique numbers
 * @ return The name of the ZIP entry */
public String add ( File file , boolean preserveExternalFileName ) { } }

implementation: File existingFile = checkFileExists ( file ) ; String result = zipPathFor ( existingFile , preserveExternalFileName ) ; entries . put ( existingFile , result ) ; return result ;


signature:
public class ZipBuilder { /** * Replace the contents of a file with a different text .
 * @ param file The file for which to replace the content
 * @ param preserveExternalFileName Whether external file names are to be preserved as much as possible , or whether
 * they should be replaced with unique numbers
 * @ param text The new content to include in the ZIP */
public void replace ( File file , boolean preserveExternalFileName , String text ) { } }

implementation: String path = entries . containsKey ( file ) ? entries . remove ( file ) : zipPathFor ( file , preserveExternalFileName ) ; entries . put ( text , path ) ;


signature:
public class ZipBuilder { /** * Build a ZIP file containing the added entries .
 * @ return A ZIP file containing the added entries
 * @ throws IOException In case an I / O error occurs */
public File build ( ) throws IOException { } }

implementation: if ( entries . isEmpty ( ) ) { throw new EmptyZipException ( ) ; } String fileName = "import_configuration" + System . currentTimeMillis ( ) + ".zip" ; File result = new File ( TEMP_DIR . toFile ( ) , fileName ) ; try ( ZipOutputStream zip = new ZipOutputStream ( Files . newOutputStream ( result . toPath ( ) , StandardOpenOption . CREATE_NEW ) ) ) { customization . init ( entries . values ( ) , this :: streamFor ) ; for ( Entry < Object , String > entry : entries . entrySet ( ) ) { try ( InputStream input = toInputStream ( entry . getKey ( ) ) ) { addEntry ( ExtraZipEntry . of ( entry . getValue ( ) , customization . customize ( entry . getValue ( ) , input ) ) , zip ) ; } } customization . extraEntries ( ) . forEach ( entry -> addEntry ( entry , zip ) ) ; zip . closeEntry ( ) ; } return result ;