cdm/src/main/java/ucar/nc2/NetcdfFile.java
public Variable findVariable(String fullNameEscaped) {
    if (fullNameEscaped == null || fullNameEscaped.isEmpty()) {
      return null;
    }

    Group g = rootGroup;
    String vars = fullNameEscaped;

    // break into group/group and var.var
    int pos = fullNameEscaped.lastIndexOf('/');
    if (pos >= 0) {
      String groups = fullNameEscaped.substring(0, pos);
      vars = fullNameEscaped.substring(pos + 1);
      StringTokenizer stoke = new StringTokenizer(groups, "/");
      while (stoke.hasMoreTokens()) {
        String token = NetcdfFile.makeNameUnescaped(stoke.nextToken());
        g = g.findGroup(token);
        if (g == null) return null;
      }
    }

    // heres var.var - tokenize respecting the possible escaped '.'
    List<String> snames = EscapeStrings.tokenizeEscapedName(vars);
    if (snames.size() == 0) return null;

    String varShortName = NetcdfFile.makeNameUnescaped(snames.get(0));
    Variable v = g.findVariable(varShortName);
    if (v == null) return null;

    int memberCount = 1;
    while (memberCount < snames.size()) {
      if (!(v instanceof Structure)) return null;
      String name = NetcdfFile.makeNameUnescaped(snames.get(memberCount++));
      v = ((Structure) v).findVariable(name);
      if (v == null) return null;
    }
    return v;
  }
public Variable findVariable(String fullNameEscaped) {
    if (fullNameEscaped == null || fullNameEscaped.isEmpty()) {
      return null;
    }

    Group g = rootGroup;
    String vars = fullNameEscaped;

    // break into group/group and var.var
    int pos = fullNameEscaped.lastIndexOf('/');
    if (pos >= 0) {
      String groups = fullNameEscaped.substring(0, pos);
      vars = fullNameEscaped.substring(pos + 1);
      StringTokenizer stoke = new StringTokenizer(groups, "/");
      while (stoke.hasMoreTokens()) {
        String token = NetcdfFile.makeNameUnescaped(stoke.nextToken());
        g = g.findGroup(token);
        if (g == null) return null;
      }
    }

    // heres var.var - tokenize respecting the possible escaped '.'
    List<String> snames = EscapeStrings.tokenizeEscapedName(vars);
    if (snames.size() == 0) return null;

    String varShortName = NetcdfFile.makeNameUnescaped(snames.get(0));
    Variable v = g.findVariable(varShortName);
    if (v == null) return null;

    int memberCount = 1;
    while (memberCount < snames.size()) {
      if (!(v instanceof Structure)) return null;
      String name = NetcdfFile.makeNameUnescaped(snames.get(memberCount++));
      v = ((Structure) v).findVariable(name);
      if (v == null) return null;
    }
    return v;
  }
public Variable findVariable ( String fullNameEscaped ) { if ( fullNameEscaped == null || fullNameEscaped . isEmpty ( ) ) { return null ; } Group g = rootGroup ; String vars = fullNameEscaped ; // break into group/group and var.var int pos = fullNameEscaped . lastIndexOf ( ' ' ) ; if ( pos >= 0 ) { String groups = fullNameEscaped . substring ( 0 , pos ) ; vars = fullNameEscaped . substring ( pos + 1 ) ; StringTokenizer stoke = new StringTokenizer ( groups , "/" ) ; while ( stoke . hasMoreTokens ( ) ) { String token = NetcdfFile . makeNameUnescaped ( stoke . nextToken ( ) ) ; g = g . findGroup ( token ) ; if ( g == null ) return null ; } } // heres var.var - tokenize respecting the possible escaped '.' List < String > snames = EscapeStrings . tokenizeEscapedName ( vars ) ; if ( snames . size ( ) == 0 ) return null ; String varShortName = NetcdfFile . makeNameUnescaped ( snames . get ( 0 ) ) ; Variable v = g . findVariable ( varShortName ) ; if ( v == null ) return null ; int memberCount = 1 ; while ( memberCount < snames . size ( ) ) { if ( ! ( v instanceof Structure ) ) return null ; String name = NetcdfFile . makeNameUnescaped ( snames . get ( memberCount ++ ) ) ; v = ( ( Structure ) v ) . findVariable ( name ) ; if ( v == null ) return null ; } return v ; }
Find a Variable, with the specified (escaped full) name.
It may possibly be nested in multiple groups and/or structures.
An embedded "." is interpreted as structure.member.
An embedded "/" is interpreted as group/variable.
If the name actually has a ".", you must escape it (call NetcdfFile.escapeName(varname))
Any other chars may also be escaped, as they are removed before testing.

@param fullNameEscaped eg "/group/subgroup/name1.name2.name".
@return Variable or null if not found.
Find a Variable with the specified ( escaped full ) name . It may possibly be nested in multiple groups and / or structures . An embedded . is interpreted as structure . member . An embedded / is interpreted as group / variable . If the name actually has a . you must escape it ( call NetcdfFile . escapeName ( varname )) Any other chars may also be escaped as they are removed before testing .