idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
37,700
private String optionListToHtml ( List < Options . OptionInfo > optList , int padding , int firstLinePadding , int refillWidth ) { StringJoiner b = new StringJoiner ( lineSep ) ; for ( Options . OptionInfo oi : optList ) { if ( oi . unpublicized ) { continue ; } StringBuilder bb = new StringBuilder ( ) ; String optHtml = optionToHtml ( oi , padding ) ; bb . append ( StringUtils . repeat ( " " , padding ) ) ; bb . append ( "<li id=\"option:" + oi . longName + "\">" ) . append ( optHtml ) ; if ( refillWidth <= 0 ) { b . add ( bb ) ; } else { b . add ( refill ( bb . toString ( ) , padding , firstLinePadding , refillWidth ) ) ; } } return b . toString ( ) ; }
Get the HTML describing many options formatted as an HTML list .
37,701
public String optionToHtml ( Options . OptionInfo oi , int padding ) { StringBuilder b = new StringBuilder ( ) ; Formatter f = new Formatter ( b ) ; if ( oi . shortName != null ) { f . format ( "<b>-%s</b> " , oi . shortName ) ; } for ( String a : oi . aliases ) { f . format ( "<b>%s</b> " , a ) ; } String prefix = getUseSingleDash ( ) ? "-" : "--" ; f . format ( "<b>%s%s=</b><i>%s</i>" , prefix , oi . longName , oi . typeName ) ; if ( oi . list != null ) { b . append ( " <code>[+]</code>" ) ; } f . format ( ".%n " ) ; f . format ( "%s" , StringUtils . repeat ( " " , padding ) ) ; String jdoc = ( ( oi . jdoc == null ) ? "" : oi . jdoc ) ; if ( oi . noDocDefault || oi . defaultStr == null ) { f . format ( "%s" , jdoc ) ; } else { String defaultStr = "default " + oi . defaultStr ; String suffix = "" ; if ( jdoc . endsWith ( "</p>" ) ) { suffix = "</p>" ; jdoc = jdoc . substring ( 0 , jdoc . length ( ) - suffix . length ( ) ) ; } f . format ( "%s [%s]%s" , jdoc , StringEscapeUtils . escapeHtml4 ( defaultStr ) , suffix ) ; } if ( oi . baseType . isEnum ( ) ) { b . append ( lineSep ) . append ( "<ul>" ) . append ( lineSep ) ; assert oi . enumJdoc != null : "@AssumeAssertion(nullness): dependent: non-null if oi.baseType is an enum" ; for ( Map . Entry < String , String > entry : oi . enumJdoc . entrySet ( ) ) { b . append ( " <li><b>" ) . append ( entry . getKey ( ) ) . append ( "</b>" ) ; if ( entry . getValue ( ) . length ( ) != 0 ) { b . append ( " " ) . append ( entry . getValue ( ) ) ; } b . append ( lineSep ) ; } b . append ( "</ul>" ) . append ( lineSep ) ; } return b . toString ( ) ; }
Get the line of HTML describing one Option .
37,702
public void setFormatJavadoc ( boolean val ) { if ( val && ! formatJavadoc ) { startDelim = "* " + startDelim ; endDelim = "* " + endDelim ; } else if ( ! val && formatJavadoc ) { startDelim = StringUtils . removeStart ( "* " , startDelim ) ; endDelim = StringUtils . removeStart ( "* " , endDelim ) ; } this . formatJavadoc = val ; }
Supply true to set the output format to Javadoc false to set the output format to HTML .
37,703
public synchronized void onLowMemory ( ) { try { this . mCachedTiles . clear ( ) ; } catch ( Exception e ) { log . log ( Level . SEVERE , "onLowMemory" , e ) ; } }
This method clears the memory cache
37,704
public TransportApiResult < Journey > getJourney ( String journeyId , String exclude ) { if ( Extensions . isNullOrWhiteSpace ( journeyId ) ) { throw new IllegalArgumentException ( "JourneyId is required." ) ; } return TransportApiClientCalls . getJourney ( tokenComponent , settings , journeyId , exclude ) ; }
Gets a journey previously requested through the POST journey call .
37,705
public TransportApiResult < Itinerary > getItinerary ( String journeyId , String itineraryId , String exclude ) { if ( Extensions . isNullOrWhiteSpace ( journeyId ) ) { throw new IllegalArgumentException ( "JourneyId is required." ) ; } if ( Extensions . isNullOrWhiteSpace ( itineraryId ) ) { throw new IllegalArgumentException ( "ItineraryId is required." ) ; } return TransportApiClientCalls . getItinerary ( tokenComponent , settings , journeyId , itineraryId , exclude ) ; }
Gets a specific itinerary of a journey previously requested through the POST journey call .
37,706
public TransportApiResult < List < Agency > > getAgencies ( AgencyQueryOptions options ) { if ( options == null ) { options = AgencyQueryOptions . defaultQueryOptions ( ) ; } return TransportApiClientCalls . getAgencies ( tokenComponent , settings , options , null , null , null ) ; }
Gets a list of all agencies in the system .
37,707
public TransportApiResult < List < Agency > > getAgenciesByBoundingBox ( AgencyQueryOptions options , String boundingBox ) { if ( options == null ) { options = AgencyQueryOptions . defaultQueryOptions ( ) ; } if ( boundingBox == null ) { throw new IllegalArgumentException ( "BoundingBox is required." ) ; } String [ ] bbox = boundingBox . split ( "," , - 1 ) ; if ( bbox . length != 4 ) { throw new IllegalArgumentException ( "Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box." ) ; } return TransportApiClientCalls . getAgencies ( tokenComponent , settings , options , null , null , boundingBox ) ; }
Gets a list of all agencies within a bounding box .
37,708
public TransportApiResult < Agency > getAgency ( String agencyId ) { if ( Extensions . isNullOrWhiteSpace ( agencyId ) ) { throw new IllegalArgumentException ( "AgencyId is required." ) ; } return TransportApiClientCalls . getAgency ( tokenComponent , settings , agencyId ) ; }
Gets a specific agency .
37,709
public TransportApiResult < List < Line > > getLines ( LineQueryOptions options ) { if ( options == null ) { options = LineQueryOptions . defaultQueryOptions ( ) ; } return TransportApiClientCalls . getLines ( tokenComponent , settings , options , null , null , null ) ; }
Gets a list of all lines in the system .
37,710
public TransportApiResult < List < Line > > getLinesNearby ( LineQueryOptions options , double latitude , double longitude , int radiusInMeters ) { if ( options == null ) { options = LineQueryOptions . defaultQueryOptions ( ) ; } if ( radiusInMeters < 0 ) { throw new IllegalArgumentException ( "Invalid limit. Valid values are positive numbers only." ) ; } return TransportApiClientCalls . getLines ( tokenComponent , settings , options , new Point ( longitude , latitude ) , radiusInMeters , null ) ; }
Gets a list of lines nearby ordered by distance from the point specified .
37,711
public TransportApiResult < List < Line > > getLinesByBoundingBox ( LineQueryOptions options , String boundingBox ) { if ( options == null ) { options = LineQueryOptions . defaultQueryOptions ( ) ; } if ( boundingBox == null ) { throw new IllegalArgumentException ( "BoundingBox is required." ) ; } String [ ] bbox = boundingBox . split ( "," , - 1 ) ; if ( bbox . length != 4 ) { throw new IllegalArgumentException ( "Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box." ) ; } return TransportApiClientCalls . getLines ( tokenComponent , settings , options , null , null , boundingBox ) ; }
Gets a list of all lines within a bounding box .
37,712
public TransportApiResult < Line > getLine ( String lineId ) { if ( Extensions . isNullOrWhiteSpace ( lineId ) ) { throw new IllegalArgumentException ( "LineId is required." ) ; } return TransportApiClientCalls . getLine ( tokenComponent , settings , lineId ) ; }
Gets a specific line .
37,713
public TransportApiResult < List < LineTimetable > > getLineTimetable ( String lineId , LineTimetableQueryOptions options ) { if ( Extensions . isNullOrWhiteSpace ( lineId ) ) { throw new IllegalArgumentException ( "LineId is required." ) ; } if ( options == null ) { options = LineTimetableQueryOptions . defaultQueryOptions ( ) ; } return TransportApiClientCalls . getLineTimetable ( tokenComponent , settings , lineId , options ) ; }
Gets a timetable for a specific line .
37,714
public TransportApiResult < List < Stop > > getStops ( StopQueryOptions options ) { if ( options == null ) { options = StopQueryOptions . defaultQueryOptions ( ) ; } return TransportApiClientCalls . getStops ( tokenComponent , settings , options , null , null , null ) ; }
Gets a list of all stops in the system .
37,715
public TransportApiResult < List < Stop > > getStopsNearby ( StopQueryOptions options , double latitude , double longitude , int radiusInMeters ) { if ( options == null ) { options = StopQueryOptions . defaultQueryOptions ( ) ; } if ( radiusInMeters < 0 ) { throw new IllegalArgumentException ( "Invalid limit. Valid values are positive numbers only." ) ; } return TransportApiClientCalls . getStops ( tokenComponent , settings , options , new Point ( longitude , latitude ) , radiusInMeters , null ) ; }
Gets a list of stops nearby ordered by distance from the point specified .
37,716
public TransportApiResult < List < Stop > > getStopsByBoundingBox ( StopQueryOptions options , String boundingBox ) { if ( options == null ) { options = StopQueryOptions . defaultQueryOptions ( ) ; } if ( boundingBox == null ) { throw new IllegalArgumentException ( "BoundingBox is required." ) ; } String [ ] bbox = boundingBox . split ( "," , - 1 ) ; if ( bbox . length != 4 ) { throw new IllegalArgumentException ( "Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box." ) ; } return TransportApiClientCalls . getStops ( tokenComponent , settings , options , null , null , boundingBox ) ; }
Gets a list of all stops within a bounding box .
37,717
public TransportApiResult < Stop > getStop ( String stopId ) { if ( Extensions . isNullOrWhiteSpace ( stopId ) ) { throw new IllegalArgumentException ( "StopId is required." ) ; } return TransportApiClientCalls . getStop ( tokenComponent , settings , stopId ) ; }
Gets a specific stop .
37,718
public TransportApiResult < List < StopTimetable > > getStopTimetable ( String stopId , StopTimetableQueryOptions options ) { if ( Extensions . isNullOrWhiteSpace ( stopId ) ) { throw new IllegalArgumentException ( "StopId is required." ) ; } if ( options == null ) { options = StopTimetableQueryOptions . defaultQueryOptions ( ) ; } return TransportApiClientCalls . getStopTimetable ( tokenComponent , settings , stopId , options ) ; }
Gets a timetable for a specific stop .
37,719
public TransportApiResult < List < FareProduct > > getFareProducts ( FareProductQueryOptions options ) { if ( options == null ) { options = FareProductQueryOptions . defaultQueryOptions ( ) ; } return TransportApiClientCalls . getFareProducts ( tokenComponent , settings , options ) ; }
Gets a list of all fare products in the system .
37,720
public TransportApiResult < FareProduct > getFareProduct ( String fareProductId ) { if ( Extensions . isNullOrWhiteSpace ( fareProductId ) ) { throw new IllegalArgumentException ( "FareProductId is required." ) ; } return TransportApiClientCalls . getFareProduct ( tokenComponent , settings , fareProductId ) ; }
Gets a specific fare product .
37,721
private static String getBookParam ( Map < String , String > bookParams , String paramName ) { String value = bookParams . get ( paramName ) ; if ( value != null && value . isEmpty ( ) ) value = null ; return value ; }
Gets a book parameter null if empty .
37,722
private static View findNewsView ( HtmlRenderer htmlRenderer ) throws ServletException { View view = htmlRenderer . getViewsByName ( ) . get ( NewsView . VIEW_NAME ) ; if ( view == null ) throw new ServletException ( "View not found: " + NewsView . VIEW_NAME ) ; return view ; }
Finds the news view .
37,723
public String getAvailableServices ( ) throws JsonGenerationException , JsonMappingException , IOException { DescribeServices services = serviceManager . getAvailableServices ( ) ; return services . asJSON ( ) ; }
Returns a JSON containing the describe service document of each service registered into the library
37,724
public String getPOIs ( String id , double lon , double lat , double distanceInMeters , List < Param > optionalParams ) throws Exception { DescribeService describeService = getDescribeServiceByID ( id ) ; double [ ] bbox = Calculator . boundingCoordinates ( lon , lat , distanceInMeters ) ; POIProxyEvent beforeEvent = new POIProxyEvent ( POIProxyEventEnum . BeforeBrowseLonLat , describeService , new Extent ( bbox [ 0 ] , bbox [ 1 ] , bbox [ 2 ] , bbox [ 3 ] ) , null , null , null , lon , lat , distanceInMeters , null , null , null ) ; notifyListenersBeforeRequest ( beforeEvent ) ; String geoJSON = getCacheData ( beforeEvent ) ; boolean fromCache = true ; if ( geoJSON == null ) { fromCache = false ; geoJSON = getResponseAsGeoJSON ( id , optionalParams , describeService , bbox [ 0 ] , bbox [ 1 ] , bbox [ 2 ] , bbox [ 3 ] , lon , lat , beforeEvent ) ; } POIProxyEvent afterEvent = new POIProxyEvent ( POIProxyEventEnum . AfterBrowseLonLat , describeService , new Extent ( bbox [ 0 ] , bbox [ 1 ] , bbox [ 2 ] , bbox [ 3 ] ) , null , null , null , lon , lat , distanceInMeters , null , geoJSON , null ) ; if ( ! fromCache ) { storeData ( afterEvent ) ; } notifyListenersBeforeRequest ( afterEvent ) ; return geoJSON ; }
This method is used to get the pois from a service and return a GeoJSON document with the data retrieved given a longitude latitude and a radius in meters .
37,725
public String getPOIs ( String id , double minX , double minY , double maxX , double maxY , List < Param > optionalParams ) throws Exception { DescribeService describeService = getDescribeServiceByID ( id ) ; POIProxyEvent beforeEvent = new POIProxyEvent ( POIProxyEventEnum . BeforeBrowseExtent , describeService , new Extent ( minX , minY , maxX , maxY ) , null , null , null , null , null , null , null , null , null ) ; notifyListenersBeforeRequest ( beforeEvent ) ; String geoJSON = this . getCacheData ( beforeEvent ) ; boolean fromCache = true ; if ( geoJSON == null ) { fromCache = false ; geoJSON = getResponseAsGeoJSON ( id , optionalParams , describeService , minX , minY , maxX , maxY , 0 , 0 , beforeEvent ) ; } POIProxyEvent afterEvent = new POIProxyEvent ( POIProxyEventEnum . AfterBrowseExtent , describeService , new Extent ( minX , minY , maxX , maxY ) , null , null , null , null , null , null , null , geoJSON , null ) ; if ( ! fromCache ) { storeData ( afterEvent ) ; } notifyListenersAfterParse ( afterEvent ) ; return geoJSON ; }
This method is used to get the pois from a service and return a GeoJSON document with the data retrieved given a bounding box corners
37,726
public int getDistanceMeters ( Extent boundingBox ) { return new Double ( Math . floor ( Calculator . latLonDist ( boundingBox . getMinX ( ) , boundingBox . getMinY ( ) , boundingBox . getMaxX ( ) , boundingBox . getMaxY ( ) ) ) ) . intValue ( ) ; }
Utility method to get the distance from the bottom left corner of the bounding box to the upper right corner
37,727
private String getErrorForUnknownService ( String id ) { StringBuffer error = new StringBuffer ( ) ; error . append ( "Services path: " + ServiceConfigurationManager . CONFIGURATION_DIR ) ; error . append ( "The service with id: " + id + " is not registered" ) ; error . append ( "\n Available services are: " ) ; Set < String > keys = serviceManager . getRegisteredConfigurations ( ) . keySet ( ) ; Iterator < String > it = keys . iterator ( ) ; while ( it . hasNext ( ) ) { error . append ( it . next ( ) ) . append ( " " ) ; } return error . toString ( ) ; }
Exception text when a service requested is not registered into the library
37,728
public void register ( DescribeService service , String describeService ) throws POIProxyException { serviceManager . registerServiceConfiguration ( service . getId ( ) , describeService , service ) ; }
Interface for registering a new service in POIProxy
37,729
public JTSFeature parseFeature ( JSONObject feature ) throws JSONException { JTSFeature feat = new JTSFeature ( null ) ; JSONObject geometry = ( JSONObject ) feature . get ( "geometry" ) ; String geomType = geometry . get ( "type" ) . toString ( ) ; if ( geomType . compareTo ( "Point" ) == 0 ) { JSONArray coords = geometry . getJSONArray ( "coordinates" ) ; double x = coords . getDouble ( 0 ) ; double y = coords . getDouble ( 1 ) ; GeometryFactory factory = new GeometryFactory ( ) ; Coordinate c = new Coordinate ( ) ; c . x = x ; c . y = y ; Point p = factory . createPoint ( c ) ; feat . setGeometry ( new JTSGeometry ( p ) ) ; } JSONObject props = feature . getJSONObject ( "properties" ) ; Iterator it = props . keys ( ) ; String key ; String val ; feat . setText ( "" ) ; while ( it . hasNext ( ) ) { key = it . next ( ) . toString ( ) ; val = props . getString ( key ) ; feat . addField ( key , val , 0 ) ; if ( val . indexOf ( "http" ) == - 1 ) { feat . setText ( feat . getText ( ) + " " + val ) ; } } return feat ; }
Parses a single feature with a Point
37,730
public synchronized Object put ( final String key , final Object value ) { try { if ( maxCacheSize == 0 ) { return null ; } if ( ! super . containsKey ( key ) && ! list . isEmpty ( ) && list . size ( ) + 1 > maxCacheSize ) { final Object deadKey = list . removeLast ( ) ; super . remove ( deadKey ) ; } updateKey ( key ) ; } catch ( Exception e ) { log . log ( Level . SEVERE , "put" , e ) ; } return super . put ( key , value ) ; }
Adds an Object to the cache . If the cache is full removes the last
37,731
public synchronized Object get ( final String key ) { try { final Object value = super . get ( key ) ; if ( value != null ) { updateKey ( key ) ; } return value ; } catch ( Exception e ) { log . log ( Level . SEVERE , "get" , e ) ; return null ; } }
Returns a cached Object given a key
37,732
public synchronized void remove ( final String key ) { try { list . remove ( key ) ; } catch ( Exception e ) { log . log ( Level . SEVERE , "remove" , e ) ; } super . remove ( key ) ; }
Removes a Object from the cache
37,733
public void setEscapeMode ( int escapeMode ) throws IllegalArgumentException { if ( escapeMode != ESCAPE_MODE_DOUBLED && escapeMode != ESCAPE_MODE_BACKSLASH ) { throw new IllegalArgumentException ( "Parameter escapeMode must be a valid value." ) ; } userSettings . EscapeMode = escapeMode ; }
Sets the current way to escape an occurance of the text qualifier inside qualified data .
37,734
public String [ ] getHeaders ( ) throws IOException { checkClosed ( ) ; if ( headersHolder . Headers == null ) { return null ; } else { String [ ] clone = new String [ headersHolder . Length ] ; System . arraycopy ( headersHolder . Headers , 0 , clone , 0 , headersHolder . Length ) ; return clone ; } }
Returns the header values as a string array .
37,735
public String get ( int columnIndex ) throws IOException { checkClosed ( ) ; if ( columnIndex > - 1 && columnIndex < columnsCount ) { return values [ columnIndex ] ; } else { return "" ; } }
Returns the current column value for a given column index .
37,736
public boolean readHeaders ( ) throws IOException { boolean result = readRecord ( ) ; headersHolder . Length = columnsCount ; headersHolder . Headers = new String [ columnsCount ] ; for ( int i = 0 ; i < headersHolder . Length ; i ++ ) { String columnValue = get ( i ) ; headersHolder . Headers [ i ] = columnValue ; headersHolder . IndexByName . put ( columnValue , new Integer ( i ) ) ; } if ( result ) { currentRecord -- ; } columnsCount = 0 ; return result ; }
Read the first record of data as column headers .
37,737
public String getHeader ( int columnIndex ) throws IOException { checkClosed ( ) ; if ( columnIndex > - 1 && columnIndex < headersHolder . Length ) { return headersHolder . Headers [ columnIndex ] ; } else { return "" ; } }
Returns the column header value for a given column index .
37,738
public int getIndex ( String headerName ) throws IOException { checkClosed ( ) ; Object indexValue = headersHolder . IndexByName . get ( headerName ) ; if ( indexValue != null ) { return ( ( Integer ) indexValue ) . intValue ( ) ; } else { return - 1 ; } }
Gets the corresponding column index for a given column header name .
37,739
public boolean skipLine ( ) throws IOException { checkClosed ( ) ; columnsCount = 0 ; boolean skippedLine = false ; if ( hasMoreData ) { boolean foundEol = false ; do { if ( dataBuffer . Position == dataBuffer . Count ) { checkDataLength ( ) ; } else { skippedLine = true ; char currentLetter = dataBuffer . Buffer [ dataBuffer . Position ] ; if ( currentLetter == Letters . CR || currentLetter == Letters . LF ) { foundEol = true ; } lastLetter = currentLetter ; if ( ! foundEol ) { dataBuffer . Position ++ ; } } } while ( hasMoreData && ! foundEol ) ; columnBuffer . Position = 0 ; dataBuffer . LineStart = dataBuffer . Position + 1 ; } rawBuffer . Position = 0 ; rawRecord = "" ; return skippedLine ; }
Skips the next line of data using the standard end of line characters and does not do any column delimited parsing .
37,740
public double [ ] transform ( String from , String to , double [ ] xy ) { return GeotoolsUtils . transform ( from , to , xy ) ; }
Transform a pair of coordinates from a SRS to another expressed as EPSG codes
37,741
private static Map < Object , Object > getAllFieldsByClassIntern ( Class < ? > pvClass , Map < Object , Object > pvFieldsMap ) { putAllFieldsIntern ( pvClass . getFields ( ) , pvFieldsMap ) ; putAllFieldsIntern ( pvClass . getDeclaredFields ( ) , pvFieldsMap ) ; if ( ! ( pvClass . getSuperclass ( ) . equals ( Object . class ) ) ) { getAllFieldsByClassIntern ( pvClass . getSuperclass ( ) , pvFieldsMap ) ; } return pvFieldsMap ; }
Recursive search all methods from the Class in the Class Hierarchy to Object class .
37,742
public Object copy ( final Object pvRootObject ) { Object lvSimple = makeSimple ( pvRootObject ) ; Object lvComplex = makeComplex ( lvSimple ) ; return lvComplex ; }
Copy of all values of the root object .
37,743
public CompareResult compare ( final Object pvObject1 , final Object pvObject2 ) { CompareResult [ ] lvCompareResults = null ; lvCompareResults = compareIntern ( pvObject1 , pvObject2 , true ) ; CompareResult lvResult = ( lvCompareResults == null ? null : lvCompareResults [ 0 ] ) ; return lvResult ; }
Compare and is stopped by find the first different value .
37,744
public < T extends Object > T findById ( Object id , Class < T > clazz ) { Preconditions . checkNotNull ( clazz , "Tryed to find an object by id, but given class is null" ) ; Preconditions . checkNotNull ( id , "Tryed to find an object by id, but given id is null" ) ; return this . datastore . get ( clazz , ( id instanceof ObjectId ) ? id : new ObjectId ( String . valueOf ( id ) ) ) ; }
Retrieves a mapped Morphia object from MongoDB . If the id is not of type ObjectId it will be converted to ObjectId
37,745
public < T extends Object > List < T > findAll ( Class < T > clazz ) { Preconditions . checkNotNull ( clazz , "Tryed to get all morphia objects of a given object, but given object is null" ) ; return this . datastore . find ( clazz ) . asList ( ) ; }
Retrieves a list of mapped Morphia objects from MongoDB
37,746
public < T extends Object > long countAll ( Class < T > clazz ) { Preconditions . checkNotNull ( clazz , "Tryed to count all a morphia objects of a given object, but given object is null" ) ; return this . datastore . find ( clazz ) . count ( ) ; }
Counts all objected of a mapped Morphia class
37,747
public < T extends Object > void deleteAll ( Class < T > clazz ) { Preconditions . checkNotNull ( clazz , "Tryed to delete list of mapped morphia objects, but given class is null" ) ; this . datastore . delete ( this . datastore . createQuery ( clazz ) ) ; }
Deletes all mapped Morphia objects of a given class
37,748
public static Map < Object , Object > getAllNotEqualsGetterAndSetterAndRemoveThisProperties ( Map < Object , Object > pvGetterMap , Map < Object , Object > pvSetterMap ) { Map < Object , Object > lvMap = new TreeMap < Object , Object > ( ) ; Iterator < Object > it = new ArrayList < Object > ( pvGetterMap . keySet ( ) ) . iterator ( ) ; lvMap . put ( Util . getKeyWordClass ( ) , pvGetterMap . get ( Util . getKeyWordClass ( ) ) ) ; while ( it . hasNext ( ) ) { Object lvGetterProp = it . next ( ) ; if ( pvSetterMap . containsKey ( lvGetterProp ) ) { lvMap . put ( lvGetterProp , pvGetterMap . get ( lvGetterProp ) ) ; } } return Collections . unmodifiableMap ( lvMap ) ; }
Remove all getter - method where no setter - method exist . If more setter - method as getter - method they wasn t removed .
37,749
public static Map < Object , Object > getAllGetterMethodWithCache ( Class < ? > pvClass , String pvFilter [ ] ) { Map < Object , Object > lvGetterMap = classPropertiesCacheGetter . getClassPropertiesMapByClass ( pvClass ) ; if ( lvGetterMap == null ) { lvGetterMap = getAllGetterMethod ( pvClass ) ; Map < Object , Object > lvSetterMap = getAllSetterMethodWithCache ( pvClass , pvFilter ) ; lvGetterMap = getAllNotEqualsGetterAndSetterAndRemoveThisProperties ( lvGetterMap , lvSetterMap ) ; classPropertiesCacheGetter . addClassPropertiesMap ( pvClass , lvGetterMap ) ; } return lvGetterMap ; }
Find all getter - method from a Class and remove all getter - method where no setter - method exist .
37,750
public static Map < Object , Object > getAllSetterMethodWithCache ( Class < ? > pvClass , String pvFilter [ ] ) { Map < Object , Object > lvMap = classPropertiesCacheSetter . getClassPropertiesMapByClass ( pvClass ) ; if ( lvMap == null ) { lvMap = getAllSetterMethod ( pvClass ) ; classPropertiesCacheSetter . addClassPropertiesMap ( pvClass , lvMap ) ; } lvMap = Util . filterMapByKeys ( lvMap , pvFilter ) ; return lvMap ; }
Find all setter - method from a Class .
37,751
private static Collection < Method > getAllMethodsByClassIntern ( Class < ? > pvClass , Set < Method > pvMethodsMap ) { putAllMethodsIntern ( pvClass . getMethods ( ) , pvMethodsMap ) ; putAllMethodsIntern ( pvClass . getDeclaredMethods ( ) , pvMethodsMap ) ; if ( ! ( pvClass . getSuperclass ( ) . equals ( Object . class ) ) ) { getAllMethodsByClassIntern ( pvClass . getSuperclass ( ) , pvMethodsMap ) ; } return pvMethodsMap ; }
Recursive search all method from the Class in the Class Hierarchy to Object . class .
37,752
public String getColumnNames ( ) { StringBuffer sb = new StringBuffer ( ) ; int lvSize = columnNames . size ( ) ; for ( int i = 0 ; i < lvSize ; i ++ ) { sb . append ( columnNames . get ( i ) ) ; if ( i < ( lvSize - 1 ) ) { sb . append ( getDelimiter ( ) ) ; } } return sb . toString ( ) ; }
Get all column - names as String separated with a selected delimiter .
37,753
public String row2String ( int pvRow ) { StringBuffer sb = new StringBuffer ( ) ; List < ? > lvColumn = rows . get ( pvRow ) ; int lvSize = lvColumn . size ( ) ; for ( int i = 0 ; i < lvSize ; i ++ ) { sb . append ( lvColumn . get ( i ) ) ; if ( i < ( lvSize - 1 ) ) { sb . append ( getDelimiter ( ) ) ; } } return sb . toString ( ) ; }
Convert a row of the table in a String where the every column is seperated with a delimiter .
37,754
public void executeSetValue ( Object pvObject , Object pvArgs ) throws IllegalArgumentException , IllegalAccessException , InvocationTargetException { AccessController . doPrivileged ( new AccessiblePrivilegedAction ( accessibleObject ) ) ; if ( propertyType == PROPERTY_TYPE_METHOD ) { ( ( Method ) accessibleObject ) . invoke ( pvObject , new Object [ ] { pvArgs } ) ; } else { ( ( Field ) accessibleObject ) . set ( pvObject , pvArgs ) ; } }
Call the setter Method or set value from Field .
37,755
public Object executeGetValue ( Object pvObject ) throws IllegalArgumentException , IllegalAccessException , InvocationTargetException { Object lvReturnValue = null ; AccessController . doPrivileged ( new AccessiblePrivilegedAction ( accessibleObject ) ) ; if ( propertyType == PROPERTY_TYPE_METHOD ) { lvReturnValue = ( ( Method ) accessibleObject ) . invoke ( pvObject ) ; } else { lvReturnValue = ( ( Field ) accessibleObject ) . get ( pvObject ) ; } return lvReturnValue ; }
Call the getter Method or get value from Field .
37,756
public static boolean isPropertyToFiltering ( ClassPropertyFilterHandler pvClassPropertyFilterHandler , Class < ? > pvClassForFindFilter , Object pvKey ) { boolean lvAddProperty = false ; if ( pvClassPropertyFilterHandler != null ) { ClassPropertyFilter lvClassPropertyFilter = pvClassPropertyFilterHandler . getClassPropertyFilterByClass ( pvClassForFindFilter ) ; String lvKey = ( pvKey == null ? null : pvKey . toString ( ) ) ; if ( lvClassPropertyFilter != null && lvClassPropertyFilter . isKnownProperty ( lvKey ) == true ) { lvAddProperty = true ; } } return lvAddProperty ; }
Check a property from a class by a handler .
37,757
private ConversionContext fireBeforeConvertRecursion ( int pvNumberOfIteration , Object pvKey , Object pvValue ) { ConversionContext lvContext = new ConversionContext ( pvNumberOfIteration , pvKey , pvValue ) ; getConverterInterceptorHandler ( ) . fireBeforeConvertRecursion ( lvContext ) ; return lvContext ; }
Create a new ConversionContext and fire before convert recursion event .
37,758
private ConversionContext fireAfterConvertRecursion ( final ConversionContext pvContext , Object pvKey , Object pvValue ) { pvContext . key = pvKey ; pvContext . value = pvValue ; getConverterInterceptorHandler ( ) . fireAfterConvertRecursion ( pvContext ) ; return pvContext ; }
Get a ConversionContext and fire after convert recursion event .
37,759
public void setUrls ( String [ ] urls ) { if ( urls == null ) { this . urls = null ; } else { this . urls = new String [ urls . length ] ; System . arraycopy ( urls , 0 , this . urls , 0 , urls . length ) ; } }
Default scope for test access .
37,760
public boolean exist ( String name , boolean bankAccount ) { String newName = name ; if ( ! Common . getInstance ( ) . getMainConfig ( ) . getBoolean ( "System.Case-sentitive" ) ) { newName = name . toLowerCase ( ) ; } boolean result ; if ( bankAccount ) { result = bankList . containsKey ( newName ) ; if ( ! result ) { result = Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . accountExist ( newName , bankAccount ) ; } } else { result = accountList . containsKey ( newName ) ; if ( ! result ) { result = Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . accountExist ( newName , bankAccount ) ; } } return result ; }
Check if a account exist in the database .
37,761
public boolean delete ( String name , boolean bankAccount ) { boolean result = false ; if ( exist ( name , bankAccount ) ) { result = Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . deleteAccount ( name , bankAccount ) ; if ( bankAccount ) { bankList . remove ( name ) ; } else { accountList . remove ( name ) ; } } return result ; }
Delete a account from the system
37,762
public List < String > getAllAccounts ( boolean bank ) { return Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . getAllAccounts ( bank ) ; }
Retrieve a list of all the accounts
37,763
private boolean loadFile ( ) { boolean result = false ; File dbFile = new File ( Common . getInstance ( ) . getServerCaller ( ) . getDataFolder ( ) , getDbConnectInfo ( ) . get ( "filename" ) ) ; if ( dbFile . exists ( ) ) { try { flatFileReader = new BufferedReader ( new FileReader ( dbFile ) ) ; result = true ; } catch ( FileNotFoundException e ) { Common . getInstance ( ) . getLogger ( ) . severe ( "iConomy database file not found!" ) ; } } return result ; }
Allow to load a flatfile database .
37,764
private void loadMySQL ( ) { try { HikariConfig config = new HikariConfig ( ) ; config . setMaximumPoolSize ( 10 ) ; config . setDataSourceClassName ( "com.mysql.jdbc.jdbc2.optional.MysqlDataSource" ) ; config . addDataSourceProperty ( "serverName" , getDbConnectInfo ( ) . get ( "address" ) ) ; config . addDataSourceProperty ( "port" , getDbConnectInfo ( ) . get ( "port" ) ) ; config . addDataSourceProperty ( "databaseName" , getDbConnectInfo ( ) . get ( "database" ) ) ; config . addDataSourceProperty ( "user" , getDbConnectInfo ( ) . get ( "username" ) ) ; config . addDataSourceProperty ( "password" , getDbConnectInfo ( ) . get ( "password" ) ) ; config . addDataSourceProperty ( "autoDeserialize" , true ) ; db = new HikariDataSource ( config ) ; } catch ( NumberFormatException e ) { Common . getInstance ( ) . getLogger ( ) . severe ( "Illegal Port!" ) ; } }
Allow to load a MySQL database .
37,765
private boolean importFlatFile ( String sender ) { boolean result = false ; try { List < String > file = new ArrayList < > ( ) ; String str ; while ( ( str = flatFileReader . readLine ( ) ) != null ) { file . add ( str ) ; } flatFileReader . close ( ) ; List < User > userList = new ArrayList < > ( ) ; for ( String aFile : file ) { String [ ] info = aFile . split ( " " ) ; try { double balance = Double . parseDouble ( info [ 1 ] . split ( ":" ) [ 1 ] ) ; userList . add ( new User ( info [ 0 ] , balance ) ) ; } catch ( NumberFormatException e ) { Common . getInstance ( ) . sendConsoleMessage ( Level . SEVERE , "User " + info [ 0 ] + " have a invalid balance" + info [ 1 ] ) ; } catch ( ArrayIndexOutOfBoundsException e ) { Common . getInstance ( ) . sendConsoleMessage ( Level . WARNING , "Line not formatted correctly. I read:" + Arrays . toString ( info ) ) ; } } addAccountToString ( sender , userList ) ; result = true ; } catch ( IOException e ) { Common . getInstance ( ) . getLogger ( ) . severe ( "A error occured while reading the iConomy database file! Message: " + e . getMessage ( ) ) ; } return result ; }
Import accounts from a flatfile .
37,766
public void playerJoinEvent ( PlayerJoinEvent event ) { if ( Common . getInstance ( ) . getMainConfig ( ) . getBoolean ( "System.CheckNewVersion" ) && Common . getInstance ( ) . getServerCaller ( ) . getPlayerCaller ( ) . isOp ( event . getP ( ) . getName ( ) ) && Common . getInstance ( ) . getVersionChecker ( ) . getResult ( ) == Updater . UpdateResult . UPDATE_AVAILABLE ) { Common . getInstance ( ) . getServerCaller ( ) . getPlayerCaller ( ) . sendMessage ( event . getP ( ) . getName ( ) , "{{DARK_CYAN}}Craftconomy is out of date! New version is " + Common . getInstance ( ) . getVersionChecker ( ) . getLatestName ( ) ) ; } }
Event handler for when a player is connecting to the server .
37,767
public void addWorldToGroup ( String groupName , String world ) { if ( ! groupName . equalsIgnoreCase ( DEFAULT_GROUP_NAME ) ) { if ( list . containsKey ( groupName ) ) { list . get ( groupName ) . addWorld ( world ) ; } else { WorldGroup group = new WorldGroup ( groupName ) ; group . addWorld ( world ) ; } } }
Add a world to a group
37,768
public String getWorldGroupName ( String world ) { String result = DEFAULT_GROUP_NAME ; for ( Entry < String , WorldGroup > entry : list . entrySet ( ) ) { if ( entry . getValue ( ) . worldExist ( world ) ) { result = entry . getKey ( ) ; } } return result ; }
Retrieve the name of the worldgroup a world belongs to
37,769
public void removeWorldFromGroup ( String world ) { String groupName = getWorldGroupName ( world ) ; if ( ! groupName . equals ( DEFAULT_GROUP_NAME ) ) { list . get ( groupName ) . removeWorld ( world ) ; } }
Remove a world from a worldgroup
37,770
public void removeGroup ( String group ) { if ( worldGroupExist ( group ) ) { Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . removeWorldGroup ( group ) ; list . remove ( group ) ; } }
Remove a world group . Reverting all the world into this group to the default one .
37,771
public void addWorldGroup ( String name ) { if ( ! worldGroupExist ( name ) ) { list . put ( name , new WorldGroup ( name ) ) ; } }
Create a world group
37,772
public void onDisable ( ) { if ( getStorageHandler ( ) != null ) { getLogger ( ) . info ( getLanguageManager ( ) . getString ( "closing_db_link" ) ) ; getStorageHandler ( ) . disable ( ) ; } accountManager = null ; config = null ; currencyManager = null ; storageHandler = null ; eventManager = null ; languageManager = null ; worldGroupManager = null ; commandManager = null ; databaseInitialized = false ; currencyInitialized = false ; initialized = false ; metrics = null ; mainConfig = null ; updater = null ; displayFormat = null ; holdings = 0.0 ; bankPrice = 0.0 ; }
Disable the plugin .
37,773
public void reloadPlugin ( ) { sendConsoleMessage ( Level . INFO , "Starting up!" ) ; sendConsoleMessage ( Level . INFO , "Loading the Configuration" ) ; config = new ConfigurationManager ( serverCaller ) ; mainConfig = config . loadFile ( serverCaller . getDataFolder ( ) , "config.yml" ) ; if ( ! mainConfig . has ( "System.Setup" ) ) { initializeConfig ( ) ; } if ( ! getMainConfig ( ) . has ( "System.Database.Prefix" ) ) { getMainConfig ( ) . setValue ( "System.Database.Prefix" , "cc3_" ) ; } languageManager = new LanguageManager ( serverCaller , serverCaller . getDataFolder ( ) , "lang.yml" ) ; loadLanguage ( ) ; serverCaller . setCommandPrefix ( languageManager . getString ( "command_prefix" ) ) ; commandManager . setCurrentLevel ( 1 ) ; initialiseDatabase ( ) ; updateDatabase ( ) ; initializeCurrency ( ) ; sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "loading_default_settings" ) ) ; loadDefaultSettings ( ) ; sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "default_settings_loaded" ) ) ; startUp ( ) ; sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "ready" ) ) ; }
Reload the plugin .
37,774
public void sendConsoleMessage ( Level level , String msg ) { if ( ! ( getServerCaller ( ) instanceof UnitTestServerCaller ) ) { getLogger ( ) . log ( level , msg ) ; } }
Sends a message to the console through the Logge . r
37,775
public String format ( String worldName , Currency currency , double balance , DisplayFormat format ) { StringBuilder string = new StringBuilder ( ) ; if ( worldName != null && ! worldName . equals ( WorldGroupsManager . DEFAULT_GROUP_NAME ) ) { string . append ( worldName ) . append ( ": " ) ; } if ( currency != null ) { String [ ] theAmount = BigDecimal . valueOf ( balance ) . toPlainString ( ) . split ( "\\." ) ; DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols ( ) ; unusualSymbols . setGroupingSeparator ( ',' ) ; DecimalFormat decimalFormat = new DecimalFormat ( "###,###" , unusualSymbols ) ; String name = currency . getName ( ) ; if ( balance > 1.0 || balance < 1.0 ) { name = currency . getPlural ( ) ; } String coin ; if ( theAmount . length == 2 ) { if ( theAmount [ 1 ] . length ( ) >= 2 ) { coin = theAmount [ 1 ] . substring ( 0 , 2 ) ; } else { coin = theAmount [ 1 ] + "0" ; } } else { coin = "0" ; } String amount ; try { amount = decimalFormat . format ( Double . parseDouble ( theAmount [ 0 ] ) ) ; } catch ( NumberFormatException e ) { amount = theAmount [ 0 ] ; } if ( format == DisplayFormat . LONG ) { String subName = currency . getMinor ( ) ; if ( Long . parseLong ( coin ) > 1 ) { subName = currency . getMinorPlural ( ) ; } string . append ( amount ) . append ( " " ) . append ( name ) . append ( " " ) . append ( coin ) . append ( " " ) . append ( subName ) ; } else if ( format == DisplayFormat . SMALL ) { string . append ( amount ) . append ( "." ) . append ( coin ) . append ( " " ) . append ( name ) ; } else if ( format == DisplayFormat . SIGN ) { string . append ( currency . getSign ( ) ) . append ( amount ) . append ( "." ) . append ( coin ) ; } else if ( format == DisplayFormat . SIGNFRONT ) { string . append ( amount ) . append ( "." ) . append ( coin ) . append ( currency . getSign ( ) ) ; } else if ( format == DisplayFormat . MAJORONLY ) { string . append ( amount ) . append ( " " ) . append ( name ) ; } } return string . toString ( ) ; }
Format a balance to a readable string .
37,776
public String format ( String worldName , Currency currency , double balance ) { return format ( worldName , currency , balance , displayFormat ) ; }
Format a balance to a readable string with the default formatting .
37,777
public void initialiseDatabase ( ) { if ( ! databaseInitialized ) { sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "loading_database_manager" ) ) ; storageHandler = new StorageHandler ( ) ; if ( getMainConfig ( ) . getBoolean ( "System.Database.ConvertFromH2" ) ) { convertDatabase ( ) ; } databaseInitialized = true ; sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "database_manager_loaded" ) ) ; } }
Initialize the database Manager
37,778
private void convertDatabase ( ) { sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "starting_database_convert" ) ) ; new H2ToMySQLConverter ( ) . run ( ) ; sendConsoleMessage ( Level . INFO , getLanguageManager ( ) . getString ( "convert_done" ) ) ; getMainConfig ( ) . setValue ( "System.Database.ConvertFromH2" , false ) ; }
Convert from SQLite to MySQL
37,779
public void addMetricsGraph ( String title , String value ) { if ( metrics != null ) { Metrics . Graph graph = metrics . createGraph ( title ) ; graph . addPlotter ( new Metrics . Plotter ( value ) { public int getValue ( ) { return 1 ; } } ) ; } }
Add a graph to Metrics
37,780
public void writeLog ( LogInfo info , Cause cause , String causeReason , Account account , double amount , Currency currency , String worldName ) { if ( getMainConfig ( ) . getBoolean ( "System.Logging.Enabled" ) ) { getStorageHandler ( ) . getStorageEngine ( ) . saveLog ( info , cause , causeReason , account , amount , currency , worldName ) ; } }
Write a transaction to the Log .
37,781
public void loadDefaultSettings ( ) { String value = getStorageHandler ( ) . getStorageEngine ( ) . getConfigEntry ( "longmode" ) ; if ( value != null ) { displayFormat = DisplayFormat . valueOf ( value . toUpperCase ( ) ) ; } else { getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "longmode" , "long" ) ; displayFormat = DisplayFormat . LONG ; } addMetricsGraph ( "Display Format" , displayFormat . toString ( ) ) ; value = getStorageHandler ( ) . getStorageEngine ( ) . getConfigEntry ( "holdings" ) ; if ( value != null && Tools . isValidDouble ( value ) ) { holdings = Double . parseDouble ( value ) ; } else { getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "holdings" , 100.0 + "" ) ; sendConsoleMessage ( Level . SEVERE , "No default value was set for account creation or was invalid! Defaulting to 100." ) ; holdings = 100.0 ; } value = getStorageHandler ( ) . getStorageEngine ( ) . getConfigEntry ( "bankprice" ) ; if ( value != null && Tools . isValidDouble ( value ) ) { bankPrice = Double . parseDouble ( value ) ; } else { getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "bankprice" , 100.0 + "" ) ; sendConsoleMessage ( Level . SEVERE , "No default value was set for bank creation or was invalid! Defaulting to 100." ) ; bankPrice = 100.0 ; } }
Reload the default settings .
37,782
public void setDefaultHoldings ( double value ) { getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "holdings" , String . valueOf ( value ) ) ; holdings = value ; }
Set the default amount of money a account will have
37,783
public void setBankPrice ( double value ) { getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "bankprice" , String . valueOf ( value ) ) ; bankPrice = value ; }
Set the bank account creation price
37,784
private void quickSetup ( ) { initialiseDatabase ( ) ; Common . getInstance ( ) . initializeCurrency ( ) ; Currency currency = Common . getInstance ( ) . getCurrencyManager ( ) . addCurrency ( getMainConfig ( ) . getString ( "System.QuickSetup.Currency.Name" ) , getMainConfig ( ) . getString ( "System.QuickSetup.Currency.NamePlural" ) , getMainConfig ( ) . getString ( "System.QuickSetup.Currency.Minor" ) , getMainConfig ( ) . getString ( "System.QuickSetup.Currency.MinorPlural" ) , getMainConfig ( ) . getString ( "System.QuickSetup.Currency.Sign" ) , true ) ; Common . getInstance ( ) . getCurrencyManager ( ) . setDefault ( currency ) ; Common . getInstance ( ) . getCurrencyManager ( ) . setDefaultBankCurrency ( currency ) ; getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "longmode" , DisplayFormat . valueOf ( getMainConfig ( ) . getString ( "System.QuickSetup.DisplayMode" ) . toUpperCase ( ) ) . toString ( ) ) ; getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "holdings" , getMainConfig ( ) . getString ( "System.QuickSetup.StartBalance" ) ) ; getStorageHandler ( ) . getStorageEngine ( ) . setConfigEntry ( "bankprice" , getMainConfig ( ) . getString ( "System.QuickSetup.PriceBank" ) ) ; initializeCurrency ( ) ; loadDefaultSettings ( ) ; Common . getInstance ( ) . startUp ( ) ; Common . getInstance ( ) . getMainConfig ( ) . setValue ( "System.Setup" , false ) ; commandManager . setCurrentLevel ( 1 ) ; sendConsoleMessage ( Level . INFO , "Quick-Config done!" ) ; }
Perform a quick setup
37,785
private void updateDatabase ( ) { if ( getMainConfig ( ) . getInt ( "Database.dbVersion" ) == 0 ) { alertOldDbVersion ( 0 , 1 ) ; String value = getStorageHandler ( ) . getStorageEngine ( ) . getConfigEntry ( "dbVersion" ) ; if ( value != null ) { try { new OldFormatConverter ( ) . run ( ) ; getMainConfig ( ) . setValue ( "Database.dbVersion" , 1 ) ; sendConsoleMessage ( Level . INFO , "Updated to Revision 1!" ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } } else { getMainConfig ( ) . setValue ( "Database.dbVersion" , 1 ) ; sendConsoleMessage ( Level . INFO , "Updated to Revision 1!" ) ; } } else if ( getMainConfig ( ) . getInt ( "Database.dbVersion" ) == - 1 ) { alertOldDbVersion ( - 1 , 1 ) ; try { new OldFormatConverter ( ) . step2 ( ) ; getMainConfig ( ) . setValue ( "Database.dbVersion" , 1 ) ; sendConsoleMessage ( Level . INFO , "Updated to Revision 1!" ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } } }
Run a database update .
37,786
private void alertOldDbVersion ( int currentVersion , int newVersion ) { Common . getInstance ( ) . sendConsoleMessage ( Level . INFO , "Your database is out of date! (Version " + currentVersion + "). Updating it to Revision " + newVersion + "." ) ; }
Alert in the console of a database update .
37,787
public boolean canDeposit ( String name ) { if ( getParent ( ) . ignoreACL ( ) ) { return true ; } String newName = name . toLowerCase ( ) ; boolean result = false ; if ( aclList . containsKey ( newName ) ) { result = aclList . get ( newName ) . canDeposit ( ) ; } return result ; }
Checks if a player can deposit money
37,788
public boolean canAcl ( String name ) { if ( getParent ( ) . ignoreACL ( ) ) { return false ; } String newName = name . toLowerCase ( ) ; boolean result = false ; if ( aclList . containsKey ( newName ) ) { result = aclList . get ( newName ) . canAcl ( ) ; } return result ; }
Checks if a player can modify the ACL
37,789
public void setDeposit ( String name , boolean deposit ) { String newName = name . toLowerCase ( ) ; if ( aclList . containsKey ( newName ) ) { AccountACLValue value = aclList . get ( newName ) ; set ( newName , deposit , value . canWithdraw ( ) , value . canAcl ( ) , value . canBalance ( ) , value . isOwner ( ) ) ; } else { set ( newName , deposit , false , false , false , false ) ; } }
Set if a player can deposit money in the account
37,790
public void setWithdraw ( String name , boolean withdraw ) { String newName = name . toLowerCase ( ) ; if ( aclList . containsKey ( name ) ) { AccountACLValue value = aclList . get ( newName ) ; set ( newName , value . canDeposit ( ) , withdraw , value . canAcl ( ) , value . canBalance ( ) , value . isOwner ( ) ) ; } else { set ( newName , false , withdraw , false , false , false ) ; } }
Set if a player can withdraw money in the account
37,791
public void setAcl ( String name , boolean acl ) { String newName = name . toLowerCase ( ) ; if ( aclList . containsKey ( newName ) ) { AccountACLValue value = aclList . get ( newName ) ; set ( newName , value . canDeposit ( ) , value . canWithdraw ( ) , acl , value . canBalance ( ) , value . isOwner ( ) ) ; } else { set ( newName , false , false , acl , false , false ) ; } }
Set if a player can modify the ACL list
37,792
public void setShow ( String name , boolean show ) { String newName = name . toLowerCase ( ) ; if ( aclList . containsKey ( newName ) ) { AccountACLValue value = aclList . get ( newName ) ; set ( newName , value . canDeposit ( ) , value . canWithdraw ( ) , value . canAcl ( ) , show , value . isOwner ( ) ) ; } else { set ( newName , false , false , false , show , false ) ; } }
Set if a player can show the bank balance .
37,793
public void set ( String name , boolean deposit , boolean withdraw , boolean acl , boolean show , boolean owner ) { String newName = name . toLowerCase ( ) ; aclList . put ( name , Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . saveACL ( account , newName , deposit , withdraw , acl , show , owner ) ) ; }
Set a player in the ACL list
37,794
public boolean isOwner ( String name ) { boolean result = false ; if ( aclList . containsKey ( name ) ) { result = aclList . get ( name ) . isOwner ( ) ; } return result ; }
Checks if the player is the bank owner . This is not affected by the ACL ignore .
37,795
public Currency getCurrency ( String name ) { Currency result ; if ( ! currencyList . containsKey ( name ) ) { result = Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . getCurrency ( name ) ; if ( result != null ) { currencyList . put ( result . getName ( ) , result ) ; } } else { result = currencyList . get ( name ) ; } return result ; }
Get a currency
37,796
public void setDefault ( Currency currency ) { if ( currencyList . containsKey ( currency . getName ( ) ) ) { Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . setDefaultCurrency ( currency ) ; defaultCurrency = currency ; currency . setDefault ( true ) ; for ( Map . Entry < String , Currency > currencyEntry : currencyList . entrySet ( ) ) { if ( ! currencyEntry . getValue ( ) . equals ( currency ) ) { currency . setDefault ( false ) ; } } } }
Set a currency as the default one .
37,797
public void deleteCurrency ( Currency currency ) { if ( currencyList . containsKey ( currency . getName ( ) ) ) { Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . deleteCurrency ( currency ) ; currencyList . remove ( currency . getName ( ) ) ; } }
Delete a currency .
37,798
public double getBalance ( String world , String currencyName ) { double balance = Double . MIN_NORMAL ; if ( ! Common . getInstance ( ) . getWorldGroupManager ( ) . worldGroupExist ( world ) ) { world = Common . getInstance ( ) . getWorldGroupManager ( ) . getWorldGroupName ( world ) ; } Currency currency = Common . getInstance ( ) . getCurrencyManager ( ) . getCurrency ( currencyName ) ; if ( currency != null ) { if ( ! hasInfiniteMoney ( ) ) { balance = Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . getBalance ( this , currency , world ) ; } else { balance = Double . MAX_VALUE ; } } return format ( balance ) ; }
Get s the player balance . Sends double . MIN_NORMAL in case of a error
37,799
public double withdraw ( double amount , String world , String currencyName , Cause cause , String causeReason ) { BalanceTable balanceTable ; double result = getBalance ( world , currencyName ) - format ( amount ) ; if ( ! Common . getInstance ( ) . getWorldGroupManager ( ) . worldGroupExist ( world ) ) { world = Common . getInstance ( ) . getWorldGroupManager ( ) . getWorldGroupName ( world ) ; } Currency currency = Common . getInstance ( ) . getCurrencyManager ( ) . getCurrency ( currencyName ) ; if ( currency != null ) { if ( ! hasInfiniteMoney ( ) ) { result = Common . getInstance ( ) . getStorageHandler ( ) . getStorageEngine ( ) . setBalance ( this , result , currency , world ) ; Common . getInstance ( ) . writeLog ( LogInfo . WITHDRAW , cause , causeReason , this , amount , currency , world ) ; Common . getInstance ( ) . getServerCaller ( ) . throwEvent ( new EconomyChangeEvent ( this . getAccountName ( ) , result ) ) ; } else { result = Double . MAX_VALUE ; } } return format ( result ) ; }
withdraw a certain amount of money in the account