private DatasetNamer readDatasetNamerElement( InvDataset parentDataset,
                                                 Element dsNamerElement)
  {
    String name = dsNamerElement.getAttributeValue( "name");
    String addLevel = dsNamerElement.getAttributeValue( "addLevel");
    String type = dsNamerElement.getAttributeValue( "type");
    String matchPattern = dsNamerElement.getAttributeValue( "matchPattern");
    String substitutePattern = dsNamerElement.getAttributeValue( "substitutePattern");
    String attribContainer = dsNamerElement.getAttributeValue( "attribContainer");
    String attribName = dsNamerElement.getAttributeValue( "attribName");

    DatasetNamer dsNamer = new DatasetNamer( parentDataset,
                                             name, addLevel, type,
                                             matchPattern, substitutePattern,
                                             attribContainer, attribName);

    return( dsNamer);
  }

private DatasetNamer readDatasetNamerElement ( InvDataset parentDataset , Element dsNamerElement ) { String name = dsNamerElement . getAttributeValue ( "name" ) ; String addLevel = dsNamerElement . getAttributeValue ( "addLevel" ) ; String type = dsNamerElement . getAttributeValue ( "type" ) ; String matchPattern = dsNamerElement . getAttributeValue ( "matchPattern" ) ; String substitutePattern = dsNamerElement . getAttributeValue ( "substitutePattern" ) ; String attribContainer = dsNamerElement . getAttributeValue ( "attribContainer" ) ; String attribName = dsNamerElement . getAttributeValue ( "attribName" ) ; DatasetNamer dsNamer = new DatasetNamer ( parentDataset , name , addLevel , type , matchPattern , substitutePattern , attribContainer , attribName ) ; return ( dsNamer ) ; }

Return a DatasetNamer when given a 'datasetNamer' JDOM element.

Return a DatasetNamer when given a datasetNamer JDOM element .


private DatasetFilter readDatasetFilterElement( DatasetSource parentDatasetSource,
                                                  Element dsFilterElement)
  {
    String name = dsFilterElement.getAttributeValue( "name");
    String type = dsFilterElement.getAttributeValue( "type");
    String matchPattern = dsFilterElement.getAttributeValue( "matchPattern");

    DatasetFilter dsFilter = new DatasetFilter( parentDatasetSource,
                                                name, DatasetFilter.Type.getType( type), matchPattern);
    String matchPatternTarget = dsFilterElement.getAttributeValue( "matchPatternTarget");
    dsFilter.setMatchPatternTarget( matchPatternTarget);

    if ( dsFilterElement.getAttributeValue( "applyToCollectionDatasets") != null)
    {
      boolean applyToCollectionDatasets = Boolean.valueOf( dsFilterElement.getAttributeValue( "applyToCollectionDatasets")).booleanValue();
      dsFilter.setApplyToCollectionDatasets( applyToCollectionDatasets);
    }
    if ( dsFilterElement.getAttributeValue( "applyToAtomicDatasets") != null)
    {
      boolean applyToAtomicDatasets = Boolean.valueOf( dsFilterElement.getAttributeValue( "applyToAtomicDatasets")).booleanValue();
      dsFilter.setApplyToAtomicDatasets( applyToAtomicDatasets);
    }
    if ( dsFilterElement.getAttributeValue( "rejectMatchingDatasets") != null)
    {
      boolean rejectMatchingDatasets = Boolean.valueOf( dsFilterElement.getAttributeValue( "rejectMatchingDatasets")).booleanValue();
      dsFilter.setRejectMatchingDatasets( rejectMatchingDatasets);
    }

    return( dsFilter);
  }

private DatasetFilter readDatasetFilterElement ( DatasetSource parentDatasetSource , Element dsFilterElement ) { String name = dsFilterElement . getAttributeValue ( "name" ) ; String type = dsFilterElement . getAttributeValue ( "type" ) ; String matchPattern = dsFilterElement . getAttributeValue ( "matchPattern" ) ; DatasetFilter dsFilter = new DatasetFilter ( parentDatasetSource , name , DatasetFilter . Type . getType ( type ) , matchPattern ) ; String matchPatternTarget = dsFilterElement . getAttributeValue ( "matchPatternTarget" ) ; dsFilter . setMatchPatternTarget ( matchPatternTarget ) ; if ( dsFilterElement . getAttributeValue ( "applyToCollectionDatasets" ) != null ) { boolean applyToCollectionDatasets = Boolean . valueOf ( dsFilterElement . getAttributeValue ( "applyToCollectionDatasets" ) ) . booleanValue ( ) ; dsFilter . setApplyToCollectionDatasets ( applyToCollectionDatasets ) ; } if ( dsFilterElement . getAttributeValue ( "applyToAtomicDatasets" ) != null ) { boolean applyToAtomicDatasets = Boolean . valueOf ( dsFilterElement . getAttributeValue ( "applyToAtomicDatasets" ) ) . booleanValue ( ) ; dsFilter . setApplyToAtomicDatasets ( applyToAtomicDatasets ) ; } if ( dsFilterElement . getAttributeValue ( "rejectMatchingDatasets" ) != null ) { boolean rejectMatchingDatasets = Boolean . valueOf ( dsFilterElement . getAttributeValue ( "rejectMatchingDatasets" ) ) . booleanValue ( ) ; dsFilter . setRejectMatchingDatasets ( rejectMatchingDatasets ) ; } return ( dsFilter ) ; }

Return a DatasetFilter when given a 'datasetFilter' JDOM element.

Return a DatasetFilter when given a datasetFilter JDOM element .


private ResultService readResultServiceElement( InvDataset parentDataset,
                                                  Element resultServiceElement)
  {
    String name = resultServiceElement.getAttributeValue( "name");
    String serviceType = resultServiceElement.getAttributeValue( "serviceType");
    String base = resultServiceElement.getAttributeValue( "base");
    String suffix = resultServiceElement.getAttributeValue( "suffix");
    String accessPointHeader =
      resultServiceElement.getAttributeValue( "accessPointHeader");

    return( new ResultService( name, ServiceType.getType( serviceType), base, suffix,
                               accessPointHeader));
  }

private ResultService readResultServiceElement ( InvDataset parentDataset , Element resultServiceElement ) { String name = resultServiceElement . getAttributeValue ( "name" ) ; String serviceType = resultServiceElement . getAttributeValue ( "serviceType" ) ; String base = resultServiceElement . getAttributeValue ( "base" ) ; String suffix = resultServiceElement . getAttributeValue ( "suffix" ) ; String accessPointHeader = resultServiceElement . getAttributeValue ( "accessPointHeader" ) ; return ( new ResultService ( name , ServiceType . getType ( serviceType ) , base , suffix , accessPointHeader ) ) ; }

Return a ResultService when given a 'resultService' JDOM element.

Return a ResultService when given a resultService JDOM element .


private org.jdom2.Element createCatGenConfigElement( CatalogGenConfig cgc)
  {
    // @todo Need to deal with the 0.6 and 1.0 namespaces.
    Element cgcElem = new Element("catalogGenConfig", CATALOG_GEN_CONFIG_NAMESPACE_0_5);
    if ( cgc != null)
    {
      if ( cgc.getType() != null)
      {
        cgcElem.setAttribute( "type", cgc.getType().toString());
      }

      // Add 'datasetSource' element
      DatasetSource dsSource = cgc.getDatasetSource();
      cgcElem.addContent( createDatasetSourceElement( dsSource));

    }

    return( cgcElem);
  }

Create a 'catalogGenConfig' JDOM element


private org.jdom2.Element createDatasetSourceElement( DatasetSource dsSource)
  {
    Element dssElem = new Element("datasetSource", CATALOG_GEN_CONFIG_NAMESPACE_0_5);
    if ( dsSource != null)
    {
      // Add 'name' attribute.
      if ( dsSource.getName() != null)
      {
        dssElem.setAttribute( "name", dsSource.getName());
      }

      // Add 'type' attribute.
      if ( dsSource.getType() != null)
      {
        dssElem.setAttribute( "type", dsSource.getType().toString());
      }

      // Add 'structure' attribute.
      if ( dsSource.getStructure() != null)
      {
        dssElem.setAttribute( "structure", dsSource.getStructure().toString());
      }

      // Add 'accessPoint' attribute.
      if ( dsSource.getAccessPoint() != null)
      {
        dssElem.setAttribute( "accessPoint", dsSource.getAccessPoint());
      }

      // Add 'createCatalogRefs' attribute.
      dssElem.setAttribute( "createCatalogRefs", Boolean.toString(  dsSource.isCreateCatalogRefs()));

      // Add 'resultService' element
      ResultService rs = dsSource.getResultService();
      dssElem.addContent( createResultServiceElement( rs));

      // Add 'datasetNamer' elements
      java.util.List list = dsSource.getDatasetNamerList();
      for ( int j=0; j < list.size(); j++)
      {
        DatasetNamer dsNamer = (DatasetNamer) list.get(j);
        dssElem.addContent( createDatasetNamerElement( dsNamer));
      }

      // Add 'datasetFilter' elements
      list = dsSource.getDatasetFilterList();
      for ( int j=0; j < list.size(); j++)
      {
        DatasetFilter dsFilter = (DatasetFilter) list.get(j);
        dssElem.addContent( createDatasetFilterElement( dsFilter));
      }
    }

    return( dssElem);
  }

private
org
.
jdom2
.
Element
createDatasetSourceElement
(
DatasetSource
dsSource
)
{
Element
dssElem
=
new
Element
(
"datasetSource"
,
CATALOG_GEN_CONFIG_NAMESPACE_0_5
)
;
if
(
dsSource
!=
)
{
// Add 'name' attribute.
if
(
dsSource
.
getName
(
)
!=
)
{
dssElem
.
setAttribute
(
"name"
,
dsSource
.
getName
(
)
)
;
}
// Add 'type' attribute.
if
(
dsSource
.
getType
(
)
!=
)
{
dssElem
.
setAttribute
(
"type"
,
dsSource
.
getType
(
)
.
toString
(
)
)
;
}
// Add 'structure' attribute.
if
(
dsSource
.
getStructure
(
)
!=
)
{
dssElem
.
setAttribute
(
"structure"
,
dsSource
.
getStructure
(
)
.
toString
(
)
)
;
}
// Add 'accessPoint' attribute.
if
(
dsSource
.
getAccessPoint
(
)
!=
)
{
dssElem
.
setAttribute
(
"accessPoint"
,
dsSource
.
getAccessPoint
(
)
)
;
}
// Add 'createCatalogRefs' attribute.
dssElem
.
setAttribute
(
"createCatalogRefs"
,
Boolean
.
toString
(
dsSource
.
isCreateCatalogRefs
(
)
)
)
;
// Add 'resultService' element
ResultService
rs
=
dsSource
.
getResultService
(
)
;
dssElem
.
addContent
(
createResultServiceElement
(
rs
)
)
;
// Add 'datasetNamer' elements
java
.
util
.
List
list
=
dsSource
.
getDatasetNamerList
(
)
;
for
(
int
j
=
0
;
j
<
list
.
size
(
)
;
j
++
)
{
DatasetNamer
dsNamer
=
(
DatasetNamer
)
list
.
get
(
j
)
;
dssElem
.
addContent
(
createDatasetNamerElement
(
dsNamer
)
)
;
}
// Add 'datasetFilter' elements
list
=
dsSource
.
getDatasetFilterList
(
)
;
for
(
int
j
=
0
;
j
<
list
.
size
(
)
;
j
++
)
{
DatasetFilter
dsFilter
=
(
DatasetFilter
)
list
.
get
(
j
)
;
dssElem
.
addContent
(
createDatasetFilterElement
(
dsFilter
)
)
;
}
}
return
(
dssElem
)
;
}


private org.jdom2.Element createDatasetNamerElement( DatasetNamer dsNamer)
  {
    Element dsnElem = new Element("datasetNamer", CATALOG_GEN_CONFIG_NAMESPACE_0_5);
    if ( dsNamer != null)
    {
      // Add 'name' attribute.
      if ( dsNamer.getName() != null)
      {
        dsnElem.setAttribute( "name", dsNamer.getName());
      }

      // Add 'addLevel' attribute.
      dsnElem.setAttribute( "addLevel", Boolean.toString( dsNamer.getAddLevel()));

      // Add 'type' attribute.
      if ( dsNamer.getType() != null)
      {
        dsnElem.setAttribute( "type", dsNamer.getType().toString());
      }

      // Add 'matchPattern' attribute.
      if ( dsNamer.getMatchPattern() != null)
      {
        dsnElem.setAttribute( "matchPattern", dsNamer.getMatchPattern());
      }

      // Add 'subsitutePattern' attribute.
      if ( dsNamer.getSubstitutePattern() != null)
      {
        dsnElem.setAttribute( "substitutePattern", dsNamer.getSubstitutePattern());
      }

      // Add 'attribContainer' attribute.
      if ( dsNamer.getAttribContainer() != null)
      {
        dsnElem.setAttribute( "attribContainer", dsNamer.getAttribContainer());
      }

      // Add 'attribName' attribute.
      if ( dsNamer.getAttribName() != null)
      {
        dsnElem.setAttribute( "attribName", dsNamer.getAttribName());
      }

    }

    return( dsnElem);
  }

