idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
144,900 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < AccountingDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < AccountingDate > ) super . localDateTime ( temporal ) ; } | Obtains a Accounting local date - time from another date - time object . |
144,901 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < AccountingDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < AccountingDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a Accounting zoned date - time from another date - time object . |
144,902 | public CopticDate date ( int prolepticYear , int month , int dayOfMonth ) { return CopticDate . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Coptic calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,903 | public CopticDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Coptic calendar system from the era year - of - era and day - of - year fields . |
144,904 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < CopticDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < CopticDate > ) super . localDateTime ( temporal ) ; } | Obtains a Coptic local date - time from another date - time object . |
144,905 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < CopticDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < CopticDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a Coptic zoned date - time from another date - time object . |
144,906 | private YearQuarter with ( int newYear , Quarter newQuarter ) { if ( year == newYear && quarter == newQuarter ) { return this ; } return new YearQuarter ( newYear , newQuarter ) ; } | Returns a copy of this year - quarter with the new year and quarter checking to see if a new object is in fact required . |
144,907 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < BritishCutoverDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < BritishCutoverDate > ) super . localDateTime ( temporal ) ; } | Obtains a British Cutover local date - time from another date - time object . |
144,908 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < BritishCutoverDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < BritishCutoverDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a British Cutover zoned date - time from another date - time object . |
144,909 | private static int weekRange ( int weekBasedYear ) { LocalDate date = LocalDate . of ( weekBasedYear , 1 , 1 ) ; if ( date . getDayOfWeek ( ) == THURSDAY || ( date . getDayOfWeek ( ) == WEDNESDAY && date . isLeapYear ( ) ) ) { return 53 ; } return 52 ; } | from IsoFields in ThreeTen - Backport |
144,910 | private YearWeek with ( int newYear , int newWeek ) { if ( year == newYear && week == newWeek ) { return this ; } return of ( newYear , newWeek ) ; } | Returns a copy of this year - week with the new year and week checking to see if a new object is in fact required . |
144,911 | void register ( long mjDay , int leapAdjustment ) { if ( leapAdjustment != - 1 && leapAdjustment != 1 ) { throw new IllegalArgumentException ( "Leap adjustment must be -1 or 1" ) ; } Data data = dataRef . get ( ) ; int pos = Arrays . binarySearch ( data . dates , mjDay ) ; int currentAdj = pos > 0 ? data . offsets [ po... | Adds a new leap second to these rules . |
144,912 | private static Data loadLeapSeconds ( ) { Data bestData = null ; URL url = null ; try { Enumeration < URL > en = Thread . currentThread ( ) . getContextClassLoader ( ) . getResources ( "META-INF/" + LEAP_SECONDS_TXT ) ; while ( en . hasMoreElements ( ) ) { url = en . nextElement ( ) ; Data candidate = loadLeapSeconds (... | Loads the rules from files in the class loader often jar files . |
144,913 | private static Data loadLeapSeconds ( URL url ) throws ClassNotFoundException , IOException { List < String > lines ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( url . openStream ( ) , StandardCharsets . UTF_8 ) ) ) { lines = reader . lines ( ) . collect ( Collectors . toList ( ) ) ; } Li... | Loads the leap second rules from a URL often in a jar file . |
144,914 | static InternationalFixedDate create ( int prolepticYear , int month , int dayOfMonth ) { YEAR_RANGE . checkValidValue ( prolepticYear , ChronoField . YEAR_OF_ERA ) ; MONTH_OF_YEAR_RANGE . checkValidValue ( month , ChronoField . MONTH_OF_YEAR ) ; DAY_OF_MONTH_RANGE . checkValidValue ( dayOfMonth , ChronoField . DAY_OF_... | Factory method validates the given triplet year month and dayOfMonth . |
144,915 | public JulianDate date ( int prolepticYear , int month , int dayOfMonth ) { return JulianDate . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Julian calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,916 | public JulianDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Julian calendar system from the era year - of - era and day - of - year fields . |
144,917 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < JulianDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < JulianDate > ) super . localDateTime ( temporal ) ; } | Obtains a Julian local date - time from another date - time object . |
144,918 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < JulianDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < JulianDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a Julian zoned date - time from another date - time object . |
144,919 | public Symmetry454Date date ( int prolepticYear , int month , int dayOfMonth ) { return Symmetry454Date . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Symmetry454 calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,920 | public Symmetry454Date dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Symmetry454 calendar system from the era year - of - era and day - of - year fields . |
144,921 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < Symmetry454Date > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < Symmetry454Date > ) super . localDateTime ( temporal ) ; } | Obtains a Symmetry454 local date - time from another date - time object . |
144,922 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < Symmetry454Date > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < Symmetry454Date > ) super . zonedDateTime ( temporal ) ; } | Obtains a Symmetry454 zoned date - time from another date - time object . |
144,923 | public Symmetry010Date date ( int prolepticYear , int month , int dayOfMonth ) { return Symmetry010Date . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Symmetry010 calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,924 | public Symmetry010Date dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Symmetry010 calendar system from the era year - of - era and day - of - year fields . |
144,925 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < Symmetry010Date > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < Symmetry010Date > ) super . localDateTime ( temporal ) ; } | Obtains a Symmetry010 local date - time from another date - time object . |
144,926 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < Symmetry010Date > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < Symmetry010Date > ) super . zonedDateTime ( temporal ) ; } | Obtains a Symmetry010 zoned date - time from another date - time object . |
144,927 | public PaxDate date ( int prolepticYear , int month , int dayOfMonth ) { return PaxDate . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Pax calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,928 | public PaxDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Pax calendar system from the era year - of - era and day - of - year fields . |
144,929 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < PaxDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < PaxDate > ) super . localDateTime ( temporal ) ; } | Obtains a Pax local date - time from another date - time object . |
144,930 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < PaxDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < PaxDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a Pax zoned date - time from another date - time object . |
144,931 | public EthiopicDate date ( Era era , int yearOfEra , int month , int dayOfMonth ) { return date ( prolepticYear ( era , yearOfEra ) , month , dayOfMonth ) ; } | Obtains a local date in Ethiopic calendar system from the era year - of - era month - of - year and day - of - month fields . |
144,932 | public EthiopicDate date ( int prolepticYear , int month , int dayOfMonth ) { return EthiopicDate . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Ethiopic calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,933 | public EthiopicDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Ethiopic calendar system from the era year - of - era and day - of - year fields . |
144,934 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < EthiopicDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < EthiopicDate > ) super . localDateTime ( temporal ) ; } | Obtains a Ethiopic local date - time from another date - time object . |
144,935 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < EthiopicDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < EthiopicDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a Ethiopic zoned date - time from another date - time object . |
144,936 | public DiscordianDate date ( int prolepticYear , int month , int dayOfMonth ) { return DiscordianDate . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in Discordian calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,937 | public DiscordianDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in Discordian calendar system from the era year - of - era and day - of - year fields . |
144,938 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < DiscordianDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < DiscordianDate > ) super . localDateTime ( temporal ) ; } | Obtains a Discordian local date - time from another date - time object . |
144,939 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < DiscordianDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < DiscordianDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a Discordian zoned date - time from another date - time object . |
144,940 | public InternationalFixedDate date ( int prolepticYear , int month , int dayOfMonth ) { return InternationalFixedDate . of ( prolepticYear , month , dayOfMonth ) ; } | Obtains a local date in International Fixed calendar system from the proleptic - year month - of - year and day - of - month fields . |
144,941 | public InternationalFixedDate dateYearDay ( Era era , int yearOfEra , int dayOfYear ) { return dateYearDay ( prolepticYear ( era , yearOfEra ) , dayOfYear ) ; } | Obtains a local date in International Fixed calendar system from the era year - of - era and day - of - year fields . |
144,942 | @ SuppressWarnings ( "unchecked" ) public ChronoLocalDateTime < InternationalFixedDate > localDateTime ( TemporalAccessor temporal ) { return ( ChronoLocalDateTime < InternationalFixedDate > ) super . localDateTime ( temporal ) ; } | Obtains a International Fixed local date - time from another date - time object . |
144,943 | @ SuppressWarnings ( "unchecked" ) public ChronoZonedDateTime < InternationalFixedDate > zonedDateTime ( TemporalAccessor temporal ) { return ( ChronoZonedDateTime < InternationalFixedDate > ) super . zonedDateTime ( temporal ) ; } | Obtains a International Fixed zoned date - time from another date - time object . |
144,944 | public final ReadOnlyObjectProperty < LatLongBounds > boundsProperty ( ) { if ( bounds == null ) { bounds = new ReadOnlyObjectWrapper < > ( getBounds ( ) ) ; addStateEventHandler ( MapStateEventType . idle , ( ) -> { bounds . set ( getBounds ( ) ) ; } ) ; } return bounds . getReadOnlyProperty ( ) ; } | A property tied to the map updated when the idle state event is fired . |
144,945 | public void addMarker ( Marker marker ) { if ( markers == null ) { markers = new HashSet < > ( ) ; } markers . add ( marker ) ; marker . setMap ( this ) ; } | Adds the supplied marker to the map . |
144,946 | public void removeMarker ( Marker marker ) { if ( markers != null && markers . contains ( marker ) ) { markers . remove ( marker ) ; } marker . setMap ( null ) ; } | Removes the supplied marker from the map . |
144,947 | public void clearMarkers ( ) { if ( markers != null && ! markers . isEmpty ( ) ) { markers . forEach ( ( m ) -> { m . setMap ( null ) ; } ) ; markers . clear ( ) ; } } | Removes all of the markers from the map . |
144,948 | protected void setProperty ( String propertyName , JavascriptObject propertyValue ) { jsObject . setMember ( propertyName , propertyValue . getJSObject ( ) ) ; } | Sets a property on this Javascript object for which the value is a Javascript object itself . |
144,949 | protected void setProperty ( String propertyName , JavascriptEnum propertyValue ) { jsObject . setMember ( propertyName , propertyValue . getEnumValue ( ) ) ; } | Sets a property on this Javascript object for which the value is a JavascriptEnum |
144,950 | protected < T > T getProperty ( String key , Class < T > type ) { Object returnValue = getProperty ( key ) ; if ( returnValue != null ) { return ( T ) returnValue ; } else { return null ; } } | Gets the property and casts to the appropriate type |
144,951 | protected < T > T invokeJavascriptReturnValue ( String function , Class < T > returnType ) { Object returnObject = invokeJavascript ( function ) ; if ( returnObject instanceof JSObject ) { try { Constructor < T > constructor = returnType . getConstructor ( JSObject . class ) ; return constructor . newInstance ( ( JSObj... | Invokes a JavaScript function that takes no arguments . |
144,952 | protected Object checkUndefined ( Object val ) { if ( val instanceof String && ( ( String ) val ) . equals ( "undefined" ) ) { return null ; } return val ; } | JSObject will return the String undefined at certain times so we need to make sure we re not getting a value that looks valid but isn t . |
144,953 | protected Boolean checkBoolean ( Object val , Boolean def ) { return ( val == null ) ? def : ( Boolean ) val ; } | Checks a returned Javascript value where we expect a boolean but could get null . |
144,954 | public String registerHandler ( GFXEventHandler handler ) { String uuid = UUID . randomUUID ( ) . toString ( ) ; handlers . put ( uuid , handler ) ; return uuid ; } | Registers a handler and returns the callback key to be passed to Javascript . |
144,955 | public void handleStateEvent ( String callbackKey ) { if ( handlers . containsKey ( callbackKey ) && handlers . get ( callbackKey ) instanceof StateEventHandler ) { ( ( StateEventHandler ) handlers . get ( callbackKey ) ) . handle ( ) ; } else { System . err . println ( "Error in handle: " + callbackKey + " for state h... | This method is called from Javascript passing in the previously created callback key . It uses that to find the correct handler and then passes on the call . State events in the Google Maps API don t pass any parameters . |
144,956 | public static final PolygonOptions buildClosedArc ( LatLong center , LatLong start , LatLong end , ArcType arcType ) { MVCArray res = buildArcPoints ( center , start , end ) ; if ( ArcType . ROUND . equals ( arcType ) ) { res . push ( center ) ; } return new PolygonOptions ( ) . paths ( res ) ; } | Builds the path for a closed arc returning a PolygonOptions that can be further customised before use . |
144,957 | public static final PolylineOptions buildOpenArc ( LatLong center , LatLong start , LatLong end ) { MVCArray res = buildArcPoints ( center , start , end ) ; return new PolylineOptions ( ) . path ( res ) ; } | Builds the path for an open arc based on a PolylineOptions . |
144,958 | public static final MVCArray buildArcPoints ( LatLong center , double startBearing , double endBearing , double radius ) { int points = DEFAULT_ARC_POINTS ; MVCArray res = new MVCArray ( ) ; if ( startBearing > endBearing ) { endBearing += 360.0 ; } double deltaBearing = endBearing - startBearing ; deltaBearing = delta... | Generates the points for an arc based on two bearings from a centre point and a radius . |
144,959 | public LatLong getLocation ( ) { if ( location == null ) { location = new LatLong ( ( JSObject ) ( getJSObject ( ) . getMember ( "location" ) ) ) ; } return location ; } | The location for this elevation . |
144,960 | protected String getArgString ( Object arg ) { if ( arg instanceof JavascriptObject ) { return ( ( JavascriptObject ) arg ) . getVariableName ( ) ; } else if ( arg instanceof JavascriptEnum ) { return ( ( JavascriptEnum ) arg ) . getEnumValue ( ) . toString ( ) ; } else { return arg . toString ( ) ; } } | Takes the specified object and converts the argument to a String . |
144,961 | private String registerEventHandler ( GFXEventHandler h ) { if ( ! registeredOnJS ) { JSObject doc = ( JSObject ) runtime . execute ( "document" ) ; doc . setMember ( "jsHandlers" , jsHandlers ) ; registeredOnJS = true ; } return jsHandlers . registerHandler ( h ) ; } | Registers an event handler in the repository shared between Javascript and Java . |
144,962 | public void addUIEventHandler ( JavascriptObject obj , UIEventType type , UIEventHandler h ) { String key = registerEventHandler ( h ) ; String mcall = "google.maps.event.addListener(" + obj . getVariableName ( ) + ", '" + type . name ( ) + "', " + "function(event) {document.jsHandlers.handleUIEvent('" + key + "', even... | Adds a handler for a mouse type event on the map . |
144,963 | public double distanceFrom ( LatLong end ) { double dLat = ( end . getLatitude ( ) - getLatitude ( ) ) * Math . PI / 180 ; double dLon = ( end . getLongitude ( ) - getLongitude ( ) ) * Math . PI / 180 ; double a = Math . sin ( dLat / 2 ) * Math . sin ( dLat / 2 ) + Math . cos ( getLatitude ( ) * Math . PI / 180 ) * Mat... | From v3_epoly . js calculates the distance between this LatLong point and another . |
144,964 | public LatLong getDestinationPoint ( double bearing , double distance ) { double brng = Math . toRadians ( bearing ) ; double lat1 = latToRadians ( ) ; double lon1 = longToRadians ( ) ; double lat2 = Math . asin ( Math . sin ( lat1 ) * Math . cos ( distance / EarthRadiusMeters ) + Math . cos ( lat1 ) * Math . sin ( dis... | Calculates the LatLong position of the end point of a line the specified distance from this LatLong along the provided bearing where North is 0 East is 90 etc . |
144,965 | public double getBearing ( LatLong end ) { if ( this . equals ( end ) ) { return 0 ; } double lat1 = latToRadians ( ) ; double lon1 = longToRadians ( ) ; double lat2 = end . latToRadians ( ) ; double lon2 = end . longToRadians ( ) ; double angle = - Math . atan2 ( Math . sin ( lon1 - lon2 ) * Math . cos ( lat2 ) , Math... | Calculates the bearing in degrees of the end LatLong point from this LatLong point . |
144,966 | public void getElevationForLocations ( LocationElevationRequest req , ElevationServiceCallback callback ) { this . callback = callback ; JSObject doc = ( JSObject ) getJSObject ( ) . eval ( "document" ) ; doc . setMember ( getVariableName ( ) , this ) ; StringBuilder r = new StringBuilder ( getVariableName ( ) ) . appe... | Create a request for elevations for multiple locations . |
144,967 | public void getElevationAlongPath ( PathElevationRequest req , ElevationServiceCallback callback ) { this . callback = callback ; JSObject doc = ( JSObject ) getJSObject ( ) . eval ( "document" ) ; doc . setMember ( getVariableName ( ) , this ) ; StringBuilder r = new StringBuilder ( getVariableName ( ) ) . append ( ".... | Create a request for elevations for samples along a path . |
144,968 | public static double distance ( double lat1 , double lon1 , double lat2 , double lon2 ) { double dLat = Math . toRadians ( lat2 - lat1 ) ; double dLon = Math . toRadians ( lon2 - lon1 ) ; lat1 = Math . toRadians ( lat1 ) ; lat2 = Math . toRadians ( lat2 ) ; double a = Math . sin ( dLat / 2 ) * Math . sin ( dLat / 2 ) +... | Returns the distance between the two points in meters . |
144,969 | public static String soundex ( String str ) { if ( str . length ( ) < 1 ) return "" ; char [ ] key = new char [ 4 ] ; key [ 0 ] = str . charAt ( 0 ) ; int pos = 1 ; char prev = '0' ; for ( int ix = 1 ; ix < str . length ( ) && pos < 4 ; ix ++ ) { char ch = str . charAt ( ix ) ; int charno ; if ( ch >= 'A' && ch <= 'Z' ... | Produces the Soundex key for the given string . |
144,970 | private static char [ ] buildTable ( ) { char [ ] table = new char [ 26 ] ; for ( int ix = 0 ; ix < table . length ; ix ++ ) table [ ix ] = '0' ; table [ 'B' - 'A' ] = '1' ; table [ 'P' - 'A' ] = '1' ; table [ 'F' - 'A' ] = '1' ; table [ 'V' - 'A' ] = '1' ; table [ 'C' - 'A' ] = '2' ; table [ 'S' - 'A' ] = '2' ; table ... | Builds the mapping table . |
144,971 | private void addStatement ( RecordImpl record , String subject , String property , String object ) { Collection < Column > cols = columns . get ( property ) ; if ( cols == null ) { if ( property . equals ( RDF_TYPE ) && ! types . isEmpty ( ) ) addValue ( record , subject , property , object ) ; return ; } for ( Column ... | common utility method for adding a statement to a record |
144,972 | public Filter geoSearch ( String value ) { GeopositionComparator comp = ( GeopositionComparator ) prop . getComparator ( ) ; double dist = comp . getMaxDistance ( ) ; double degrees = DistanceUtils . dist2Degrees ( dist , DistanceUtils . EARTH_MEAN_RADIUS_KM * 1000.0 ) ; Shape circle = spatialctx . makeCircle ( parsePo... | Returns a geoquery . |
144,973 | private Point parsePoint ( String point ) { int comma = point . indexOf ( ',' ) ; if ( comma == - 1 ) return null ; float lat = Float . valueOf ( point . substring ( 0 , comma ) ) ; float lng = Float . valueOf ( point . substring ( comma + 1 ) ) ; return spatialctx . makePoint ( lng , lat ) ; } | Parses coordinates into a Spatial4j point shape . |
144,974 | public static Statement open ( String jndiPath ) { try { Context ctx = new InitialContext ( ) ; DataSource ds = ( DataSource ) ctx . lookup ( jndiPath ) ; Connection conn = ds . getConnection ( ) ; return conn . createStatement ( ) ; } catch ( NamingException e ) { throw new DukeException ( "No database configuration f... | Get a configured database connection via JNDI . |
144,975 | public static Statement open ( String driverklass , String jdbcuri , Properties props ) { try { Driver driver = ( Driver ) ObjectUtils . instantiate ( driverklass ) ; Connection conn = driver . connect ( jdbcuri , props ) ; if ( conn == null ) throw new DukeException ( "Couldn't connect to database at " + jdbcuri ) ; r... | Opens a JDBC connection with the given parameters . |
144,976 | public static void close ( Statement stmt ) { try { Connection conn = stmt . getConnection ( ) ; try { if ( ! stmt . isClosed ( ) ) stmt . close ( ) ; } catch ( UnsupportedOperationException e ) { stmt . close ( ) ; } if ( conn != null && ! conn . isClosed ( ) ) conn . close ( ) ; } catch ( SQLException e ) { throw new... | Closes the JDBC statement and its associated connection . |
144,977 | public static boolean validate ( Statement stmt ) { try { Connection conn = stmt . getConnection ( ) ; if ( conn == null ) return false ; if ( ! conn . isClosed ( ) && conn . isValid ( 10 ) ) return true ; stmt . close ( ) ; conn . close ( ) ; } catch ( SQLException e ) { } return false ; } | Verifies that the connection is still alive . Returns true if it is false if it is not . If the connection is broken we try closing everything too so that the caller need only open a new connection . |
144,978 | public static int queryForInt ( Statement stmt , String sql , int nullvalue ) { try { ResultSet rs = stmt . executeQuery ( sql ) ; try { if ( ! rs . next ( ) ) return nullvalue ; return rs . getInt ( 1 ) ; } finally { rs . close ( ) ; } } catch ( SQLException e ) { throw new DukeException ( e ) ; } } | Runs a query that returns a single int . |
144,979 | public static boolean queryHasResult ( Statement stmt , String sql ) { try { ResultSet rs = stmt . executeQuery ( sql ) ; try { return rs . next ( ) ; } finally { rs . close ( ) ; } } catch ( SQLException e ) { throw new DukeException ( e ) ; } } | Returns true if the query result has at least one row . |
144,980 | public static String replaceAnyOf ( String value , String chars , char replacement ) { char [ ] tmp = new char [ value . length ( ) ] ; int pos = 0 ; for ( int ix = 0 ; ix < tmp . length ; ix ++ ) { char ch = value . charAt ( ix ) ; if ( chars . indexOf ( ch ) != - 1 ) tmp [ pos ++ ] = replacement ; else tmp [ pos ++ ]... | Replaces all characters in the second parameter found in the first parameter with the final character . |
144,981 | public static String normalizeWS ( String value ) { char [ ] tmp = new char [ value . length ( ) ] ; int pos = 0 ; boolean prevws = false ; for ( int ix = 0 ; ix < tmp . length ; ix ++ ) { char ch = value . charAt ( ix ) ; if ( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' ) { if ( prevws && pos != 0 ) tmp [ pos ... | Removes trailing and leading whitespace and also reduces each sequence of internal whitespace to a single space . |
144,982 | public static String get ( Properties props , String name , String defval ) { String value = props . getProperty ( name ) ; if ( value == null ) value = defval ; return value ; } | Returns the value of an optional property if the property is set . If it is not set defval is returned . |
144,983 | public Collection < DataSource > getDataSources ( int groupno ) { if ( groupno == 1 ) return group1 ; else if ( groupno == 2 ) return group2 ; else throw new DukeConfigException ( "Invalid group number: " + groupno ) ; } | Returns the data sources belonging to a particular group of data sources . Data sources are grouped in record linkage mode but not in deduplication mode so only use this method in record linkage mode . |
144,984 | public void addDataSource ( int groupno , DataSource datasource ) { if ( groupno == 0 ) datasources . add ( datasource ) ; else if ( groupno == 1 ) group1 . add ( datasource ) ; else if ( groupno == 2 ) group2 . add ( datasource ) ; } | Adds a data source to the configuration . If in deduplication mode groupno == 0 otherwise it gives the number of the group to which the data source belongs . |
144,985 | public double compare ( String v1 , String v2 ) { if ( comparator == null ) return 0.5 ; double sim = comparator . compare ( v1 , v2 ) ; if ( sim >= 0.5 ) return ( ( high - 0.5 ) * ( sim * sim ) ) + 0.5 ; else return low ; } | Returns the probability that the records v1 and v2 came from represent the same entity based on high and low probability settings etc . |
144,986 | public SparqlResult runQuery ( String endpoint , String query ) { return SparqlClient . execute ( endpoint , query , username , password ) ; } | An extension point so we can control how the query gets executed . This exists for testing purposes not because we believe it will actually be used for real . |
144,987 | private void merge ( Integer cid1 , Integer cid2 ) { Collection < String > klass1 = classix . get ( cid1 ) ; Collection < String > klass2 = classix . get ( cid2 ) ; if ( klass1 . size ( ) < klass2 . size ( ) ) { Collection < String > tmp = klass2 ; klass2 = klass1 ; klass1 = tmp ; Integer itmp = cid2 ; cid2 = cid1 ; ci... | Merges the two classes into a single class . The smaller class is removed while the largest class is kept . |
144,988 | private void bumpScores ( Map < Long , Score > candidates , List < Bucket > buckets , int ix ) { for ( ; ix < buckets . size ( ) ; ix ++ ) { Bucket b = buckets . get ( ix ) ; if ( b . nextfree > CUTOFF_FACTOR_2 * candidates . size ( ) ) return ; double score = b . getScore ( ) ; for ( Score s : candidates . values ( ) ... | Goes through the buckets from ix and out checking for each candidate if it s in one of the buckets and if so increasing its score accordingly . No new candidates are added . |
144,989 | private int collectCandidates ( Map < Long , Score > candidates , List < Bucket > buckets , int threshold ) { int ix ; for ( ix = 0 ; ix < threshold && candidates . size ( ) < ( CUTOFF_FACTOR_1 * max_search_hits ) ; ix ++ ) { Bucket b = buckets . get ( ix ) ; long [ ] ids = b . records ; double score = b . getScore ( )... | Goes through the first buckets picking out candidate records and tallying up their scores . |
144,990 | private List < Bucket > lookup ( Record record ) { List < Bucket > buckets = new ArrayList ( ) ; for ( Property p : config . getLookupProperties ( ) ) { String propname = p . getName ( ) ; Collection < String > values = record . getValues ( propname ) ; if ( values == null ) continue ; for ( String value : values ) { S... | Tokenizes lookup fields and returns all matching buckets in the index . |
144,991 | public void spawnThread ( DukeController controller , int check_interval ) { this . controller = controller ; timer = mgr . schedule ( this , 0 , check_interval * 1000 ) ; } | Starts a background thread which calls the controller every check_interval milliseconds . Returns immediately leaving the background thread running . |
144,992 | public String [ ] init ( String [ ] argv , int min , int max , Collection < CommandLineParser . Option > options ) throws IOException , SAXException { parser = new CommandLineParser ( ) ; parser . setMinimumArguments ( min ) ; parser . setMaximumArguments ( max ) ; parser . registerOption ( new CommandLineParser . Bool... | These exact lines are shared between three different tools so they have been moved here to reduce code duplication . |
144,993 | public static File createTempDirectory ( String prefix ) { File temp = null ; try { temp = File . createTempFile ( prefix != null ? prefix : "temp" , Long . toString ( System . nanoTime ( ) ) ) ; if ( ! ( temp . delete ( ) ) ) { throw new IOException ( "Could not delete temp file: " + temp . getAbsolutePath ( ) ) ; } i... | Creates a temporary folder using the given prefix to generate its name . |
144,994 | public static Configuration loadFromString ( String config ) throws IOException , SAXException { ConfigurationImpl cfg = new ConfigurationImpl ( ) ; XMLReader parser = XMLReaderFactory . createXMLReader ( ) ; parser . setContentHandler ( new ConfigHandler ( cfg , null ) ) ; Reader reader = new StringReader ( config ) ;... | Loads the configuration XML from the given string . |
144,995 | public void endRecord_ ( ) { Collection < Link > oldlinks = linkdb . getAllLinksFor ( getIdentity ( current ) ) ; if ( oldlinks != null ) { Map < String , Link > oldmap = new HashMap ( oldlinks . size ( ) ) ; for ( Link l : oldlinks ) oldmap . put ( makeKey ( l ) , l ) ; for ( Link newl : new ArrayList < Link > ( curli... | this method is called from the event methods |
144,996 | public void write ( Configuration config ) throws IOException { pp . startDocument ( ) ; pp . startElement ( "duke" , null ) ; pp . startElement ( "schema" , null ) ; writeElement ( "threshold" , "" + config . getThreshold ( ) ) ; if ( config . getMaybeThreshold ( ) != 0.0 ) writeElement ( "maybe-threshold" , "" + conf... | Writes the given configuration to the given file . |
144,997 | public static void parse ( Reader src , StatementHandler handler ) throws IOException { new NTriplesParser ( src , handler ) . parse ( ) ; } | Reads the NTriples file from the reader pushing statements into the handler . |
144,998 | public static int distance ( String s1 , String s2 ) { if ( s1 . length ( ) == 0 ) return s2 . length ( ) ; if ( s2 . length ( ) == 0 ) return s1 . length ( ) ; int s1len = s1 . length ( ) ; int [ ] matrix = new int [ ( s1len + 1 ) * ( s2 . length ( ) + 1 ) ] ; for ( int col = 0 ; col <= s2 . length ( ) ; col ++ ) matr... | This is the original naive implementation using the Wagner & Fischer algorithm from 1974 . It uses a flattened matrix for speed but still computes the entire matrix . |
144,999 | public static int compactDistance ( String s1 , String s2 ) { if ( s1 . length ( ) == 0 ) return s2 . length ( ) ; if ( s2 . length ( ) == 0 ) return s1 . length ( ) ; int maxdist = Math . min ( s1 . length ( ) , s2 . length ( ) ) / 2 ; int s1len = s1 . length ( ) ; int [ ] column = new int [ s1len + 1 ] ; int ix2 = 0 ... | Optimized version of the Wagner & Fischer algorithm that only keeps a single column in the matrix in memory at a time . It implements the simple cutoff but otherwise computes the entire matrix . It is roughly twice as fast as the original function . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.