-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Handlers #187
Merged
Merged
More Handlers #187
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
546091d
EDDGridSideBySideHandler and Test
ayushsingh01042003 132aea1
EDDTableAggregateRowsHandler
ayushsingh01042003 cdb6830
EDDTableCopyHandler
ayushsingh01042003 9812be8
EDDTableFromCassandraHandler
ayushsingh01042003 d99f87a
EDDTableFromDapSequenceHandler
ayushsingh01042003 6ad3cfd
EDDTableFromDatabaseHandler
ayushsingh01042003 184a019
EDDTableFromAsciiServiceHandler
ayushsingh01042003 95e7c67
Private Handler variables
ayushsingh01042003 e63db55
ArrayLists to Arrays
ayushsingh01042003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
WEB-INF/classes/gov/noaa/pfel/erddap/handlers/EDDGridSideBySideHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package gov.noaa.pfel.erddap.handlers; | ||
|
||
import static gov.noaa.pfel.erddap.dataset.EDDGrid.DEFAULT_MATCH_AXIS_N_DIGITS; | ||
|
||
import com.cohort.array.StringArray; | ||
import com.cohort.util.String2; | ||
import gov.noaa.pfel.erddap.dataset.EDD; | ||
import gov.noaa.pfel.erddap.dataset.EDDGrid; | ||
import gov.noaa.pfel.erddap.dataset.EDDGridSideBySide; | ||
import gov.noaa.pfel.erddap.util.EDStatic; | ||
import java.util.ArrayList; | ||
import org.xml.sax.Attributes; | ||
import org.xml.sax.SAXException; | ||
|
||
public class EDDGridSideBySideHandler extends State { | ||
private StringBuilder content = new StringBuilder(); | ||
private String datasetID; | ||
private State completeState; | ||
private SaxParsingContext context; | ||
|
||
public EDDGridSideBySideHandler( | ||
SaxHandler saxHandler, String datasetID, State completeState, SaxParsingContext context) { | ||
super(saxHandler); | ||
this.datasetID = datasetID; | ||
this.completeState = completeState; | ||
this.context = context; | ||
} | ||
|
||
private ArrayList tChildDatasets = new ArrayList(); | ||
private StringBuilder messages = new StringBuilder(); | ||
private String tAccessibleTo = null; | ||
private String tGraphsAccessibleTo = null; | ||
private boolean tAccessibleViaWMS = true; | ||
private boolean tAccessibleViaFiles = EDStatic.defaultAccessibleViaFiles; | ||
private int tMatchAxisNDigits = DEFAULT_MATCH_AXIS_N_DIGITS; | ||
private StringArray tOnChange = new StringArray(); | ||
private String tFgdcFile = null; | ||
private String tIso19115File = null; | ||
private String tDefaultDataQuery = null; | ||
private String tDefaultGraphQuery = null; | ||
private int tnThreads = -1; | ||
private boolean tDimensionValuesInMemory = true; | ||
|
||
@Override | ||
public void startElement(String uri, String localName, String qName, Attributes attributes) | ||
throws SAXException { | ||
if (localName.equals("dataset")) { | ||
String tType = attributes.getValue("type"); | ||
if (tType == null || !tType.startsWith("EDDGrid")) { | ||
throw new RuntimeException( | ||
"The datasets defined in an " + "EDDGridSideBySide must be a subclass of EDDGrid."); | ||
} | ||
String active = attributes.getValue("active"); | ||
String childDatasetID = attributes.getValue("datasetID"); | ||
State state = | ||
HandlerFactory.getHandlerFor(tType, childDatasetID, active, this, saxHandler, context); | ||
saxHandler.setState(state); | ||
} | ||
} | ||
|
||
@Override | ||
public void characters(char[] ch, int start, int length) throws SAXException { | ||
content.append(ch, start, length); | ||
} | ||
|
||
@Override | ||
public void endElement(String uri, String localName, String qName) throws Throwable { | ||
String contentStr = content.toString().trim(); | ||
|
||
switch (localName) { | ||
case "onChange" -> tOnChange.add(contentStr); | ||
case "matchAxisNDigits" -> | ||
tMatchAxisNDigits = String2.parseInt(contentStr, DEFAULT_MATCH_AXIS_N_DIGITS); | ||
case "ensureAxisValuesAreEqual" -> | ||
tMatchAxisNDigits = String2.parseBoolean(contentStr) ? 20 : 0; | ||
case "accessibleTo" -> tAccessibleTo = contentStr; | ||
case "graphsAccessibleTo" -> tGraphsAccessibleTo = contentStr; | ||
case "accessibleViaWMS" -> tAccessibleViaWMS = String2.parseBoolean(contentStr); | ||
case "accessibleViaFiles" -> tAccessibleViaFiles = String2.parseBoolean(contentStr); | ||
case "fgdcFile" -> tFgdcFile = contentStr; | ||
case "iso19115File" -> tIso19115File = contentStr; | ||
case "defaultDataQuery" -> tDefaultDataQuery = contentStr; | ||
case "defaultGraphQuery" -> tDefaultGraphQuery = contentStr; | ||
case "nThreads" -> tnThreads = String2.parseInt(contentStr); | ||
case "dimensionValuesInMemory" -> tDimensionValuesInMemory = String2.parseBoolean(contentStr); | ||
case "dataset" -> { | ||
EDDGrid[] tcds = new EDDGrid[tChildDatasets.size()]; | ||
for (int c = 0; c < tChildDatasets.size(); c++) { | ||
tcds[c] = (EDDGrid) tChildDatasets.get(c); | ||
} | ||
EDD dataset = | ||
new EDDGridSideBySide( | ||
datasetID, | ||
tAccessibleTo, | ||
tGraphsAccessibleTo, | ||
tAccessibleViaWMS, | ||
tAccessibleViaFiles, | ||
tMatchAxisNDigits, | ||
tOnChange, | ||
tFgdcFile, | ||
tIso19115File, | ||
tDefaultDataQuery, | ||
tDefaultGraphQuery, | ||
tcds, | ||
tnThreads, | ||
tDimensionValuesInMemory); | ||
this.completeState.handleDataset(dataset); | ||
saxHandler.setState(this.completeState); | ||
} | ||
default -> String2.log("Unexpected end tag: " + localName); | ||
} | ||
content.setLength(0); | ||
} | ||
|
||
@Override | ||
public void handleDataset(EDD dataset) { | ||
tChildDatasets.add(dataset); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make the tChildDatasets of type
ArrayList<EDDGrid>
, you should be able to just usetChildDatasets.toArray()
instead of a for loop here.