Java Arrays Examples

Java Arrays - 30 examples found. These are the top rated real world Java examples of java.util.Arrays extracted from open source projects. You can rate examples to help us improve the quality of examples.
  public Chunk(World par1World, int par2, int par3) {
    this.storageArrays = new ExtendedBlockStorage[16];
    this.blockBiomeArray = new byte[256];
    this.precipitationHeightMap = new int[256];
    this.updateSkylightColumns = new boolean[256];
    this.isGapLightingUpdated = false;
    this.chunkTileEntityMap = new HashMap();
    this.isTerrainPopulated = false;
    this.isModified = false;
    this.hasEntities = false;
    this.lastSaveTime = 0L;
    this.sendUpdates = false;
    this.field_82912_p = 0;
    this.queuedLightChecks = 4096;
    this.field_76653_p = false;
    this.entityLists = new List[16];
    this.worldObj = par1World;
    this.xPosition = par2;
    this.zPosition = par3;
    this.heightMap = new int[256];

    for (int var4 = 0; var4 < this.entityLists.length; ++var4) {
      this.entityLists[var4] = new ArrayList();
    }

    Arrays.fill(this.precipitationHeightMap, -999);
    Arrays.fill(this.blockBiomeArray, (byte) -1);
  }
  private String[] expStringToArray(String exp) {

    String[] splitExp = new String[exp.length()];
    Arrays.fill(splitExp, "");

    int j = 0;
    for (int i = 0; i < exp.length(); ++i) {
      char ch = exp.charAt(i);

      if (ch == '+' || ch == '-') {
        splitExp[++j] += ch;
      } else if (ch == '*' || ch == '/') {
        splitExp[++j] += ch;
        ++j;
      } else {
        splitExp[j] += ch;
      }
    }

    ArrayList<String> utilityArray = new ArrayList<>(Arrays.asList(splitExp));
    Predicate<String> p = (s) -> s.equals("");

    utilityArray.removeIf(p);
    splitExp = new String[0];
    splitExp = utilityArray.toArray(splitExp);
    return splitExp;
  }
  private void mountFiles(String path, Class<?> clazz) {
    try {
      List<Resource> list = new ArrayList<>();
      String packagePath = clazz.getPackage().getName().replace('.', '/');

      PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
      Resource[] res = resolver.getResources("classpath:" + packagePath + "/*.png");
      if (res != null) {
        list.addAll(Arrays.asList(res));
      }
      res = resolver.getResources("classpath:" + packagePath + "/*.gif");
      if (res != null) {
        list.addAll(Arrays.asList(res));
      }

      for (Resource resource : list) {
        URI uri = resource.getURI();
        File file = new File(uri.toString());
        mountResource(
            path + "/" + file.getName(), new SharedResourceReference(clazz, file.getName()));
      }
    } catch (Exception ex) {
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't mount files", ex);
    }
  }
  Object invoke(String methodName, Object... parameters)
      throws IllegalAccessException, InvocationTargetException {
    String mid = methodId(methodName, parameters.length);
    List<Method> methods = methodCache.get(mid);
    Method method = null;

    if (methods == null) {
      throw new IllegalAccessException("No method " + mid); // NOI18N
    }
    if (methods.size() == 1) {
      method = methods.get(0);
    } else {
      Class[] parClasses = new Class[parameters.length];

      for (int i = 0; i < parameters.length; i++) {
        Class cl = parameters[i].getClass();
        if (primitiveTypes.containsKey(cl)) {
          cl = primitiveTypes.get(cl);
        }
        parClasses[i] = cl;
      }
      for (Method m : methods) {
        if (Arrays.deepEquals(m.getParameterTypes(), parClasses)) {
          method = m;
          break;
        }
      }
    }
    if (method == null) {
      throw new IllegalArgumentException(
          instance + " " + methodName + " " + Arrays.toString(parameters));
    }
    return method.invoke(instance, parameters);
  }
Example #5
0
  public SelectMany05Bean() {

    HobbitBean[] hobbits = {
      new HobbitBean("Bilbo", "Ring Finder"),
      new HobbitBean("Frodo", "Ring Bearer"),
      new HobbitBean("Merry", "Trouble Maker"),
      new HobbitBean("Pippin", "Trouble Maker")
    };

    Set<SelectItem> items = new LinkedHashSet<SelectItem>();
    for (HobbitBean hobbit : hobbits) {
      items.add(new SelectItem(hobbit.getName()));
    }
    hobbitCollection = new TreeSet<HobbitBean>();
    hobbitCollection.addAll(Arrays.asList(hobbits));
    possibleValues = Collections.unmodifiableSet(items);
    initialSortedSetValues = new TreeSet<String>(Collections.reverseOrder());
    initialSortedSetValues.add("Pippin");
    initialSortedSetValues.add("Frodo");
    initialCollectionValues = new LinkedHashSet<String>(2);
    initialCollectionValues.add("Bilbo");
    initialCollectionValues.add("Merry");
    initialSetValues = new CopyOnWriteArraySet<String>(); // not Cloneable
    initialSetValues.add("Frodo");
    initialListValues = new Vector<String>();
    initialListValues.add("Bilbo");
    initialListValues.add("Pippin");
    initialListValues.add("Merry");
    hobbitDataModel =
        new ListDataModel<HobbitBean>(new ArrayList<HobbitBean>(Arrays.asList(hobbits)));
  }
Example #6
0
 static void validateColumnPath(String tablename, ColumnPath column_path)
     throws InvalidRequestException {
   validateTable(tablename);
   ColumnFamilyType cfType = validateColumnFamily(tablename, column_path.column_family);
   if (cfType == ColumnFamilyType.Standard) {
     if (column_path.super_column != null) {
       throw new InvalidRequestException(
           "supercolumn parameter is invalid for standard CF " + column_path.column_family);
     }
     if (column_path.column == null) {
       throw new InvalidRequestException(
           "column parameter is not optional for standard CF " + column_path.column_family);
     }
   } else {
     if (column_path.super_column == null)
       throw new InvalidRequestException(
           "supercolumn parameter is not optional for super CF " + column_path.column_family);
   }
   if (column_path.column != null) {
     validateColumns(
         tablename,
         column_path.column_family,
         column_path.super_column,
         Arrays.asList(column_path.column));
   }
   if (column_path.super_column != null) {
     validateColumns(
         tablename, column_path.column_family, null, Arrays.asList(column_path.super_column));
   }
 }