コード例 #1
1
ファイル: Tree.java プロジェクト: top-projects/javaslang
 @Override
 default <U> Tree<Tuple2<T, U>> zipAll(Iterable<U> that, T thisElem, U thatElem) {
   Objects.requireNonNull(that, "that is null");
   if (isEmpty()) {
     return Iterator.ofAll(that).map(elem -> Tuple.of(thisElem, elem)).toTree();
   } else {
     final java.util.Iterator<U> thatIter = that.iterator();
     final Tree<Tuple2<T, U>> tree = ZipAll.apply((Node<T>) this, thatIter, thatElem);
     if (thatIter.hasNext()) {
       final Iterable<Node<Tuple2<T, U>>> remainder =
           Iterator.ofAll(thatIter).map(elem -> Tree.of(Tuple.of(thisElem, elem)));
       return new Node<>(tree.getValue(), tree.getChildren().appendAll(remainder));
     } else {
       return tree;
     }
   }
 }
コード例 #2
0
 private void jj_add_error_token(int kind, int pos) {
   if (pos >= 100) return;
   if (pos == jj_endpos + 1) {
     jj_lasttokens[jj_endpos++] = kind;
   } else if (jj_endpos != 0) {
     jj_expentry = new int[jj_endpos];
     for (int i = 0; i < jj_endpos; i++) {
       jj_expentry[i] = jj_lasttokens[i];
     }
     jj_entries_loop:
     for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext(); ) {
       int[] oldentry = (int[]) (it.next());
       if (oldentry.length == jj_expentry.length) {
         for (int i = 0; i < jj_expentry.length; i++) {
           if (oldentry[i] != jj_expentry[i]) {
             continue jj_entries_loop;
           }
         }
         jj_expentries.add(jj_expentry);
         break jj_entries_loop;
       }
     }
     if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
   }
 }
コード例 #3
0
ファイル: JuceAppActivity.java プロジェクト: eriser/KentDAW
  private final void clearDataCache() {
    java.util.Iterator it = dataCache.values().iterator();

    while (it.hasNext()) {
      File f = (File) it.next();
      f.delete();
    }
  }
コード例 #4
0
ファイル: Os.java プロジェクト: jthuggins/jeditide
  /**
   * Dale Anson: One of the main reasons I borrowed this class from Ant was to be able to read
   * environment variables. It makes sense to add a method to easily fetch the value of an
   * environment variable here.
   *
   * @param name the name of an environment variable. Much of this code was copied from
   *     org.apache.tools.ant.taskdefs.Execute.
   * @return the value of the environment variable, or null if there is no value for the given name
   */
  public static String getEnvironmentValue(String name) {
    if (environment != null) {
      return (String) environment.get(name);
    }
    environment = new Hashtable<String, String>();

    try {
      String[] env_cmd = getProcEnvCommand();
      Process process = Runtime.getRuntime().exec(env_cmd);
      InputStream is = new BufferedInputStream(process.getInputStream());
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      CopyUtils.copy(is, baos);

      BufferedReader in = new BufferedReader(new StringReader(baos.toString()));

      // this portion copied from org.apache.tools.ant.taskdefs.Execute //
      Vector<String> procEnvironment = new Vector<String>();
      String var = null;
      String line, lineSep = System.getProperty("line.separator");
      while ((line = in.readLine()) != null) {
        if (line.indexOf('=') == -1) {
          // Chunk part of previous env var (UNIX env vars can
          // contain embedded new lines).
          if (var == null) {
            var = lineSep + line;
          } else {
            var += lineSep + line;
          }
        } else {
          // New env var...append the previous one if we have it.
          if (var != null) {
            procEnvironment.addElement(var);
          }
          var = line;
        }
      }
      // Since we "look ahead" before adding, there's one last env var.
      if (var != null) {
        procEnvironment.addElement(var);
      }
      // end copy from Execute //

      // now split out the names from the values and populate a Hashtable
      if (procEnvironment.size() > 0) {
        java.util.Iterator it = procEnvironment.iterator();
        while (it.hasNext()) {
          var = (String) it.next();
          int index = var.indexOf("=");
          String key = var.substring(0, index);
          String value = var.substring(index + 1);
          environment.put(key, value);
        }
      }
    } catch (Exception ignored) {
    }
    return getEnvironmentValue(name);
  }