private
org
.
jdom2
.
Element
createDatasetNamerElement
(
DatasetNamer
dsNamer
)
{
Element
dsnElem
=
new
Element
(
"datasetNamer"
,
CATALOG_GEN_CONFIG_NAMESPACE_0_5
)
;
if
(
dsNamer
!=
)
{
// Add 'name' attribute.
if
(
dsNamer
.
getName
(
)
!=
)
{
dsnElem
.
setAttribute
(
"name"
,
dsNamer
.
getName
(
)
)
;
}
// Add 'addLevel' attribute.
dsnElem
.
setAttribute
(
"addLevel"
,
Boolean
.
toString
(
dsNamer
.
getAddLevel
(
)
)
)
;
// Add 'type' attribute.
if
(
dsNamer
.
getType
(
)
!=
)
{
dsnElem
.
setAttribute
(
"type"
,
dsNamer
.
getType
(
)
.
toString
(
)
)
;
}
// Add 'matchPattern' attribute.
if
(
dsNamer
.
getMatchPattern
(
)
!=
)
{
dsnElem
.
setAttribute
(
"matchPattern"
,
dsNamer
.
getMatchPattern
(
)
)
;
}
// Add 'subsitutePattern' attribute.
if
(
dsNamer
.
getSubstitutePattern
(
)
!=
)
{
dsnElem
.
setAttribute
(
"substitutePattern"
,
dsNamer
.
getSubstitutePattern
(
)
)
;
}
// Add 'attribContainer' attribute.
if
(
dsNamer
.
getAttribContainer
(
)
!=
)
{
dsnElem
.
setAttribute
(
"attribContainer"
,
dsNamer
.
getAttribContainer
(
)
)
;
}
// Add 'attribName' attribute.
if
(
dsNamer
.
getAttribName
(
)
!=
)
{
dsnElem
.
setAttribute
(
"attribName"
,
dsNamer
.
getAttribName
(
)
)
;
}
}
return
(
dsnElem
)
;
}


private org.jdom2.Element createDatasetFilterElement( DatasetFilter dsFilter)
  {
    Element dsfElem = new Element("datasetFilter", CATALOG_GEN_CONFIG_NAMESPACE_0_5);
    if ( dsFilter != null)
    {
      // Add 'name' attribute.
      if ( dsFilter.getName() != null)
      {
        dsfElem.setAttribute( "name", dsFilter.getName());
      }

      // Add 'type' attribute.
      if ( dsFilter.getType() != null)
      {
        dsfElem.setAttribute( "type", dsFilter.getType().toString());
      }

      // Add 'matchPattern' attribute.
      if ( dsFilter.getMatchPattern() != null)
      {
        dsfElem.setAttribute( "matchPattern", dsFilter.getMatchPattern());
      }

      // Add 'matchPatternTarget' attribute.
      if ( dsFilter.getMatchPatternTarget() != null)
      {
        dsfElem.setAttribute( "matchPatternTarget", dsFilter.getMatchPatternTarget());
      }

      // Add 'applyToCollectionDatasets' attribute.
      dsfElem.setAttribute( "applyToCollectionDatasets", String.valueOf( dsFilter.isApplyToCollectionDatasets()));

      // Add 'applyToAtomicDatasets' attribute.
      dsfElem.setAttribute( "applyToAtomicDatasets", String.valueOf( dsFilter.isApplyToAtomicDatasets()));

      // Add 'rejectMatchingDatasets' attribute.
      dsfElem.setAttribute( "rejectMatchingDatasets", String.valueOf( dsFilter.isRejectMatchingDatasets()));

    }

    return( dsfElem);
  }


private org.jdom2.Element createResultServiceElement( ResultService resultService)
  {
    Element rsElem = new Element("resultService", CATALOG_GEN_CONFIG_NAMESPACE_0_5);
    if ( resultService != null)
    {
      // Add 'name' attribute.
      if ( resultService.getName() != null)
      {
        rsElem.setAttribute( "name", resultService.getName());
      }

      // Add 'serviceType' attribute.
      if ( resultService.getServiceType() != null)
      {
        rsElem.setAttribute( "serviceType", resultService.getServiceType().toString());
      }

      // Add 'base' attribute.
      if ( resultService.getBase() != null)
      {
        rsElem.setAttribute( "base", resultService.getBase());
      }

      // Add 'suffix' attribute.
      if ( resultService.getSuffix() != null)
      {
        rsElem.setAttribute( "suffix", resultService.getSuffix());
      }

      // Add 'accessPointHeader' attribute.
      if ( resultService.getAccessPointHeader() != null)
      {
        rsElem.setAttribute( "accessPointHeader", resultService.getAccessPointHeader());
      }
    }

    return( rsElem);
  }

private
org
.
jdom2
.
Element
createResultServiceElement
(
ResultService
resultService
)
{
Element
rsElem
=
new
Element
(
"resultService"
,
CATALOG_GEN_CONFIG_NAMESPACE_0_5
)
;
if
(
resultService
!=
)
{
// Add 'name' attribute.
if
(
resultService
.
getName
(
)
!=
)
{
rsElem
.
setAttribute
(
"name"
,
resultService
.
getName
(
)
)
;
}
// Add 'serviceType' attribute.
if
(
resultService
.
getServiceType
(
)
!=
)
{
rsElem
.
setAttribute
(
"serviceType"
,
resultService
.
getServiceType
(
)
.
toString
(
)
)
;
}
// Add 'base' attribute.
if
(
resultService
.
getBase
(
)
!=
)
{
rsElem
.
setAttribute
(
"base"
,
resultService
.
getBase
(
)
)
;
}
// Add 'suffix' attribute.
if
(
resultService
.
getSuffix
(
)
!=
)
{
rsElem
.
setAttribute
(
"suffix"
,
resultService
.
getSuffix
(
)
)
;
}
// Add 'accessPointHeader' attribute.
if
(
resultService
.
getAccessPointHeader
(
)
!=
)
{
rsElem
.
setAttribute
(
"accessPointHeader"
,
resultService
.
getAccessPointHeader
(
)
)
;
}
}
return
(
rsElem
)
;
}


static public boolean isSet(String flagName) {
    if (store == null) return false;

    NamePart np = partit( flagName);
    if (debug) {
      try {
        if ((np.storeName.length() > 0) && !store.nodeExists(np.storeName))
          System.out.println("Debug.isSet create node = "+ flagName+" "+np);
        else if (null == store.node(np.storeName).get( np.keyName, null))
          System.out.println("Debug.isSet create flag = "+ flagName+" "+np);
      } catch (BackingStoreException e) { }
    }
    // add it if it doesnt already exist
    boolean value =  store.node(np.storeName).getBoolean( np.keyName, false);
    store.node(np.storeName).putBoolean( np.keyName, value);
    return value;
  }

static
public
boolean
isSet
(
String
flagName
)
{
if
(
store
==
)
return
false
;
NamePart
np
=
partit
(
flagName
)
;
if
(
debug
)
{
try
{
if
(
(
np
.
storeName
.
length
(
)
>
0
)
&&
!
store
.
nodeExists
(
np
.
storeName
)
)
System
.
out
.
println
(
"Debug.isSet create node = "
+
flagName
+
" "
+
np
)
;
else
if
(
==
store
.
node
(
np
.
storeName
)
.
get
(
np
.
keyName
,
)
)
System
.
out
.
println
(
"Debug.isSet create flag = "
+
flagName
+
" "
+
np
)
;
}
catch
(
BackingStoreException
e
)
{
}
}
// add it if it doesnt already exist
boolean
value
=
store
.
node
(
np
.
storeName
)
.
getBoolean
(
np
.
keyName
,
false
)
;
store
.
node
(
np
.
storeName
)
.
putBoolean
(
np
.
keyName
,
value
)
;
return
value
;
}

Return the value of the named flag. If it doesnt exist, it will be added
to the store and the menu with a value of "false".

Return the value of the named flag . If it doesnt exist it will be added to the store and the menu with a value of false .


static public void constructMenu(JMenu topMenu) {
    if (debug) System.out.println("Debug.constructMenu ");

    if (topMenu.getItemCount() > 0)
      topMenu.removeAll();

    try {
      addToMenu( topMenu, store); // recursive
    } catch (BackingStoreException e) { }

    topMenu.revalidate();
  }

static
public
void
constructMenu
(
JMenu
topMenu
)
{
if
(
debug
)
System
.
out
.
println
(
"Debug.constructMenu "
)
;
if
(
topMenu
.
getItemCount
(
)
>
0
)
topMenu
.
removeAll
(
)
;
try
{
addToMenu
(
topMenu
,
store
)
;
// recursive
}
catch
(
BackingStoreException
e
)
{
}
topMenu
.
revalidate
(
)
;
}

Construct cascading pull-aside menus using the values of the debug flags
in the Preferences object.
@param topMenu attach the menus as children of this one.

Construct cascading pull - aside menus using the values of the debug flags in the Preferences object .


static private void addToMenu( JMenu menu, Preferences prefs) throws BackingStoreException {
    if (debug) System.out.println(" addMenu "+ prefs.name());

    String[] keys = prefs.keys();
    for (String key : keys) {
      boolean bval = prefs.getBoolean(key, false);
      String fullname = prefs.absolutePath() + "/" + key;
      menu.add(new DebugMenuItem(fullname, key, bval)); // menu leaf
      if (debug) System.out.println("   leaf= <" + key + "><" + fullname + ">");
    }

    String[] kidName = prefs.childrenNames();
    for (String aKidName : kidName) {
      Preferences pkid = prefs.node(aKidName);
      JMenu subMenu = new JMenu(pkid.name());
      menu.add(subMenu);
      addToMenu(subMenu, pkid);
    }
  }

static
private
void
addToMenu
(
JMenu
menu
,
Preferences
prefs
)
throws
BackingStoreException
{
if
(
debug
)
System
.
out
.
println
(
" addMenu "
+
prefs
.
name
(
)
)
;
String
[
]
keys
=
prefs
.
keys
(
)
;
for
(
String
key
:
keys
)
{
boolean
bval
=
prefs
.
getBoolean
(
key
,
false
)
;
String
fullname
=
prefs
.
absolutePath
(
)
+
"/"
+
key
;
menu
.
add
(
new
DebugMenuItem
(
fullname
,
key
,
bval
)
)
;
// menu leaf
if
(
debug
)
System
.
out
.
println
(
"   leaf= <"
+
key
+
"><"
+
fullname
+
">"
)
;
}
String
[
]
kidName
=
prefs
.
childrenNames
(
)
;
for
(
String
aKidName
:
kidName
)
{
Preferences
pkid
=
prefs
.
node
(
aKidName
)
;
JMenu
subMenu
=
new
JMenu
(
pkid
.
name
(
)
)
;
menu
.
add
(
subMenu
)
;
addToMenu
(
subMenu
,
pkid
)
;
}
}


public void addParameters(String tbl) throws IOException {
    try (InputStream is = getInputStream(tbl)) {
      if (is == null) {
        throw new IOException("Unable to open " + tbl);
      }
      String content = readContents(is);   // LOOK this is silly - should just read one line at a time
      // List           lines   = StringUtil.split(content, "\n", false);
      String[] lines = content.split("\n");
      List<String[]> result = new ArrayList<>();
      for (String line : lines) {
        //String line  = (String) lines.get(i);
        String tline = line.trim();
        if (tline.length() == 0) {
          continue;
        }
        if (tline.startsWith("!")) {
          continue;
        }
        String[] words = new String[indices.length];
        for (int idx = 0; idx < indices.length; idx++) {
          if (indices[idx] >= tline.length()) {
            continue;
          }
          if (indices[idx] + lengths[idx] > tline.length()) {
            words[idx] = line.substring(indices[idx]);
          } else {
            words[idx] = line.substring(indices[idx],
                    indices[idx] + lengths[idx]);
          }
          //if (trimWords) {
          words[idx] = words[idx].trim();
          //}
        }
        result.add(words);
      }
      for (String[] aResult : result) {
        GempakParameter p = makeParameter(aResult);
        if (p != null) {
          if (p.getName().contains("(")) {
            templateParamMap.put(p.getName(), p);
          } else {
            paramMap.put(p.getName(), p);
          }
        }
      }
    }

  }

Add parameters from the table

@param tbl table location
@throws IOException problem reading table.


