Skip to content

Commit

Permalink
Merge pull request #1207 from tdrwenski/cleanups
Browse files Browse the repository at this point in the history
Code style fixes for ncml reader and test class
  • Loading branch information
haileyajohnson authored Jul 7, 2023
2 parents 34e722a + f9dccb7 commit 5ea0fbb
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 173 deletions.
30 changes: 6 additions & 24 deletions cdm/core/src/main/java/ucar/nc2/internal/ncml/NcmlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private void readNetcdf(String ncmlLocation, NetcdfDataset.Builder builder, Elem
/**
* Read the NcML group element, and nested elements.
*
* @param parent the parent group builder, or null when its the root group.
* @param parent the parent group builder, or null when it's the root group.
* @param refParent parent Group in referenced dataset, may be null
* @param groupElem ncml group element
*/
Expand Down Expand Up @@ -670,7 +670,7 @@ private void readAtt(AttributeContainer dest, @Nullable AttributeContainer ref,
return;
}

// see if its new
// see if it's new
ucar.nc2.Attribute oldatt = null;
if (ref != null) {
oldatt = findAttribute(ref, nameInFile);
Expand Down Expand Up @@ -806,10 +806,7 @@ private void readDim(Group.Builder groupBuilder, @Nullable Group refGroup, Eleme
return;
}

String nameInFile = dimElem.getAttributeValue("orgName");
if (nameInFile == null) {
nameInFile = name;
}
String nameInFile = dimElem.getAttributeValue("orgName") != null ? dimElem.getAttributeValue("orgName") : name;

// LOOK this is wrong, groupBuilder may already have the dimension.
// see if it already exists
Expand All @@ -827,21 +824,10 @@ private void readDim(Group.Builder groupBuilder, @Nullable Group refGroup, Eleme

boolean isUnlimited = "true".equalsIgnoreCase(isUnlimitedS);
boolean isVariableLength = "true".equalsIgnoreCase(isVariableLengthS);
boolean isShared = true;
if ("false".equalsIgnoreCase(isSharedS)) {
isShared = false;
}
boolean isShared = !"false".equalsIgnoreCase(isSharedS);

int len;
if (isVariableLength) {
len = Dimension.VLEN.getLength();
} else {
len = Integer.parseInt(lengthS);
}
int len = isVariableLength ? Dimension.VLEN.getLength() : Integer.parseInt(lengthS);

if (debugConstruct) {
System.out.println(" add new dim = " + name);
}
// LOOK change to replaceDimension to get fort.54 working.
groupBuilder.replaceDimension(Dimension.builder().setName(name).setIsShared(isShared).setIsUnlimited(isUnlimited)
.setIsVariableLength(isVariableLength).setLength(len).build());
Expand Down Expand Up @@ -872,10 +858,6 @@ private void readDim(Group.Builder groupBuilder, @Nullable Group refGroup, Eleme
newDim.setLength(len);
}

if (debugConstruct) {
System.out.println(" modify existing dim = " + name);
}

groupBuilder.removeDimension(name);
groupBuilder.addDimension(newDim.build());
}
Expand Down Expand Up @@ -1600,7 +1582,7 @@ public NetcdfFile open(DatasetUrl cacheName, int buffer_size, CancelTask cancelT
}

/////////////////////////////////////////////
// command procesing
// command processing

private void cmdRemove(Group.Builder g, String type, String name) {
boolean err = false;
Expand Down
Loading

0 comments on commit 5ea0fbb

Please sign in to comment.