Example usage for java.util LinkedList get

List of usage examples for java.util LinkedList get

Introduction

In this page you can find the example usage for java.util LinkedList get.

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:report.mainReport.java

public static String createpathInfos(Connection c, Statement s, String dvId, int irang, LinkedList pList) {
    boolean flag, first;
    ResultSet rs = null;/*from  w  w w .  jav a 2  s .  c om*/
    String accountID = "";
    String deviceID = "";
    String deviceIDlast = "";
    Double latitude = 0.0;
    Double longitude = 0.0;
    Timestamp dateEV = null;
    String dateEVbegin = "";
    String dateEVend = "";
    String datem;
    int vitesse = 0;
    int tmps, nbpath = 0;
    int nb = 0;
    String pathinfos = "";
    int indexbegin = 0, indexend = 0;

    formatSymbols.setDecimalSeparator('.');
    DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
    for (int i = 0; i < pList.size(); i++) {
        Events evt = (Events) pList.get(i);
        accountID = evt.getAccountID();
        if (evt.getDeviceID().equals(dvId)) {
            int k = i + 1;
            tmps = 0;
            if (k < pList.size()) {
                Events evtnxt = (Events) pList.get(k);
                if (evtnxt.getDeviceID().equals(dvId)) {
                    double diff = evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime();
                    tmps = (int) diff / 1000;
                }
            }
            if (nbpath == 0) {
                pathinfos = "Array(";
                dateEVbegin = new SimpleDateFormat("yyyMMddHHmmss").format(evt.getDateEvt());
                datem = new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt());
                indexbegin = i;
            } else {
                datem = new SimpleDateFormat("HHmmss").format(evt.getDateEvt());
                pathinfos = pathinfos + ", ";
            }
            pathinfos = pathinfos + "Array(" + dec.format(evt.getLatitude()) + ", "
                    + dec.format(evt.getLongitude()) + ", " + datem + ", " + evt.getHeading() + ", "
                    + (int) evt.getSpeed() + ")";
            nbpath++;
            dateEVend = new SimpleDateFormat("yyyMMddHHmmss").format(evt.getDateEvt());
            indexend = i;
        }
    }
    Events evt = (Events) pList.get(indexbegin);
    Events evtnxt = (Events) pList.get(indexend);
    int distance = (int) (evtnxt.getOdometerKM() - evt.getOdometerKM());

    if (nbpath > 1 && distance > 1) {
        pathinfos = pathinfos + ")";
        String sql = "SELECT accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                + accountID + "' and deviceID='" + dvId + "';";
        try {
            rs = s.executeQuery(sql);
            if (rs.next()) {
                String vehicleMake = rs.getObject("vehicleMake") != null ? rs.getString("vehicleMake") : null;
                String vehicleModel = rs.getObject("vehicleModel") != null ? rs.getString("vehicleModel")
                        : null;
                String licensePlate = rs.getObject("licensePlate") != null ? rs.getString("licensePlate")
                        : null;
                pathinfos = "Array(" + pathinfos + ", \"" + dateEVbegin + "\", \"" + dateEVend + "\", 1)";

            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("Nb de points path: " + nbpath);
        System.out.println(pathinfos);
    } else {
        pathinfos = null;
        System.out.println(deviceIDlast + " AUCUN pathInfos");
    }
    return pathinfos;
}

From source file:oct.analysis.application.comp.EZWorker.java

@Override
protected EZEdgeCoord doInBackground() throws Exception {
    int foveaCenterXPosition = analysisManager.getFoveaCenterXPosition();
    /*//  ww  w. ja va 2  s.co  m
     first get a sharpened version of the OCT and use that to obtain the segmentation
     of the Bruch's membrane. Use a Loess interpolation algorithm to smooth 
     out imperfetions in the segmentation line.
     */
    UnivariateInterpolator interpolator = new LoessInterpolator(0.1, 0);
    ArrayList<Point> rawBrmPoints = new ArrayList<>(analysisManager
            .getSegmentation(new SharpenOperation(15, 0.5F)).getSegment(Segmentation.BrM_SEGMENT));
    double[][] brmSeg = Util.getXYArraysFromPoints(rawBrmPoints);
    UnivariateFunction brmInterp = interpolator.interpolate(brmSeg[0], brmSeg[1]);
    BufferedImage sharpOCT = analysisManager.getSharpenedOctImage(8.5D, 1.0F);
    setProgress(10);
    /*
     Starting from the identified location of the fovea search northward in 
     the image until the most northern pixels northward (in a 3x3 matrix of 
     pixels arround the the search point (X,Y) ) are black (ie. the search
     matrix is has found that the search point isn't totally surrounded by
     white pixels). Then a recursive search algorithm determines if the 
     black area signifies the seperation between bands or simply represents
     a closed (a black blob entirely surrounded by white pixels) black band.
     It will continue searching northward in the image until it can find an 
     open region of all blak pixels. Once this is found it will find the contour
     of the edge between the black and white pixels along the width of the image.
     */
    int searchY = (int) Math.round(brmInterp.value(foveaCenterXPosition)) + 1;
    do {
        searchY--;
    } while (Util.calculateGrayScaleValue(sharpOCT.getRGB(foveaCenterXPosition, searchY)) > 0
            || !isContrastPoint(foveaCenterXPosition, searchY, sharpOCT));
    LinkedList<Point> contour = new LinkedList<>();
    Point startPoint = new Point(foveaCenterXPosition, searchY);
    //find contour by searching for white pixel boundary to te right of the fovea
    contour.add(findContourRight(startPoint, Cardinality.SOUTH, startPoint, Cardinality.SOUTH, contour,
            sharpOCT, 0));
    //search until open black area found (ie. if the search algorithm arrives back at
    //the starting pixel keep moving north to next black area to search)
    while (contour.get(0).equals(startPoint)) {
        contour = new LinkedList<>();
        do {
            searchY--;
        } while (Util.calculateGrayScaleValue(sharpOCT.getRGB(foveaCenterXPosition, searchY)) == 0);
        do {
            searchY--;
        } while (Util.calculateGrayScaleValue(sharpOCT.getRGB(foveaCenterXPosition, searchY)) > 0
                || isSurroundedByWhite(foveaCenterXPosition, searchY, sharpOCT));
        startPoint = new Point(foveaCenterXPosition, searchY);
        contour.add(findContourRight(startPoint, Cardinality.SOUTH, startPoint, Cardinality.SOUTH, contour,
                sharpOCT, 0));
    }
    setProgress(20);
    //open balck space found, complete contour to left of fovea
    contour.add(
            findContourLeft(startPoint, Cardinality.SOUTH, startPoint, Cardinality.SOUTH, contour, sharpOCT));
    analysisManager.getImgPanel().setDrawPoint(new Point(foveaCenterXPosition, searchY));
    setProgress(30);
    /*
     since the contour can snake around due to aberations and low image density 
     we need to create a single line (represented by points) from left to right
     to represent the countour. This is easily done by building a line of
     points consisting of the point with the largest Y value (furthest from 
     the top of the image) at each X value. This eliminates overhangs from the 
     contour line.
     */
    Map<Double, List<Point>> grouped = contour.stream().collect(Collectors.groupingBy(Point::getX));
    List<Point> refinedEZContour = grouped.values().stream().map((List<Point> points) -> {
        int maxY = points.stream().mapToInt((Point p) -> p.y).min().getAsInt();
        return new Point(points.get(0).x, maxY);
    }).sorted((Point p1, Point p2) -> Integer.compare(p1.x, p2.x)).collect(Collectors.toList());
    setProgress(35);
    /*
     Starting from the identified location of the fovea search southward in 
     the image until the most southern pixels (in a 3x3 matrix of 
     pixels arround the the search point (X,Y) ) are black (ie. the search
     matrix has found that the search point isn't totally surrounded by
     white pixels). Then a recursive search algorithm determines if the 
     black area signifies the bottom of the Bruch's membrane or simply represents
     a closed (a black blob entirely surrounded by white pixels) black band.
     It will continue searching southward in the image until it can find an 
     open region of all black pixels. Once this is found it will find the contour
     of the edge between the black and white pixels, along the width of the image,
     of the bottom of the Bruch's membrane.
     */
    //        sharpOCT = getSharpenedOctImage(5D, 1.0F);
    searchY = (int) Math.round(brmInterp.value(foveaCenterXPosition));
    do {
        searchY++;
    } while (Util.calculateGrayScaleValue(sharpOCT.getRGB(foveaCenterXPosition, searchY)) > 0
            || isSurroundedByWhite(foveaCenterXPosition, searchY, sharpOCT));
    contour = new LinkedList<>();
    startPoint = new Point(foveaCenterXPosition, searchY);
    /*
     Find contour by searching for white pixel boundary to te right of the fovea.
     Sometimes the crap below the Bruchs membrane causes too much interferance for the
     algorithm to work properly so we must tweak some of the parameters of the 
     sharpening performed on the image until the algorithm succedes or we can no longer
     tweak parameters. In the case of the later event we can use the raw segmented
     Bruchs membrane as a substitute to keep the method from failing.
     */
    contour.add(findContourRight(startPoint, Cardinality.NORTH, startPoint, Cardinality.NORTH, contour,
            sharpOCT, 0));
    double filtValue = 8.5D;
    boolean tweakFailed = false;
    while (contour.contains(null)) {
        contour = new LinkedList<>();
        filtValue -= 0.5D;
        System.out.println("Reducing sigma to " + filtValue);
        if (filtValue <= 0D) {
            tweakFailed = true;
            break;
        }
        sharpOCT = analysisManager.getSharpenedOctImage(8.5D, 1.0F);
        contour.add(findContourRight(startPoint, Cardinality.NORTH, startPoint, Cardinality.NORTH, contour,
                sharpOCT, 0));
    }

    if (tweakFailed) {
        contour = new LinkedList<>(rawBrmPoints);
    } else {
        //search until open black area found (ie. if the search algorithm arrives back at
        //the starting pixel keep moving south to next black area to search)
        while (contour.get(0).equals(startPoint)) {
            contour = new LinkedList<>();
            do {
                searchY++;
            } while (Util.calculateGrayScaleValue(sharpOCT.getRGB(foveaCenterXPosition, searchY)) == 0);
            do {
                searchY++;
            } while (Util.calculateGrayScaleValue(sharpOCT.getRGB(foveaCenterXPosition, searchY)) > 0
                    || isSurroundedByWhite(foveaCenterXPosition, searchY, sharpOCT));
            startPoint = new Point(foveaCenterXPosition, searchY);
            contour.add(findContourRight(startPoint, Cardinality.NORTH, startPoint, Cardinality.NORTH, contour,
                    sharpOCT, 0));
        }
        setProgress(45);
        //open balck space found, complete contour to left of fovea
        contour.add(findContourLeft(startPoint, Cardinality.NORTH, startPoint, Cardinality.NORTH, contour,
                sharpOCT));
    }
    setProgress(55);
    /*
     since the contour can snake around due to aberations and low image density 
     we need to create a single line (represented by points) from left to right
     to represent the countour. This is easily done by building a line of
     points consisting of the point with the smallest Y value (closest to 
     the top of the image) at each X value. This eliminates overhangs from the 
     contour line.
     */
    grouped = contour.stream().collect(Collectors.groupingBy(Point::getX));
    List<Point> refinedBruchsMembraneContour = grouped.values().stream().map((List<Point> points) -> {
        int minY = points.stream().mapToInt((Point p) -> p.y).min().getAsInt();
        return new Point(points.get(0).x, minY);
    }).sorted((Point p1, Point p2) -> Integer.compare(p1.x, p2.x)).collect(Collectors.toList());
    setProgress(70);

    /*
     use a Loess interpolator again to smooth the new contours of the EZ and Bruch's Membrane
     */
    double[][] refinedContourPoints = Util.getXYArraysFromPoints(refinedEZContour);
    UnivariateFunction interpEZContour = interpolator.interpolate(refinedContourPoints[0],
            refinedContourPoints[1]);
    refinedContourPoints = Util.getXYArraysFromPoints(refinedBruchsMembraneContour);
    UnivariateFunction interpBruchsContour = interpolator.interpolate(refinedContourPoints[0],
            refinedContourPoints[1]);

    /*
     find the average difference in the distance in the Y between the 10 pixels
     at each end of the Bruch's Membrane contour and the contour created
     along the top of the EZ.
     */
    //since the lines are sorted on X position it is easy to align the lines
    //based on the tails of each line
    int minX = refinedEZContour.get(0).x;
    int maxX;
    //the interpolator can shorten the range of the X values from the original supplied
    //so we need to test where the end of the range occurs since it isn't directly accessible
    for (maxX = refinedEZContour.get(refinedEZContour.size() - 1).x; maxX > minX; maxX--) {
        try {
            double tmp = interpEZContour.value(maxX) - interpBruchsContour.value(maxX);
            //if this break is reached we have found the max value the interpolators will allow
            break;
        } catch (OutOfRangeException oe) {
            //do nothing but let loop continue
        }
    }
    double avgDif = Stream
            .concat(IntStream.range(minX + 30, minX + 50).boxed(),
                    IntStream.range(maxX - 49, maxX - 28).boxed())
            .mapToDouble(x -> interpBruchsContour.value(x) - interpEZContour.value(x)).average().getAsDouble();

    int height = sharpOCT.getHeight();//make to use in lambda expression
    List<LinePoint> ezLine = IntStream.rangeClosed(minX, maxX)
            .mapToObj(x -> new LinePoint(x, height - interpEZContour.value(x) - avgDif))
            .collect(Collectors.toList());
    List<LinePoint> bmLine = IntStream.rangeClosed(minX, maxX)
            .mapToObj(x -> new LinePoint(x, height - interpBruchsContour.value(x)))
            .collect(Collectors.toList());
    List<LinePoint> bmUnfiltLine = refinedBruchsMembraneContour.stream()
            .map((Point p) -> new LinePoint(p.x, height - p.getY())).collect(Collectors.toList());
    Util.graphPoints(ezLine, bmLine, bmUnfiltLine);
    analysisManager.getImgPanel().setDrawnLines(
            IntStream.rangeClosed(minX, maxX).mapToObj(x -> new LinePoint(x, interpEZContour.value(x)))
                    .collect(Collectors.toList()),
            IntStream.rangeClosed(minX, maxX).mapToObj(x -> new LinePoint(x, interpBruchsContour.value(x)))
                    .collect(Collectors.toList()));
    /*
     Find the difference between the two contours (Bruch's membrane and the
     EZ + Bruch's membrane) and use this to determine where the edge of the
     EZ is
     */
    List<LinePoint> diffLine = findDiffWithAdjustment(interpBruchsContour, 0D, interpEZContour, avgDif, minX,
            maxX);
    setProgress(90);
    //        List<LinePoint> peaks = Util.findPeaksAndVallies(diffLine);
    //        Util.graphPoints(diffLine, peaks);

    /*
     Find the first zero crossings of the difference line on both sides of the fovea.
     If a zero crossing can't be found then search for the first crossing of a
     value of 1, then 2, then 3, etc. until an X coordinate of a crossing is
     found on each side of the fovea.
     */
    OptionalInt ezLeftEdge;
    double crossingThreshold = 0.25D;
    do {
        double filtThresh = crossingThreshold;
        System.out.println("Crossing threshold = " + crossingThreshold);
        ezLeftEdge = diffLine.stream().filter(lp -> lp.getY() <= filtThresh && lp.getX() < foveaCenterXPosition)
                .mapToInt(LinePoint::getX).max();
        crossingThreshold += 0.25D;
    } while (!ezLeftEdge.isPresent());
    OptionalInt ezRightEdge;
    crossingThreshold = 0.25D;
    do {
        double filtThresh = crossingThreshold;
        System.out.println("Crossing threshold = " + crossingThreshold);
        ezRightEdge = diffLine.stream()
                .filter(lp -> lp.getY() <= filtThresh && lp.getX() > foveaCenterXPosition)
                .mapToInt(LinePoint::getX).min();
        crossingThreshold += 0.25D;
    } while (!ezRightEdge.isPresent());
    //return findings
    return new EZEdgeCoord(ezLeftEdge.getAsInt(), ezRightEdge.getAsInt());
}

From source file:com.splicemachine.derby.stream.function.merge.AbstractMergeJoinFlatMapFunction.java

protected void initRightScan(PeekingIterator<LocatedRow> leftPeekingIterator) throws StandardException {
    ExecRow firstHashRow = joinOperation.getKeyRow(leftPeekingIterator.peek().getRow());
    ExecRow startPosition = joinOperation.getRightResultSet().getStartPosition();
    int[] columnOrdering = getColumnOrdering(joinOperation.getRightResultSet());
    int nCols = startPosition != null ? startPosition.nColumns() : 0;
    ExecRow scanStartOverride = null;/*from   w  w  w .ja  va  2 s.  c o  m*/
    int[] scanKeys = null;
    // If start row of right table scan has as many columns as key colummns of the table, cannot further
    // narrow down scan space, so return right tabel scan start row.
    if (nCols == columnOrdering.length) {
        scanStartOverride = startPosition;
        scanKeys = columnOrdering;
    } else {
        int[] rightHashKeys = joinOperation.getRightHashKeys();
        // Find valid hash column values to narrow down right scan. The valid hash columns must:
        // 1) not be used as a start key for inner table scan
        // 2) be consecutive
        // 3) be a key column
        LinkedList<Pair<Integer, Integer>> hashColumnIndexList = new LinkedList<>();
        for (int i = 0; i < rightHashKeys.length; ++i) {
            if (rightHashKeys[i] > nCols - 1) {
                if ((hashColumnIndexList.isEmpty()
                        || hashColumnIndexList.getLast().getValue() == rightHashKeys[i] - 1)
                        && isKeyColumn(columnOrdering, rightHashKeys[i])) {
                    hashColumnIndexList.add(new ImmutablePair<Integer, Integer>(i, rightHashKeys[i]));
                } else {
                    break;
                }
            }
        }

        scanStartOverride = new ValueRow(nCols + hashColumnIndexList.size());
        if (startPosition != null) {
            for (int i = 1; i <= startPosition.nColumns(); ++i) {
                scanStartOverride.setColumn(i, startPosition.getColumn(i));
            }
        }
        for (int i = 0; i < hashColumnIndexList.size(); ++i) {
            Pair<Integer, Integer> hashColumnIndex = hashColumnIndexList.get(i);
            int index = hashColumnIndex.getKey();
            scanStartOverride.setColumn(nCols + i + 1, firstHashRow.getColumn(index + 1));
        }

        // Scan key should include columns
        // 1) preceding the first hash column, these columns are in the form of "col=constant"
        // 2) all hash columns that are key columns
        scanKeys = new int[hashColumnIndexList.size() + rightHashKeys[0]];
        for (int i = 0; i < rightHashKeys[0]; ++i) {
            scanKeys[i] = i;
        }
        for (int i = 0; i < hashColumnIndexList.size(); ++i) {
            Pair<Integer, Integer> hashColumnIndex = hashColumnIndexList.get(i);
            int colPos = hashColumnIndex.getValue();
            scanKeys[rightHashKeys[0] + i] = colPos;
        }
    }

    ((BaseActivation) joinOperation.getActivation()).setScanStartOverride(scanStartOverride);
    ((BaseActivation) joinOperation.getActivation()).setScanKeys(scanKeys);
    if (startPosition != null) {
        ((BaseActivation) joinOperation.getActivation()).setScanStopOverride(startPosition);
    }

}

From source file:com.mine.psf.PsfPlaybackService.java

private void generateShuffleList() {
    shuffleList = new int[playList.length];
    if (playShuffle) {
        // make a shuffle list
        // algro: get rand(),
        LinkedList<Integer> tmpList = new LinkedList<Integer>();
        for (int i = 0; i < playList.length; ++i) {
            tmpList.add(i);/* ww  w . ja v  a  2s.c  om*/
        }
        Random r = new Random();
        for (int i = 0; i < playList.length; ++i) {
            int tmp = r.nextInt(playList.length - i);
            shuffleList[i] = tmpList.get(tmp);
            tmpList.remove(tmp);
        }
    } else {
        for (int i = 0; i < playList.length; ++i) {
            shuffleList[i] = i;
        }
    }
    //       StringBuilder sb = new StringBuilder();
    //       for (int i = 0; i < playList.length; ++i) {
    //          sb.append(shuffleList[i]);
    //          sb.append(",");
    //       }
    //       Log.d(LOGTAG, "GetShuffleList: " + sb.toString());
}

From source file:net.semanticmetadata.lire.solr.FastLireRequestHandler.java

/**
 * Search based on the given image hashes.
 *
 * @param req/*from  w  w  w  .  j  a v  a 2 s.  co m*/
 * @param rsp
 * @throws java.io.IOException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private void handleHashSearch(SolrQueryRequest req, SolrQueryResponse rsp)
        throws IOException, IllegalAccessException, InstantiationException {
    SolrParams params = req.getParams();
    SolrIndexSearcher searcher = req.getSearcher();
    // get the params needed:
    // hashes=x y z ...
    // feature=<base64>
    // field=<cl_ha|ph_ha|...>

    String[] hashStrings = params.get("hashes").trim().split(" ");
    byte[] featureVector = Base64.decodeBase64(params.get("feature"));
    String paramField = "cl_ha";
    if (req.getParams().get("field") != null)
        paramField = req.getParams().get("field");
    int paramRows = defaultNumberOfResults;
    if (params.getInt("rows") != null)
        paramRows = params.getInt("rows");
    numberOfQueryTerms = req.getParams().getDouble("accuracy", DEFAULT_NUMBER_OF_QUERY_TERMS);
    numberOfCandidateResults = req.getParams().getInt("candidates", DEFAULT_NUMBER_OF_CANDIDATES);
    // create boolean query:
    //        System.out.println("** Creating query.");
    LinkedList<Term> termFilter = new LinkedList<Term>();
    BooleanQuery query = new BooleanQuery();
    for (int i = 0; i < hashStrings.length; i++) {
        // be aware that the hashFunctionsFileName of the field must match the one you put the hashes in before.
        hashStrings[i] = hashStrings[i].trim();
        if (hashStrings[i].length() > 0) {
            termFilter.add(new Term(paramField, hashStrings[i].trim()));
            //                System.out.println("** " + field + ": " + hashes[i].trim());
        }
    }
    Collections.shuffle(termFilter);
    for (int k = 0; k < termFilter.size() * numberOfQueryTerms; k++) {
        query.add(new BooleanClause(new TermQuery(termFilter.get(k)), BooleanClause.Occur.SHOULD));
    }
    //        System.out.println("** Doing search.");

    // query feature
    LireFeature queryFeature = (LireFeature) FeatureRegistry.getClassForHashField(paramField).newInstance();
    queryFeature.setByteArrayRepresentation(featureVector);

    // get results:
    doSearch(req, rsp, searcher, paramField, paramRows, termFilter, new MatchAllDocsQuery(), queryFeature);
}

From source file:fi.ni.IFC_ClassModel.java

/**
 * Map entries.//  w  w  w. jav a 2  s.c o m
 */
@SuppressWarnings("unchecked")
private void mapEntries() {
    for (Map.Entry<Long, IFC_X3_VO> entry : linemap.entrySet()) {
        IFC_X3_VO vo = entry.getValue();

        // Initialize the object_buffer
        try {
            Thing thing = object_buffer.get(vo.getLine_num());
            if (thing == null) {
                @SuppressWarnings("rawtypes")
                Class cls = Class.forName("fi.ni.ifc2x3." + entities.get(vo.name).getName());
                @SuppressWarnings("rawtypes")
                Constructor ct = cls.getConstructor();
                thing = (Thing) ct.newInstance();
                thing.i.drum_setLine_number(vo.getLine_num());
                object_buffer.put(vo.getLine_num(), (Thing) thing);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (int i = 0; i < vo.list.size(); i++) {
            Object o = vo.list.get(i);
            if (String.class.isInstance(o)) {
                String s = (String) o;
                if (s.length() < 1)
                    continue;
                if (s.charAt(0) == '#') {
                    Object or = linemap.get(toLong(s.substring(1)));
                    vo.list.set(i, or);
                }
            }
            if (LinkedList.class.isInstance(o)) {
                LinkedList<Object> tmp_list = (LinkedList<Object>) o;
                for (int j = 0; j < tmp_list.size(); j++) {
                    Object o1 = tmp_list.get(j);
                    if (String.class.isInstance(o1)) {
                        String s = (String) o1;
                        if (s.length() < 1)
                            continue;
                        if (s.charAt(0) == '#') {
                            Object or = linemap.get(toLong(s.substring(1)));
                            if (or == null) {
                                System.err.println("Reference to non-existing line in the IFC file.");
                                tmp_list.set(j, "-");
                            } else
                                tmp_list.set(j, or);
                        }
                    } else if (LinkedList.class.isInstance(o1)) {
                        LinkedList<Object> tmp2_list = (LinkedList<Object>) o1;
                        for (int j2 = 0; j2 < tmp2_list.size(); j2++) {
                            Object o2 = tmp2_list.get(j2);
                            if (String.class.isInstance(o2)) {
                                String s = (String) o2;
                                if (s.length() < 1)
                                    continue;
                                if (s.charAt(0) == '#') {
                                    Object or = linemap.get(toLong(s.substring(1)));
                                    if (or == null) {
                                        System.err.println("Reference to non-existing line in the IFC file.");
                                        tmp_list.set(j, "-");
                                    } else
                                        tmp_list.set(j, or);
                                }
                            }
                        }

                    }

                }
            }
        }
    }

}

From source file:fi.ni.IFC_ClassModel.java

/**
 * Estimate_level./*from  ww w.  java 2s . c  om*/
 * 
 * @param vo
 *            the value object representing the IFC file line
 * @param level
 *            the iteration count in the recursive run
 */
private void estimate_level(IFC_X3_VO vo, int level) {
    if (level > vo.getMaxlevel())
        vo.setMaxlevel(level);
    EntityVO evo = entities.get(vo.name);
    int pointer = 0;

    for (int i = 0; i < vo.list.size(); i++) {
        Object o = vo.list.get(i);

        if (String.class.isInstance(o)) {
            if (!((String) o).equals("$")) { // Do not handle empty values

                if ((evo != null) && (evo.getDerived_attribute_list() != null)
                        && (evo.getDerived_attribute_list().size() > pointer)) {
                    if (evo.getDerived_attribute_list().get(pointer).getName()
                            .equals(IFC_CLassModelConstants.GLOBAL_ID)) {
                        vo.setGid(filter_extras((String) o));
                    }
                }
            }
            pointer++;
        } else if (IFC_X3_VO.class.isInstance(o)) {
            estimate_level((IFC_X3_VO) o, level + 1);
        } else if (LinkedList.class.isInstance(o)) {
            @SuppressWarnings("unchecked")
            LinkedList<Object> tmp_list = (LinkedList<Object>) o;
            for (int j = 0; j < tmp_list.size(); j++) {
                Object o1 = tmp_list.get(j);
                if (IFC_X3_VO.class.isInstance(o1)) {
                    estimate_level((IFC_X3_VO) o1, level + 1);
                } else if (LinkedList.class.isInstance(o1)) {
                    @SuppressWarnings("unchecked")
                    LinkedList<Object> tmp2_list = (LinkedList<Object>) o1;
                    for (int j2 = 0; j2 < tmp2_list.size(); j2++) {
                        Object o2 = tmp2_list.get(j2);
                        if (IFC_X3_VO.class.isInstance(o2)) {
                            estimate_level((IFC_X3_VO) o2, level + 1);
                        } else if (String.class.isInstance(o2)) {
                            // if (!((String) o2).equals("?"))
                            // System.err.println("ts:" + ((String) o2));
                        } else if (Character.class.isInstance(o2))
                            ;
                        else
                            System.err.println("t:" + o2.getClass().getSimpleName());
                    }
                }

            }
        }
    }

}

From source file:com.commander4j.util.JUtility.java

public static String getTimeStampStringFormat(Timestamp ts, String fmt) {
    String result = "";
    LinkedList<String> fmtList = new LinkedList<String>();
    LinkedList<String> valList = new LinkedList<String>();
    fmtList.clear();// ww w.j a  v a  2s .  c  o m
    valList.clear();

    result = ts.toString();

    fmtList.add("yyyy");
    valList.add(result.substring(0, 4));

    fmtList.add("yy");
    valList.add(result.substring(2, 4));

    fmtList.add("mm");
    valList.add(result.substring(5, 7));

    fmtList.add("dd");
    valList.add(result.substring(8, 10));

    fmtList.add("hh");
    valList.add(result.substring(11, 13));

    fmtList.add("mi");
    valList.add(result.substring(14, 16));

    fmtList.add("ss");
    valList.add(result.substring(17, 19));

    fmtList.add("yymmdd");
    valList.add(result.substring(2, 4) + result.substring(5, 7) + result.substring(8, 10));

    int pos = fmtList.indexOf(fmt);

    if (pos >= 0) {
        result = valList.get(pos);
    } else {
        result = "";
    }

    return result;
}

From source file:report.mainReport.java

public static String createeventsInfos(Connection c, Statement s, String dvId, int irang, LinkedList pList) {
    boolean flag;
    ResultSet rs = null;//from ww w .  j  a va2s.  c  o  m
    String eventsInfos = "";
    String accountID = "";
    String deviceID = "";
    String deviceIDlast = "";
    Double latitude = 0.0;
    Double longitude = 0.0;
    float vitesse = 0;
    String accountIDlast = "";
    Double latitudelast = 0.0;
    Double longitudelast = 0.0;
    Timestamp dateEVlast = null;
    int speed, speedmax = 0, nbevents = 0;
    int dureepararret = 0;
    int nbrdepvitesse = 0;
    int dureedepvitesse = 0;

    formatSymbols.setDecimalSeparator('.');
    DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
    speedmax = 0;
    for (int i = 0; i < pList.size(); i++) {
        Events evt = (Events) pList.get(i);
        if (evt.getDeviceID().equalsIgnoreCase(dvId)) {
            accountID = evt.getAccountID();
            deviceID = evt.getDeviceID();
            if (speedmax < evt.getSpeed()) {
                speedmax = (int) evt.getSpeed();
                latitudelast = evt.getLatitude();
                longitudelast = evt.getLongitude();
                dateEVlast = evt.getDateEvt();
            }
            if (evt.getSpeed() > evt.getSpeedMax()) { // Vrification vitesse maximum
                nbrdepvitesse++;
                if (nbevents == 0) {
                    eventsInfos = "Array(";
                } else
                    eventsInfos = eventsInfos + ", ";
                int limit = 60;
                if (evt.getSpeed() > 65)
                    limit = 65;
                if (evt.getSpeed() > 70)
                    limit = 70;

                eventsInfos = eventsInfos + "Array(" + dec.format(evt.getLatitude()) + ", "
                        + dec.format(evt.getLongitude()) + ", "
                        + new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt()) + ", "
                        + new SimpleDateFormat("HHmmss").format(evt.getDateEvt())
                        + ",\"\", \"Vitesse maximale\", " + evt.getSpeed() + ", " + limit + ")";
                nbevents++;
            }
        }
    }
    if (speedmax > 0) {
        if (nbevents == 0) {
            eventsInfos = "Array(";
        } else
            eventsInfos = eventsInfos + ", ";
        //Array(Array(-18.94375, 47.50367, 20151208070953, 289, 0), Array(-18.94341, 47.50208, 71013, 309, 32))

        eventsInfos = eventsInfos + "Array(" + dec.format(latitudelast) + ", " + dec.format(longitudelast)
                + ", " + new SimpleDateFormat("yyyyMMddHHmmss").format(dateEVlast) + ", "
                + new SimpleDateFormat("HHmmss").format(dateEVlast) + ",\"\", \"Vitesse maximale\", " + speedmax
                + ", -2" + ")";
        nbevents++;
    }

    if (nbevents > 0) {
        eventsInfos = eventsInfos + ")";

        String sql = "SELECT accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                + accountID + "' and deviceID='" + deviceID + "';";
        try {
            rs = s.executeQuery(sql);
            if (rs.next()) {
                String vehicleMake = rs.getObject("vehicleMake") != null ? rs.getString("vehicleMake") : null;
                String vehicleModel = rs.getObject("vehicleModel") != null ? rs.getString("vehicleModel")
                        : null;
                String licensePlate = rs.getObject("licensePlate") != null ? rs.getString("licensePlate")
                        : null;
                eventsInfos = "Array(" + eventsInfos + ", \"" + licensePlate + " " + vehicleModel + "\")";

            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(deviceIDlast + " eventsInfos");
        //System.out.println(eventsInfos);
    } else {
        eventsInfos = null;
        System.out.println(deviceIDlast + " AUCUN eventsInfos");
    }
    return eventsInfos;
}

From source file:org.apache.hadoop.tracing.TraceAdmin.java

@Override
public int run(String argv[]) throws Exception {
    LinkedList<String> args = new LinkedList<String>();
    for (String arg : argv) {
        args.add(arg);// www  . ja v a 2s . com
    }
    if (StringUtils.popOption("-h", args) || StringUtils.popOption("-help", args)) {
        usage();
        return 0;
    } else if (args.size() == 0) {
        usage();
        return 0;
    }
    String hostPort = StringUtils.popOptionWithArgument("-host", args);
    if (hostPort == null) {
        System.err.println("You must specify a host with -host.");
        return 1;
    }
    if (args.size() < 0) {
        System.err.println("You must specify an operation.");
        return 1;
    }
    RPC.setProtocolEngine(getConf(), TraceAdminProtocolPB.class, ProtobufRpcEngine.class);
    InetSocketAddress address = NetUtils.createSocketAddr(hostPort);
    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    Class<?> xface = TraceAdminProtocolPB.class;
    proxy = (TraceAdminProtocolPB) RPC.getProxy(xface, RPC.getProtocolVersion(xface), address, ugi, getConf(),
            NetUtils.getDefaultSocketFactory(getConf()), 0);
    remote = new TraceAdminProtocolTranslatorPB(proxy);
    try {
        if (args.get(0).equals("-list")) {
            return listSpanReceivers(args.subList(1, args.size()));
        } else if (args.get(0).equals("-add")) {
            return addSpanReceiver(args.subList(1, args.size()));
        } else if (args.get(0).equals("-remove")) {
            return removeSpanReceiver(args.subList(1, args.size()));
        } else {
            System.err.println("Unrecognized tracing command: " + args.get(0));
            System.err.println("Use -help for help.");
            return 1;
        }
    } finally {
        remote.close();
    }
}