private GempakParameter makeParameter(String[] words) {
    int num = 0;
    String description;
    if (words[0] != null) {
      num = (int) Double.parseDouble(words[0]);
    }
    if ((words[3] == null) || words[3].equals("")) {  // no param name
      return null;
    }
    String name = words[3];
    if (name.contains("-")) {
      int first = name.indexOf("-");
      int last = name.lastIndexOf("-");
      StringBuilder buf = new StringBuilder(name.substring(0, first));
      buf.append("(");
      for (int i = first; i <= last; i++) {
        buf.append("\\d");
      }
      buf.append(")");
      buf.append(name.substring(last + 1));
      name = buf.toString();
    }

    if ((words[1] == null) || words[1].equals("")) {
      description = words[3];
    } else {
      description = words[1];
    }
    String unit = words[2];
    if (unit != null) {
      unit = unit.replaceAll("\\*\\*", "");
      if (unit.equals("-")) {
        unit = "";
      }
    }
    int decimalScale;
    try {
      decimalScale = Integer.parseInt(words[4].trim());
    } catch (NumberFormatException ne) {
      decimalScale = 0;
    }

    return new GempakParameter(num, name, description, unit,
            decimalScale);
  }

private
GempakParameter
makeParameter
(
String
[
]
words
)
{
int
num
=
0
;
String
description
;
if
(
words
[
0
]
!=
)
{
num
=
(
int
)
Double
.
parseDouble
(
words
[
0
]
)
;
}
if
(
(
words
[
3
]
==
)
||
words
[
3
]
.
equals
(
""
)
)
{
// no param name
return
;
}
String
name
=
words
[
3
]
;
if
(
name
.
contains
(
"-"
)
)
{
int
first
=
name
.
indexOf
(
"-"
)
;
int
last
=
name
.
lastIndexOf
(
"-"
)
;
StringBuilder
buf
=
new
StringBuilder
(
name
.
substring
(
0
,
first
)
)
;
buf
.
append
(
"("
)
;
for
(
int
i
=
first
;
i
<=
last
;
i
++
)
{
buf
.
append
(
"\\d"
)
;
}
buf
.
append
(
")"
)
;
buf
.
append
(
name
.
substring
(
last
+
1
)
)
;
name
=
buf
.
toString
(
)
;
}
if
(
(
words
[
1
]
==
)
||
words
[
1
]
.
equals
(
""
)
)
{
description
=
words
[
3
]
;
}
else
{
description
=
words
[
1
]
;
}
String
unit
=
words
[
2
]
;
if
(
unit
!=
)
{
unit
=
unit
.
replaceAll
(
"\\*\\*"
,
""
)
;
if
(
unit
.
equals
(
"-"
)
)
{
unit
=
""
;
}
}
int
decimalScale
;
try
{
decimalScale
=
Integer
.
parseInt
(
words
[
4
]
.
trim
(
)
)
;
}
catch
(
NumberFormatException
ne
)
{
decimalScale
=
0
;
}
return
new
GempakParameter
(
num
,
name
,
description
,
unit
,
decimalScale
)
;
}

Make a parameter from the tokens

@param words the tokens
@return a grid parameter (may be null)


public GempakParameter getParameter(String name) {
    GempakParameter param = paramMap.get(name);
    if (param == null) {  // try the regex list
      Set<String> keys = templateParamMap.keySet();
      if (!keys.isEmpty()) {
        for (String key : keys) {
          Pattern p = Pattern.compile(key);
          Matcher m = p.matcher(name);
          if (m.matches()) {
            //System.out.println("found match " + key + " for " + name);
            String value = m.group(1);
            GempakParameter match = templateParamMap.get(key);
            param = new GempakParameter(match.getNumber(), name,
                    match.getDescription() + " (" + value
                            + " hour)", match.getUnit(),
                    match.getDecimalScale());
            paramMap.put(name, param);
            break;
          }
        }
      }
    }
    return param;
  }

Get the parameter for the given name

@param name name of the parameter (eg:, TMPK);
@return corresponding parameter or null if not found in table


private String readContents(InputStream is) throws IOException {
    return new String(readBytes(is), CDM.utf8Charset);
  }

private String readContents ( InputStream is ) throws IOException { return new String ( readBytes ( is ) , CDM . utf8Charset ) ; }

Read in the bytes from the given InputStream
and construct and return a String.
Closes the InputStream argument.

@param is InputStream to read from
@return contents as a String
@throws IOException problem reading contents

Read in the bytes from the given InputStream and construct and return a String . Closes the InputStream argument .


private byte[] readBytes(InputStream is) throws IOException {
    int totalRead = 0;
    byte[] content = new byte[1000000];
    while (true) {
      int howMany = is.read(content, totalRead,
              content.length - totalRead);
      if (howMany < 0) {
        break;
      }
      if (howMany == 0) {
        continue;
      }
      totalRead += howMany;
      if (totalRead >= content.length) {
        byte[] tmp = content;
        int newLength = ((content.length < 25000000)
                ? content.length * 2
                : content.length + 5000000);
        content = new byte[newLength];
        System.arraycopy(tmp, 0, content, 0, totalRead);
      }
    }
    is.close();
    byte[] results = new byte[totalRead];
    System.arraycopy(content, 0, results, 0, totalRead);
    return results;
  }

private byte [ ] readBytes ( InputStream is ) throws IOException { int totalRead = 0 ; byte [ ] content = new byte [ 1000000 ] ; while ( true ) { int howMany = is . read ( content , totalRead , content . length - totalRead ) ; if ( howMany < 0 ) { break ; } if ( howMany == 0 ) { continue ; } totalRead += howMany ; if ( totalRead >= content . length ) { byte [ ] tmp = content ; int newLength = ( ( content . length < 25000000 ) ? content . length * 2 : content . length + 5000000 ) ; content = new byte [ newLength ] ; System . arraycopy ( tmp , 0 , content , 0 , totalRead ) ; } } is . close ( ) ; byte [ ] results = new byte [ totalRead ] ; System . arraycopy ( content , 0 , results , 0 , totalRead ) ; return results ; }

Read the bytes in the given input stream.

@param is The input stream
@return The bytes
@throws IOException On badness

Read the bytes in the given input stream .


public String replaceFileTemplate(String filespec, int ensIndex) {
        return filespec.replaceAll(ENS_TEMPLATE_ID,
                                   getEnsembleNames().get(ensIndex));
    }

public String replaceFileTemplate ( String filespec , int ensIndex ) { return filespec . replaceAll ( ENS_TEMPLATE_ID , getEnsembleNames ( ) . get ( ensIndex ) ) ; }

Replace the ensemble template parameter in a filename

@param filespec  the file template
@param ensIndex the ensemble index

@return  the filled in template


public void setStationInfo(String stnIdVName, String stnDescVName) {
    this.stnIdVName = stnIdVName;
    this.stnDescVName = stnDescVName;

    Variable stationVar = ncfile.findVariable(stnIdVName);
    stationIdType = stationVar.getDataType();
  }

public void setStationInfo ( String stnIdVName , String stnDescVName ) { this . stnIdVName = stnIdVName ; this . stnDescVName = stnDescVName ; Variable stationVar = ncfile . findVariable ( stnIdVName ) ; stationIdType = stationVar . getDataType ( ) ; }

Set extra information used by station obs datasets.

@param stnIdVName   the obs variable that is used to find the station in the stnHash; may be type  int or a String (char).
@param stnDescVName optional station var containing station description

Set extra information used by station obs datasets .


protected boolean accept(StringBuffer buff){
     if (!validate(buff)) {
       validate(buff);
       return false;
     }
     if (acceptIfDifferent( getEditValue())) {
      setStoreValue( validValue);
      sendEvent();
     }
     return true;
   }

protected boolean accept ( StringBuffer buff ) { if ( ! validate ( buff ) ) { validate ( buff ) ; return false ; } if ( acceptIfDifferent ( getEditValue ( ) ) ) { setStoreValue ( validValue ) ; sendEvent ( ) ; } return true ; }

Get current value from editComponent, save to store.
If different from old value, fire PropertyChangeEvent.
Return false if invalid format, add error message to buff if not null.

Get current value from editComponent save to store . If different from old value fire PropertyChangeEvent . Return false if invalid format add error message to buff if not null .


static private void showFormatInfo( JFormattedTextField tf) {
      JFormattedTextField.AbstractFormatter ff = tf.getFormatter();
      System.out.println("AbstractFormatter  " +  ff.getClass().getName());
      if (ff instanceof NumberFormatter) {
        NumberFormatter nf = (NumberFormatter) ff;
        Format f = nf.getFormat();
        System.out.println(" Format  = " + f.getClass().getName());
        if (f instanceof NumberFormat) {
          NumberFormat nfat = (NumberFormat) f;
          System.out.println(" getMinimumIntegerDigits=" +
                             nfat.getMinimumIntegerDigits());
          System.out.println(" getMaximumIntegerDigits=" +
                             nfat.getMaximumIntegerDigits());
          System.out.println(" getMinimumFractionDigits=" +
                             nfat.getMinimumFractionDigits());
          System.out.println(" getMaximumFractionDigits=" +
                             nfat.getMaximumFractionDigits());
        }
        if (f instanceof DecimalFormat) {
          DecimalFormat df = (DecimalFormat) f;
          System.out.println(" Pattern  = " + df.toPattern());
        }
      }
    }

static
private
void
showFormatInfo
(
JFormattedTextField
tf
)
{
JFormattedTextField
.
AbstractFormatter
ff
=
tf
.
getFormatter
(
)
;
System
.
out
.
println
(
"AbstractFormatter  "
+
ff
.
getClass
(
)
.
getName
(
)
)
;
if
(
ff
instanceof
NumberFormatter
)
{
NumberFormatter
nf
=
(
NumberFormatter
)
ff
;
Format
f
=
nf
.
getFormat
(
)
;
System
.
out
.
println
(
" Format  = "
+
f
.
getClass
(
)
.
getName
(
)
)
;
if
(
f
instanceof
NumberFormat
)
{
NumberFormat
nfat
=
(
NumberFormat
)
f
;
System
.
out
.
println
(
" getMinimumIntegerDigits="
+
nfat
.
getMinimumIntegerDigits
(
)
)
;
System
.
out
.
println
(
" getMaximumIntegerDigits="
+
nfat
.
getMaximumIntegerDigits
(
)
)
;
System
.
out
.
println
(
" getMinimumFractionDigits="
+
nfat
.
getMinimumFractionDigits
(
)
)
;
System
.
out
.
println
(
" getMaximumFractionDigits="
+
nfat
.
getMaximumFractionDigits
(
)
)
;
}
if
(
f
instanceof
DecimalFormat
)
{
DecimalFormat
df
=
(
DecimalFormat
)
f
;
System
.
out
.
println
(
" Pattern  = "
+
df
.
toPattern
(
)
)
;
}
}
}

An integer input field with an associated CDM.UNITS label.

static public class IntUnits extends Int implements UnitsField {
private String units;
IntUnits(String name, String label, String units, int defValue, PersistenceManager storeData) {
super(name, label, defValue, storeData);
this.units = units;
}
public String getUnits() { return units; }
}

A boolean input box that is used to enable/disable another field.

static public class BooleanEnabler extends YesNo {
private JRadioButton enabler;
private Field enabledField;

BooleanEnabler(String fldName, boolean initValue, Field enField, PersistenceManager storeData) {
super( fldName, "", initValue, storeData);
this.enabledField = enField;

enabler = new JRadioButton();
enabler.setSelected( ((Boolean)valueObj).booleanValue());
editComp = (JComponent) enabler;

enabledField.setEnabled(initValue);
enabler.addItemListener( new ItemListener() {
public void itemStateChanged(ItemEvent e) {
boolean isOn = (e.getStateChange() == ItemEvent.SELECTED);
enabledField.setEnabled(isOn);
}
});
}

protected void setValue(Object newValue) {
boolean bvalue = ((Boolean)newValue).booleanValue();
enabler.setSelected(bvalue);
enabledField.setEnabled(bvalue);
_setValue( newValue);
}

public boolean isSelected() { return enabler.isSelected(); }
public void setSelected(boolean v) { enabler.setSelected(v); }

Field getEnabledField() { return enabledField; }
}

An integer input field with an associated CDM . UNITS label .


@Nullable
  public byte[] getBitmap(RandomAccessFile raf) throws IOException {
    // no bitMap
    if (bitMapIndicator == 255)
      return null;

    // LOOK: bitMapIndicator=254 == previously defined bitmap
    if (bitMapIndicator == 254)
      logger.debug("HEY bitMapIndicator=254 previously defined bitmap");

    if (bitMapIndicator != 0) {
      throw new UnsupportedOperationException("Grib2 Bit map section pre-defined (provided by center) = " + bitMapIndicator);
    }

    raf.seek(startingPosition);
    int length = GribNumbers.int4(raf);
    raf.skipBytes(2);

    byte[] data = new byte[length - 6];
    raf.readFully(data);

    return data;
  }

Read the bit map array.

@param raf read from here
@return bit map as array of byte values, or null if none.
@throws java.io.IOException on read error


public void setNetcdfFile(NetcdfFile ncf) {
        this.ncfile = ncf;
        this.filename = ncf.getLocation();

        final GetDataRunnable runner = new GetDataRunnable() {
            public void run(Object o) throws IOException {
                final StringWriter sw = new StringWriter(50000);
                NCdumpW.print(ncfile, command, sw, task);
                result = sw.toString();
            }
        };
        task = new GetDataTask(runner, filename, null);
        stopButton.startProgressMonitorTask(task);
    }