コード例 #5
0
 /**
  * Sets the accelerator sequence
  *
  * @param accSeq The new accelSeq value
  */
 public void setAccelSeq(AcceleratorSeq accSeq) {
   java.util.List<AcceleratorNode> accNodes = accSeq.getNodesOfType(Electromagnet.s_strType);
   java.util.Iterator<AcceleratorNode> itr = accNodes.iterator();
   while (itr.hasNext()) {
     Electromagnet emg = (Electromagnet) itr.next();
     if (emg.getStatus()) {
       emg.setUseFieldReadback(false);
     }
   }
   ringFoilPosCorr.setAccelSeq(accSeq);
 }
コード例 #6
0
ファイル: Tree.java プロジェクト: top-projects/javaslang
 @SuppressWarnings("unchecked")
 static <T, U> Tree<Tuple2<T, U>> apply(Node<T> node, java.util.Iterator<U> that) {
   if (!that.hasNext()) {
     return Empty.instance();
   } else {
     final Tuple2<T, U> value = Tuple.of(node.getValue(), that.next());
     final List<Node<Tuple2<T, U>>> children =
         (List<Node<Tuple2<T, U>>>)
             (Object)
                 node.getChildren().map(child -> Zip.apply(child, that)).filter(Tree::isDefined);
     return new Node<>(value, children);
   }
 }
コード例 #7
0
ファイル: ShapefileAdapter.java プロジェクト: Unidata/IDV
  /**
   * Read the shapefile
   *
   * @param shapefile shapefile
   * @param bbox _more_
   * @return List of point sets
   */
  private List doRead(EsriShapefile shapefile, Rectangle2D bbox) {

    this.shapefile = shapefile;
    List features = shapefile.getFeatures();
    java.util.Iterator si = features.iterator();
    dbFile = shapefile.getDbFile();
    List s0 = new ArrayList();

    int pointCnt = 0;
    for (int i = 0; si.hasNext(); i++) {
      EsriShapefile.EsriFeature gf = (EsriShapefile.EsriFeature) si.next();
      SampledSet mapLines = gf.getMapLines(bbox);
      pointCnt += gf.getPointCount();
      if (mapLines != null) {
        s0.add(mapLines);
      }
    }
    return s0;
  }
コード例 #8
0
ファイル: DesignUtils.java プロジェクト: xiaoyaowansui/fr
  /**
   * 当前的报表运行环境切换到env
   *
   * @param env 需要切换去的环境
   */
  public static void switchToEnv(Env env) {
    if (env == null) {
      return;
    }

    Env oldEnv = FRContext.getCurrentEnv();
    String oldEnvPath = oldEnv == null ? null : oldEnv.getPath();

    // 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName
    DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
    java.util.Iterator<String> nameIt = envManager.getEnvNameIterator();
    while (nameIt.hasNext()) {
      String name = nameIt.next();
      if (ComparatorUtils.equals(envManager.getEnv(name), env)) {
        envManager.setCurEnvName(name);
        break;
      }
    }

    // 更新CurrentEnv于FRContext & DesignerEnvManager
    FRContext.setCurrentEnv(env);

    final Env run_env = env;

    // 刷新DesignerFrame里面的面板
    SwingUtilities.invokeLater(
        new Runnable() {

          public void run() {
            if (DesignerContext.getDesignerFrame() == null) {
              return;
            }
            DesignerContext.getDesignerFrame().refreshEnv(run_env);
            DesignerContext.getDesignerFrame().repaint(); // kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变.
          }
        });
    // 当换了运行环境,重置服务器,让它下次预览时重启
    if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) {
      StartServer.currentEnvChanged();
    }
  }
コード例 #9
0
ファイル: SeminarDatabase.java プロジェクト: bklimt/irlab
 protected void write() throws IOException {
   BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
   java.util.Set ids = seminars.keySet();
   java.util.Iterator iterator = ids.iterator();
   while (iterator.hasNext()) {
     String id = (String) iterator.next();
     Vector vector = (Vector) seminars.get(id);
     for (int i = 0; i < vector.size(); i++) {
       Seminar seminar = (Seminar) vector.get(i);
       writer.write(id + "\t" + seminar.getAnnotations().length + "\n");
       for (int j = 0; j < seminar.getAnnotations().length; j++) {
         Annotation annotation = seminar.getAnnotations()[j];
         writer.write(annotation.type + "\t");
         writer.write(annotation.offset + "\t");
         writer.write(annotation.length + "\t");
         writer.write(annotation.text + "\n");
       }
     }
   }
   writer.flush();
   writer.close();
 }