idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
6,200
public void rotate ( Quaternion rotation ) { Transform3D m = new Transform3D ( ) ; m . transform ( this . getFirstAxis ( ) ) ; m . transform ( this . getSecondAxis ( ) ) ; m . transform ( this . getThirdAxis ( ) ) ; this . setFirstAxisExtent ( this . getFirstAxis ( ) . length ( ) ) ; this . setSecondAxisExtent ( this . getSecondAxis ( ) . length ( ) ) ; this . setThirdAxisExtent ( this . getThirdAxis ( ) . length ( ) ) ; this . getFirstAxis ( ) . normalize ( ) ; this . getSecondAxis ( ) . normalize ( ) ; this . getThirdAxis ( ) . normalize ( ) ; }
Rotate the box around its pivot point . The pivot point is the center of the box .
176
19
6,201
public void rotate ( Quaternion rotation , Point3D pivot ) { if ( pivot != null ) { // Change the center Transform3D m1 = new Transform3D ( ) ; m1 . setTranslation ( - pivot . getX ( ) , - pivot . getY ( ) , - pivot . getZ ( ) ) ; Transform3D m2 = new Transform3D ( ) ; m2 . setRotation ( rotation ) ; Transform3D m3 = new Transform3D ( ) ; m3 . setTranslation ( pivot . getX ( ) , pivot . getY ( ) , pivot . getZ ( ) ) ; Transform3D r = new Transform3D ( ) ; r . mul ( m1 , m2 ) ; r . mul ( m3 ) ; r . transform ( this . getCenter ( ) ) ; } rotate ( rotation ) ; }
Rotate the box around a given pivot point . The default pivot point of the center of the box .
184
21
6,202
protected void definePath ( ZoomableGraphicsContext gc , T element ) { gc . beginPath ( ) ; final PathIterator2afp < PathElement2d > pathIterator = element . toPath2D ( ) . getPathIterator ( ) ; switch ( pathIterator . getWindingRule ( ) ) { case EVEN_ODD : gc . setFillRule ( FillRule . EVEN_ODD ) ; break ; case NON_ZERO : gc . setFillRule ( FillRule . NON_ZERO ) ; break ; default : throw new IllegalStateException ( ) ; } while ( pathIterator . hasNext ( ) ) { final PathElement2d pelement = pathIterator . next ( ) ; switch ( pelement . getType ( ) ) { case LINE_TO : gc . lineTo ( pelement . getToX ( ) , pelement . getToY ( ) ) ; break ; case MOVE_TO : gc . moveTo ( pelement . getToX ( ) , pelement . getToY ( ) ) ; break ; case CLOSE : gc . closePath ( ) ; break ; case CURVE_TO : gc . bezierCurveTo ( pelement . getCtrlX1 ( ) , pelement . getCtrlY1 ( ) , pelement . getCtrlX2 ( ) , pelement . getCtrlY2 ( ) , pelement . getToX ( ) , pelement . getToY ( ) ) ; break ; case QUAD_TO : gc . quadraticCurveTo ( pelement . getCtrlX1 ( ) , pelement . getCtrlY1 ( ) , pelement . getToX ( ) , pelement . getToY ( ) ) ; break ; case ARC_TO : //TODO: implements arcTo gc . lineTo ( pelement . getToX ( ) , pelement . getToY ( ) ) ; break ; default : break ; } } }
Draw the polyline path .
424
6
6,203
@ Pure public static String getFirstFreeBusStopName ( BusNetwork busNetwork ) { if ( busNetwork == null ) { return null ; } int nb = busNetwork . getBusStopCount ( ) ; String name ; do { ++ nb ; name = Locale . getString ( "NAME_TEMPLATE" , Integer . toString ( nb ) ) ; //$NON-NLS-1$ } while ( busNetwork . getBusStop ( name ) != null ) ; return name ; }
Replies a bus stop name that was not exist in the specified bus network .
110
16
6,204
private void notifyDependencies ( ) { if ( getContainer ( ) != null ) { for ( final BusHub hub : busHubs ( ) ) { hub . checkPrimitiveValidity ( ) ; } for ( final BusItineraryHalt halt : getBindedBusHalts ( ) ) { halt . checkPrimitiveValidity ( ) ; } } }
Notifies any dependent object about a validation change from this bus stop .
78
14
6,205
public void setPosition ( GeoLocationPoint position ) { if ( ( this . position == null && position != null ) || ( this . position != null && ! this . position . equals ( position ) ) ) { this . position = position ; fireShapeChanged ( ) ; checkPrimitiveValidity ( ) ; } }
Set the position of the element .
66
7
6,206
@ Pure public double distance ( double x , double y ) { if ( isValidPrimitive ( ) ) { final GeoLocationPoint p = getGeoPosition ( ) ; return Point2D . getDistancePointPoint ( p . getX ( ) , p . getY ( ) , x , y ) ; } return Double . NaN ; }
Replies the distance between the given point and this bus stop .
73
13
6,207
@ Pure public double distance ( BusStop stop ) { if ( isValidPrimitive ( ) && stop . isValidPrimitive ( ) ) { final GeoLocationPoint p = getGeoPosition ( ) ; final GeoLocationPoint p2 = stop . getGeoPosition ( ) ; return Point2D . getDistancePointPoint ( p . getX ( ) , p . getY ( ) , p2 . getX ( ) , p2 . getY ( ) ) ; } return Double . NaN ; }
Replies the distance between the given bus stop and this bus stop .
108
14
6,208
void addBusHub ( BusHub hub ) { if ( this . hubs == null ) { this . hubs = new WeakArrayList <> ( ) ; } this . hubs . add ( hub ) ; }
Add a hub reference .
43
5
6,209
void removeBusHub ( BusHub hub ) { if ( this . hubs != null ) { this . hubs . remove ( hub ) ; if ( this . hubs . isEmpty ( ) ) { this . hubs = null ; } } }
Remove a hub reference .
49
5
6,210
void addBusHalt ( BusItineraryHalt halt ) { if ( this . halts == null ) { this . halts = new WeakArrayList <> ( ) ; } this . halts . add ( halt ) ; }
Add a bus halt reference .
51
6
6,211
void removeBusHalt ( BusItineraryHalt halt ) { if ( this . halts != null ) { this . halts . remove ( halt ) ; if ( this . halts . isEmpty ( ) ) { this . halts = null ; } } }
Remove a bus halt reference .
58
6
6,212
@ Pure public Iterable < BusItineraryHalt > getBindedBusHalts ( ) { if ( this . halts == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableCollection ( this . halts ) ; }
Replies the bus itinerary halts associated to this bus stop .
56
14
6,213
public static Vector2ifx convert ( Tuple2D < ? > tuple ) { if ( tuple instanceof Vector2ifx ) { return ( Vector2ifx ) tuple ; } return new Vector2ifx ( tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Vector2ifx .
62
13
6,214
@ Pure public static int compareAttrs ( Attribute arg0 , Attribute arg1 ) { if ( arg0 == arg1 ) { return 0 ; } if ( arg0 == null ) { return 1 ; } if ( arg1 == null ) { return - 1 ; } final String n0 = arg0 . getName ( ) ; final String n1 = arg1 . getName ( ) ; final int cmp = compareAttrNames ( n0 , n1 ) ; if ( cmp == 0 ) { return compareValues ( arg0 , arg1 ) ; } return cmp ; }
Compare the two specified attributes .
126
6
6,215
@ Pure public static int compareAttrNames ( String arg0 , String arg1 ) { if ( arg0 == arg1 ) { return 0 ; } if ( arg0 == null ) { return Integer . MAX_VALUE ; } if ( arg1 == null ) { return Integer . MIN_VALUE ; } return arg0 . compareToIgnoreCase ( arg1 ) ; }
Compare the two specified attribute names .
79
7
6,216
@ Pure public boolean isTemporaryChange ( ) { final Object src = getSource ( ) ; if ( src instanceof MapLayer ) { return ( ( MapLayer ) src ) . isTemporaryLayer ( ) ; } return false ; }
Replies if the change in the layer was marked as temporary . The usage of this information depends on the listener s behaviour .
50
25
6,217
@ Pure protected final Graph < ST , PT > getParentGraph ( ) { return this . parentGraph == null ? null : this . parentGraph . get ( ) ; }
Replies the parent graph is this subgraph was built .
36
12
6,218
public final void build ( GraphIterator < ST , PT > iterator , SubGraphBuildListener < ST , PT > listener ) { assert iterator != null ; final Set < ComparableWeakReference < PT > > reachedPoints = new TreeSet <> ( ) ; GraphIterationElement < ST , PT > element ; ST segment ; PT point ; PT firstPoint = null ; this . parentGraph = new WeakReference <> ( iterator . getGraph ( ) ) ; this . segments . clear ( ) ; this . pointNumber = 0 ; this . terminalPoints . clear ( ) ; while ( iterator . hasNext ( ) ) { element = iterator . nextElement ( ) ; point = element . getPoint ( ) ; segment = element . getSegment ( ) ; // First reached segment if ( this . segments . isEmpty ( ) ) { firstPoint = point ; } this . segments . add ( segment ) ; if ( listener != null ) { listener . segmentAdded ( this , element ) ; } // Register terminal points point = segment . getOtherSidePoint ( point ) ; final ComparableWeakReference < PT > ref = new ComparableWeakReference <> ( point ) ; if ( element . isTerminalSegment ( ) ) { if ( ! reachedPoints . contains ( ref ) ) { this . terminalPoints . add ( ref ) ; if ( listener != null ) { listener . terminalPointReached ( this , point , segment ) ; } } } else { this . terminalPoints . remove ( ref ) ; reachedPoints . add ( ref ) ; if ( listener != null ) { listener . nonTerminalPointReached ( this , point , segment ) ; } } } if ( firstPoint != null ) { final ComparableWeakReference < PT > ref = new ComparableWeakReference <> ( firstPoint ) ; if ( ! reachedPoints . contains ( ref ) ) { this . terminalPoints . add ( ref ) ; } } this . pointNumber = this . terminalPoints . size ( ) + reachedPoints . size ( ) ; reachedPoints . clear ( ) ; }
Build a subgraph from the specified graph .
431
9
6,219
@ Pure public List < Object > getAddedValues ( ) { if ( this . newValues == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . newValues ) ; }
Replies the list of added data .
47
8
6,220
@ Pure public List < Object > getRemovedValues ( ) { if ( this . oldValues == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . oldValues ) ; }
Replies the list of removed data .
47
8
6,221
@ Pure public List < Object > getCurrentValues ( ) { if ( this . allValues == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . allValues ) ; }
Replies the list of current data .
47
8
6,222
public static < A , B > ImmutableMultiset < B > transformedCopy ( Multiset < A > ms , Function < A , B > func ) { final ImmutableMultiset . Builder < B > ret = ImmutableMultiset . builder ( ) ; for ( final Multiset . Entry < A > entry : ms . entrySet ( ) ) { final B transformedElement = func . apply ( entry . getElement ( ) ) ; ret . addCopies ( transformedElement , entry . getCount ( ) ) ; } return ret . build ( ) ; }
Returns a new Multiset resulting from transforming each element of the input Multiset by a function . If two or more elements are mapped to the same value by the function their counts will be summed in the new Multiset .
122
47
6,223
public static < A , B > Multiset < B > mutableTransformedCopy ( Multiset < A > ms , Function < A , B > func ) { final Multiset < B > ret = HashMultiset . create ( ) ; for ( final Multiset . Entry < A > entry : ms . entrySet ( ) ) { final B transformedElement = func . apply ( entry . getElement ( ) ) ; ret . add ( transformedElement , entry . getCount ( ) ) ; } return ret ; }
Same as transformedCopy except the returned Multiset is mutable .
112
14
6,224
public static boolean allSameSize ( List < Collection < ? > > collections ) { if ( collections . isEmpty ( ) ) { return true ; } final int referenceSize = collections . get ( 0 ) . size ( ) ; for ( final Collection < ? > col : collections ) { if ( col . size ( ) != referenceSize ) { return false ; } } return true ; }
Returns true if and only if all the collections in the provided list have the same size . Returns true if the provided list is empty .
80
27
6,225
public static < T > List < T > coerceNullToEmpty ( List < T > list ) { return MoreObjects . firstNonNull ( list , ImmutableList . < T > of ( ) ) ; }
Turns null into an empty list and leaves other inputs untouched .
46
13
6,226
protected void update ( DocumentEvent event ) { String text ; try { text = event . getDocument ( ) . getText ( event . getDocument ( ) . getStartPosition ( ) . getOffset ( ) , event . getDocument ( ) . getEndPosition ( ) . getOffset ( ) - 1 ) ; model . setObject ( text ) ; } catch ( BadLocationException e1 ) { log . log ( Level . SEVERE , "some portion of the given range was not a valid part of the document. " + "The location in the exception is the first bad position encountered." , e1 ) ; } }
Update the underlying model object .
131
6
6,227
@ Pure public static String makeAndroidApplicationName ( String applicationName ) { final String fullName ; if ( applicationName . indexOf ( ' ' ) >= 0 ) { fullName = applicationName ; } else { fullName = "org.arakhne.partnership." + applicationName ; //$NON-NLS-1$ } return fullName ; }
Make a valid android application name from the given application name . A valid android application name is a package name followed by the name of the application .
78
29
6,228
@ Pure public static ClassLoader getContextClassLoader ( ) throws AndroidException { synchronized ( Android . class ) { final ClassLoader cl = ( contextClassLoader == null ) ? null : contextClassLoader . get ( ) ; if ( cl != null ) { return cl ; } } final Object context = getContext ( ) ; try { final Method method = context . getClass ( ) . getMethod ( "getClassLoader" ) ; //$NON-NLS-1$ final Object classLoader = method . invoke ( context ) ; final ClassLoader cl = ( ClassLoader ) classLoader ; synchronized ( Android . class ) { contextClassLoader = new WeakReference <> ( cl ) ; } return cl ; } catch ( Exception e ) { throw new AndroidException ( e ) ; } }
Replies the class loader of the current Android context .
165
11
6,229
public static void showExceptionDialog ( Exception exception , Component parentComponent , String ... additionalMessages ) { String title = exception . getLocalizedMessage ( ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<html><body width='650'>" ) ; sb . append ( "<h2>" ) ; sb . append ( exception . getLocalizedMessage ( ) ) ; sb . append ( "</h2>" ) ; sb . append ( "<p>" ) ; sb . append ( exception . getMessage ( ) ) ; Stream . of ( additionalMessages ) . forEach ( am -> sb . append ( "<p>" + am ) ) ; String htmlMessage = sb . toString ( ) ; JOptionPane . showMessageDialog ( parentComponent , htmlMessage , title , JOptionPane . ERROR_MESSAGE ) ; }
Show exception dialog .
191
4
6,230
@ SuppressWarnings ( "unchecked" ) public static < ObsT , SummaryT > Builder < ObsT , SummaryT > forSummarizer ( final ObservationSummarizer < ? super ObsT , ? extends SummaryT > observationSummarizer , int numSamples , final Random rng ) { return new Builder < ObsT , SummaryT > ( ( ObservationSummarizer < ObsT , SummaryT > ) observationSummarizer , numSamples , rng ) ; }
cast is safe - see covariance and contravariance notes on ObservationSummarizer
106
19
6,231
@ SuppressWarnings ( "static-method" ) @ Provides @ Singleton public PrintConfigCommand providePrintConfigCommand ( Provider < BootLogger > bootLogger , Provider < ModulesMetadata > modulesMetadata , Injector injector ) { return new PrintConfigCommand ( bootLogger , modulesMetadata , injector ) ; }
Provide the command for running the command for printing out the configuration values .
74
15
6,232
protected final void fireShapeChanged ( ) { resetBoundingBox ( ) ; if ( isEventFirable ( ) ) { final GISElementContainer < ? > container = getContainer ( ) ; if ( container != null ) { container . onMapElementGraphicalAttributeChanged ( ) ; } } }
Invoked when the shape of this element changed .
63
10
6,233
@ Pure protected final boolean boundsIntersects ( Shape2D < ? , ? , ? , ? , ? , ? extends Rectangle2afp < ? , ? , ? , ? , ? , ? > > rectangle ) { final Rectangle2d bounds = getBoundingBox ( ) ; assert bounds != null ; return bounds . intersects ( rectangle ) ; }
Replies if the bounds of this element has an intersection with the specified rectangle .
77
16
6,234
@ Pure public boolean isContainerColorUsed ( ) { final AttributeValue val = getAttributeCollection ( ) . getAttribute ( ATTR_USE_CONTAINER_COLOR ) ; if ( val != null ) { try { return val . getBoolean ( ) ; } catch ( AttributeException e ) { // } } return false ; }
Replies the flag that indicates if this element use its color or the container s color .
72
18
6,235
@ Pure public VisualizationType getVisualizationType ( ) { if ( this . vizualizationType == null ) { final AttributeValue val = getAttributeCollection ( ) . getAttribute ( ATTR_VISUALIZATION_TYPE ) ; if ( val != null ) { try { this . vizualizationType = val . getJavaObject ( ) ; } catch ( Exception e ) { // } } if ( this . vizualizationType == null ) { this . vizualizationType = VisualizationType . SHAPE_ONLY ; } } return this . vizualizationType ; }
Replies the type of visualization that must be used by this element .
125
14
6,236
public void setVisualizationType ( VisualizationType type ) { try { if ( getVisualizationType ( ) != type ) { this . vizualizationType = type ; getAttributeCollection ( ) . setAttribute ( ATTR_VISUALIZATION_TYPE , new AttributeValueImpl ( type ) ) ; } } catch ( AttributeException e ) { // } }
Set the type of visualization that must be used by this element .
78
13
6,237
@ SuppressWarnings ( "static-method" ) public Vector1dfx newVector ( ObjectProperty < WeakReference < Segment1D < ? , ? > > > segment , DoubleProperty x , DoubleProperty y ) { return new Vector1dfx ( segment , x , y ) ; }
Create a vector with properties .
62
6
6,238
public static final boolean isBlank ( String s ) { if ( s == null || s . trim ( ) . length ( ) == 0 ) { return true ; } return false ; }
Whether string is a space or null
39
7
6,239
public T set ( T newValue ) { final T obj = this . object ; this . object = newValue ; return obj ; }
Set the parameter .
28
4
6,240
@ Pure public static String getPreferredAttributeNameForRoadWidth ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . get ( "ROAD_WIDTH_ATTR_NAME" , DEFAULT_ATTR_ROAD_WIDTH ) ; //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_WIDTH ; }
Replies the preferred name for the width of the roads .
104
12
6,241
public static void setPreferredAttributeNameForRoadWidth ( String name ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( name == null || "" . equals ( name ) || DEFAULT_ATTR_ROAD_WIDTH . equalsIgnoreCase ( name ) ) { //$NON-NLS-1$ prefs . remove ( "ROAD_WIDTH_ATTR_NAME" ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_WIDTH_ATTR_NAME" , name ) ; //$NON-NLS-1$ } } }
Set the preferred name for the width of the roads .
157
11
6,242
@ Pure public static String getPreferredAttributeNameForLaneCount ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . get ( "LANE_COUNT_ATTR_NAME" , DEFAULT_ATTR_LANE_COUNT ) ; //$NON-NLS-1$ } return DEFAULT_ATTR_LANE_COUNT ; }
Replies the preferred name for the number of lanes of the roads .
102
14
6,243
public static void setPreferredAttributeNameForLaneCount ( String name ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( name == null || "" . equals ( name ) || DEFAULT_ATTR_LANE_COUNT . equalsIgnoreCase ( name ) ) { //$NON-NLS-1$ prefs . remove ( "LANE_COUNT_ATTR_NAME" ) ; //$NON-NLS-1$ } else { prefs . put ( "LANE_COUNT_ATTR_NAME" , name ) ; //$NON-NLS-1$ } } }
Set the preferred name for the number of lanes of the roads .
155
13
6,244
@ Pure public static int getPreferredLaneCount ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . getInt ( "LANE_COUNT" , DEFAULT_LANE_COUNT ) ; //$NON-NLS-1$ } return DEFAULT_LANE_COUNT ; }
Replies the preferred number of lanes for a road segment .
89
12
6,245
public static void setPreferredLaneCount ( int count ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( count < 0 ) { prefs . remove ( "LANE_COUNT" ) ; //$NON-NLS-1$ } else { prefs . putInt ( "LANE_COUNT" , count ) ; //$NON-NLS-1$ } } }
Set the preferred number of lanes for a road segment .
106
11
6,246
@ Pure public static double getPreferredLaneWidth ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . getDouble ( "LANE_WIDTH" , DEFAULT_LANE_WIDTH ) ; //$NON-NLS-1$ } return DEFAULT_LANE_WIDTH ; }
Replies the preferred width of a lane for a road segment .
92
13
6,247
public static void setPreferredLaneWidth ( double width ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( width <= 0 ) { prefs . remove ( "LANE_WIDTH" ) ; //$NON-NLS-1$ } else { prefs . putDouble ( "LANE_WIDTH" , width ) ; //$NON-NLS-1$ } } }
Set the preferred width of a lane for a road segment .
108
12
6,248
@ Pure public static LegalTrafficSide getPreferredLegalTrafficSide ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; String name = null ; if ( prefs != null ) { name = prefs . get ( "LEGAL_TRAFFIC_SIDE" , null ) ; //$NON-NLS-1$ } if ( name != null ) { LegalTrafficSide side ; try { side = LegalTrafficSide . valueOf ( name ) ; } catch ( Throwable exception ) { side = null ; } if ( side != null ) { return side ; } } return LegalTrafficSide . getCurrent ( ) ; }
Replies the preferred side of traffic for vehicles on road segments .
151
13
6,249
public static void setPreferredLegalTrafficSide ( LegalTrafficSide side ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( side == null ) { prefs . remove ( "LEGAL_TRAFFIC_SIDE" ) ; //$NON-NLS-1$ } else { prefs . put ( "LEGAL_TRAFFIC_SIDE" , side . name ( ) ) ; //$NON-NLS-1$ } } }
Set the preferred side of traffic for vehicles on road segments .
125
12
6,250
@ Pure public static String getPreferredAttributeNameForTrafficDirection ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . get ( "TRAFFIC_DIRECTION_ATTR_NAME" , DEFAULT_ATTR_TRAFFIC_DIRECTION ) ; //$NON-NLS-1$ } return DEFAULT_ATTR_TRAFFIC_DIRECTION ; }
Replies the preferred name for the traffic direction on the roads .
112
13
6,251
public static void setPreferredAttributeNameForTrafficDirection ( String name ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( name == null || "" . equals ( name ) || DEFAULT_ATTR_TRAFFIC_DIRECTION . equalsIgnoreCase ( name ) ) { //$NON-NLS-1$ prefs . remove ( "TRAFFIC_DIRECTION_ATTR_NAME" ) ; //$NON-NLS-1$ } else { prefs . put ( "TRAFFIC_DIRECTION_ATTR_NAME" , name ) ; //$NON-NLS-1$ } } }
Set the preferred name for the traffic direction on the roads .
165
12
6,252
@ Pure public static String getPreferredAttributeValueForTrafficDirection ( TrafficDirection direction , int index ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { final StringBuilder b = new StringBuilder ( ) ; b . append ( "TRAFFIC_DIRECTION_VALUE_" ) ; //$NON-NLS-1$ b . append ( direction . name ( ) ) ; b . append ( "_" ) ; //$NON-NLS-1$ b . append ( index ) ; final String v = prefs . get ( b . toString ( ) , null ) ; if ( v != null && ! "" . equals ( v ) ) { //$NON-NLS-1$ return v ; } } try { return getSystemDefault ( direction , index ) ; } catch ( AssertionError e ) { throw e ; } catch ( Throwable exception ) { return null ; } }
Replies the preferred value of traffic direction used in the attributes for the traffic direction on the roads .
216
20
6,253
@ Pure public static List < String > getPreferredAttributeValuesForTrafficDirection ( TrafficDirection direction ) { final List < String > array = new ArrayList <> ( ) ; int i = 0 ; String value = getPreferredAttributeValueForTrafficDirection ( direction , i ) ; while ( value != null ) { array . add ( value ) ; value = getPreferredAttributeValueForTrafficDirection ( direction , ++ i ) ; } return array ; }
Replies the preferred values of traffic direction used in the attributes for the traffic direction on the roads .
102
20
6,254
@ Pure public static String getSystemDefault ( TrafficDirection direction , int valueIndex ) { // Values from the IGN-BDCarto standard switch ( direction ) { case DOUBLE_WAY : switch ( valueIndex ) { case 0 : return DEFAULT_DOUBLE_WAY_TRAFFIC_DIRECTION_0 ; case 1 : return DEFAULT_DOUBLE_WAY_TRAFFIC_DIRECTION_1 ; default : throw new IndexOutOfBoundsException ( ) ; } case NO_ENTRY : switch ( valueIndex ) { case 0 : return DEFAULT_NO_ENTRY_TRAFFIC_DIRECTION_0 ; case 1 : return DEFAULT_NO_ENTRY_TRAFFIC_DIRECTION_1 ; default : throw new IndexOutOfBoundsException ( ) ; } case NO_WAY : switch ( valueIndex ) { case 0 : return DEFAULT_NO_WAY_TRAFFIC_DIRECTION_0 ; case 1 : return DEFAULT_NO_WAY_TRAFFIC_DIRECTION_1 ; default : throw new IndexOutOfBoundsException ( ) ; } case ONE_WAY : switch ( valueIndex ) { case 0 : return DEFAULT_ONE_WAY_TRAFFIC_DIRECTION_0 ; case 1 : return DEFAULT_ONE_WAY_TRAFFIC_DIRECTION_1 ; default : throw new IndexOutOfBoundsException ( ) ; } default : } throw new IllegalArgumentException ( ) ; }
Replies the system default string - value for the traffic direction at the given index in the list of system default values .
333
24
6,255
@ Pure public static String getSystemDefault ( RoadType type ) { switch ( type ) { case OTHER : return DEFAULT_OTHER_ROAD_TYPE ; case PRIVACY_PATH : return DEFAULT_PRIVACY_ROAD_TYPE ; case TRACK : return DEFAULT_TRACK_ROAD_TYPE ; case BIKEWAY : return DEFAULT_BIKEWAY_ROAD_TYPE ; case LOCAL_ROAD : return DEFAULT_LOCAL_ROAD_ROAD_TYPE ; case INTERCHANGE_RAMP : return DEFAULT_INTERCHANGE_RAMP_ROAD_TYPE ; case MAJOR_URBAN_AXIS : return DEFAULT_MAJOR_URBAN_ROAD_TYPE ; case SECONDARY_ROAD : return DEFAULT_SECONDARY_ROAD_TYPE ; case MAJOR_ROAD : return DEFAULT_MAJOR_ROAD_TYPE ; case FREEWAY : return DEFAULT_FREEWAY_ROAD_TYPE ; default : } throw new IllegalArgumentException ( ) ; }
Replies the system - default value for the type of road .
238
13
6,256
@ Pure public static List < String > getSystemDefaults ( TrafficDirection direction ) { final List < String > array = new ArrayList <> ( ) ; try { int i = 0 ; while ( true ) { array . add ( getSystemDefault ( direction , i ) ) ; ++ i ; } } catch ( AssertionError e ) { throw e ; } catch ( Throwable exception ) { // } return array ; }
Replies the system default string - values for the traffic direction .
91
13
6,257
public static void setPreferredAttributeValueForTrafficDirection ( TrafficDirection direction , int index , String value ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { final StringBuilder keyName = new StringBuilder ( ) ; keyName . append ( "TRAFFIC_DIRECTION_VALUE_" ) ; //$NON-NLS-1$ keyName . append ( direction . name ( ) ) ; keyName . append ( "_" ) ; //$NON-NLS-1$ keyName . append ( index ) ; String sysDef ; try { sysDef = getSystemDefault ( direction , index ) ; } catch ( IndexOutOfBoundsException exception ) { sysDef = null ; } if ( value == null || "" . equals ( value ) //$NON-NLS-1$ || ( sysDef != null && sysDef . equalsIgnoreCase ( value ) ) ) { prefs . remove ( keyName . toString ( ) ) ; return ; } prefs . put ( keyName . toString ( ) , value ) ; } }
Set the preferred value of traffic direction used in the attributes for the traffic direction on the roads .
248
19
6,258
@ Pure public static double getPreferredRoadConnectionDistance ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . getDouble ( "ROAD_CONNECTION_DISTANCE" , DEFAULT_ROAD_CONNECTION_DISTANCE ) ; //$NON-NLS-1$ } return DEFAULT_ROAD_CONNECTION_DISTANCE ; }
Replies the preferred distance below which roads may be connected .
104
12
6,259
public static void setPreferredRoadConnectionDistance ( double distance ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( distance <= 0. ) { prefs . remove ( "ROAD_CONNECTION_DISTANCE" ) ; //$NON-NLS-1$ } else { prefs . putDouble ( "ROAD_CONNECTION_DISTANCE" , distance ) ; //$NON-NLS-1$ } } }
Set the preferred distance below which roads may be connected .
117
11
6,260
@ Pure public static RoadType getPreferredRoadType ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; String name = null ; if ( prefs != null ) { name = prefs . get ( "ROAD_TYPE" , null ) ; //$NON-NLS-1$ } if ( name != null ) { RoadType type ; try { type = RoadType . valueOf ( name ) ; } catch ( Throwable exception ) { type = null ; } if ( type != null ) { return type ; } } return RoadType . OTHER ; }
Replies the preferred type of road segment .
131
9
6,261
public static void setPreferredRoadType ( RoadType type ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( type == null ) { prefs . remove ( "ROAD_TYPE" ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_TYPE" , type . name ( ) ) ; //$NON-NLS-1$ } } }
Set the preferred type of road segment .
107
8
6,262
@ Pure public static String getPreferredAttributeNameForRoadType ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . get ( "ROAD_TYPE_ATTR_NAME" , DEFAULT_ATTR_ROAD_TYPE ) ; //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_TYPE ; }
Replies the preferred name for the types of the roads .
98
12
6,263
public static void setPreferredAttributeNameForRoadType ( String name ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( name == null || "" . equals ( name ) || DEFAULT_ATTR_ROAD_TYPE . equalsIgnoreCase ( name ) ) { //$NON-NLS-1$ prefs . remove ( "ROAD_TYPE_ATTR_NAME" ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_TYPE_ATTR_NAME" , name ) ; //$NON-NLS-1$ } } }
Set the preferred name for the types of the roads .
151
11
6,264
@ Pure public static String getPreferredAttributeValueForRoadType ( RoadType type ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { final String v = prefs . get ( "ROAD_TYPE_VALUE_" + type . name ( ) , null ) ; //$NON-NLS-1$ if ( v != null && ! "" . equals ( v ) ) { //$NON-NLS-1$ return v ; } } return getSystemDefault ( type ) ; }
Replies the preferred value of road type used in the attributes for the types of the roads .
124
19
6,265
public static void setPreferredAttributeValueForRoadType ( RoadType type , String value ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { final String sysDef = getSystemDefault ( type ) ; if ( value == null || "" . equals ( value ) || sysDef . equalsIgnoreCase ( value ) ) { //$NON-NLS-1$ prefs . remove ( "ROAD_TYPE_VALUE_" + type . name ( ) ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_TYPE_VALUE_" + type . name ( ) , value ) ; //$NON-NLS-1$ } } }
Set the preferred value of road type used in the attributes for the types of the roads .
167
18
6,266
@ Pure public static String getPreferredAttributeNameForRoadName ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . get ( "ROAD_NAME_ATTR_NAME" , DEFAULT_ATTR_ROAD_NAME ) ; //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_NAME ; }
Replies the preferred name for the name of the roads .
98
12
6,267
public static void setPreferredAttributeNameForRoadName ( String name ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( name == null || "" . equals ( name ) || DEFAULT_ATTR_ROAD_NAME . equalsIgnoreCase ( name ) ) { //$NON-NLS-1$ prefs . remove ( "ROAD_NAME_ATTR_NAME" ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_NAME_ATTR_NAME" , name ) ; //$NON-NLS-1$ } } }
Set the preferred name for the name of the roads .
151
11
6,268
@ Pure public static String getPreferredAttributeNameForRoadNumber ( ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { return prefs . get ( "ROAD_NUMBER_ATTR_NAME" , DEFAULT_ATTR_ROAD_NUMBER ) ; //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_NUMBER ; }
Replies the preferred name for the numbers of the roads .
101
12
6,269
public static void setPreferredAttributeNameForRoadNumber ( String name ) { final Preferences prefs = Preferences . userNodeForPackage ( RoadNetworkConstants . class ) ; if ( prefs != null ) { if ( name == null || "" . equals ( name ) || DEFAULT_ATTR_ROAD_NUMBER . equalsIgnoreCase ( name ) ) { //$NON-NLS-1$ prefs . remove ( "ROAD_NUMBER_ATTR_NAME" ) ; //$NON-NLS-1$ } else { prefs . put ( "ROAD_NUMBER_ATTR_NAME" , name ) ; //$NON-NLS-1$ } } }
Set the preferred name for the numbers of the roads .
154
11
6,270
@ SuppressWarnings ( "checkstyle:magicnumber" ) public void readDBFHeader ( ) throws IOException { if ( this . finished ) { throw new EOFDBaseFileException ( ) ; } if ( this . fieldCount != - 1 ) { // The header was already red return ; } //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 0 1 byte DBF Format id // 0x03: FoxBase+, FoxPro, dBASEIII+ // dBASEIV, no memo // 0x83: FoxBase+, dBASEIII+ with memo // 0xF5: FoxPro with memo // 0x8B: dBASEIV with memo // 0x8E: dBASEIV with SQL table this . fileVersion = this . stream . readByte ( ) ; //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 1-3 3 bytes Date of last update: YMD final Calendar cal = new GregorianCalendar ( ) ; cal . set ( Calendar . YEAR , this . stream . readByte ( ) + 1900 ) ; cal . set ( Calendar . MONTH , this . stream . readByte ( ) - 1 ) ; cal . set ( Calendar . DAY_OF_MONTH , this . stream . readByte ( ) ) ; this . lastUpdateDate = cal . getTime ( ) ; // Get the count of records // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 4-7 4 bytes Number of records in the table this . recordCount = this . stream . readLEInt ( ) ; // Get the count of fields (nbBytes / size of a Field - ending byte ODh) // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 8-9 2 bytes Number of bytes in the header // #bytes = 32 + 32 * #fields + 1; this . fieldCount = ( this . stream . readLEShort ( ) - 1 ) / 32 - 1 ; // Skip the ending chars of the header // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 10-11 2 bytes Number of bytes in the record this . recordSize = this . stream . readLEShort ( ) ; //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 12-13 2 bytes Reserved // 14 1 byte Incomplete transaction // 0x00: Ignored / Transaction End // 0x01: Transaction started // 15 1 byte Encryption flag // 0x00: Not encrypted // 0x01: Encrypted // 16-19 4 bytes Free record thread (reserved for LAN only) // 20-27 8 bytes Reserved for multi-user dBASE (dBASE III+) // 28 1 byte MDX flag (dBASE IV) // 0x00: index upon demand // 0x01: production index exists this . stream . skipBytes ( 17 ) ; // use skipBytes because it force to skip the specified amount, instead of skip() //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 29 1 byte Language driver ID // See {@link DBaseCodePage} for details. final byte b = this . stream . readByte ( ) ; this . codePage = DBaseCodePage . fromLanguageCode ( b ) ; //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 30-31 2 bytes Reserved this . stream . skipBytes ( 2 ) ; // use skipBytes because it force to skip the specified amount, instead of skip() // Update the offset of the first record with the size of the header this . firstRecordOffset = 32 ; }
Read the header of the DBF file .
736
9
6,271
@ Pure public String getDBFFieldName ( int index ) { if ( this . fieldCount != - 1 ) { try { final DBaseFileField field = this . fields . get ( index ) ; if ( field != null ) { return field . getName ( ) ; } } catch ( Exception exception ) { // } } return null ; }
Replies the name of the i - th field .
73
11
6,272
@ Pure public int getDBFFieldIndex ( String name ) { assert name != null ; if ( this . fieldCount != - 1 ) { try { int i = 0 ; for ( final DBaseFileField field : this . fields ) { if ( field != null && name . equals ( field . getName ( ) ) ) { return i ; } ++ i ; } } catch ( Exception exception ) { // } } return - 1 ; }
Replies the column index of the specified column name .
93
11
6,273
@ Pure public DBaseFieldType getDBFFieldType ( int index ) { if ( this . fieldCount != - 1 ) { try { final DBaseFileField field = this . fields . get ( index ) ; if ( field != null ) { return field . getType ( ) ; } } catch ( Exception exception ) { // } } return null ; }
Replies the type of the i - th field .
76
11
6,274
@ SuppressWarnings ( { "checkstyle:npathcomplexity" , "checkstyle:magicnumber" } ) public List < DBaseFileField > readDBFFields ( ) throws IOException , EOFException { if ( this . fields != null ) { return this . fields ; } if ( this . finished ) { throw new EOFDBaseFileException ( ) ; } if ( this . fieldCount == - 1 ) { throw new MustCallReadHeaderFunctionException ( ) ; } // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 32-m n*32 bytes Field descriptors (see bellow) // m+1 1 byte terminator character 0x0D // A field contains at least the "removal flag" byte int byteSize = 1 ; final ArrayList < DBaseFileField > array = new ArrayList <> ( ) ; final Charset charSet = ( this . codePage == null ) ? null : this . codePage . getChatset ( ) ; String columnName ; for ( int idxFields = 0 ; idxFields < this . fieldCount ; ++ idxFields ) { // Read the field header // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 0-10 11 bytes Field name, filled with 0x00 // 11 1 byte Field type (see bellow) // 12-15 4 bytes Field data address, not useful for disk // 16 1 byte Field length // 17 1 byte Field decimal count // 18-19 2 bytes Reserved for dBASE III+ on a Lan // 20 1 byte Work area ID // 21-22 2 bytes Reserved for dBASE III+ on a Lan // 23 1 byte SET FIELDS flag // 24-31 7 bytes Reserved final byte [ ] header = new byte [ 32 ] ; this . stream . readFully ( header ) ; // Update the offset of the first record with the end-of-header character this . firstRecordOffset += header . length ; // Read the name of the field until 0x00 int nbChars = 0 ; for ( int i = 0 ; i <= 10 ; ++ i ) { if ( header [ i ] == 0 ) { break ; } ++ nbChars ; } final byte [ ] bName = new byte [ nbChars ] ; System . arraycopy ( header , 0 , bName , 0 , nbChars ) ; if ( charSet != null ) { columnName = new String ( bName , charSet ) ; } else { columnName = new String ( bName ) ; } // Read the type final DBaseFieldType dbftype = DBaseFieldType . fromByte ( header [ 11 ] ) ; final DBaseFileField field = new DBaseFileField ( columnName , dbftype , // convert unsigned byte into int header [ 16 ] & 0xFF , // convert unsigned byte into int header [ 17 ] & 0xFF , idxFields ) ; array . add ( field ) ; byteSize += field . getLength ( ) ; } // Check if the byte size of the field list corresponds to size specified record size inside the header if ( byteSize != this . recordSize ) { throw new InvalidRecordSizeException ( this . recordSize , byteSize ) ; } // Read the terminator character 0x0D final byte bt = this . stream . readByte ( ) ; if ( bt != 0x0D ) { throw new InvalidDBaseFieldTerminationException ( bt ) ; } // Update the offset of the first record with the end-of-header character ++ this . firstRecordOffset ; this . fields = array ; // Save the position inside the input stream for seeking function if ( this . stream . markSupported ( ) ) { this . stream . mark ( this . recordSize * this . recordCount + this . firstRecordOffset + 1 ) ; } return array ; }
Read the field definitions . Multiple calls to this method will return always the same data structure . The column list is red only at the first call to this function . So you could use this method to obtain the list of the dBASE file s columns .
823
50
6,275
public void skip ( int skipAmount ) throws IOException { if ( this . recordCount == - 1 ) { throw new MustCallReadHeaderFunctionException ( ) ; } if ( ( this . readingPosition + skipAmount ) >= this . recordCount ) { throw new EOFException ( ) ; } if ( skipAmount > 0 ) { this . readingPosition += skipAmount ; //this.stream.reset(); //this.stream.skipBytes(this.recordSize * this.readingPosition); final long skippedAmount = this . stream . skipBytes ( this . recordSize * skipAmount ) ; // use skipBytes because it force to skip the specified amount, instead of skip() assert skippedAmount == this . recordSize * skipAmount ; } }
Move the reading head by the specified record count amount .
155
11
6,276
public List < DBaseFileRecord > readRestOfDBFRecords ( ) throws IOException { if ( this . finished ) { throw new EOFDBaseFileException ( ) ; } if ( this . recordCount == - 1 ) { throw new MustCallReadHeaderFunctionException ( ) ; } final Vector < DBaseFileRecord > records = new Vector <> ( ) ; try { while ( this . readingPosition < this . recordCount ) { final DBaseFileRecord record = readNextDBFRecord ( ) ; if ( record != null ) { records . add ( record ) ; } } } catch ( EOFException e ) { // } this . finished = true ; this . stream . close ( ) ; return records ; }
Read all the records .
155
5
6,277
private int readStringRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < String > value ) throws IOException { final byte [ ] recordData = new byte [ field . getLength ( ) ] ; System . arraycopy ( rawData , rawOffset , recordData , 0 , recordData . length ) ; String data ; if ( hasOption ( OPTION_DECODE_STRING ) ) { data = Locale . decodeString ( recordData ) . trim ( ) ; } else { data = new String ( recordData ) . trim ( ) ; } // ignore the data that does not contain anything if ( data == null || data . length ( ) == 0 || DBaseFileField . isUnsetValue ( data ) ) { data = null ; } value . set ( data ) ; return recordData . length ; }
Read a STRING record value .
190
7
6,278
@ SuppressWarnings ( "checkstyle:magicnumber" ) private static int readDateRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < Date > value ) throws IOException { final GregorianCalendar cal = new GregorianCalendar ( ) ; final int year = ( ( rawData [ rawOffset ] & 0xFF ) - ' ' ) * 1000 + ( ( rawData [ rawOffset + 1 ] & 0xFF ) - ' ' ) * 100 + ( ( rawData [ rawOffset + 2 ] & 0xFF ) - ' ' ) * 10 + ( ( rawData [ rawOffset + 3 ] & 0xFF ) - ' ' ) ; final int month = ( ( rawData [ rawOffset + 4 ] & 0xFF ) - ' ' ) * 10 + ( ( rawData [ rawOffset + 5 ] & 0xFF ) - ' ' ) ; final int day = ( ( rawData [ rawOffset + 6 ] & 0xFF ) - ' ' ) * 10 + ( ( rawData [ rawOffset + 7 ] & 0xFF ) - ' ' ) ; cal . set ( Calendar . YEAR , year ) ; cal . set ( Calendar . MONTH , month ) ; cal . set ( Calendar . DAY_OF_MONTH , day ) ; if ( year == cal . get ( Calendar . YEAR ) && month == cal . get ( Calendar . MONTH ) && day == cal . get ( Calendar . DAY_OF_MONTH ) ) { value . set ( cal . getTime ( ) ) ; return 8 ; } throw new InvalidRawDataFormatException ( nrecord , nfield , new String ( rawData , rawOffset , field . getLength ( ) ) ) ; }
Read a DATE record value .
383
7
6,279
private static int readNumberRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < Double > value ) throws IOException { final String buffer = new String ( rawData , rawOffset , field . getLength ( ) ) ; try { final String b = buffer . trim ( ) ; if ( b != null && b . length ( ) > 0 ) { value . set ( new Double ( b ) ) ; return field . getLength ( ) ; } } catch ( NumberFormatException e ) { // } throw new InvalidRawDataFormatException ( nrecord , nfield , buffer ) ; }
Read a NUMBER record value .
140
7
6,280
@ SuppressWarnings ( "checkstyle:magicnumber" ) private static int readBooleanRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < Boolean > value ) throws IOException { final int byteCode = rawData [ rawOffset ] & 0xFF ; if ( TRUE_CHARS . indexOf ( byteCode ) != - 1 ) { value . set ( true ) ; return 1 ; } if ( FALSE_CHARS . indexOf ( byteCode ) != - 1 ) { value . set ( false ) ; return 1 ; } throw new InvalidRawDataFormatException ( nrecord , nfield , Integer . toString ( byteCode ) ) ; }
Read a BOOLEAN record value .
158
9
6,281
private static int read2ByteIntegerRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < Integer > value ) throws IOException { final short rawNumber = EndianNumbers . toLEShort ( rawData [ rawOffset ] , rawData [ rawOffset + 1 ] ) ; try { value . set ( new Integer ( rawNumber ) ) ; return 2 ; } catch ( NumberFormatException exception ) { throw new InvalidRawDataFormatException ( nrecord , nfield , Short . toString ( rawNumber ) ) ; } }
Read a 2 BYTE INTEGER record value .
128
11
6,282
@ SuppressWarnings ( "checkstyle:magicnumber" ) private static int read4ByteIntegerRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < Long > value ) throws IOException { final int rawNumber = EndianNumbers . toLEInt ( rawData [ rawOffset ] , rawData [ rawOffset + 1 ] , rawData [ rawOffset + 2 ] , rawData [ rawOffset + 3 ] ) ; try { value . set ( new Long ( rawNumber ) ) ; return 4 ; } catch ( NumberFormatException exception ) { throw new InvalidRawDataFormatException ( nrecord , nfield , Long . toString ( rawNumber ) ) ; } }
Read a 4 BYTE INTEGER record value .
160
11
6,283
@ SuppressWarnings ( "checkstyle:magicnumber" ) private static int read8ByteDoubleRecordValue ( DBaseFileField field , int nrecord , int nfield , byte [ ] rawData , int rawOffset , OutputParameter < Double > value ) throws IOException { final double rawNumber = EndianNumbers . toLEDouble ( rawData [ rawOffset ] , rawData [ rawOffset + 1 ] , rawData [ rawOffset + 2 ] , rawData [ rawOffset + 3 ] , rawData [ rawOffset + 4 ] , rawData [ rawOffset + 5 ] , rawData [ rawOffset + 6 ] , rawData [ rawOffset + 7 ] ) ; try { value . set ( new Double ( rawNumber ) ) ; return 8 ; } catch ( NumberFormatException exception ) { throw new InvalidRawDataFormatException ( nrecord , nfield , Double . toString ( rawNumber ) ) ; } }
Read a 8 BYTE DOUBLE record value .
196
11
6,284
@ Pure public boolean isColumnSelectable ( DBaseFileField column ) { return column != null && ( this . selectedColumns . isEmpty ( ) || this . selectedColumns . contains ( column ) ) ; }
Replies if the specified column could be replied or ignored .
46
12
6,285
public static void loadDefaultEncryptionModule ( ) { // Be sure that the cryptographical algorithms are loaded final Provider [ ] providers = Security . getProviders ( ) ; boolean found = false ; for ( final Provider provider : providers ) { if ( provider instanceof SunJCE ) { found = true ; break ; } } if ( ! found ) { Security . addProvider ( new SunJCE ( ) ) ; } }
Load the default encryption module .
88
6
6,286
public static String md5 ( String str ) { if ( str == null ) { return "" ; //$NON-NLS-1$ } final byte [ ] uniqueKey = str . getBytes ( ) ; byte [ ] hash = null ; try { hash = MessageDigest . getInstance ( "MD5" ) . digest ( uniqueKey ) ; //$NON-NLS-1$ } catch ( NoSuchAlgorithmException e ) { throw new Error ( Locale . getString ( "NO_MD5" ) ) ; //$NON-NLS-1$ } final StringBuilder hashString = new StringBuilder ( ) ; for ( int i = 0 ; i < hash . length ; ++ i ) { final String hex = Integer . toHexString ( hash [ i ] ) ; if ( hex . length ( ) == 1 ) { hashString . append ( ' ' ) ; hashString . append ( hex . charAt ( hex . length ( ) - 1 ) ) ; } else { hashString . append ( hex . substring ( hex . length ( ) - 2 ) ) ; } } return hashString . toString ( ) ; }
Replies a MD5 key .
247
7
6,287
public BooleanProperty isMultiPartsProperty ( ) { if ( this . isMultipart == null ) { this . isMultipart = new ReadOnlyBooleanWrapper ( this , MathFXAttributeNames . IS_MULTIPARTS , false ) ; this . isMultipart . bind ( Bindings . createBooleanBinding ( ( ) -> { boolean foundOne = false ; for ( final PathElementType type : innerTypesProperty ( ) ) { if ( type == PathElementType . MOVE_TO ) { if ( foundOne ) { return true ; } foundOne = true ; } } return false ; } , innerTypesProperty ( ) ) ) ; } return this . isMultipart ; }
Replies the isMultiParts property .
152
8
6,288
private String getWthInsiCodeOr ( Map wthData ) { String insiName = getWthInsiCode ( wthData ) ; if ( insiName . equals ( "" ) ) { return getNextDefName ( ) ; } else { return insiName ; } }
Get the 4 - bit institute code for weather file name if not available from data holder then use default code
63
21
6,289
public static String getWthInsiCode ( Map wthData ) { String wst_name = getValueOr ( wthData , "wst_name" , "" ) ; if ( wst_name . matches ( "(\\w{4})|(\\w{8})" ) ) { return wst_name ; } String wst_id = getValueOr ( wthData , "wst_id" , "" ) ; if ( wst_id . matches ( "(\\w{4})|(\\w{8})" ) ) { return wst_id ; } wst_id = getValueOr ( wthData , "dssat_insi" , "" ) ; if ( wst_id . matches ( "(\\w{4})|(\\w{8})" ) ) { return wst_id ; } return "" ; }
Get the 4 - bit institute code for weather file nam
192
12
6,290
public static String getWthYearDuration ( Map wthData ) { String yearDur = "" ; ArrayList < Map > wthRecords = ( ArrayList ) getObjectOr ( wthData , "dailyWeather" , new ArrayList ( ) ) ; if ( ! wthRecords . isEmpty ( ) ) { // Get the year of starting date and end date String startYear = getValueOr ( ( wthRecords . get ( 0 ) ) , "w_date" , " " ) . substring ( 2 , 4 ) . trim ( ) ; String endYear = getValueOr ( ( wthRecords . get ( wthRecords . size ( ) - 1 ) ) , "w_date" , " " ) . substring ( 2 , 4 ) . trim ( ) ; // If not available, do not show year and duration in the file name if ( ! startYear . equals ( "" ) && ! endYear . equals ( "" ) ) { yearDur += startYear ; try { int iStartYear = Integer . parseInt ( startYear ) ; int iEndYear = Integer . parseInt ( endYear ) ; iStartYear += iStartYear <= 15 ? 2000 : 1900 ; // P.S. 2015 is the cross year for the current version iEndYear += iEndYear <= 15 ? 2000 : 1900 ; // P.S. 2015 is the cross year for the current version int duration = iEndYear - iStartYear + 1 ; // P.S. Currently the system only support the maximum of 99 years for duration duration = duration > 99 ? 99 : duration ; yearDur += String . format ( "%02d" , duration ) ; } catch ( Exception e ) { yearDur += "01" ; // Default duration uses 01 (minimum value) } } } return yearDur ; }
Get the last 2 - bit year number and 2 - bit of the duration for weather file name
386
19
6,291
private static IndexEnvironment setupIndexer ( File outputDirectory , int memory , boolean storeDocs ) throws Exception { final IndexEnvironment env = new IndexEnvironment ( ) ; env . setMemory ( memory * ONE_MEGABYTE ) ; final Specification spec = env . getFileClassSpec ( "trectext" ) ; env . addFileClass ( spec ) ; env . setStoreDocs ( storeDocs ) ; // if we don't build indices on DOCNO then getting the docIds at query time is // extremely slow env . setMetadataIndexedFields ( new String [ ] { "docno" } , new String [ ] { "docno" } ) ; env . create ( outputDirectory . getAbsolutePath ( ) , statusMonitor ) ; return env ; }
because its only reference is in native code then we will get a crash .
168
15
6,292
@ SuppressWarnings ( "unchecked" ) void registerConsumer ( Inspector < ? super OutT > subInspector ) { consumers . add ( ( Inspector < OutT > ) subInspector ) ; }
Inspector is contravariant in its type
47
11
6,293
@ Pure public static int classifies ( AbstractGISTreeSetNode < ? , ? > node , GeoLocation location ) { if ( node . getZone ( ) == IcosepQuadTreeZone . ICOSEP ) { return classifiesIcocep ( node . verticalSplit , node . horizontalSplit , location . toBounds2D ( ) ) ; } return classifiesNonIcocep ( node . verticalSplit , node . horizontalSplit , location . toBounds2D ( ) ) ; }
Replies the classificiation of the specified location .
109
11
6,294
@ Pure static boolean contains ( int region , double cutX , double cutY , double pointX , double pointY ) { switch ( IcosepQuadTreeZone . values ( ) [ region ] ) { case SOUTH_WEST : return pointX <= cutX && pointY <= cutY ; case SOUTH_EAST : return pointX >= cutX && pointY <= cutY ; case NORTH_WEST : return pointX <= cutX && pointY >= cutY ; case NORTH_EAST : return pointX >= cutX && pointY >= cutY ; case ICOSEP : return true ; default : } return false ; }
Replies if the given region contains the given point .
139
11
6,295
@ Pure private static boolean isOutsideNodeBuildingBounds ( AbstractGISTreeSetNode < ? , ? > node , Rectangle2afp < ? , ? , ? , ? , ? , ? > location ) { final Rectangle2d b2 = getNormalizedNodeBuildingBounds ( node , location ) ; if ( b2 == null ) { return false ; } return Rectangle2afp . classifiesRectangleRectangle ( b2 . getMinX ( ) , b2 . getMinY ( ) , b2 . getMaxX ( ) , b2 . getMaxY ( ) , location . getMinX ( ) , location . getMinY ( ) , location . getMaxX ( ) , location . getMaxY ( ) ) != IntersectionType . INSIDE ; }
Replies if the given geolocation is outside the building bounds of the given node .
170
18
6,296
private static Rectangle2d union ( AbstractGISTreeSetNode < ? , ? > node , Rectangle2afp < ? , ? , ? , ? , ? , ? > shape ) { final Rectangle2d b = getNodeBuildingBounds ( node ) ; b . setUnion ( shape ) ; normalize ( b , shape ) ; return b ; }
Compute the union of the building bounds of the given node and the given geolocation .
78
19
6,297
@ Pure public static Rectangle2d getNodeBuildingBounds ( AbstractGISTreeSetNode < ? , ? > node ) { assert node != null ; final double w = node . nodeWidth / 2. ; final double h = node . nodeHeight / 2. ; final IcosepQuadTreeZone zone = node . getZone ( ) ; final double lx ; final double ly ; if ( zone == null ) { // Is root node lx = node . verticalSplit - w ; ly = node . horizontalSplit - h ; } else { switch ( zone ) { case SOUTH_EAST : lx = node . verticalSplit ; ly = node . horizontalSplit - h ; break ; case SOUTH_WEST : lx = node . verticalSplit - w ; ly = node . horizontalSplit - h ; break ; case NORTH_EAST : lx = node . verticalSplit ; ly = node . horizontalSplit ; break ; case NORTH_WEST : lx = node . verticalSplit - w ; ly = node . horizontalSplit ; break ; case ICOSEP : return getNodeBuildingBounds ( node . getParentNode ( ) ) ; default : throw new IllegalStateException ( ) ; } } return new Rectangle2d ( lx , ly , node . nodeWidth , node . nodeHeight ) ; }
Replies the bounds of the area covered by the node . The replied rectangle is not normalized .
282
19
6,298
private static < P extends GISPrimitive , N extends AbstractGISTreeSetNode < P , N > > N createNode ( N parent , IcosepQuadTreeZone region , GISTreeSetNodeFactory < P , N > builder ) { Rectangle2d area = parent . getAreaBounds ( ) ; if ( region == IcosepQuadTreeZone . ICOSEP ) { return builder . newNode ( IcosepQuadTreeZone . ICOSEP , area . getMinX ( ) , area . getMinY ( ) , area . getWidth ( ) , area . getHeight ( ) ) ; } if ( parent . getZone ( ) == IcosepQuadTreeZone . ICOSEP ) { area = computeIcosepSubarea ( region , area ) ; return builder . newNode ( region , area . getMinX ( ) , area . getMinY ( ) , area . getWidth ( ) , area . getHeight ( ) ) ; } final Point2d childCutPlane = computeCutPoint ( region , parent ) ; assert childCutPlane != null ; final double w = area . getWidth ( ) / 4. ; final double h = area . getHeight ( ) / 4. ; return builder . newNode ( region , childCutPlane . getX ( ) - w , childCutPlane . getY ( ) - h , 2. * w , 2. * h ) ; }
Create a child node that supports the specified region .
311
10
6,299
private static Rectangle2d computeIcosepSubarea ( IcosepQuadTreeZone region , Rectangle2d area ) { if ( area == null || area . isEmpty ( ) ) { return area ; } final double demiWidth = area . getWidth ( ) / 2. ; final double demiHeight = area . getHeight ( ) / 2. ; switch ( region ) { case ICOSEP : return area ; case SOUTH_WEST : return new Rectangle2d ( area . getMinX ( ) , area . getMinY ( ) , demiWidth , demiHeight ) ; case NORTH_WEST : return new Rectangle2d ( area . getMinX ( ) , area . getCenterY ( ) , demiWidth , demiHeight ) ; case NORTH_EAST : return new Rectangle2d ( area . getCenterX ( ) , area . getMinY ( ) , demiWidth , demiHeight ) ; case SOUTH_EAST : return new Rectangle2d ( area . getMinX ( ) , area . getMinY ( ) , demiWidth , demiHeight ) ; default : } throw new IllegalStateException ( ) ; }
Computes the area covered by a child node of an icosep - node .
261
17