public void setNetcdfFile ( NetcdfFile ncf ) { this . ncfile = ncf ; this . filename = ncf . getLocation ( ) ; final GetDataRunnable runner = new GetDataRunnable ( ) { public void run ( Object o ) throws IOException { final StringWriter sw = new StringWriter ( 50000 ) ; NCdumpW . print ( ncfile , command , sw , task ) ; result = sw . toString ( ) ; } } ; task = new GetDataTask ( runner , filename , null ) ; stopButton . startProgressMonitorTask ( task ) ; }


static public void setDebugFlags(ucar.nc2.util.DebugFlags debugFlag)
  {
    debugCE = debugFlag.isSet("DODS/constraintExpression");
    debugServerCall = debugFlag.isSet("DODS/serverCall");
    debugOpenResult = debugFlag.isSet("DODS/debugOpenResult");
    debugDataResult = debugFlag.isSet("DODS/debugDataResult");
    debugCharArray = debugFlag.isSet("DODS/charArray");
    debugConstruct = debugFlag.isSet("DODS/constructNetcdf");
    debugPreload = debugFlag.isSet("DODS/preload");
    debugTime = debugFlag.isSet("DODS/timeCalls");
    showNCfile = debugFlag.isSet("DODS/showNCfile");
    debugAttributes = debugFlag.isSet("DODS/attributes");
    debugCached = debugFlag.isSet("DODS/cache");
  }

static public void setDebugFlags ( ucar . nc2 . util . DebugFlags debugFlag ) { debugCE = debugFlag . isSet ( "DODS/constraintExpression" ) ; debugServerCall = debugFlag . isSet ( "DODS/serverCall" ) ; debugOpenResult = debugFlag . isSet ( "DODS/debugOpenResult" ) ; debugDataResult = debugFlag . isSet ( "DODS/debugDataResult" ) ; debugCharArray = debugFlag . isSet ( "DODS/charArray" ) ; debugConstruct = debugFlag . isSet ( "DODS/constructNetcdf" ) ; debugPreload = debugFlag . isSet ( "DODS/preload" ) ; debugTime = debugFlag . isSet ( "DODS/timeCalls" ) ; showNCfile = debugFlag . isSet ( "DODS/showNCfile" ) ; debugAttributes = debugFlag . isSet ( "DODS/attributes" ) ; debugCached = debugFlag . isSet ( "DODS/cache" ) ; }

Debugging flags. This is a way to decouple setting flags from particular implementations.

@param debugFlag set of debug flags.

Debugging flags . This is a way to decouple setting flags from particular implementations .


NamePieces parseName(String name) {
    NamePieces pieces = new NamePieces();
    int dotpos = name.lastIndexOf('.');
    int slashpos = name.lastIndexOf('/');
    if (slashpos < 0 && dotpos < 0) {
      pieces.name = name;
    } else if (slashpos >= 0 && dotpos < 0) {
      pieces.prefix = name.substring(0, slashpos);
      pieces.name = name.substring(slashpos + 1, name.length());
    } else if (slashpos < 0 && dotpos >= 0) {
      pieces.var = name.substring(0, dotpos);
      pieces.name = name.substring(dotpos + 1, name.length());
    } else {//slashpos >= 0 && dotpos >= 0)
      if (slashpos > dotpos) {
        pieces.prefix = name.substring(0, slashpos);
        pieces.name = name.substring(slashpos + 1, name.length());
      } else {//slashpos < dotpos)
        pieces.prefix = name.substring(0, slashpos);
        pieces.var = name.substring(slashpos + 1, dotpos);
        pieces.name = name.substring(dotpos + 1, name.length());
      }
    }
    // fixup
    if (pieces.prefix != null && pieces.prefix.length() == 0) pieces.prefix = null;
    if (pieces.var != null && pieces.var.length() == 0) pieces.var = null;
    if (pieces.name.length() == 0) pieces.name = null;
    return pieces;
  }

NamePieces
parseName
(
String
name
)
{
NamePieces
pieces
=
new
NamePieces
(
)
;
int
dotpos
=
name
.
lastIndexOf
(
'
'
)
;
int
slashpos
=
name
.
lastIndexOf
(
'
'
)
;
if
(
slashpos
<
0
&&
dotpos
<
0
)
{
pieces
.
name
=
name
;
}
else
if
(
slashpos
>=
0
&&
dotpos
<
0
)
{
pieces
.
prefix
=
name
.
substring
(
0
,
slashpos
)
;
pieces
.
name
=
name
.
substring
(
slashpos
+
1
,
name
.
length
(
)
)
;
}
else
if
(
slashpos
<
0
&&
dotpos
>=
0
)
{
pieces
.
var
=
name
.
substring
(
0
,
dotpos
)
;
pieces
.
name
=
name
.
substring
(
dotpos
+
1
,
name
.
length
(
)
)
;
}
else
{
//slashpos >= 0 && dotpos >= 0)
if
(
slashpos
>
dotpos
)
{
pieces
.
prefix
=
name
.
substring
(
0
,
slashpos
)
;
pieces
.
name
=
name
.
substring
(
slashpos
+
1
,
name
.
length
(
)
)
;
}
else
{
//slashpos < dotpos)
pieces
.
prefix
=
name
.
substring
(
0
,
slashpos
)
;
pieces
.
var
=
name
.
substring
(
slashpos
+
1
,
dotpos
)
;
pieces
.
name
=
name
.
substring
(
dotpos
+
1
,
name
.
length
(
)
)
;
}
}
// fixup
if
(
pieces
.
prefix
!=
&&
pieces
.
prefix
.
length
(
)
==
0
)
pieces
.
prefix
=
;
if
(
pieces
.
var
!=
&&
pieces
.
var
.
length
(
)
==
0
)
pieces
.
var
=
;
if
(
pieces
.
name
.
length
(
)
==
0
)
pieces
.
name
=
;
return
pieces
;
}


private boolean isGroup(DStructure dstruct) {
    BaseType parent = (BaseType) dstruct.getParent();
    if (parent == null) return true;
    if (parent instanceof DStructure)
      return isGroup((DStructure) parent);
    return true;
  }

private boolean isGroup ( DStructure dstruct ) { BaseType parent = ( BaseType ) dstruct . getParent ( ) ; if ( parent == null ) return true ; if ( parent instanceof DStructure ) return isGroup ( ( DStructure ) parent ) ; return true ; }

make a structure into a group if its scalar and all parents are groups


Dimension getNetcdfStrlenDim(DODSVariable v) {
    AttributeTable table = das.getAttributeTableN(v.getFullName()); // LOOK this probably doesnt work for nested variables
    if (table == null) return null;

    opendap.dap.Attribute dodsAtt = table.getAttribute("DODS");
    if (dodsAtt == null) return null;

    AttributeTable dodsTable = dodsAtt.getContainerN();
    if (dodsTable == null) return null;

    opendap.dap.Attribute att = dodsTable.getAttribute("strlen");
    if (att == null) return null;
    String strlen = att.getValueAtN(0);

    opendap.dap.Attribute att2 = dodsTable.getAttribute("dimName");
    String dimName = (att2 == null) ? null : att2.getValueAtN(0);
    if (debugCharArray) System.out.println(v.getFullName() + " has strlen= " + strlen + " dimName= " + dimName);

    int dimLength;
    try {
      dimLength = Integer.parseInt(strlen);
    } catch (NumberFormatException e) {
      logger.warn("DODSNetcdfFile " + location + " var = " + v.getFullName() + " error on strlen attribute = " + strlen);
      return null;
    }

    if (dimLength <= 0) return null; // LOOK what about unlimited ??
    return new Dimension(dimName, dimLength, dimName != null);
  }

Checks to see if this is netcdf char array.

@param v must be type STRING
@return string length dimension, else null

Checks to see if this is netcdf char array .


Dimension getSharedDimension(Group group, Dimension d) {
    if (d.getShortName() == null) return d;

    if (group == null) group = rootGroup;
    for (Dimension sd : group.getDimensions()) {
      if (sd.getShortName().equals(d.getShortName()) && sd.getLength() == d.getLength())
        return sd;
    }
    d.setShared(true);
    group.addDimension(d);
    return d;
  }

Dimension getSharedDimension ( Group group , Dimension d ) { if ( d . getShortName ( ) == null ) return d ; if ( group == null ) group = rootGroup ; for ( Dimension sd : group . getDimensions ( ) ) { if ( sd . getShortName ( ) . equals ( d . getShortName ( ) ) && sd . getLength ( ) == d . getLength ( ) ) return sd ; } d . setShared ( true ) ; group . addDimension ( d ) ; return d ; }

If an equivilent shared dimension already exists, use it, else add d to shared dimensions.
Equivilent is same name and length.

@param group from this group, if null, use rootGroup
@param d     find equivilent shared dimension to this one.
@return equivilent shared dimension or d.

If an equivilent shared dimension already exists use it else add d to shared dimensions . Equivilent is same name and length .


List<Dimension> constructDimensions(Group group, opendap.dap.DArray dodsArray) {
    if (group == null) group = rootGroup;

    List<Dimension> dims = new ArrayList<Dimension>();
    Enumeration enumerate = dodsArray.getDimensions();
    while (enumerate.hasMoreElements()) {
      opendap.dap.DArrayDimension dad = (opendap.dap.DArrayDimension) enumerate.nextElement();
      String name = dad.getEncodedName();
      if (name != null)
        name = StringUtil2.unescape(name);

      Dimension myd;

      if (name == null) { // if no name, make an anonymous dimension
        myd = new Dimension(null, dad.getSize(), false);

      } else { // see if shared
        if (RC.getUseGroups()) {
          if (name.indexOf('/') >= 0) {// place dimension in proper group
            group = group.makeRelativeGroup(this, name, true);
            // change our name
            name = name.substring(name.lastIndexOf('/') + 1);
          }
        }
        myd = group.findDimension(name);
        if (myd == null) { // add as shared
          myd = new Dimension(name, dad.getSize());
          group.addDimension(myd);
        } else if (myd.getLength() != dad.getSize()) { // make a non-shared dimension
          myd = new Dimension(name, dad.getSize(), false);
        } // else use existing, shared dimension
      }
      dims.add(myd); // add it to the list
    }

    return dims;
  }


static public boolean isUnsigned(opendap.dap.BaseType dtype)
  {
    return (dtype instanceof DByte) ||
            (dtype instanceof DUInt16) ||
            (dtype instanceof DUInt32);
  }

static public boolean isUnsigned ( opendap . dap . BaseType dtype ) { return ( dtype instanceof DByte ) || ( dtype instanceof DUInt16 ) || ( dtype instanceof DUInt32 ) ; }

Get whether this is an unsigned type.

@param dtype DODS BaseType.
@return true if unsigned


DataDDS readDataDDSfromServer(String CE) throws IOException, opendap.dap.DAP2Exception
  {
    if (debugServerCall) System.out.println("DODSNetcdfFile.readDataDDSfromServer = <" + CE + ">");

    long start = 0;
    if (debugTime) start = System.currentTimeMillis();

    if (!CE.startsWith("?"))
      CE = "?" + CE;
    DataDDS data;
    synchronized (this) {
      data = dodsConnection.getData(CE, null);
    }
    if (debugTime)
      System.out.println("DODSNetcdfFile.readDataDDSfromServer took = " + (System.currentTimeMillis() - start) / 1000.0);

    if (debugDataResult) {
      System.out.println(" dataDDS return:");
      data.print(System.out);
    }

    return data;
  }

This does the actual connection to the opendap server and reading of the data.
All data calls go through here so we can add debugging.

@param CE constraint expression; use empty string if none
@return DataDDS
@throws java.io.IOException                on io error
@throws opendap.dap.parsers.ParseException
if error parsing return
@throws opendap.dap.DAP2Exception          if you have otherwise been bad

This does the actual connection to the opendap server and reading of the data . All data calls go through here so we can add debugging .


public static ImageIcon getIcon( String fullIconName, boolean errMsg) {
    ImageIcon icon = null;

    java.net.URL iconR = cl.getResource(fullIconName);
    if (debugIcon) {
      System.out.println("classLoader "+cl.getClassLoader());
      System.out.println("  Resource.getIcon on "+fullIconName+" = "+iconR);
    }

    if (iconR != null)
      icon = new ImageIcon(iconR);

    if ((icon == null) && errMsg) System.out.println("  ERROR: Resource.getIcon failed on "+fullIconName);
    else if (debugIcon) System.out.println("  Resource.getIcon ok on "+fullIconName);

    return icon;
  }

