idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
6,600
@ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) public static AttributeValueImpl parse ( String text ) { final AttributeValueImpl value = new AttributeValueImpl ( text ) ; if ( text != null && ! text . isEmpty ( ) ) { Object binValue ; for ( final AttributeType type : AttributeType . values ( ) ) { try { binValue = null ; switch ( type ) { case BOOLEAN : binValue = value . getBoolean ( ) ; break ; case DATE : binValue = value . getDate ( ) ; break ; case ENUMERATION : binValue = value . getEnumeration ( ) ; break ; case INET_ADDRESS : binValue = value . getInetAddress ( ) ; break ; case INTEGER : binValue = value . getInteger ( ) ; break ; case OBJECT : binValue = value . getJavaObject ( ) ; break ; case POINT : binValue = parsePoint ( ( String ) value . value , true ) ; break ; case POINT3D : binValue = parsePoint3D ( ( String ) value . value , true ) ; break ; case POLYLINE : binValue = parsePolyline ( ( String ) value . value , true ) ; break ; case POLYLINE3D : binValue = parsePolyline3D ( ( String ) value . value , true ) ; break ; case REAL : binValue = value . getReal ( ) ; break ; case STRING : binValue = value . getString ( ) ; break ; case TIMESTAMP : binValue = value . getTimestamp ( ) ; break ; case TYPE : binValue = value . getJavaClass ( ) ; break ; case URI : binValue = parseURI ( ( String ) value . value ) ; break ; case URL : binValue = value . getURL ( ) ; break ; case UUID : binValue = parseUUID ( ( String ) value . value ) ; break ; default : } if ( binValue != null ) { return new AttributeValueImpl ( type , binValue ) ; } } catch ( Throwable exception ) { } } } return value ; }
Replies the best attribute value that is representing the given text .
6,601
public static int compareValues ( AttributeValue arg0 , AttributeValue arg1 ) { if ( arg0 == arg1 ) { return 0 ; } if ( arg0 == null ) { return Integer . MAX_VALUE ; } if ( arg1 == null ) { return Integer . MIN_VALUE ; } Object v0 ; Object v1 ; try { v0 = arg0 . getValue ( ) ; } catch ( Exception exception ) { v0 = null ; } try { v1 = arg1 . getValue ( ) ; } catch ( Exception exception ) { v1 = null ; } return compareRawValues ( v0 , v1 ) ; }
Compare the two specified values .
6,602
@ SuppressWarnings ( { "unchecked" , "rawtypes" , "checkstyle:returncount" , "checkstyle:npathcomplexity" } ) private static int compareRawValues ( Object arg0 , Object arg1 ) { if ( arg0 == arg1 ) { return 0 ; } if ( arg0 == null ) { return Integer . MAX_VALUE ; } if ( arg1 == null ) { return Integer . MIN_VALUE ; } if ( ( arg0 instanceof Number ) && ( arg1 instanceof Number ) ) { return Double . compare ( ( ( Number ) arg0 ) . doubleValue ( ) , ( ( Number ) arg1 ) . doubleValue ( ) ) ; } try { if ( arg0 instanceof Comparable < ? > ) { return ( ( Comparable ) arg0 ) . compareTo ( arg1 ) ; } } catch ( RuntimeException exception ) { } try { if ( arg1 instanceof Comparable < ? > ) { return - ( ( Comparable ) arg1 ) . compareTo ( arg0 ) ; } } catch ( RuntimeException exception ) { } if ( arg0 . equals ( arg1 ) ) { return 0 ; } final String sv0 = arg0 . toString ( ) ; final String sv1 = arg1 . toString ( ) ; if ( sv0 == sv1 ) { return 0 ; } if ( sv0 == null ) { return Integer . MAX_VALUE ; } if ( sv1 == null ) { return Integer . MIN_VALUE ; } return sv0 . compareTo ( sv1 ) ; }
Compare the internal objects of two specified values .
6,603
protected void setInternalValue ( Object value , AttributeType type ) { this . value = value ; this . assigned = this . value != null ; this . type = type ; }
Set this value with the content of the specified one .
6,604
private static Date extractDate ( String text , Locale locale ) { DateFormat fmt ; for ( int style = 0 ; style <= 3 ; ++ style ) { for ( int style2 = 0 ; style2 <= 3 ; ++ style2 ) { fmt = DateFormat . getDateTimeInstance ( style , style2 , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { } } fmt = DateFormat . getDateInstance ( style , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { } fmt = DateFormat . getTimeInstance ( style , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { } } return null ; }
Parse a date according to the specified locale .
6,605
public static boolean isDbaseFile ( File file ) { return FileType . isContentType ( file , MimeName . MIME_DBASE_FILE . getMimeConstant ( ) ) ; }
Replies if the specified file content is a dBase file .
6,606
protected void stroke ( ZoomableGraphicsContext gc , T element ) { final double radius = element . getRadius ( ) ; final double diameter = radius * radius ; final double minx = element . getX ( ) - radius ; final double miny = element . getY ( ) - radius ; gc . strokeOval ( minx , miny , diameter , diameter ) ; }
Stroke the circle .
6,607
protected void fill ( ZoomableGraphicsContext gc , T element ) { final double radius = element . getRadius ( ) ; final double diameter = radius * radius ; final double minx = element . getX ( ) - radius ; final double miny = element . getY ( ) - radius ; gc . fillOval ( minx , miny , diameter , diameter ) ; }
Fill the circle .
6,608
public static String getFirstFreeBushaltName ( BusItinerary busItinerary ) { if ( busItinerary == null ) { return null ; } int nb = busItinerary . size ( ) ; String name ; do { ++ nb ; name = Locale . getString ( "NAME_TEMPLATE" , Integer . toString ( nb ) ) ; } while ( busItinerary . getBusHalt ( name ) != null ) ; return name ; }
Replies a bus halt name that was not exist in the specified bus itinerary .
6,609
public boolean setBusStop ( BusStop busStop ) { final BusStop old = getBusStop ( ) ; if ( ( busStop == null && old != null ) || ( busStop != null && ! busStop . equals ( old ) ) ) { if ( old != null ) { old . removeBusHalt ( this ) ; } this . busStop = busStop == null ? null : new WeakReference < > ( busStop ) ; if ( busStop != null ) { busStop . addBusHalt ( this ) ; } clearPositionBuffers ( ) ; fireShapeChanged ( ) ; checkPrimitiveValidity ( ) ; return true ; } return false ; }
Set the bus stop associated to this halt .
6,610
public RoadSegment getRoadSegment ( ) { final BusItinerary itinerary = getContainer ( ) ; if ( itinerary != null && this . roadSegmentIndex >= 0 && this . roadSegmentIndex < itinerary . getRoadSegmentCount ( ) ) { return itinerary . getRoadSegmentAt ( this . roadSegmentIndex ) ; } return null ; }
Replies the road segment on which this bus halt was .
6,611
public Direction1D getRoadSegmentDirection ( ) { final BusItinerary itinerary = getContainer ( ) ; if ( itinerary != null && this . roadSegmentIndex >= 0 && this . roadSegmentIndex < itinerary . getRoadSegmentCount ( ) ) { return itinerary . getRoadSegmentDirection ( this . roadSegmentIndex ) ; } return null ; }
Replies on which direction the bus halt is located on the road segment .
6,612
public void setType ( BusItineraryHaltType type ) { if ( type != null && type != this . type ) { this . type = type ; firePrimitiveChanged ( ) ; } }
Set the type of the bus halt .
6,613
public boolean insideBusHub ( ) { final BusStop busStop = getBusStop ( ) ; if ( busStop != null ) { return busStop . insideBusHub ( ) ; } return false ; }
Replies if this bus halt is inside a hub throught an associated bus stop .
6,614
public Iterable < BusHub > busHubs ( ) { final BusStop busStop = getBusStop ( ) ; if ( busStop != null ) { return busStop . busHubs ( ) ; } return Collections . emptyList ( ) ; }
Replies the hubs in which this bus halt is located in throught an associated bus stop .
6,615
public Iterator < BusHub > busHubIterator ( ) { final BusStop busStop = getBusStop ( ) ; if ( busStop != null ) { return busStop . busHubIterator ( ) ; } return Collections . emptyIterator ( ) ; }
Replies the hubs in which this bus stop is located in throught an associated bus stop .
6,616
public GeoLocationPoint getGeoPosition ( ) { final Point2d p = getPosition2D ( ) ; if ( p != null ) { return new GeoLocationPoint ( p . getX ( ) , p . getY ( ) ) ; } return null ; }
Replies the geo position .
6,617
public double distanceToBusStop ( ) { final Point2d p1 = getPosition2D ( ) ; if ( p1 != null ) { final BusStop stop = getBusStop ( ) ; if ( stop != null ) { final Point2d p2 = stop . getPosition2D ( ) ; if ( p2 != null ) { return p1 . getDistance ( p2 ) ; } } } return Double . NaN ; }
Replies the distance between the position of this bus itinerary halt and the position of the bus stop associated to this bus itinerary halt .
6,618
public double distance ( Point2D < ? , ? > point ) { assert point != null ; final GeoLocationPoint p = getGeoPosition ( ) ; if ( p != null ) { return Point2D . getDistancePointPoint ( p . getX ( ) , p . getY ( ) , point . getX ( ) , point . getY ( ) ) ; } return Double . NaN ; }
Replies the distance between the given point and this bus halt .
6,619
public double distance ( BusItineraryHalt halt ) { assert halt != null ; final GeoLocationPoint p = getGeoPosition ( ) ; final GeoLocationPoint p2 = halt . getGeoPosition ( ) ; if ( p != null && p2 != null ) { return Point2D . getDistancePointPoint ( p . getX ( ) , p . getY ( ) , p2 . getX ( ) , p2 . getY ( ) ) ; } return Double . NaN ; }
Replies the distance between the given bus halt and this bus halt .
6,620
public double distance ( BusStop busStop ) { assert busStop != null ; final GeoLocationPoint p = getGeoPosition ( ) ; final GeoLocationPoint p2 = busStop . getGeoPosition ( ) ; if ( p != null && p2 != null ) { 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 halt .
6,621
public static < NodeT extends ConstituentNode < NodeT , ? > > HeadFinder < NodeT > createChinesePTBFromResources ( ) throws IOException { final boolean headInitial = true ; final CharSource resource = Resources . asCharSource ( EnglishAndChineseHeadRules . class . getResource ( "ch_heads.sun.txt" ) , Charsets . UTF_8 ) ; final ImmutableMap < Symbol , HeadRule < NodeT > > headRules = headRulesFromResources ( headInitial , resource ) ; return MapHeadFinder . create ( headRules ) ; }
Head finder using English NP rules and the Chinese head table as defined in
6,622
public void write ( Tree < ? , ? > tree ) throws IOException { this . writer . append ( "digraph G" ) ; this . writer . append ( Integer . toString ( this . graphIndex ++ ) ) ; this . writer . append ( " {\n" ) ; if ( tree != null ) { Iterator < ? extends TreeNode < ? , ? > > iterator = tree . broadFirstIterator ( ) ; TreeNode < ? , ? > node ; int dataCount ; while ( iterator . hasNext ( ) ) { node = iterator . next ( ) ; dataCount = node . getUserDataCount ( ) ; final String name = "NODE" + Integer . toHexString ( System . identityHashCode ( node ) ) ; final String label = Integer . toString ( dataCount ) ; this . writer . append ( "\t" ) ; this . writer . append ( name ) ; this . writer . append ( " [label=\"" ) ; this . writer . append ( label ) ; this . writer . append ( "\"]\n" ) ; } this . writer . append ( "\n" ) ; iterator = tree . broadFirstIterator ( ) ; Class < ? extends Enum < ? > > partitionType ; TreeNode < ? , ? > child ; String childName ; while ( iterator . hasNext ( ) ) { node = iterator . next ( ) ; final String name = "NODE" + Integer . toHexString ( System . identityHashCode ( node ) ) ; if ( ! node . isLeaf ( ) ) { partitionType = node . getPartitionEnumeration ( ) ; final int childCount = node . getChildCount ( ) ; for ( int i = 0 ; i < childCount ; ++ i ) { child = node . getChildAt ( i ) ; if ( child != null ) { childName = "NODE" + Integer . toHexString ( System . identityHashCode ( child ) ) ; final String label ; if ( partitionType != null ) { label = partitionType . getEnumConstants ( ) [ i ] . name ( ) ; } else { label = Integer . toString ( i ) ; } this . writer . append ( "\t" ) ; this . writer . append ( name ) ; this . writer . append ( "->" ) ; this . writer . append ( childName ) ; this . writer . append ( " [label=\"" ) ; this . writer . append ( label ) ; this . writer . append ( "\"]\n" ) ; } } } } } this . writer . append ( "}\n\n" ) ; }
Write the given tree inside the . dot output stream .
6,623
public static boolean containsCapsulePoint ( double capsule1Ax , double capsule1Ay , double capsule1Az , double capsule1Bx , double capsule1By , double capsule1Bz , double capsule1Radius , double px , double py , double pz ) { double distPointToCapsuleSegment = AbstractSegment3F . distanceSquaredSegmentPoint ( capsule1Ax , capsule1Ay , capsule1Az , capsule1Bx , capsule1By , capsule1Bz , px , py , pz ) ; return ( distPointToCapsuleSegment <= ( capsule1Radius * capsule1Radius ) ) ; }
Compute intersection between a point and a capsule .
6,624
public static boolean intersectsCapsuleAlignedBox ( double mx1 , double my1 , double mz1 , double mx2 , double my2 , double mz2 , double radius , double minx , double miny , double minz , double maxx , double maxy , double maxz ) { Point3f closest1 = AlignedBox3f . computeClosestPoint ( minx , miny , minz , maxx , maxy , maxz , mx1 , my1 , mz1 ) ; Point3f closest2 = AlignedBox3f . computeClosestPoint ( minx , miny , minz , maxx , maxy , maxz , mx2 , my2 , mz2 ) ; double sq = AbstractSegment3F . distanceSquaredSegmentSegment ( mx1 , my1 , mz1 , mx2 , my2 , mz2 , closest1 . getX ( ) , closest1 . getY ( ) , closest1 . getZ ( ) , closest2 . getX ( ) , closest2 . getY ( ) , closest2 . getZ ( ) ) ; return ( sq <= ( radius * radius ) ) ; }
Replies if the capsule intersects the aligned box .
6,625
public static boolean intersectsCapsuleCapsule ( double capsule1Ax , double capsule1Ay , double capsule1Az , double capsule1Bx , double capsule1By , double capsule1Bz , double capsule1Radius , double capsule2Ax , double capsule2Ay , double capsule2Az , double capsule2Bx , double capsule2By , double capsule2Bz , double capsule2Radius ) { double dist2 = AbstractSegment3F . distanceSquaredSegmentSegment ( capsule1Ax , capsule1Ay , capsule1Az , capsule1Bx , capsule1By , capsule1Bz , capsule2Ax , capsule2Ay , capsule2Az , capsule2Bx , capsule2By , capsule2Bz ) ; double radius = capsule1Radius + capsule2Radius ; return dist2 <= ( radius * radius ) ; }
Replies if the specified capsules intersect .
6,626
protected void ensureAIsLowerPoint ( ) { CoordinateSystem3D cs = CoordinateSystem3D . getDefaultCoordinateSystem ( ) ; boolean swap = false ; if ( cs . isZOnUp ( ) ) { swap = ( this . getMedial1 ( ) . getZ ( ) > this . getMedial2 ( ) . getZ ( ) ) ; } else if ( cs . isYOnUp ( ) ) { swap = ( this . getMedial1 ( ) . getY ( ) > this . getMedial2 ( ) . getY ( ) ) ; } if ( swap ) { double x = this . getMedial1 ( ) . getX ( ) ; double y = this . getMedial1 ( ) . getY ( ) ; double z = this . getMedial1 ( ) . getZ ( ) ; this . getMedial1 ( ) . set ( this . getMedial2 ( ) ) ; this . getMedial2 ( ) . set ( x , y , z ) ; } }
Ensure that a has the lower coordinates than b .
6,627
public static Vector3ifx convert ( Tuple3D < ? > tuple ) { if ( tuple instanceof Vector3ifx ) { return ( Vector3ifx ) tuple ; } return new Vector3ifx ( tuple . getX ( ) , tuple . getY ( ) , tuple . getZ ( ) ) ; }
Convert the given tuple to a real Vector3ifx .
6,628
protected HashMap readFile ( HashMap brMap ) throws IOException { HashMap ret = new HashMap ( ) ; ArrayList < HashMap > sites = readSoilSites ( brMap , new HashMap ( ) ) ; ret . put ( "soils" , sites ) ; return ret ; }
DSSAT Soil Data input method for only inputing soil file
6,629
public static Point3d convert ( Tuple3D < ? > tuple ) { if ( tuple instanceof Point3d ) { return ( Point3d ) tuple ; } return new Point3d ( tuple . getX ( ) , tuple . getY ( ) , tuple . getZ ( ) ) ; }
Convert the given tuple to a real Point3d .
6,630
public final N getChildAt ( OctTreeZone zone ) { if ( zone != null ) { return getChildAt ( zone . ordinal ( ) ) ; } return null ; }
Replies count of children in this node .
6,631
@ SuppressWarnings ( "checkstyle:magicnumber" ) private boolean setChild6 ( N newChild ) { if ( this . child6 == newChild ) { return false ; } if ( this . child6 != null ) { this . child6 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 5 , this . child5 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child6 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 5 , newChild ) ; } return true ; }
Set the child 6 .
6,632
@ SuppressWarnings ( "checkstyle:magicnumber" ) private boolean setChild7 ( N newChild ) { if ( this . child7 == newChild ) { return false ; } if ( this . child7 != null ) { this . child7 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 6 , this . child7 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child7 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 6 , newChild ) ; } return true ; }
Set the child 7 .
6,633
@ SuppressWarnings ( "checkstyle:magicnumber" ) private boolean setChild8 ( N newChild ) { if ( this . child8 == newChild ) { return false ; } if ( this . child8 != null ) { this . child8 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 7 , this . child8 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child8 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 7 , newChild ) ; } return true ; }
Set the child 8 .
6,634
protected synchronized void executeMojo ( File targetDir ) throws MojoExecutionException { if ( this . generateTargets . contains ( targetDir ) && targetDir . isDirectory ( ) ) { getLog ( ) . debug ( "Skiping " + targetDir + " because is was already generated" ) ; return ; } this . generateTargets . add ( targetDir ) ; final File [ ] sourceDirs ; final File mainDirectory = new File ( getSourceDirectory ( ) , "main" ) ; if ( this . sources == null || this . sources . length == 0 ) { sourceDirs = new File [ ] { new File ( mainDirectory , "java" ) , } ; } else { sourceDirs = this . sources ; } clearInternalBuffers ( ) ; for ( final File sourceDir : sourceDirs ) { Map < File , File > htmlBasedFiles = this . bufferedFiles . get ( sourceDir ) ; if ( htmlBasedFiles == null ) { htmlBasedFiles = new TreeMap < > ( ) ; if ( sourceDir . isDirectory ( ) ) { findFiles ( sourceDir , new JavaSourceFileFilter ( ) , htmlBasedFiles ) ; } this . bufferedFiles . put ( sourceDir , htmlBasedFiles ) ; } for ( final Entry < File , File > entry : htmlBasedFiles . entrySet ( ) ) { final String baseFile = removePathPrefix ( entry . getValue ( ) , entry . getKey ( ) ) ; replaceInFileBuffered ( entry . getKey ( ) , new File ( targetDir , baseFile ) , ReplacementType . HTML , sourceDirs , false ) ; } } }
Execute the replacement mojo inside the given target directory .
6,635
public static org . arakhne . afc . vmutil . caller . Caller getCaller ( ) { synchronized ( Caller . class ) { if ( caller == null ) { caller = new StackTraceCaller ( ) ; } return caller ; } }
Replies the stack trace mamager used by this utility class .
6,636
public P getElementAt ( int index ) { if ( index >= 0 && index < this . referenceElementCount ) { int idx = 0 ; for ( final GridCellElement < P > element : this . elements ) { if ( element . isReferenceCell ( this ) ) { if ( idx == index ) { return element . get ( ) ; } ++ idx ; } } } throw new IndexOutOfBoundsException ( ) ; }
Replies the reference element at the specified index in this cell .
6,637
public Iterator < P > iterator ( Rectangle2afp < ? , ? , ? , ? , ? , ? > bounds ) { return new BoundsIterator < > ( this . elements . iterator ( ) , bounds ) ; }
Replies the iterator on the elements of the cell that are intersecting the specified bounds .
6,638
public boolean addElement ( GridCellElement < P > element ) { if ( element != null && this . elements . add ( element ) ) { if ( element . addCellLink ( this ) ) { ++ this . referenceElementCount ; } return true ; } return false ; }
Add an element in the cell .
6,639
public GridCellElement < P > removeElement ( P element ) { final GridCellElement < P > elt = remove ( element ) ; if ( elt != null ) { if ( elt . removeCellLink ( this ) ) { -- this . referenceElementCount ; } } return elt ; }
Remove the specified element from the cell .
6,640
@ SuppressWarnings ( { "rawtypes" } ) public MapElement getElementUnderMouse ( GisPane < ? > pane , double x , double y ) { final GISContainer model = pane . getDocumentModel ( ) ; final Point2d mousePosition = pane . toDocumentPosition ( x , y ) ; final Rectangle2d selectionArea = pane . toDocumentRect ( x - 2 , y - 2 , 5 , 5 ) ; return getElementUnderMouse ( model , mousePosition , selectionArea ) ; }
Replies the element at the given mouse position .
6,641
protected E getSelectedEnumFromRadioButtons ( ) { for ( final E enumValue : this . radioButtonMap . keySet ( ) ) { final JRadioButton btn = this . radioButtonMap . get ( enumValue ) ; if ( btn . isSelected ( ) ) { return enumValue ; } } return null ; }
Resolves the selected enum from the radio buttons .
6,642
private void setSelectedRadioButton ( final E enumValue ) { if ( enumValue != null ) { final JRadioButton radioButton = this . radioButtonMap . get ( enumValue ) ; radioButton . setSelected ( true ) ; } else { for ( final JRadioButton radioButton : this . radioButtonMap . values ( ) ) { radioButton . setSelected ( false ) ; } } }
Sets the selected radio button .
6,643
public static String toEnvironmentVariableName ( String bootiqueVariable ) { if ( Strings . isNullOrEmpty ( bootiqueVariable ) ) { return null ; } final StringBuilder name = new StringBuilder ( ) ; final Pattern pattern = Pattern . compile ( "((?:[a-z0_9_]+)|(?:[A-Z]+[^A-Z]*))" ) ; for ( final String component : bootiqueVariable . split ( "[^a-zA-Z0_9_]+" ) ) { final Matcher matcher = pattern . matcher ( component ) ; while ( matcher . find ( ) ) { final String word = matcher . group ( 1 ) ; if ( name . length ( ) > 0 ) { name . append ( "_" ) ; } name . append ( word . toUpperCase ( ) ) ; } } return name . toString ( ) ; }
Replies the name of an environment variable that corresponds to the name of a bootique variable .
6,644
void processEvent ( DelayQueue < Delayed > delayQueue ) { WatchKey key ; try { key = watcher . poll ( 250 , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException | ClosedWatchServiceException x ) { return ; } if ( key == null ) { return ; } Path dir = keys . get ( key ) ; if ( dir == null ) { return ; } for ( WatchEvent < ? > event : key . pollEvents ( ) ) { WatchEvent . Kind < ? > kind = event . kind ( ) ; if ( kind == OVERFLOW ) { continue ; } @ SuppressWarnings ( "unchecked" ) WatchEvent < Path > ev = ( WatchEvent < Path > ) event ; Path name = ev . context ( ) ; Path child = dir . resolve ( name ) ; if ( ignore . contains ( child ) ) { return ; } if ( ! ignorePattern . stream ( ) . anyMatch ( m -> child . getFileSystem ( ) . getPathMatcher ( m ) . matches ( child . getFileName ( ) ) ) ) { delayQueue . add ( new WatchDirDelay ( ) ) ; } if ( kind == ENTRY_CREATE ) { try { if ( Files . isDirectory ( child , NOFOLLOW_LINKS ) ) { registerAll ( child ) ; } } catch ( IOException x ) { } } } boolean valid = key . reset ( ) ; if ( ! valid ) { keys . remove ( key ) ; if ( keys . isEmpty ( ) ) { return ; } } }
Process a single key queued to the watcher
6,645
public static BufferedImage concatenateImages ( final List < BufferedImage > imgCollection , final int width , final int height , final int imageType , final Direction concatenationDirection ) { final BufferedImage img = new BufferedImage ( width , height , imageType ) ; int x = 0 ; int y = 0 ; for ( final BufferedImage bi : imgCollection ) { final boolean imageDrawn = img . createGraphics ( ) . drawImage ( bi , x , y , null ) ; if ( ! imageDrawn ) { throw new RuntimeException ( "BufferedImage could not be drawn:" + bi . toString ( ) ) ; } if ( concatenationDirection . equals ( Direction . vertical ) ) { y += bi . getHeight ( ) ; } else { x += bi . getWidth ( ) ; } } return img ; }
Concatenate the given list of BufferedImage objects to one image and returns the concatenated BufferedImage object .
6,646
public static void createPdf ( final OutputStream result , final List < BufferedImage > images ) throws DocumentException , IOException { final Document document = new Document ( ) ; PdfWriter . getInstance ( document , result ) ; for ( final BufferedImage image : images ) { final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ImageIO . write ( image , "png" , baos ) ; final Image img = Image . getInstance ( baos . toByteArray ( ) ) ; document . setPageSize ( img ) ; document . newPage ( ) ; img . setAbsolutePosition ( 0 , 0 ) ; document . add ( img ) ; } document . close ( ) ; }
Creates from the given Collection of images an pdf file .
6,647
public static byte [ ] resize ( final BufferedImage originalImage , final Method scalingMethod , final Mode resizeMode , final String formatName , final int targetWidth , final int targetHeight ) { try { final BufferedImage resizedImage = Scalr . resize ( originalImage , scalingMethod , resizeMode , targetWidth , targetHeight ) ; return toByteArray ( resizedImage , formatName ) ; } catch ( final Exception e ) { return null ; } }
Resize the given image .
6,648
public static byte [ ] resize ( final BufferedImage originalImage , final String formatName , final int targetWidth , final int targetHeight ) { return resize ( originalImage , Scalr . Method . QUALITY , Scalr . Mode . FIT_EXACT , formatName , targetWidth , targetHeight ) ; }
Resize the given BufferedImage .
6,649
public static byte [ ] toByteArray ( final BufferedImage bi , final String formatName ) throws IOException { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { ImageIO . write ( bi , formatName , baos ) ; baos . flush ( ) ; final byte [ ] byteArray = baos . toByteArray ( ) ; return byteArray ; } }
Converts the given BufferedImage to a byte array .
6,650
protected Rectangle2d calcBounds ( ) { final Rectangle2d bb = new Rectangle2d ( ) ; boolean first = true ; Rectangle2afp < ? , ? , ? , ? , ? , ? > b ; N child ; for ( int i = 0 ; i < getChildCount ( ) ; ++ i ) { child = getChildAt ( i ) ; if ( child != null ) { b = child . getBounds ( ) ; if ( b != null ) { if ( first ) { first = false ; bb . setFromCorners ( b . getMinX ( ) , b . getMinY ( ) , b . getMaxX ( ) , b . getMaxY ( ) ) ; } else { bb . setUnion ( b ) ; } } } } P primitive ; GeoLocation location ; for ( int i = 0 ; i < getUserDataCount ( ) ; ++ i ) { primitive = getUserDataAt ( i ) ; if ( primitive != null ) { location = primitive . getGeoLocation ( ) ; if ( location != null ) { b = location . toBounds2D ( ) ; if ( b != null ) { if ( first ) { first = false ; bb . setFromCorners ( b . getMinX ( ) , b . getMinY ( ) , b . getMaxX ( ) , b . getMaxY ( ) ) ; } else { bb . setUnion ( b ) ; } } } } } return first ? null : bb ; }
Compute and replies the bounds for this node .
6,651
public boolean setContainer ( C container ) { this . mapContainer = container == null ? null : new WeakReference < > ( container ) ; return true ; }
Sets the container of this MapElement .
6,652
public Object getTopContainer ( ) { if ( this . mapContainer == null ) { return null ; } final C container = this . mapContainer . get ( ) ; if ( container == null ) { return null ; } if ( container instanceof GISContentElement < ? > ) { return ( ( GISContentElement < ? > ) container ) . getTopContainer ( ) ; } return container ; }
Replies the top - most object which contains this MapElement .
6,653
public UUID getUUID ( ) { if ( this . uid == null ) { this . uid = UUID . randomUUID ( ) ; } return this . uid ; }
Replies an unique identifier for element .
6,654
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static Node writeBusNetwork ( BusNetwork busNetwork , XMLBuilder builder , XMLResources resources ) throws IOException { final Element element = builder . createElement ( NODE_BUSNETWORK ) ; writeGISElementAttributes ( element , busNetwork , builder , resources ) ; final Integer color = busNetwork . getRawColor ( ) ; if ( color != null ) { element . setAttribute ( ATTR_COLOR , toColor ( color ) ) ; } final Element stopsNode = builder . createElement ( NODE_BUSSTOPS ) ; for ( final BusStop stop : busNetwork . busStops ( ) ) { final Node stopNode = writeBusStop ( stop , builder , resources ) ; if ( stopNode != null ) { stopsNode . appendChild ( stopNode ) ; } } if ( stopsNode . getChildNodes ( ) . getLength ( ) > 0 ) { element . appendChild ( stopsNode ) ; } final Element hubsNode = builder . createElement ( NODE_BUSHUBS ) ; for ( final BusHub hub : busNetwork . busHubs ( ) ) { final Node hubNode = writeBusHub ( hub , builder , resources ) ; if ( hubNode != null ) { hubsNode . appendChild ( hubNode ) ; } } if ( hubsNode . getChildNodes ( ) . getLength ( ) > 0 ) { element . appendChild ( hubsNode ) ; } final Element linesNode = builder . createElement ( NODE_BUSLINES ) ; for ( final BusLine line : busNetwork . busLines ( ) ) { final Node lineNode = writeBusLine ( line , builder , resources ) ; if ( lineNode != null ) { linesNode . appendChild ( lineNode ) ; } } if ( linesNode . getChildNodes ( ) . getLength ( ) > 0 ) { element . appendChild ( linesNode ) ; } return element ; }
Create and reply an XML representation of the given bus network .
6,655
public static BusNetwork readBusNetwork ( Element xmlNode , RoadNetwork roadNetwork , PathBuilder pathBuilder , XMLResources resources ) throws IOException { final UUID id = getAttributeUUID ( xmlNode , NODE_BUSNETWORK , ATTR_ID ) ; final BusNetwork busNetwork = new BusNetwork ( id , roadNetwork ) ; final Node stopsNode = getNodeFromPath ( xmlNode , NODE_BUSNETWORK , NODE_BUSSTOPS ) ; if ( stopsNode != null ) { for ( final Element stopNode : getElementsFromPath ( stopsNode , NODE_BUSSTOP ) ) { final BusStop stop = readBusStop ( stopNode , pathBuilder , resources ) ; if ( stop != null ) { busNetwork . addBusStop ( stop ) ; } } } final Node hubsNode = getNodeFromPath ( xmlNode , NODE_BUSNETWORK , NODE_BUSHUBS ) ; if ( hubsNode != null ) { for ( final Element hubNode : getElementsFromPath ( hubsNode , NODE_BUSHUB ) ) { readBusHub ( hubNode , busNetwork , pathBuilder , resources ) ; } } final Node linesNode = getNodeFromPath ( xmlNode , NODE_BUSNETWORK , NODE_BUSLINES ) ; if ( linesNode != null ) { BusLine line ; for ( final Element lineNode : getElementsFromPath ( linesNode , NODE_BUSLINE ) ) { line = readBusLine ( lineNode , busNetwork , roadNetwork , pathBuilder , resources ) ; if ( line != null ) { busNetwork . addBusLine ( line ) ; } } } readGISElementAttributes ( xmlNode , busNetwork , pathBuilder , resources ) ; final Integer color = getAttributeColorWithDefault ( xmlNode , null , ATTR_COLOR ) ; if ( color != null ) { busNetwork . setColor ( color ) ; } busNetwork . revalidate ( ) ; return busNetwork ; }
Create and reply the bus network which is described by the given XML representation .
6,656
public long readBELong ( ) throws IOException { return EndianNumbers . toBELong ( read ( ) , read ( ) , read ( ) , read ( ) , read ( ) , read ( ) , read ( ) , read ( ) ) ; }
Read a Big Endian long on 8 bytes .
6,657
public long readLELong ( ) throws IOException { return EndianNumbers . toLELong ( read ( ) , read ( ) , read ( ) , read ( ) , read ( ) , read ( ) , read ( ) , read ( ) ) ; }
Read a Little Endian long on 8 bytes .
6,658
@ SuppressWarnings ( "unchecked" ) public static Iterator < Drawer < ? > > getAllDrawers ( ) { if ( services == null ) { services = ServiceLoader . load ( Drawer . class ) ; } return services . iterator ( ) ; }
Replies all the registered document drawers .
6,659
@ SuppressWarnings ( "unchecked" ) public static < T > Drawer < T > getDrawerFor ( Class < ? extends T > type ) { assert type != null : AssertMessages . notNullParameter ( ) ; final Drawer < ? > bufferedType = buffer . get ( type ) ; Drawer < T > defaultChoice = null ; if ( bufferedType != null ) { defaultChoice = ( Drawer < T > ) bufferedType ; } else { final Iterator < Drawer < ? > > iterator = getAllDrawers ( ) ; while ( iterator . hasNext ( ) ) { final Drawer < ? > drawer = iterator . next ( ) ; final Class < ? > drawerType = drawer . getPrimitiveType ( ) ; if ( drawerType . equals ( type ) ) { defaultChoice = ( Drawer < T > ) drawer ; break ; } else if ( drawerType . isAssignableFrom ( type ) && ( defaultChoice == null || drawerType . isAssignableFrom ( defaultChoice . getPrimitiveType ( ) ) ) ) { defaultChoice = ( Drawer < T > ) drawer ; } } if ( defaultChoice != null ) { buffer . put ( type , defaultChoice ) ; } } return defaultChoice ; }
Replies the first registered document drawer that is supporting the given type .
6,660
public DoubleProperty arcWidthProperty ( ) { if ( this . arcWidth == null ) { this . arcWidth = new DependentSimpleDoubleProperty < ReadOnlyDoubleProperty > ( this , MathFXAttributeNames . ARC_WIDTH , widthProperty ( ) ) { protected void invalidated ( ReadOnlyDoubleProperty dependency ) { final double value = get ( ) ; if ( value < 0. ) { set ( 0. ) ; } else { final double maxArcWidth = dependency . get ( ) / 2. ; if ( value > maxArcWidth ) { set ( maxArcWidth ) ; } } } } ; } return this . arcWidth ; }
Replies the property for the arc width .
6,661
public DoubleProperty arcHeightProperty ( ) { if ( this . arcHeight == null ) { this . arcHeight = new DependentSimpleDoubleProperty < ReadOnlyDoubleProperty > ( this , MathFXAttributeNames . ARC_HEIGHT , heightProperty ( ) ) { protected void invalidated ( ReadOnlyDoubleProperty dependency ) { final double value = get ( ) ; if ( value < 0. ) { set ( 0. ) ; } else { final double maxArcHeight = dependency . get ( ) / 2. ; if ( value > maxArcHeight ) { set ( maxArcHeight ) ; } } } } ; } return this . arcHeight ; }
Replies the property for the arc height .
6,662
public Rectangle2d toBounds2D ( ) { int startIndex = this . id . indexOf ( '#' ) ; if ( startIndex <= 0 ) { return null ; } try { int endIndex = this . id . indexOf ( ';' , startIndex ) ; if ( endIndex <= startIndex ) { return null ; } final long minx = Long . parseLong ( this . id . substring ( startIndex + 1 , endIndex ) ) ; startIndex = endIndex + 1 ; endIndex = this . id . indexOf ( ';' , startIndex ) ; if ( endIndex <= startIndex ) { return null ; } final long miny = Long . parseLong ( this . id . substring ( startIndex , endIndex ) ) ; startIndex = endIndex + 1 ; endIndex = this . id . indexOf ( ';' , startIndex ) ; if ( endIndex <= startIndex ) { return null ; } final long maxx = Long . parseLong ( this . id . substring ( startIndex , endIndex ) ) ; startIndex = endIndex + 1 ; final long maxy = Long . parseLong ( this . id . substring ( startIndex ) ) ; final Rectangle2d r = new Rectangle2d ( ) ; r . setFromCorners ( minx , miny , maxx , maxy ) ; return r ; } catch ( Throwable exception ) { } return null ; }
Extract the primitive bounds from this geoId .
6,663
public String getInternalId ( ) { final int endIndex = this . id . indexOf ( '#' ) ; if ( endIndex <= 0 ) { return null ; } return this . id . substring ( 0 , endIndex ) ; }
Extract the unique identifier stored in this geoId .
6,664
private final long checkSessionTimeout ( ) { long nextTimeout = 0 ; if ( configuration . getCheckSessionTimeoutInterval ( ) > 0 ) { gate . lock ( ) ; try { if ( selectTries * 1000 >= configuration . getCheckSessionTimeoutInterval ( ) ) { nextTimeout = configuration . getCheckSessionTimeoutInterval ( ) ; for ( SelectionKey key : selector . keys ( ) ) { if ( key . attachment ( ) != null ) { long n = checkExpiredIdle ( key , getSessionFromAttchment ( key ) ) ; nextTimeout = n < nextTimeout ? n : nextTimeout ; } } selectTries = 0 ; } } finally { gate . unlock ( ) ; } } return nextTimeout ; }
Check session timeout or idle
6,665
public static Vector1d convert ( Tuple1d < ? > tuple ) { if ( tuple instanceof Vector1d ) { return ( Vector1d ) tuple ; } return new Vector1d ( tuple . getSegment ( ) , tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Vector1d .
6,666
protected static URL getContributorURL ( Contributor contributor , Log log ) { URL url = null ; if ( contributor != null ) { String rawUrl = contributor . getUrl ( ) ; if ( rawUrl != null && ! EMPTY_STRING . equals ( rawUrl ) ) { try { url = new URL ( rawUrl ) ; } catch ( Throwable exception ) { url = null ; } } if ( url == null ) { rawUrl = contributor . getEmail ( ) ; if ( rawUrl != null && ! EMPTY_STRING . equals ( rawUrl ) ) { try { url = new URL ( "mailto:" + rawUrl ) ; } catch ( Throwable exception ) { url = null ; } } } } return url ; }
Replies the preferred URL for the given contributor .
6,667
public final void dirCopy ( File in , File out , boolean skipHiddenFiles ) throws IOException { assert in != null ; assert out != null ; getLog ( ) . debug ( in . toString ( ) + "->" + out . toString ( ) ) ; getLog ( ) . debug ( "Ignore hidden files: " + skipHiddenFiles ) ; out . mkdirs ( ) ; final LinkedList < File > candidates = new LinkedList < > ( ) ; candidates . add ( in ) ; File [ ] children ; while ( ! candidates . isEmpty ( ) ) { final File f = candidates . removeFirst ( ) ; getLog ( ) . debug ( "Scanning: " + f ) ; if ( f . isDirectory ( ) ) { children = f . listFiles ( ) ; if ( children != null && children . length > 0 ) { for ( final File c : children ) { if ( ! skipHiddenFiles || ! c . isHidden ( ) ) { getLog ( ) . debug ( "Discovering: " + c ) ; candidates . add ( c ) ; } } } } else { final File targetFile = toOutput ( in , f , out ) ; targetFile . getParentFile ( ) . mkdirs ( ) ; fileCopy ( f , targetFile ) ; } } }
Copy a directory .
6,668
public final void dirRemove ( File dir ) throws IOException { if ( dir != null ) { getLog ( ) . debug ( "Deleting tree: " + dir . toString ( ) ) ; final LinkedList < File > candidates = new LinkedList < > ( ) ; candidates . add ( dir ) ; File [ ] children ; final BuildContext buildContext = getBuildContext ( ) ; while ( ! candidates . isEmpty ( ) ) { final File f = candidates . getFirst ( ) ; getLog ( ) . debug ( "Scanning: " + f ) ; if ( f . isDirectory ( ) ) { children = f . listFiles ( ) ; if ( children != null && children . length > 0 ) { for ( final File c : children ) { getLog ( ) . debug ( "Discovering: " + c ) ; candidates . push ( c ) ; } } else { getLog ( ) . debug ( "Deleting: " + f ) ; candidates . removeFirst ( ) ; f . delete ( ) ; buildContext . refresh ( f . getParentFile ( ) ) ; } } else { candidates . removeFirst ( ) ; if ( f . exists ( ) ) { getLog ( ) . debug ( "Deleting: " + f ) ; f . delete ( ) ; buildContext . refresh ( f . getParentFile ( ) ) ; } } } getLog ( ) . debug ( "Deletion done" ) ; } }
Delete a directory and its content .
6,669
public static final String getLString ( Class < ? > source , String label , Object ... params ) { final ResourceBundle rb = ResourceBundle . getBundle ( source . getCanonicalName ( ) ) ; String text = rb . getString ( label ) ; text = text . replaceAll ( "[\\n\\r]" , "\n" ) ; text = text . replaceAll ( "\\t" , "\t" ) ; text = MessageFormat . format ( text , params ) ; return text ; }
Read a resource property and replace the parametrized macros by the given parameters .
6,670
public static final String removePathPrefix ( File prefix , File file ) { final String r = file . getAbsolutePath ( ) . replaceFirst ( "^" + Pattern . quote ( prefix . getAbsolutePath ( ) ) , EMPTY_STRING ) ; if ( r . startsWith ( File . separator ) ) { return r . substring ( File . separator . length ( ) ) ; } return r ; }
Remove the path prefix from a file .
6,671
public final synchronized ExtendedArtifact searchArtifact ( File file ) { final String filename = removePathPrefix ( getBaseDirectory ( ) , file ) ; getLog ( ) . debug ( "Retreiving module for " + filename ) ; File theFile = file ; File pomDirectory = null ; while ( theFile != null && pomDirectory == null ) { if ( theFile . isDirectory ( ) ) { final File pomFile = new File ( theFile , "pom.xml" ) ; if ( pomFile . exists ( ) ) { pomDirectory = theFile ; } } theFile = theFile . getParentFile ( ) ; } if ( pomDirectory != null ) { ExtendedArtifact a = this . localArtifactDescriptions . get ( pomDirectory ) ; if ( a == null ) { a = readPom ( pomDirectory ) ; this . localArtifactDescriptions . put ( pomDirectory , a ) ; getLog ( ) . debug ( "Found local module description for " + a . toString ( ) ) ; } return a ; } final BuildContext buildContext = getBuildContext ( ) ; buildContext . addMessage ( file , 1 , 1 , "The maven module for this file cannot be retreived." , BuildContext . SEVERITY_WARNING , null ) ; return null ; }
Search and reply the maven artifact which is corresponding to the given file .
6,672
public final Artifact resolveArtifact ( Artifact mavenArtifact ) throws MojoExecutionException { final org . eclipse . aether . artifact . Artifact aetherArtifact = createArtifact ( mavenArtifact ) ; final ArtifactRequest request = new ArtifactRequest ( ) ; request . setArtifact ( aetherArtifact ) ; request . setRepositories ( getRemoteRepositoryList ( ) ) ; final ArtifactResult result ; try { result = getRepositorySystem ( ) . resolveArtifact ( getRepositorySystemSession ( ) , request ) ; } catch ( ArtifactResolutionException e ) { throw new MojoExecutionException ( e . getMessage ( ) , e ) ; } return createArtifact ( result . getArtifact ( ) ) ; }
Retreive the extended artifact definition of the given artifact .
6,673
public final Artifact resolveArtifact ( String groupId , String artifactId , String version ) throws MojoExecutionException { return resolveArtifact ( createArtifact ( groupId , artifactId , version ) ) ; }
Retreive the extended artifact definition of the given artifact id .
6,674
public final Artifact createArtifact ( String groupId , String artifactId , String version ) { return createArtifact ( groupId , artifactId , version , "runtime" , "jar" ) ; }
Create an Jar runtime artifact from the given values .
6,675
protected static final org . eclipse . aether . artifact . Artifact createArtifact ( Artifact artifact ) { return new DefaultArtifact ( artifact . getGroupId ( ) , artifact . getArtifactId ( ) , artifact . getClassifier ( ) , artifact . getType ( ) , artifact . getVersion ( ) ) ; }
Convert the maven artifact to Aether artifact .
6,676
protected final Artifact createArtifact ( org . eclipse . aether . artifact . Artifact artifact ) { return createArtifact ( artifact . getGroupId ( ) , artifact . getArtifactId ( ) , artifact . getVersion ( ) ) ; }
Convert the Aether artifact to maven artifact .
6,677
public final Artifact createArtifact ( String groupId , String artifactId , String version , String scope , String type ) { VersionRange versionRange = null ; if ( version != null ) { versionRange = VersionRange . createFromVersion ( version ) ; } String desiredScope = scope ; if ( Artifact . SCOPE_TEST . equals ( desiredScope ) ) { desiredScope = Artifact . SCOPE_TEST ; } if ( Artifact . SCOPE_PROVIDED . equals ( desiredScope ) ) { desiredScope = Artifact . SCOPE_PROVIDED ; } if ( Artifact . SCOPE_SYSTEM . equals ( desiredScope ) ) { desiredScope = Artifact . SCOPE_SYSTEM ; } final ArtifactHandler handler = getArtifactHandlerManager ( ) . getArtifactHandler ( type ) ; return new org . apache . maven . artifact . DefaultArtifact ( groupId , artifactId , versionRange , desiredScope , type , null , handler , false ) ; }
Create an artifact from the given values .
6,678
protected final void assertNotNull ( String message , Object obj ) { if ( getLog ( ) . isDebugEnabled ( ) ) { getLog ( ) . debug ( "\t(" + getLogType ( obj ) + ") " + message + " = " + obj ) ; } if ( obj == null ) { throw new AssertionError ( "assertNotNull: " + message ) ; } }
Throw an exception when the given object is null .
6,679
public static String join ( String joint , String ... values ) { final StringBuilder b = new StringBuilder ( ) ; for ( final String value : values ) { if ( value != null && ! EMPTY_STRING . equals ( value ) ) { if ( b . length ( ) > 0 ) { b . append ( joint ) ; } b . append ( value ) ; } } return b . toString ( ) ; }
Join the values with the given joint .
6,680
public MavenProject getMavenProject ( Artifact artifact ) { try { final MavenSession session = getMavenSession ( ) ; final MavenProject current = session . getCurrentProject ( ) ; final MavenProject prj = getMavenProjectBuilder ( ) . buildFromRepository ( artifact , current . getRemoteArtifactRepositories ( ) , session . getLocalRepository ( ) ) ; return prj ; } catch ( ProjectBuildingException e ) { getLog ( ) . warn ( e ) ; } return null ; }
Load the Maven project for the given artifact .
6,681
@ SuppressWarnings ( "checkstyle:nestedifdepth" ) protected final List < GraphIterationElement < ST , PT > > getNextSegments ( boolean avoid_visited_segments , GraphIterationElement < ST , PT > element ) { assert this . allowManyReplies || this . visited != null ; if ( element != null ) { final ST segment = element . getSegment ( ) ; final PT point = element . getPoint ( ) ; if ( ( segment != null ) && ( point != null ) ) { final PT pts = segment . getOtherSidePoint ( point ) ; if ( pts != null ) { final double distanceToReach = element . getDistanceToReachSegment ( ) + segment . getLength ( ) ; GraphIterationElement < ST , PT > candidate ; final double restToConsume = element . distanceToConsume - segment . getLength ( ) ; final List < GraphIterationElement < ST , PT > > list = new ArrayList < > ( ) ; for ( final ST theSegment : pts . getConnectedSegmentsStartingFrom ( segment ) ) { if ( ! theSegment . equals ( segment ) ) { candidate = newIterationElement ( segment , theSegment , pts , distanceToReach , restToConsume ) ; if ( ( this . allowManyReplies ) || ( ! avoid_visited_segments ) || ( ! this . visited . contains ( candidate ) ) ) { list . add ( candidate ) ; } } } return list ; } } } throw new NoSuchElementException ( ) ; }
Replies the next segments .
6,682
public final GraphIterationElement < ST , PT > nextElement ( ) { if ( ! this . courseModel . isEmpty ( ) ) { final GraphIterationElement < ST , PT > theElement = this . courseModel . removeNextIterationElement ( ) ; if ( theElement != null ) { final List < GraphIterationElement < ST , PT > > list = getNextSegments ( true , theElement ) ; final Iterator < GraphIterationElement < ST , PT > > iterator ; boolean hasFollowingSegments = false ; GraphIterationElement < ST , PT > elt ; if ( this . courseModel . isReversedRestitution ( ) ) { iterator = new ReverseIterator < > ( list ) ; } else { iterator = list . iterator ( ) ; } while ( iterator . hasNext ( ) ) { elt = iterator . next ( ) ; if ( canGotoIntoElement ( elt ) ) { hasFollowingSegments = true ; this . courseModel . addIterationElement ( elt ) ; if ( ! this . allowManyReplies ) { this . visited . add ( elt ) ; } } } theElement . setTerminalSegment ( ! hasFollowingSegments ) ; theElement . replied = true ; this . current = theElement ; return this . current ; } } clear ( ) ; throw new NoSuchElementException ( ) ; }
Replies the next segment .
6,683
protected GraphIterationElement < ST , PT > newIterationElement ( ST previous_segment , ST segment , PT point , double distanceToReach , double distanceToConsume ) { return new GraphIterationElement < > ( previous_segment , segment , point , distanceToReach , distanceToConsume ) ; }
Create an instance of GraphIterationElement .
6,684
public void ignoreElementsAfter ( GraphIterationElement < ST , PT > element ) { final List < GraphIterationElement < ST , PT > > nexts = getNextSegments ( false , element ) ; this . courseModel . removeIterationElements ( nexts ) ; }
Ignore the elements after the specified element .
6,685
public void removeChild ( final ITreeNode < T > child ) { if ( children != null ) { children . remove ( child ) ; } else { children = new ArrayList < > ( ) ; } }
Removes the child .
6,686
public static String getDefaultMapElementNodeName ( Class < ? extends MapElement > type ) { if ( MapPolyline . class . isAssignableFrom ( type ) ) { return NODE_POLYLINE ; } if ( MapPoint . class . isAssignableFrom ( type ) ) { return NODE_POINT ; } if ( MapPolygon . class . isAssignableFrom ( type ) ) { return NODE_POLYGON ; } if ( MapCircle . class . isAssignableFrom ( type ) ) { return NODE_CIRCLE ; } if ( MapMultiPoint . class . isAssignableFrom ( type ) ) { return NODE_MULTIPOINT ; } return null ; }
Replies the default name of the XML node for the given type of map element .
6,687
public static void writeGISElementAttributes ( Element element , GISElement primitive , XMLBuilder builder , XMLResources resources ) throws IOException { XMLAttributeUtil . writeAttributeContainer ( element , primitive , builder , resources , false ) ; element . setAttribute ( XMLUtil . ATTR_NAME , primitive . getName ( ) ) ; element . setAttribute ( XMLAttributeUtil . ATTR_GEOID , primitive . getGeoId ( ) . toString ( ) ) ; element . setAttribute ( XMLUtil . ATTR_ID , primitive . getUUID ( ) . toString ( ) ) ; }
Write the attributes of the given GISElement in the the XML description . Only the name geoId id and additional attributes are written . Icon and color are not written .
6,688
public static void readGISElementAttributes ( Element element , GISElement primitive , PathBuilder pathBuilder , XMLResources resources ) throws IOException { XMLAttributeUtil . readAttributeContainer ( element , primitive , pathBuilder , resources , false ) ; primitive . setName ( XMLUtil . getAttributeValueWithDefault ( element , null , XMLUtil . ATTR_NAME ) ) ; }
Read the attributes of a GISElement from the XML description . Only the name and additional attributes are read . Id geoId icon and color are not read .
6,689
@ SuppressWarnings ( "unchecked" ) public Set < LeftT > alignedToRightItem ( final Object rightItem ) { if ( rightToLeft . containsKey ( rightItem ) ) { return rightToLeft . get ( ( RightT ) rightItem ) ; } else { return ImmutableSet . of ( ) ; } }
if it s in the map it must be RightT
6,690
@ SuppressWarnings ( "unchecked" ) public Set < RightT > alignedToLeftItem ( final Object leftItem ) { if ( leftToRight . containsKey ( leftItem ) ) { return leftToRight . get ( ( LeftT ) leftItem ) ; } else { return ImmutableSet . of ( ) ; } }
if it s in the map it must be LeftT
6,691
public static void ensureParentDirectoryExists ( File f ) throws IOException { final File parent = f . getParentFile ( ) ; if ( parent != null ) { java . nio . file . Files . createDirectories ( parent . toPath ( ) ) ; } }
Create the parent directories of the given file if needed .
6,692
public static ImmutableList < File > loadFileList ( final Iterable < String > fileNames ) throws IOException { final ImmutableList . Builder < File > ret = ImmutableList . builder ( ) ; for ( String filename : fileNames ) { if ( ! filename . isEmpty ( ) ) { ret . add ( new File ( filename . trim ( ) ) ) ; } } return ret . build ( ) ; }
Takes a List of filenames and returns a list of files ignoring any empty strings and any trailing whitespace .
6,693
public static void writeFileList ( Iterable < File > files , CharSink sink ) throws IOException { writeUnixLines ( FluentIterable . from ( files ) . transform ( toAbsolutePathFunction ( ) ) , sink ) ; }
Writes the absolutes paths of the given files in iteration order one - per - line . Each line will end with a Unix newline .
6,694
public static void writeSymbolToFileMap ( Map < Symbol , File > symbolToFileMap , CharSink sink ) throws IOException { writeSymbolToFileEntries ( symbolToFileMap . entrySet ( ) , sink ) ; }
Writes a map from symbols to file absolute paths to a file . Each line has a mapping with the key and value separated by a single tab . The file will have a trailing newline .
6,695
public static void writeSymbolToFileEntries ( final Iterable < Map . Entry < Symbol , File > > entries , final CharSink sink ) throws IOException { writeUnixLines ( transform ( MapUtils . transformValues ( entries , toAbsolutePathFunction ( ) ) , TO_TAB_SEPARATED_ENTRY ) , sink ) ; }
Writes map entries from symbols to file absolute paths to a file . Each line has a mapping with the key and value separated by a single tab . The file will have a trailing newline . Note that the same key may appear in the file with multiple mappings .
6,696
public static void writeIntegerToStart ( final File f , final int num ) throws IOException { final RandomAccessFile fixupFile = new RandomAccessFile ( f , "rw" ) ; fixupFile . writeInt ( num ) ; fixupFile . close ( ) ; }
Writes a single integer to the beginning of a file overwriting what was there originally but leaving the rest of the file intact . This is useful when you are writing a long binary file with a size header but don t know how many elements are there until the end .
6,697
public static File siblingDirectory ( final File f , final String siblingDirName ) { checkNotNull ( f ) ; checkNotNull ( siblingDirName ) ; checkArgument ( ! siblingDirName . isEmpty ( ) ) ; final File parent = f . getParentFile ( ) ; if ( parent != null ) { return new File ( parent , siblingDirName ) ; } else { throw new RuntimeException ( String . format ( "Cannot create sibling directory %s of %s because the latter has no parent." , siblingDirName , f ) ) ; } }
Given a file returns a File representing a sibling directory with the specified name .
6,698
public static Predicate < File > endsWithPredicate ( final String suffix ) { checkArgument ( ! suffix . isEmpty ( ) ) ; return new EndsWithPredicate ( suffix ) ; }
Make a predicate to test files for their name ending with the specified suffix .
6,699
public static Predicate < File > isDirectoryPredicate ( ) { return new Predicate < File > ( ) { public boolean apply ( final File input ) { return input . isDirectory ( ) ; } } ; }
Guava predicates and functions