@Test public void testMakeDimensionsList() { Dimension dim = new Dimension("dimname", 5); Dimension anon = Dimension.builder().setLength(5).setIsShared(false).build(); Group.Builder groupb = Group.builder().addDimension(dim); ImmutableList<Dimension> list = Dimensions.makeDimensionsList(groupb::findDimension, "dimname 5"); assertThat(ImmutableList.of(dim, anon)).isEqualTo(list); assertThat(Dimensions.makeDimensionsList(groupb::findDimension, null)).isEmpty(); assertThat(Dimensions.makeDimensionsList(groupb::findDimension, "")).isEmpty(); }
public static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString) throws IllegalArgumentException { if (dimString == null) return ImmutableList.of(); dimString = dimString.trim(); if (dimString.isEmpty()) return ImmutableList.of(); ImmutableList.Builder<Dimension> newDimensions = ImmutableList.builder(); StringTokenizer stoke = new StringTokenizer(dimString); while (stoke.hasMoreTokens()) { String dimName = stoke.nextToken(); Dimension d; if (dimName.equals("*")) { d = Dimension.VLEN; } else { d = finder.findByName(dimName).orElse(null); } if (d == null) { try { int len = Integer.parseInt(dimName); d = Dimension.builder().setLength(len).setIsShared(false).build(); } catch (Exception e) { throw new IllegalArgumentException("Dimension " + dimName + " does not exist"); } } newDimensions.add(d); } return newDimensions.build(); }
Dimensions { public static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString) throws IllegalArgumentException { if (dimString == null) return ImmutableList.of(); dimString = dimString.trim(); if (dimString.isEmpty()) return ImmutableList.of(); ImmutableList.Builder<Dimension> newDimensions = ImmutableList.builder(); StringTokenizer stoke = new StringTokenizer(dimString); while (stoke.hasMoreTokens()) { String dimName = stoke.nextToken(); Dimension d; if (dimName.equals("*")) { d = Dimension.VLEN; } else { d = finder.findByName(dimName).orElse(null); } if (d == null) { try { int len = Integer.parseInt(dimName); d = Dimension.builder().setLength(len).setIsShared(false).build(); } catch (Exception e) { throw new IllegalArgumentException("Dimension " + dimName + " does not exist"); } } newDimensions.add(d); } return newDimensions.build(); } }
Dimensions { public static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString) throws IllegalArgumentException { if (dimString == null) return ImmutableList.of(); dimString = dimString.trim(); if (dimString.isEmpty()) return ImmutableList.of(); ImmutableList.Builder<Dimension> newDimensions = ImmutableList.builder(); StringTokenizer stoke = new StringTokenizer(dimString); while (stoke.hasMoreTokens()) { String dimName = stoke.nextToken(); Dimension d; if (dimName.equals("*")) { d = Dimension.VLEN; } else { d = finder.findByName(dimName).orElse(null); } if (d == null) { try { int len = Integer.parseInt(dimName); d = Dimension.builder().setLength(len).setIsShared(false).build(); } catch (Exception e) { throw new IllegalArgumentException("Dimension " + dimName + " does not exist"); } } newDimensions.add(d); } return newDimensions.build(); } private  Dimensions(); }
Dimensions { public static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString) throws IllegalArgumentException { if (dimString == null) return ImmutableList.of(); dimString = dimString.trim(); if (dimString.isEmpty()) return ImmutableList.of(); ImmutableList.Builder<Dimension> newDimensions = ImmutableList.builder(); StringTokenizer stoke = new StringTokenizer(dimString); while (stoke.hasMoreTokens()) { String dimName = stoke.nextToken(); Dimension d; if (dimName.equals("*")) { d = Dimension.VLEN; } else { d = finder.findByName(dimName).orElse(null); } if (d == null) { try { int len = Integer.parseInt(dimName); d = Dimension.builder().setLength(len).setIsShared(false).build(); } catch (Exception e) { throw new IllegalArgumentException("Dimension " + dimName + " does not exist"); } } newDimensions.add(d); } return newDimensions.build(); } private  Dimensions(); static ucar.ma2.Section.Builder makeSectionFromDimensions(Iterable<Dimension> dimensions); static long getSize(Iterable<Dimension> dimensions); static int[] makeShapeAll(Variable v); static int[] makeShape(Iterable<Dimension> dimensions); static String makeDimensionsString(List<Dimension> dimensions); static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString); static ImmutableList<Dimension> makeDimensionsAnon(int[] shape); static ImmutableList<Dimension> makeDimensionsAll(Variable v); }
Dimensions { public static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString) throws IllegalArgumentException { if (dimString == null) return ImmutableList.of(); dimString = dimString.trim(); if (dimString.isEmpty()) return ImmutableList.of(); ImmutableList.Builder<Dimension> newDimensions = ImmutableList.builder(); StringTokenizer stoke = new StringTokenizer(dimString); while (stoke.hasMoreTokens()) { String dimName = stoke.nextToken(); Dimension d; if (dimName.equals("*")) { d = Dimension.VLEN; } else { d = finder.findByName(dimName).orElse(null); } if (d == null) { try { int len = Integer.parseInt(dimName); d = Dimension.builder().setLength(len).setIsShared(false).build(); } catch (Exception e) { throw new IllegalArgumentException("Dimension " + dimName + " does not exist"); } } newDimensions.add(d); } return newDimensions.build(); } private  Dimensions(); static ucar.ma2.Section.Builder makeSectionFromDimensions(Iterable<Dimension> dimensions); static long getSize(Iterable<Dimension> dimensions); static int[] makeShapeAll(Variable v); static int[] makeShape(Iterable<Dimension> dimensions); static String makeDimensionsString(List<Dimension> dimensions); static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString); static ImmutableList<Dimension> makeDimensionsAnon(int[] shape); static ImmutableList<Dimension> makeDimensionsAll(Variable v);  }