public
static
ImageIcon
getIcon
(
String
fullIconName
,
boolean
errMsg
)
{
ImageIcon
icon
=
;
java
.
net
.
URL
iconR
=
cl
.
getResource
(
fullIconName
)
;
if
(
debugIcon
)
{
System
.
out
.
println
(
"classLoader "
+
cl
.
getClassLoader
(
)
)
;
System
.
out
.
println
(
"  Resource.getIcon on "
+
fullIconName
+
" = "
+
iconR
)
;
}
if
(
iconR
!=
)
icon
=
new
ImageIcon
(
iconR
)
;
if
(
(
icon
==
)
&&
errMsg
)
System
.
out
.
println
(
"  ERROR: Resource.getIcon failed on "
+
fullIconName
)
;
else
if
(
debugIcon
)
System
.
out
.
println
(
"  Resource.getIcon ok on "
+
fullIconName
)
;
return
icon
;
}

Get a gif file, make it into an ImageIcon.
@param fullIconName full path name of gif file (use forward slashes!)
@param errMsg print err message on failure
@return ImageIcon or null on failure

Get a gif file make it into an ImageIcon .


public static Image getImage( String fullImageName) {
    Image image = null;
    java.net.URL url = cl.getResource(fullImageName);
    if (url != null)
      image = Toolkit.getDefaultToolkit().createImage(url);
    if (image == null) System.out.println("  ERROR: Resource.getImageResource failed on "+fullImageName);
    return image;
  }

Get a gif file, make it into an Image.
@param fullImageName full path name of gif file (use forward slashes!)
@return Image or null on failure


public static Cursor makeCursor( String name) {
    Image image = getImage(name);
    if (null == image)
      return null;

    Cursor cursor;
    try {
      Toolkit tk = Toolkit.getDefaultToolkit();
      if (debug) {
        ImageObserver obs = new ImageObserver() {
          public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) {
            return true;
          }
        };
        System.out.println(" bestCursorSize = "+ tk.getBestCursorSize(image.getWidth(obs), image.getHeight(obs)));
        System.out.println(" getMaximumCursorColors = "+ tk.getMaximumCursorColors());
      }
      cursor = tk.createCustomCursor(image, new Point(17,17), name);
    } catch (IndexOutOfBoundsException e) {
      System.out.println("NavigatedPanel createCustomCursor failed " + e);
      return null;
    }
    return cursor;
  }

Get a gif file, make it into a Cursor.
@param name full path name of gif file (use forward slashes!)
@return Cursor or null on failure


static public Object readDataFill(RandomAccessFile raf, Layout index, DataType dataType, Object fillValue,
                                    int byteOrder) throws java.io.IOException {
    Object arr = (fillValue == null) ? makePrimitiveArray((int) index.getTotalNelems(), dataType) :
            makePrimitiveArray((int) index.getTotalNelems(), dataType, fillValue);
    return readData(raf, index, dataType, arr, byteOrder, true);
  }

static public Object readDataFill ( RandomAccessFile raf , Layout index , DataType dataType , Object fillValue , int byteOrder ) throws java . io . IOException { Object arr = ( fillValue == null ) ? makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType ) : makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType , fillValue ) ; return readData ( raf , index , dataType , arr , byteOrder , true ) ; }

Read data subset from RandomAccessFile, create primitive array of size Layout.getTotalNelems.
Reading is controlled by the Layout object.

@param raf       read from here.
@param index     handles skipping around in the file.
@param dataType  dataType of the variable
@param fillValue must be Number if dataType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
@param byteOrder if equal to RandomAccessFile.ORDER_XXXX, set the byte order just before reading
@return primitive array with data read in
@throws java.io.IOException on read error

Read data subset from RandomAccessFile create primitive array of size Layout . getTotalNelems . Reading is controlled by the Layout object .


static public Object readDataFill(PositioningDataInputStream is, Layout index, DataType dataType, Object fillValue) throws java.io.IOException {
    Object arr = (fillValue == null) ? makePrimitiveArray((int) index.getTotalNelems(), dataType) :
            makePrimitiveArray((int) index.getTotalNelems(), dataType, fillValue);
    return readData(is, index, dataType, arr);
  }

static public Object readDataFill ( PositioningDataInputStream is , Layout index , DataType dataType , Object fillValue ) throws java . io . IOException { Object arr = ( fillValue == null ) ? makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType ) : makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType , fillValue ) ; return readData ( is , index , dataType , arr ) ; }

Read data subset from PositioningDataInputStream, create primitive array of size Layout.getTotalNelems.
Reading is controlled by the Layout object.

@param is        read from here.
@param index     handles skipping around in the file.
@param dataType  dataType of the variable
@param fillValue must be Number if dataType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
@return primitive array with data read in
@throws java.io.IOException on read error

Read data subset from PositioningDataInputStream create primitive array of size Layout . getTotalNelems . Reading is controlled by the Layout object .


static public Object readDataFill(LayoutBB layout, DataType dataType, Object fillValue) throws java.io.IOException {
    long size = layout.getTotalNelems();
    if (dataType == DataType.STRUCTURE) size *= layout.getElemSize();
    Object arr = (fillValue == null) ? makePrimitiveArray((int) size, dataType) :
            makePrimitiveArray((int) size, dataType, fillValue);
    return readData(layout, dataType, arr);
  }

static public Object readDataFill ( LayoutBB layout , DataType dataType , Object fillValue ) throws java . io . IOException { long size = layout . getTotalNelems ( ) ; if ( dataType == DataType . STRUCTURE ) size *= layout . getElemSize ( ) ; Object arr = ( fillValue == null ) ? makePrimitiveArray ( ( int ) size , dataType ) : makePrimitiveArray ( ( int ) size , dataType , fillValue ) ; return readData ( layout , dataType , arr ) ; }

Read data subset from ByteBuffer, create primitive array of size Layout.getTotalNelems.
Reading is controlled by the Layout object.

@param layout    handles skipping around in the file, provide ByteBuffer to read from
@param dataType  dataType of the variable
@param fillValue must be Number if dataType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
@return primitive array with data read in
@throws java.io.IOException on read error

Read data subset from ByteBuffer create primitive array of size Layout . getTotalNelems . Reading is controlled by the Layout object .


static public Object makePrimitiveArray(int size, DataType dataType) {
    Object arr = null;

    if ((dataType.getPrimitiveClassType() == byte.class) || (dataType == DataType.CHAR) || (dataType == DataType.OPAQUE) || (dataType == DataType.STRUCTURE)) {
      arr = new byte[size];

    } else if (dataType.getPrimitiveClassType() == short.class) {
      arr = new short[size];

    } else if (dataType.getPrimitiveClassType() == int.class) {
      arr = new int[size];

    } else if (dataType.getPrimitiveClassType() == long.class) {
      arr = new long[size];

    } else if (dataType == DataType.FLOAT) {
      arr = new float[size];

    } else if (dataType == DataType.DOUBLE) {
      arr = new double[size];

   } else if (dataType == DataType.STRING) {
      arr = new String[size];
    }

    return arr;
  }

static public Object makePrimitiveArray ( int size , DataType dataType ) { Object arr = null ; if ( ( dataType . getPrimitiveClassType ( ) == byte . class ) || ( dataType == DataType . CHAR ) || ( dataType == DataType . OPAQUE ) || ( dataType == DataType . STRUCTURE ) ) { arr = new byte [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { arr = new short [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { arr = new int [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { arr = new long [ size ] ; } else if ( dataType == DataType . FLOAT ) { arr = new float [ size ] ; } else if ( dataType == DataType . DOUBLE ) { arr = new double [ size ] ; } else if ( dataType == DataType . STRING ) { arr = new String [ size ] ; } return arr ; }

Create 1D primitive array of the given size and type

@param size     the size of the array to create
@param dataType dataType of the variable
@return primitive array with data read in


static public char[] convertByteToCharUTF(byte[] byteArray) {
    Charset c = CDM.utf8Charset;
    CharBuffer output = c.decode(ByteBuffer.wrap(byteArray));
    return output.array();
  }

static public char [ ] convertByteToCharUTF ( byte [ ] byteArray ) { Charset c = CDM . utf8Charset ; CharBuffer output = c . decode ( ByteBuffer . wrap ( byteArray ) ) ; return output . array ( ) ; }

convert byte array to char array, assuming UTF-8 encoding

convert byte array to char array assuming UTF - 8 encoding


static public byte[] convertCharToByteUTF(char[] from) {
    Charset c = CDM.utf8Charset;
    ByteBuffer output = c.encode(CharBuffer.wrap(from));
    return output.array();
  }

static public byte [ ] convertCharToByteUTF ( char [ ] from ) { Charset c = CDM . utf8Charset ; ByteBuffer output = c . encode ( CharBuffer . wrap ( from ) ) ; return output . array ( ) ; }

convert char array to byte array, assuming UTF-8 encoding

convert char array to byte array assuming UTF - 8 encoding


static public char[] convertByteToChar(byte[] byteArray) {
    int size = byteArray.length;
    char[] cbuff = new char[size];
    for (int i = 0; i < size; i++)
      cbuff[i] = (char) DataType.unsignedByteToShort(byteArray[i]); // NOTE: not Unicode !
    return cbuff;
  }

  // convert char array to byte array

  static public byte[] convertCharToByte(char[] from) {
    byte[] to = null;
    if (from != null) {
      int size = from.length;
      to = new byte[size];
      for (int i = 0; i < size; i++)
        to[i] = (byte) from[i]; // LOOK wrong, convert back to unsigned byte ???
    }
    return to;
  }


static public ucar.ma2.Array readSection(ParsedSectionSpec cer) throws IOException, InvalidRangeException {
    Variable inner = null;
    List<Range> totalRanges = new ArrayList<>();
    ParsedSectionSpec current = cer;
    while (current != null) {
      totalRanges.addAll(current.section.getRanges());
      inner = current.v;
      current = current.child;
    }
    assert inner != null;

    Section total = new Section(totalRanges);
    Array result = Array.factory(inner.getDataType(), total.getShape());

    // must be a Structure
    Structure outer = (Structure) cer.v;
    Structure outerSubset = outer.select(cer.child.v.getShortName()); // allows IOSPs to optimize for  this case
    ArrayStructure outerData = (ArrayStructure) outerSubset.read(cer.section);
    extractSection(cer.child, outerData, result.getIndexIterator());
    return result;
  }


static private ArrayStructure sectionArrayStructure(ParsedSectionSpec child, ArrayStructure innerData, StructureMembers.Member m) throws IOException, InvalidRangeException {
    StructureMembers membersw = new StructureMembers(m.getStructureMembers()); // no data arrays get propagated
    ArrayStructureW result = new ArrayStructureW(membersw, child.section.getShape());

    int count = 0;
    Section.Iterator iter = child.section.getIterator(child.v.getShape());
    while (iter.hasNext()) {
      int recno = iter.next(null);
      StructureData sd = innerData.getStructureData(recno);
      result.setStructureData(sd, count++);
    }

    return result;
  }

static
private
ArrayStructure
sectionArrayStructure
(
ParsedSectionSpec
child
,
ArrayStructure
innerData
,
StructureMembers
.
Member
m
)
throws
IOException
,
InvalidRangeException
{
StructureMembers
membersw
=
new
StructureMembers
(
m
.
getStructureMembers
(
)
)
;
// no data arrays get propagated
ArrayStructureW
result
=
new
ArrayStructureW
(
membersw
,
child
.
section
.
getShape
(
)
)
;
int
count
=
0
;
Section
.
Iterator
iter
=
child
.
section
.
getIterator
(
child
.
v
.
getShape
(
)
)
;
while
(
iter
.
hasNext
(
)
)
{
int
recno
=
iter
.
next
(
)
;
StructureData
sd
=
innerData
.
getStructureData
(
recno
)
;
result
.
setStructureData
(
sd
,
count
++
)
;
}
return
result
;
}


public String getScalarString(int recnum, StructureMembers.Member m)
    {
        Array data = m.getDataArray();
        return (String) data.getObject(recnum).toString();
    }

public String getScalarString ( int recnum , StructureMembers . Member m ) { Array data = m . getDataArray ( ) ; return ( String ) data . getObject ( recnum ) . toString ( ) ; }

Get member databuffer of type String or char.

@param recnum get databuffer from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();
@param m      get databuffer from this StructureMembers.Member. Must be of type String or char.
@return scalar String value

Get member databuffer of type String or char .


public StructureData
    getScalarStructure(int index, StructureMembers.Member m)
    {
        if(m.getDataType() != DataType.STRUCTURE)
            throw new ForbiddenConversionException("Atomic field cannot be converted to Structure");
        Array ca = memberArray(index, memberIndex(m));
        if(ca.getDataType() != DataType.STRUCTURE && ca.getDataType() != DataType.SEQUENCE)
            throw new ForbiddenConversionException("Attempt to access non-structure member");
        CDMArrayStructure as = (CDMArrayStructure) ca;
        return as.getStructureData(0);
    }


@Override
    public ucar.ma2.Array
    getArray(int recno, StructureMembers.Member m)
    {
        return (ucar.ma2.Array) memberArray(recno, memberIndex(m));
    }

@ Override public ucar . ma2 . Array getArray ( int recno , StructureMembers . Member m ) { return ( ucar . ma2 . Array ) memberArray ( recno , memberIndex ( m ) ) ; }

Key interface method coming in from StructureDataA.

@param recno The instance # of the array of Structure instances
@param m     The member of interest in the Structure instance
@return The ucar.ma2.Array instance corresponding to the instance.
<p>
Hidden: friend of StructureDataA

Key interface method coming in from StructureDataA .


static StructureMembers
    computemembers(DapVariable var)
    {
        DapStructure ds = (DapStructure)var.getBaseType();
        StructureMembers sm
                = new StructureMembers(ds.getShortName());
        List<DapVariable> fields = ds.getFields();
        for(int i = 0; i < fields.size(); i++) {
            DapVariable field = fields.get(i);
            DapType dt = field.getBaseType();
            DataType cdmtype = CDMTypeFcns.daptype2cdmtype(dt);
            StructureMembers.Member m =
                    sm.addMember(
                            field.getShortName(), "", null,
                            cdmtype,
                            CDMUtil.computeEffectiveShape(field.getDimensions()));
            m.setDataParam(i); // So we can index into various lists
            // recurse if this field is itself a structure
            if(dt.getTypeSort().isStructType()) {
                StructureMembers subsm = computemembers(field);
                m.setStructureMembers(subsm);
            }
        }
        return sm;
    }

Compute the StructureMembers object
from a DapStructure. May need to recurse
if a field is itself a Structure

@param var The DapVariable to use to construct
a StructureMembers object.
@return The StructureMembers object for the given DapStructure

Compute the StructureMembers object from a DapStructure . May need to recurse if a field is itself a Structure


public void addDimensionsToNetcdfFile(NetcdfFile ncfile, Group g) {
    ncfile.addDimension(g, new Dimension(getName(), getNEnsembles(), true));
  }

public void addDimensionsToNetcdfFile ( NetcdfFile ncfile , Group g ) { ncfile . addDimension ( g , new Dimension ( getName ( ) , getNEnsembles ( ) , true ) ) ; }

Add this as a dimension to a netCDF file

@param ncfile the netCDF file
@param g      the group in the file


public static CrawlableDataset createCrawlableDataset( String path, String className, Object configObj )
          throws IOException,
                 ClassNotFoundException, NoSuchMethodException,
                 IllegalAccessException, InvocationTargetException,
                 InstantiationException, IllegalArgumentException, NullPointerException
          // throws CrDsException, IllegalArgumentException
  {
    if ( path == null ) throw new NullPointerException( "Given path must not be null.");
    String tmpClassName = ( className == null
                            ? defaultClassName
                            : className );

    // @todo Remove alias until sure how to handle things like ".scour*" being a regular file.
//    if ( CrawlableDatasetAlias.isAlias( tmpPath) )
//        return new CrawlableDatasetAlias( tmpPath, tmpClassName, configObj );

    // Get the Class instance for desired CrawlableDataset implementation.
    Class crDsClass = Class.forName( tmpClassName );

    // Check that the Class is a CrawlableDataset.
    if ( ! CrawlableDataset.class.isAssignableFrom( crDsClass ) )
    {
      throw new IllegalArgumentException( "Requested class <" + className + "> not an implementation of thredds.crawlabledataset.CrawlableDataset.");
    }

    // Instantiate the desired CrawlableDataset.
    Class [] argTypes = { String.class, Object.class };
    Object [] args = { path, configObj };
    Constructor constructor = crDsClass.getDeclaredConstructor( argTypes );

    try
    {
      return (CrawlableDataset) constructor.newInstance( args );
    }
    catch ( InvocationTargetException e )
    {
      if ( IOException.class.isAssignableFrom( e.getCause().getClass()) )
        throw (IOException) e.getCause();
      else throw e;
    }
  }

Construct a CrawlableDataset for the given path using the
CrawlableDataset implementation indicated by the given class name.

The class given by className is used to instantiate the requested
CrawlableDataset and so must be an implementation of
thredds.crawlabledataset.CrawlableDataset. The given class must also
supply a public constructor with a single String argument. The String
argument is the path for the CrawlableDataset being constructed.

If className is null, thredds.crawlabledataset.CrawlableDatasetFile will
be used.

If the path is an alias containing wildcard characters ("*"),
the class thredds.crawlabledataset.CrawlableDatasetAlias will be used to
expand the alias into a collection of CrawlableDatasets of the type given
by className.

@param path the path of the CrawlableDataset.
@param className the class name of the CrawlableDataset implementation to instantiate.
@param configObj

@return a CrawlableDataset for the given path and of the type given by the class name.

@throws IOException if a CrawlableDataset cannot be created due to IO problems.
@throws ClassNotFoundException if the given CrawlableDataset implementation was not found.
@throws NoSuchMethodException if the given CrawlableDataset implementation does not have a constructor with a single String parameter which is required.
@throws IllegalAccessException if the constructor is inaccessible due to Java language access control.
@throws InvocationTargetException if the constructor throws an exception.
@throws InstantiationException if the given CrawlableDataset implementation is an abstract class.

@throws NullPointerException if the given path is null.
@throws IllegalArgumentException if the given class name is not an implementation of CrawlableDataset.

Construct a CrawlableDataset for the given path using the CrawlableDataset implementation indicated by the given class name .


public static String normalizePath( String path )
  {
    // Replace any occurance of a backslash ("\") with a slash ("/").
    // NOTE: Both String and Pattern escape backslash, so need four backslashes to find one.
    // NOTE: No longer replace multiple backslashes with one slash, which allows for UNC pathnames (Windows LAN addresses).
    //       Was path.replaceAll( "\\\\+", "/");
    String newPath = path.replaceAll( "\\\\", "/");

    // Remove trailing slashes.
    while ( newPath.endsWith( "/") && ! newPath.equals("/") )
      newPath = newPath.substring( 0, newPath.length() - 1 );

    return newPath;
  }

//       Was path.replaceAll( "\\\\+", "/");

Normalize the given path so that it can be used in the creation of a CrawlableDataset.
This method can be used on absolute or relative paths.

Normal uses slashes ("/") as path seperator, not backslashes ("\"), and does
not use trailing slashes. This function allows users to specify Windows
pathnames and UNC pathnames in there normal manner.

@param path the path to be normalized.
@return the normalized path.
@throws NullPointerException if path is null.

Normalize the given path so that it can be used in the creation of a CrawlableDataset . This method can be used on absolute or relative paths .


public void addExplicitDataset(String cacheName, String location, String id, String ncoordS, String coordValueS, String sectionSpec,
                                 ucar.nc2.util.cache.FileFactory reader) {

    Dataset nested = makeDataset(cacheName, location, id, ncoordS, coordValueS, sectionSpec, null, reader);
    explicitDatasets.add(nested);
  }

public void addExplicitDataset ( String cacheName , String location , String id , String ncoordS , String coordValueS , String sectionSpec , ucar . nc2 . util . cache . FileFactory reader ) { Dataset nested = makeDataset ( cacheName , location , id , ncoordS , coordValueS , sectionSpec , null , reader ) ; explicitDatasets . add ( nested ) ; }

Add a nested dataset, specified by an explicit netcdf element.
enhance is handled by the reader, so its always false here.

@param cacheName   a unique name to use for caching
@param location    attribute "location" on the netcdf element
@param id          attribute "id" on the netcdf element
@param ncoordS     attribute "ncoords" on the netcdf element
@param coordValueS attribute "coordValue" on the netcdf element
@param sectionSpec attribute "section" on the netcdf element
@param reader      factory for reading this netcdf dataset

Add a nested dataset specified by an explicit netcdf element . enhance is handled by the reader so its always false here .


public void addDatasetScan(Element crawlableDatasetElement, String dirName, String suffix,
          String regexpPatternString, String dateFormatMark, Set<NetcdfDataset.Enhance> enhanceMode, String subdirs, String olderThan) {

    datasetManager.addDirectoryScan(dirName, suffix, regexpPatternString, subdirs, olderThan, enhanceMode);

    this.dateFormatMark = dateFormatMark;
    if (dateFormatMark != null) {
      isDate = true;
      if (type == Type.joinExisting) type = Type.joinExistingOne; // tricky
      DateExtractor dateExtractor = new DateExtractorFromName(dateFormatMark, true);
      datasetManager.setDateExtractor(dateExtractor);
    }
 }

public
void
addDatasetScan
(
Element
crawlableDatasetElement
,
String
dirName
,
String
suffix
,
String
regexpPatternString
,
String
dateFormatMark
,
Set
<
NetcdfDataset
.
Enhance
>
enhanceMode
,
String
subdirs
,
String
olderThan
)
{
datasetManager
.
addDirectoryScan
(
dirName
,
suffix
,
regexpPatternString
,
subdirs
,
olderThan
,
enhanceMode
)
;
this
.
dateFormatMark
=
dateFormatMark
;
if
(
dateFormatMark
!=
)
{
isDate
=
true
;
if
(
type
==
Type
.
joinExisting
)
type
=
Type
.
joinExistingOne
;
// tricky
DateExtractor
dateExtractor
=
new
DateExtractorFromName
(
dateFormatMark
,
true
)
;
datasetManager
.
setDateExtractor
(
dateExtractor
)
;
}
}

Add a dataset scan

@param crawlableDatasetElement defines a CrawlableDataset, or null
@param dirName             scan this directory
@param suffix              filter on this suffix (may be null)
@param regexpPatternString include if full name matches this regular expression (may be null)
@param dateFormatMark      create dates from the filename (may be null)
@param enhanceMode         how should files be enhanced
@param subdirs             equals "false" if should not descend into subdirectories
@param olderThan           files must be older than this time (now - lastModified >= olderThan); must be a time unit, may ne bull


public void finish(CancelTask cancelTask) throws IOException {
    datasetManager.scan(true); // Make the list of Datasets, by scanning if needed.
    cacheDirty = true;
    makeDatasets(cancelTask);

    //ucar.unidata.io.RandomAccessFile.setDebugAccess( true);
    buildNetcdfDataset(cancelTask);
    //ucar.unidata.io.RandomAccessFile.setDebugAccess( false);
  }

all elements are processed, finish construction

all elements are processed finish construction


protected void makeDatasets(CancelTask cancelTask) throws IOException {

    // heres where the results will go
    datasets = new ArrayList<>();

    for (MFile cd : datasetManager.getFilesSorted()) {
      datasets.add( makeDataset(cd));
    }

    // sort using Aggregation.Dataset as Comparator.
    // Sort by date if it exists, else filename.
    Collections.sort(datasets);

      /* optionally extract the date
      String dateCoordS = null;
      if (null != dateFormatMark) {
        String filename = myf.getName(); // LOOK operates on name, not path
        Date dateCoord = DateFromString.getDateUsingDemarkatedCount(filename, dateFormatMark, '#');
        dateCoordS = formatter.toDateTimeStringISO(dateCoord);
        if (debugDateParse) System.out.println("  adding " + myf.getPath() + " date= " + dateCoordS);
      } else {
        if (debugDateParse) System.out.println("  adding " + myf.getPath());
      }

      String location = myf.getPath();
      Aggregation.Dataset ds = makeDataset(location, location, null, null, dateCoordS, null, enhance, null);
      datasets.add(ds);
    }

    // Sort by date if it exists, else filename.
    Collections.sort(datasets, new Comparator<Aggregation.Dataset>() {
      public int compare(Aggregation.Dataset ds1, Aggregation.Dataset ds2) {
        if(ds1.cd == null)
           return ds1.getLocation().compareTo(ds2.getLocation()) ;
        if (ds1.cd.dateCoord != null) // LOOK can we generalize
          return ds1.cd.dateCoord.compareTo(ds2.cd.dateCoord);
        else
          return ds1.cd.file.getName().compareTo(ds2.cd.file.getName());
      }
    });  */

    // add the explicit datasets - these need to be kept in order
    // LOOK - should they be before or after scanned? Does it make sense to mix scan and explicit?
    // AggFmrcSingle sets explicit datasets - the scan is empty
    for (Aggregation.Dataset dataset : explicitDatasets) {
      datasets.add(dataset);
    }

    // Remove unreadable files (i.e. due to permissions) from the aggregation.
    // LOOK: Is this logic we should install "upstream", perhaps in MFileCollectionManager?
    // It would affect other collections than just NcML aggregation in that case.
    for (Iterator<Dataset> datasetsIter = datasets.iterator(); datasetsIter.hasNext(); ) {
      Dataset dataset = datasetsIter.next();

      Path datasetPath;
      if (dataset.getMFile() instanceof MFileOS) {
        datasetPath = ((MFileOS) dataset.getMFile()).getFile().toPath();
      } else if (dataset.getMFile() instanceof MFileOS7) {
        datasetPath = ((MFileOS7) dataset.getMFile()).getNioPath();
      } else {
        continue;
      }

      if (!Files.isReadable(datasetPath)) {  // File.canRead() is broken on Windows, but the JDK7 methods work.
        logger.warn("Aggregation member isn't readable (permissions issue?). Skipping: " + datasetPath);
        datasetsIter.remove();
      }
    }

    // check for duplicate location
    Set<String> dset = new HashSet<>( 2 * datasets.size());
    for (Aggregation.Dataset dataset : datasets) {
      if (dset.contains(dataset.cacheLocation))
        logger.warn("Duplicate dataset in aggregation = "+dataset.cacheLocation);
      dset.add(dataset.cacheLocation);
    }

    if (datasets.size() == 0) {
      throw new IllegalStateException("There are no datasets in the aggregation " + datasetManager);
    }
  }

Make the list of Datasets, from explicit and scans.

@param cancelTask user can cancel
@throws IOException on i/o error

Make the list of Datasets from explicit and scans .


protected Dataset getTypicalDataset() throws IOException {
    List<Dataset> nestedDatasets = getDatasets();
    int n = nestedDatasets.size();
    if (n == 0)
      throw new FileNotFoundException("No datasets in this aggregation");

    int select;
    if (typicalDatasetMode == TypicalDataset.LATEST)
      select = n - 1;
    else if (typicalDatasetMode == TypicalDataset.PENULTIMATE)
      select = (n < 2) ? 0 : n - 2;
    else if (typicalDatasetMode == TypicalDataset.FIRST)
      select = 0;
    else { // random is default
      if (r == null) r = new Random();
      select = (n < 2) ? 0 : r.nextInt(n);
    }

    return nestedDatasets.get(select);
  }

protected
Dataset
getTypicalDataset
(
)
throws
IOException
{
List
<
Dataset
>
nestedDatasets
=
getDatasets
(
)
;
int
n
=
nestedDatasets
.
size
(
)
;
if
(
n
==
0
)
throw
new
FileNotFoundException
(
"No datasets in this aggregation"
)
;
int
select
;
if
(
typicalDatasetMode
==
TypicalDataset
.
LATEST
)
select
=
n
1
;
else
if
(
typicalDatasetMode
==
TypicalDataset
.
PENULTIMATE
)
select
=
(
n
<
2
)
0
:
n
2
;
else
if
(
typicalDatasetMode
==
TypicalDataset
.
FIRST
)
select
=
0
;
else
{
// random is default
if
(
r
==
)
r
=
new
Random
(
)
;
select
=
(
n
<
2
)
0
:
r
.
nextInt
(
n
)
;
}
return
nestedDatasets
.
get
(
select
)
;
}

Open one of the nested datasets as a template for the aggregation dataset.

@return a typical Dataset
@throws IOException if there are no datasets

Open one of the nested datasets as a template for the aggregation dataset .


protected Dataset makeDataset(String cacheName, String location, String id, String ncoordS, String coordValueS,
          String sectionSpec, EnumSet<NetcdfDataset.Enhance> enhance, ucar.nc2.util.cache.FileFactory reader) {
    return new Dataset(cacheName, location, id, enhance, reader); // overridden in OuterDim, tiled
  }

protected
Dataset
makeDataset
(
String
cacheName
,
String
location
,
String
id
,
String
ncoordS
,
String
coordValueS
,
String
sectionSpec
,
EnumSet
<
NetcdfDataset
.
Enhance
>
enhance
,
ucar
.
nc2
.
util
.
cache
.
FileFactory
reader
)
{
return
new
Dataset
(
cacheName
,
location
,
id
,
enhance
,
reader
)
;
// overridden in OuterDim, tiled
}

Dataset factory, so subclasses can override

@param cacheName   a unique name to use for caching
@param location    attribute "location" on the netcdf element
@param id          attribute "id" on the netcdf element
@param ncoordS     attribute "ncoords" on the netcdf element
@param coordValueS attribute "coordValue" on the netcdf element
@param sectionSpec attribute "sectionSpec" on the netcdf element
@param enhance     open dataset in enhance mode NOT USED
@param reader      factory for reading this netcdf dataset
@return a Aggregation.Dataset

Dataset factory so subclasses can override


void putResourceControl(Dataset ds) {
    if (logger.isDebugEnabled()) logger.debug("putResourceControl " + ds.getRestrictAccess() + " for " + ds.getName());
    resourceControlHash.put(ds.getUrlPath(), ds.getRestrictAccess());

    // resourceControl is inherited, but no guarentee that children paths are related, unless its a
    //   DatasetScan or InvDatasetFmrc. So we keep track of all datasets that have a ResourceControl, including children
    // DatasetScan and InvDatasetFmrc must use a PathMatcher, others can use exact match (hash)

    /* if (ds instanceof DatasetScan) {
      DatasetScan scan = (DatasetScan) ds;
      if (debugResourceControl)
        System.out.println("putResourceControl " + ds.getRestrictAccess() + " for datasetScan " + scan.getPath());
      resourceControlMatcher.put(scan.getPath(), ds.getRestrictAccess());

    } else { // dataset
      if (debugResourceControl)
        System.out.println("putResourceControl " + ds.getRestrictAccess() + " for dataset " + ds.getUrlPath());

      // LOOK: seems like you only need to add if InvAccess.InvService.isReletive
      // LOOK: seems like we should use resourceControlMatcher to make sure we match .dods, etc
      for (Access access : ds.getAccess()) {
        if (access.getService().isRelativeBase())
          resourceControlHash.put(access.getUrlPath(), ds.getRestrictAccess());
      }
    }  */

    hasResourceControl = true;
  }

This tracks Dataset elements that have resource control attributes

@param ds the dataset


public void addPoint(double x, double y) {
		Point ptPrev = null;

		if(points.size() > 0) {
			ptPrev = points.get(points.size() - 1);
		}

		this.points.add(new CFPoint(x, y, ptPrev, null, null));

	}

public void addPoint ( double x , double y ) { Point ptPrev = null ; if ( points . size ( ) > 0 ) { ptPrev = points . get ( points . size ( ) - 1 ) ; } this . points . add ( new CFPoint ( x , y , ptPrev , null , null ) ) ; }


public double[] getBBUpper() {
		double[] bbUpper = new double[2];

		List<Point> ptList = this.getPoints();
		if(ptList.isEmpty()) return null;
		bbUpper[0] = ptList.get(0).getY();
		bbUpper[1] = ptList.get(0).getY();

		for(Point pt : this.getPoints()) {
			if(bbUpper[0] < pt.getX()){
				bbUpper[0] = pt.getX();
			}

			if(bbUpper[1] < pt.getY()) {
				bbUpper[1] = pt.getY();
			}
		}

		// Got maximum points, add some padding.
		bbUpper[0] += 10;
		bbUpper[1] += 10;

		return bbUpper;
	}

Gets the upper bounding box coordinate on the line.
@return double array = (x, y)

Gets the upper bounding box coordinate on the line .


public double[] getBBLower() {
		double[] bbLower = new double[2];

		List<Point> ptList = this.getPoints();
		if(ptList.isEmpty()) return null;
		bbLower[0] = ptList.get(0).getY();
		bbLower[1] = ptList.get(0).getY();

		for(Point pt : this.getPoints()) {
			if(bbLower[0] > pt.getX()){
				bbLower[0] = pt.getX();
			}

			if(bbLower[1] > pt.getY()) {
				bbLower[1] = pt.getY();
			}
		}

		// Got minimum points, add some padding.
		bbLower[0] -= 10;
		bbLower[1] -= 10;

		return bbLower;
	}

Gets the lower bounding box coordinate on the line.
@return double array = (x, y)

Gets the lower bounding box coordinate on the line .


boolean validate(StringBuilder out) {
    this.isValid = true;

    // If log from construction has content, append to validation output msg.
    if (this.log.length() > 0) {
      out.append(this.log);
    }

    // Validity check: 'name' cannot be null. (Though, 'name'
    // can be an empty string.)
    if (this.getName() == null) {
      isValid = false;
      out.append(" ** DatasetFilter (4): null value for name is not valid.");
    }

    // Check that type is not null.
    if (this.getType() == null) {
      isValid = false;
      out.append(" ** DatasetFilter (5): null value for type is not valid (set with bad string?).");
    }

    // Validity check: 'matchPattern' must be null if 'type' value
    // is not 'RegExp'.
    if (this.type == DatasetFilter.Type.REGULAR_EXPRESSION &&
            this.matchPattern == null) {
      isValid = false;
      out.append(" ** DatasetFilter (6): null value for matchPattern not valid when type is 'RegExp'.");
    }
    if (this.type != DatasetFilter.Type.REGULAR_EXPRESSION &&
            this.type != null &&
            this.matchPattern != null) {
      isValid = false;
      out.append(" ** DatasetFilter (7): matchPattern value (" + this.matchPattern +
              ") must be null if type is not 'RegExp'.");
    }

    return (this.isValid);
  }

Validate this DatasetFilter object. Return true if valid, false if invalid.

@param out StringBuffer with validation messages.
@return boolean true if valid, false if invalid

Validate this DatasetFilter object . Return true if valid false if invalid .


private boolean match(InvDataset dataset) {
    // Check whether this filter applies to the given dataset.
    if (this.getParentDatasetSource().isCollection(dataset) && !this.applyToCollectionDatasets)
      return (false);
    if ((!this.getParentDatasetSource().isCollection(dataset)) && !this.applyToAtomicDatasets)
      return (false);

    // Set the default matchPatternTarget so old versions still work.
    if (this.matchPatternTarget == null) {
      if (this.getParentDatasetSource().isCollection(dataset)) {
        this.setMatchPatternTarget("name");
      } else {
        this.setMatchPatternTarget("urlPath");
      }
    }

    if (this.type == DatasetFilter.Type.REGULAR_EXPRESSION) {
      boolean isMatch;
      if (this.getMatchPatternTarget().equals("name")) {
        java.util.regex.Matcher matcher = this.regExpPattern.matcher(dataset.getName());
        isMatch = matcher.find();
      } else if (this.getMatchPatternTarget().equals("urlPath")) {
        java.util.regex.Matcher matcher = this.regExpPattern.matcher(((InvDatasetImpl) dataset).getUrlPath());
        isMatch = matcher.find();
      } else {
        // ToDo deal with any matchPatternTarget (XPath-ish)
        isMatch = false;
      }

//      // Invert the meaning of a match (accept things that don't match).
//      if ( this.isRejectMatchingDatasets())
//      {
//        // If match, return false.
//        return( regExpMatch == null ? true : false );
//      }
//      // Don't invert (a match is a match).
//      else
//      {
      // If match, return true.
      return (isMatch);
//      }
    } else {
      System.err.println("WARNING -- DatasetFilter.accept(): unsupported type" +
              " <" + this.type.toString() + ">.");
      return (false);
      // @todo think about exceptions.
      //throw new java.lang.Exception( "DatasetFilter.accept():" +
      //  " unsupported type <" + this.type.toString() + ">.");
    }

  }

Test whether the given dataset matches the filter criteria.

@param dataset - the dataset to be tested.
@return true if and only if the dataset matches the filter criteria.

Test whether the given dataset matches the filter criteria .


public void addAll(FeatureDatasetPoint fdPoint) throws IOException {
        try (PointFeatureIterator pointFeatIter =
                new FlattenedDatasetPointCollection(fdPoint).getPointFeatureIterator()) {
            while (pointFeatIter.hasNext()) {
                StationPointFeature pointFeat = (StationPointFeature) pointFeatIter.next();
                add(pointFeat);
            }
        }
    }

public void addAll ( FeatureDatasetPoint fdPoint ) throws IOException { try ( PointFeatureIterator pointFeatIter = new FlattenedDatasetPointCollection ( fdPoint ) . getPointFeatureIterator ( ) ) { while ( pointFeatIter . hasNext ( ) ) { StationPointFeature pointFeat = ( StationPointFeature ) pointFeatIter . next ( ) ; add ( pointFeat ) ; } } }


public void parseConstraint(ReqState rs)
            throws ParseException, opendap.dap.DAP2Exception, NoSuchVariableException,
            NoSuchFunctionException, InvalidOperatorException,
            InvalidParameterException, SBHException, WrongTypeException
    {
           parseConstraint(rs.getConstraintExpression(),rs.getRequestURL().toString());
    }

public void parseConstraint ( ReqState rs ) throws ParseException , opendap . dap . DAP2Exception , NoSuchVariableException , NoSuchFunctionException , InvalidOperatorException , InvalidParameterException , SBHException , WrongTypeException { parseConstraint ( rs . getConstraintExpression ( ) , rs . getRequestURL ( ) . toString ( ) ) ; }

Convenience wrapper for parseConstraint.

@param rs
@throws ParseException
@throws opendap.dap.DAP2Exception
@throws NoSuchVariableException
@throws NoSuchFunctionException
@throws InvalidOperatorException
@throws InvalidParameterException
@throws SBHException
@throws WrongTypeException

Convenience wrapper for parseConstraint .


public boolean evalClauses(Object specialO) throws NoSuchVariableException, DAP2ServerSideException, IOException {

        boolean result = true;
        Enumeration ec = getClauses();

        while (ec.hasMoreElements() && result == true) {
            Object o = ec.nextElement();
            if (_Debug) {
                System.out.println("Evaluating clause: " + ec.nextElement());
            }

            result = ((TopLevelClause) o).evaluate();

        }

        // Hack: pop the projections of all DArrayDimensions that
        // have been pushed.

        return (result);
    }

Evaluate all of the Clauses in the Clause vector.

@param specialO That special Object that can be passed down
through the DDS.send() method.
@return True if all the Clauses evaluate to true, false otherwise.

Evaluate all of the Clauses in the Clause vector .


public void printConstraint(PrintWriter pw)
        {
            Enumeration ec = getClauses();
            boolean first = true;
            while (ec.hasMoreElements()) {
                Clause cl = (Clause)ec.nextElement();
                if(!first) pw.print(" & ");
                cl.printConstraint(pw);
                first = false;
            }
            pw.flush();
        }

public
void
printConstraint
(
PrintWriter
pw
)
{
Enumeration
ec
=
getClauses
(
)
;
boolean
first
=
true
;
while
(
ec
.
hasMoreElements
(
)
)
{
Clause
cl
=
(
Clause
)
ec
.
nextElement
(
)
;
if
(
!
first
)
pw
.
print
(
" & "
)
;
cl
.
printConstraint
(
pw
)
;
first
=
false
;
}
pw
.
flush
(
)
;
}

Print all of the Clauses in the Clause vector.

Print all of the Clauses in the Clause vector .


static public boolean amendFromODL(NetcdfFile ncfile, Group eosGroup) throws IOException {
    String smeta = getStructMetadata(eosGroup);
    if (smeta == null) { return false; }

    HdfEos fixer = new HdfEos();
    fixer.fixAttributes(ncfile.getRootGroup());
    fixer.amendFromODL(ncfile, smeta);
    return true;
  }

static public boolean amendFromODL ( NetcdfFile ncfile , Group eosGroup ) throws IOException { String smeta = getStructMetadata ( eosGroup ) ; if ( smeta == null ) { return false ; } HdfEos fixer = new HdfEos ( ) ; fixer . fixAttributes ( ncfile . getRootGroup ( ) ) ; fixer . amendFromODL ( ncfile , smeta ) ; return true ; }

Amend the given NetcdfFile with metadata from HDF-EOS structMetadata.
All Variables named StructMetadata.n, where n= 1, 2, 3 ... are read in and their contents concatenated
to make the structMetadata String.

@param ncfile   Amend this file
@param eosGroup the group containing variables named StructMetadata.*
@return true if HDF-EOS info was found
@throws IOException on read error

Amend the given NetcdfFile with metadata from HDF - EOS structMetadata . All Variables named StructMetadata . n where n = 1 2 3 ... are read in and their contents concatenated to make the structMetadata String .


private void setSharedDimensions(Variable v, List<Element> values, List<Dimension> unknownDims, String location) {
    if (values.size() == 0) {
      return;
    }

    // remove the "scalar" dumbension
    Iterator<Element> iter = values.iterator();
    while (iter.hasNext()) {
      Element value = iter.next();
      String dimName = value.getText().trim();
      if (dimName.equalsIgnoreCase("scalar")) {
        iter.remove();
      }
    }

    // gotta have same number of dimensions
    List<Dimension> oldDims = v.getDimensions();
    if (oldDims.size() != values.size()) {
      log.error("Different number of dimensions for {} {}", v, location);
      return;
    }

    List<Dimension> newDims = new ArrayList<>();
    Group group = v.getParentGroup();

    for (int i = 0; i < values.size(); i++) {
      Element value = values.get(i);
      String dimName = value.getText().trim();
      dimName = NetcdfFile.makeValidCdmObjectName(dimName);

      Dimension dim = group.findDimension(dimName);
      Dimension oldDim = oldDims.get(i);
      if (dim == null) {
        dim = checkUnknownDims(dimName, unknownDims, oldDim, location);
      }

      if (dim == null) {
        log.error("Unknown Dimension= {} for variable = {} {} ", dimName, v.getFullName(), location);
        return;
      }
      if (dim.getLength() != oldDim.getLength()) {
        log.error("Shared dimension ({}) has different length than data dimension ({}) shared={} org={} for {} {}",
                    dim.getShortName(),oldDim.getShortName(),
             dim.getLength() , oldDim.getLength() , v,location);
        return;
      }
      newDims.add(dim);
    }
    v.setDimensions(newDims);
    if (showWork) { log.debug(" set shared dimensions for {}", v.getNameAndDimensions()); }
  }


private Dimension checkUnknownDims(String wantDim, List<Dimension> unknownDims, Dimension oldDim, String location) {
    for (Dimension dim : unknownDims) {
      if (dim.getShortName().equals(wantDim)) {
        int len = oldDim.getLength();
        if (len == 0) {
          dim.setUnlimited(true); // allow zero length dimension !!
        }
        dim.setLength(len); // use existing (anon) dimension
        Group parent = dim.getGroup();
        parent.addDimensionIfNotExists(dim);  // add to the parent
        unknownDims.remove(dim); // remove from list LOOK is this ok?
        log.warn("unknownDim {} length set to {}{}", wantDim, oldDim.getLength(), location);
        return dim;
      }
    }
    return null;
  }

private
Dimension
checkUnknownDims
(
String
wantDim
,
List
<
Dimension
>
unknownDims
,
Dimension
oldDim
,
String
location
)
{
for
(
Dimension
dim
:
unknownDims
)
{
if
(
dim
.
getShortName
(
)
.
equals
(
wantDim
)
)
{
int
len
=
oldDim
.
getLength
(
)
;
if
(
len
==
0
)
{
dim
.
setUnlimited
(
true
)
;
// allow zero length dimension !!
}
dim
.
setLength
(
len
)
;
// use existing (anon) dimension
Group
parent
=
dim
.
getGroup
(
)
;
parent
.
addDimensionIfNotExists
(
dim
)
;
// add to the parent
unknownDims
.
remove
(
dim
)
;
// remove from list LOOK is this ok?
log
.
warn
(
"unknownDim {} length set to {}{}"
,
wantDim
,
oldDim
.
getLength
(
)
,
location
)
;
return
dim
;
}
}
return
;
}

look if the wanted dimension is in the  unknownDims list.

look if the wanted dimension is in the unknownDims list .


private Group findGroupNested(Group parent, String name) {

    for (Group g : parent.getGroups()) {
      if (g.getShortName().equals(name)) { return g; }
    }
    for (Group g : parent.getGroups()) {
      Group result = findGroupNested(g, name);
      if (result != null) { return result; }
    }
    return null;
  }

private Group findGroupNested ( Group parent , String name ) { for ( Group g : parent . getGroups ( ) ) { if ( g . getShortName ( ) . equals ( name ) ) { return g ; } } for ( Group g : parent . getGroups ( ) ) { Group result = findGroupNested ( g , name ) ; if ( result != null ) { return result ; } } return null ; }

look for a group with the given name. recurse into subgroups if needed. breadth first

look for a group with the given name . recurse into subgroups if needed . breadth first


public String readXlinkContent() throws java.io.IOException {
    if (uri == null) return "";

    URL url = uri.toURL();
    InputStream is = url.openStream();
    ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());

    // copy to string
    byte[] buffer = new byte[1024];
    while (true) {
      int bytesRead = is.read(buffer);
      if (bytesRead == -1) break;
      os.write(buffer, 0, bytesRead);
    }
    is.close();

    return new String(os.toByteArray(), CDM.utf8Charset);
  }

public
String
readXlinkContent
(
)
throws
java
.
io
.
IOException
{
if
(
uri
==
)
return
""
;
URL
url
=
uri
.
toURL
(
)
;
InputStream
is
=
url
.
openStream
(
)
;
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
(
is
.
available
(
)
)
;
// copy to string
byte
[
]
buffer
=
new
byte
[
1024
]
;
while
(
true
)
{
int
bytesRead
=
is
.
read
(
buffer
)
;
if
(
bytesRead
==
1
)
break
;
os
.
write
(
buffer
,
0
,
bytesRead
)
;
}
is
.
close
(
)
;
return
new
String
(
os
.
toByteArray
(
)
,
CDM
.
utf8Charset
)
;
}

Get inline content as a string, else null if there is none

@return inline content as a string, else null

Get inline content as a string else null if there is none


public URI getStandardUri() {
    try {
      InvCatalog cat = dataset.getParentCatalog();
      if (cat == null)
        return new URI(getUnresolvedUrlName());

      return cat.resolveUri(getUnresolvedUrlName());

    } catch (java.net.URISyntaxException e) {
      logger.warn("Error parsing URL= " + getUnresolvedUrlName());
      return null;
    }
  }

public
URI
getStandardUri
(
)
{
try
{
InvCatalog
cat
=
dataset
.
getParentCatalog
(
)
;
if
(
cat
==
)
return
new
URI
(
getUnresolvedUrlName
(
)
)
;
return
cat
.
resolveUri
(
getUnresolvedUrlName
(
)
)
;
}
catch
(
java
.
net
.
URISyntaxException
e
)
{
logger
.
warn
(
"Error parsing URL= "
+
getUnresolvedUrlName
(
)
)
;
return
;
}
}

Construct the standard THREDDS access URI for this dataset access method,
resolve if the URI is relative.

@return the standard fully resolved THREDDS access URI for this dataset access method, or null if error.

Construct the standard THREDDS access URI for this dataset access method resolve if the URI is relative .


public void setProjection(ProjectionManager.ProjectionClass pc)  {
      // clear out any fields
      removeAll();

      for (ProjectionManager.ProjectionParam pp : pc.paramList) {
        // construct the label
        JPanel thisPanel = new JPanel();
        thisPanel.add(new JLabel(pp.name + ": "));

        // text input field
        JTextField tf = new JTextField();
        pp.setTextField(tf);
        tf.setColumns(12);
        thisPanel.add(tf);
        add(thisPanel);
      }
      revalidate();
    }

public
void
setProjection
(
ProjectionManager
.
ProjectionClass
pc
)
{
// clear out any fields
removeAll
(
)
;
for
(
ProjectionManager
.
ProjectionParam
pp
:
pc
.
paramList
)
{
// construct the label
JPanel
thisPanel
=
new
JPanel
(
)
;
thisPanel
.
add
(
new
JLabel
(
pp
.
name
+
": "
)
)
;
// text input field
JTextField
tf
=
new
JTextField
(
)
;
pp
.
setTextField
(
tf
)
;
tf
.
setColumns
(
12
)
;
thisPanel
.
add
(
tf
)
;
add
(
thisPanel
)
;
}
revalidate
(
)
;
}

construct input fields based on Projection Class


public void addLayoutComponent(Component comp, Object constraint) {
      if (debug) System.out.println(name+ " addLayoutComponent= "+ comp.getClass().getName()+" "+comp.hashCode()+" "+constraint);
      if (!(constraint instanceof Constraint))
        throw new IllegalArgumentException( "MySpringLayout must be Constraint");
      constraintMap.put( comp, constraint);
      globalBounds = null;
    }

public
void
addLayoutComponent
(
Component
comp
,
Object
constraint
)
{
if
(
debug
)
System
.
out
.
println
(
name
+
" addLayoutComponent= "
+
comp
.
getClass
(
)
.
getName
(
)
+
" "
+
comp
.
hashCode
(
)
+
" "
+
constraint
)
;
if
(
!
(
constraint
instanceof
Constraint
)
)
throw
new
IllegalArgumentException
(
"MySpringLayout must be Constraint"
)
;
constraintMap
.
put
(
comp
,
constraint
)
;
globalBounds
=
;
}

Adds the specified component to the layout, using the specified
constraint object.
@param comp the component to be added
@param constraint  where/how the component is added to the layout.

Adds the specified component to the layout using the specified constraint object .


public void invalidateLayout(Container target){
      if (debug) System.out.println(name+" invalidateLayout ");
      globalBounds = null;

      // this probably need to be scheduled later ??
      // layoutContainer( target);
    }

Invalidates the layout, indicating that if the layout manager
has cached information it should be discarded.

Invalidates the layout indicating that if the layout manager has cached information it should be discarded .


public void removeLayoutComponent(Component comp){
      if (debug) System.out.println("removeLayoutComponent");
      constraintMap.remove(comp);
      globalBounds = null;
    }

public void removeLayoutComponent ( Component comp ) { if ( debug ) System . out . println ( "removeLayoutComponent" ) ; constraintMap . remove ( comp ) ; globalBounds = null ; }

Removes the specified component from the layout.
@param comp the component to be removed

Removes the specified component from the layout .


public Dimension minimumLayoutSize(Container parent){
      if (debug) System.out.println("minimumLayoutSize");
      if (globalBounds == null) layoutContainer(parent);
      return globalBounds.getSize();
    }

public Dimension minimumLayoutSize ( Container parent ) { if ( debug ) System . out . println ( "minimumLayoutSize" ) ; if ( globalBounds == null ) layoutContainer ( parent ) ; return globalBounds . getSize ( ) ; }

Calculates the minimum size dimensions for the specified
container, given the components it contains.
@param parent the component to be laid out
@see #preferredLayoutSize

Calculates the minimum size dimensions for the specified container given the components it contains .