Class HecDssCatalog

All Implemented Interfaces:
HecDssListener, Cloneable, EventListener
Direct Known Subclasses:
HecDSSDataAttributes

public class HecDssCatalog extends HecDSSFileAccess implements HecDssListener, Cloneable
HecDssCatalog has methods to query or inventory the contents of a DSS file, supports listeners that report on modifications to the DSS file
Primary calls that are:
  • Field Details

    • pathnameList

      protected String[] pathnameList
    • pathnameWithWild

      protected String pathnameWithWild
    • listIsComplete

      protected boolean listIsComplete
    • listIsSorted

      protected boolean listIsSorted
    • listIsCollection

      protected boolean listIsCollection
    • _useCollectionGroups

      protected boolean _useCollectionGroups
    • _forceNewCatalog

      protected static boolean _forceNewCatalog
    • _listenerList

      protected EventListenerList _listenerList
    • _observerThreads

      protected Hashtable<HecDssListener,Thread> _observerThreads
    • _catalogName

      @Deprecated protected String _catalogName
      Deprecated.
    • statusWanted

      protected int statusWanted
    • statusRead

      protected int statusRead
    • maxNumberToRetrieve

      protected int maxNumberToRetrieve
    • dataTypeStart

      protected int dataTypeStart
    • dataTypeEnd

      protected int dataTypeEnd
    • startDates

      protected int[] startDates
    • endDates

      protected int[] endDates
    • pathnameHash

      protected long[] pathnameHash
    • lastWriteTimeRecord

      protected long[] lastWriteTimeRecord
    • crcValues

      protected int[] crcValues
    • lastWriteTimeFile

      protected long lastWriteTimeFile
    • pathnameAddresses

      protected long[] pathnameAddresses
  • Constructor Details

    • HecDssCatalog

      public HecDssCatalog(String dssFileName)
    • HecDssCatalog

      public HecDssCatalog()
  • Method Details

    • pathname

      public String pathname()
    • getCatalog

      public String[] getCatalog(boolean sorted, String pathnameFilter)
      Obtain a catalog (list of pathnames) in a DSS file.
      Parameters:
      sorted - when true returns sorted list of pathnames Sort order is stored internally, so subsequent sorts can be faster.
      pathnameFilter - The pathname filter to use. If not null (no filtering), it may be one of:
      Filter Type Description Rules Examples
      Wildcards Pseudo pathname with optional "*" and "?" wildcard characters anywhere.
      • '*' character matches zero or more characters, including '/'
      • '?' character matches one character, including '/'
      • /*/*/Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • *Flow*
        Pathname contains Flow in any part
      Pathname Parts Specified pathname parts (can include wildcard characters "*" and "?")
      • Filter contains A=... B=... etc for A-F parts
      • Unspecified parts match anything, same as specifying "*"
      • Interior spaces are preserved, but quotes must be used to preserve beginning or trailing spaces
      • C=Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • B = Green River F = " Trial Run "
        Any A, C, D, and E parts, B part is Green River, F part is " Trial Run " (spaces preserved)
      All pathname matching is performed ignoring character case
      Returns:
      The internal list of pathnames (not a copy), as generated by callCatalog(String). To force pathname matching to be performed in the native library, call callCatalogOriginal(String) before calling this method.
    • getCatalog

      public String[] getCatalog(boolean sorted)
      Obtain a catalog (list of pathnames) in a DSS file. No filtering will be performed on the catalog
      Parameters:
      sorted - when true returns sorted list of pathnames Sort order is stored internally, so subsequent sorts can be faster.
      Returns:
      The internal list of pathnames (not a copy), as generated by callCatalog(String).
    • getCatalog

      public String[] getCatalog(boolean sorted, String pathnameFilter, int matcherType, boolean ignoreCase)
      Obtain a catalog (list of pathnames) in a DSS file
      Parameters:
      sorted - when true returns sorted list of pathnames Sort order is stored internally, so subsequent sorts can be faster.
      pathnameFilter - The pathname filter to use. If not null (no filtering), it may be one of:
      Filter Type Description Rules Examples
      Wildcards Pseudo pathname with optional "*" and "?" wildcard characters.
      • '*' character matches zero or more characters, including '/'
      • '?' character matches one character, including '/'
      • /*/*/Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • *Flow*
        Pathname contains Flow in any part
      Regular Expressions Pseudo pathname with regular expressions Java regular expressions are used
      • /*/*/(Flow|Stage).*
        Any A, B, D, E, and F parts, C part starts with Flow or Stage
      • .*(Flow|Stage).*
        Pathname contains Flow or Stage in any part
      Pathname Parts Specified pathname parts (can include wildcard characters or regular expressions)
      • Filter contains A=... B=... etc for A-F parts
      • Unspecified parts match anything, same as specifying wildcard "*" or regular expression ".*"
      • Interior spaces are preserved, but quotes must be used to preserve beginning or trailing spaces
      • C=Flow*
        (if matcherType == DssPathnameMatcher.MATCHER_TYPE_GLOB) Any A, B, D, E, and F parts, C part starts with Flow
      • C=(Flow|Stage).*
        (if matcherType == DssPathnameMatcher.MATCHER_TYPE_REGEX) Any A, B, D, E, and F parts, C part starts with Flow or Elev
      • B = Green River F = " Trial Run "
        Any A, C, D, and E parts, B part is Green River, F part is " Trial Run " (spaces preserved)
      matcherType - Specifies whether the pathname filter contains wildcards or regular expressions. Must be one of
      • DssPathnameMatcher.MATCHER_TYPE_GLOB
      • DssPathnameMatcher.MATCHER_TYPE_REGEX
      Returns:
      The internal list of pathnames (not a copy), as generated by callCatalog(String, int, boolean). To force pathname matching to be performed in the native library, call callCatalogOriginal(String) before calling this method.
    • getCondensedCatalog

      public CondensedReference[] getCondensedCatalog(String pathnameFilter)
      Constructs and returns a condensed catalog
      Parameters:
      pathnameFilter - The pathname filter to use. If not null (no filtering), it may be one of:
      Filter Type Description Rules Examples
      Wildcards Pseudo pathname with optional "*" and "?" wildcard characters anywhere.
      • '*' character matches zero or more characters, including '/'
      • '?' character matches one character, including '/'
      • /*/*/Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • *Flow*
        Pathname contains Flow in any part
      Pathname Parts Specified pathname parts (can include wildcard characters "*" and "?")
      • Filter contains A=... B=... etc for A-F parts
      • Unspecified parts match anything, same as specifying "*"
      • Interior spaces are preserved, but quotes must be used to preserve beginning or trailing spaces
      • C=Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • B = Green River F = " Trial Run "
        Any A, C, D, and E parts, B part is Green River, F part is " Trial Run " (spaces preserved)
      Returns:
      Condensed catalog as generated by callCatalog(String). To force pathname matching to be performed in the native library, call callCatalogOriginal(String) before calling this method.
    • getCondensedCatalog

      public CondensedReference[] getCondensedCatalog(String pathnameFilter, int matcherType, boolean ignoreCase)
      Constructs and returns a condensed catalog
      Parameters:
      pathnameFilter - The pathname filter to use. If not null (no filtering), it may be one of:
      Filter Type Description Rules Examples
      Wildcards Pseudo pathname with optional "*" and "?" wildcard characters.
      • '*' character matches zero or more characters, including '/'
      • '?' character matches one character, including '/'
      • /*/*/Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • *Flow*
        Pathname contains Flow in any part
      Regular Expressions Pseudo pathname with regular expressions Java regular expressions are used
      • /*/*/(Flow|Stage).*
        Any A, B, D, E, and F parts, C part starts with Flow or Stage
      • .*(Flow|Stage).*
        Pathname contains Flow or Stage in any part
      Pathname Parts Specified pathname parts (can include wildcard characters or regular expressions)
      • Filter contains A=... B=... etc for A-F parts
      • Unspecified parts match anything, same as specifying wildcard "*" or regular expression ".*"
      • Interior spaces are preserved, but quotes must be used to preserve beginning or trailing spaces
      • C=Flow*
        (if matcherType == DssPathnameMatcher.MATCHER_TYPE_GLOB) Any A, B, D, E, and F parts, C part starts with Flow
      • C=(Flow|Stage).*
        (if matcherType == DssPathnameMatcher.MATCHER_TYPE_REGEX) Any A, B, D, E, and F parts, C part starts with Flow or Elev
      • B = Green River F = " Trial Run "
        Any A, C, D, and E parts, B part is Green River, F part is " Trial Run " (spaces preserved)
      matcherType - Specifies whether the pathname filter contains wildcards or regular expressions. Must be one of
      • DssPathnameMatcher.MATCHER_TYPE_GLOB
      • DssPathnameMatcher.MATCHER_TYPE_REGEX
      ignoreCase - Specifies whether pathname matching is to be performed with or without considering character case
      Returns:
      Condensed catalog as generated by callCatalog(String, int, boolean). To force pathname matching to be performed in the native library, call callCatalogOriginal(String) before calling this method.
    • catalogFile

      public int catalogFile(String catalogName, boolean sorted, String pathWithWildChars)
    • setPathWithWildChars

      public void setPathWithWildChars(String pathWithWildChars, boolean getCollection)
    • setStatusWanted

      public void setStatusWanted(int status)
    • getStatusRead

      public int getStatusRead()
    • setMaxNumberToRetrieve

      public void setMaxNumberToRetrieve(int maxNumber)
    • getStartDates

      public int[] getStartDates()
    • getEndDates

      public int[] getEndDates()
    • getPathnames

      public String[] getPathnames()
    • setTypeWanted

      public void setTypeWanted(int typeStart, int typeEnd)
    • setForceNewCatalog

      public void setForceNewCatalog(boolean forceNewCatalog)
    • setUseCollectionGroups

      public void setUseCollectionGroups(boolean useCollectionGroups)
    • getUseCollectionGroups

      public boolean getUseCollectionGroups()
    • wildCharsToRegex

      protected String wildCharsToRegex(String pathnameWithWild)
    • isPathnamePartsString

      protected boolean isPathnamePartsString(String maybePathnameParts)
    • pathNamePartsToRegex

      protected String pathNamePartsToRegex(String pathnameParts)
    • callCatalogOriginal

      public int callCatalogOriginal(String pathWithWildChars)
      Constructs the (optionally filtered) internal pathname list from the DSS file. Pathname matching is performed in the native library.
      Parameters:
      pathWithWildChars - Pathnames match, using "*" as wild characters on either end of pathname parts, or "null" to return all pathnames (usual case)
      • null - return all pathnames
      • /American/Fair Oaks/*Flow*//*/1day/*/ - Any C part containing "flow" (Also can use "*Flow" or "Flow*", but not "Flow*Out")
      Returns:
      -4 if the object cannot access the DSS file, or otherwise the status from Heclib.zcatalog(int[], HecDssCatalog)
    • callCatalog

      protected int callCatalog(String pathnameFilter)
      Constructs the (optionally filtered) internal pathname list from the DSS file. Pathname matching is performed in Java.
      Parameters:
      pathnameFilter - The pathname filter to use. If not null (no filtering), it may be one of:
      Filter Type Description Rules Examples
      Wildcards Pseudo pathname with optional "*" and "?" wildcard characters anywhere.
      • '*' character matches zero or more characters, including '/'
      • '?' character matches one character, including '/'
      • /*/*/Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • *Flow*
        Pathname contains Flow in any part
      Pathname Parts Specified pathname parts (can include wildcard characters "*" and "?")
      • Filter contains A=... B=... etc for A-F parts
      • Unspecified parts match anything, same as specifying "*"
      • Interior spaces are preserved, but quotes must be used to preserve beginning or trailing spaces
      • C=Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • B = Green River F = " Trial Run "
        Any A, C, D, and E parts, B part is Green River, F part is " Trial Run " (spaces preserved)
      All pathname matching is performed ignoring character case
      Returns:
      -4 if the object cannot access the DSS file, or otherwise the status from Heclib.zcatalog(int[], HecDssCatalog)
    • callCatalog

      protected int callCatalog(String pathnameFilter, int matcherType, boolean ignoreCase)
      Constructs the (optionally filtered) internal pathname list from the DSS file. Pathname matching is performed in Java.
      Parameters:
      pathnameFilter - The pathname filter to use. If not null (no filtering), it may be one of:
      Filter Type Description Rules Examples
      Wildcards Pseudo pathname with optional "*" and "?" wildcard characters.
      • '*' character matches zero or more characters, including '/'
      • '?' character matches one character, including '/'
      • /*/*/Flow*
        Any A, B, D, E, and F parts, C part starts with Flow
      • *Flow*
        Pathname contains Flow in any part
      Regular Expressions Pseudo pathname with regular expressions Java regular expressions are used
      • /*/*/(Flow|Stage).*
        Any A, B, D, E, and F parts, C part starts with Flow or Stage
      • .*(Flow|Stage).*
        Pathname contains Flow or Stage in any part
      Pathname Parts Specified pathname parts (can include wildcard characters or regular expressions)
      • Filter contains A=... B=... etc for A-F parts
      • Unspecified parts match anything, same as specifying wildcard "*" or regular expression ".*"
      • Interior spaces are preserved, but quotes must be used to preserve beginning or trailing spaces
      • C=Flow*
        (if matcherType == DssPathnameMatcher.MATCHER_TYPE_GLOB) Any A, B, D, E, and F parts, C part starts with Flow
      • C=(Flow|Stage).*
        (if matcherType == DssPathnameMatcher.MATCHER_TYPE_REGEX) Any A, B, D, E, and F parts, C part starts with Flow or Elev
      • B = Green River F = " Trial Run "
        Any A, C, D, and E parts, B part is Green River, F part is " Trial Run " (spaces preserved)
      matcherType - Specifies whether the pathname filter contains wildcards or regular expressions. Must be one of
      • DssPathnameMatcher.MATCHER_TYPE_GLOB
      • DssPathnameMatcher.MATCHER_TYPE_REGEX
      ignoreCase - Specifies whether pathname matching is to be performed with or without considering character case
      Returns:
      -4 if the object cannot access the DSS file, or otherwise the status from Heclib.zcatalog(int[], HecDssCatalog)
    • callCatalog

      protected int callCatalog(Pattern pattern)
      Constructs the (optionally filtered) internal pathname list from the DSS file. Pathname matching is performed in Java.
      Parameters:
      pattern - The pathname filter to use. May be null (no filtering). For best performance anchor start and of expression with '^' and '$' characters
      Returns:
      -4 if the object cannot access the DSS file, or otherwise the status from Heclib.zcatalog(int[], HecDssCatalog)
    • clearList

      protected void clearList()
    • whatChangedSetStart

      public int whatChangedSetStart()
    • whatChangedSetStart

      public int whatChangedSetStart(String pathnameWithWildChars, boolean useCRCforData)
    • whatChangedSetStart

      public int whatChangedSetStart(HecDssCatalog catalog, String pathnameWithWildChars, boolean useCRCforData)
    • whatChanged

      public String[] whatChanged()
    • whatChanged

      public String[] whatChanged(String pathWithWild)
    • whatChangedCompare

      public String[] whatChangedCompare(HecDssCatalog dssCatalogBefore, String pathWithWild, boolean boolUseCRC)
    • sortCatalog

      public int sortCatalog(String pathWithWildChar)
    • sort

      public String[] sort()
    • getCatalogSortAddresses

      protected long[] getCatalogSortAddresses()
    • setCatalogSortAddresses

      protected void setCatalogSortAddresses(long[] sortAddresses)
    • buildCondensedList

      protected void buildCondensedList(Vector<CondensedReference> condensedList)
    • compareCondensedPaths

      public static boolean compareCondensedPaths(String pathname1, String pathname2)
      Determine if the only difference between two pathnames is the D (date) part (and that part appears to be a date)
      Parameters:
      pathname1 - Description
      pathname2 - Description
      Returns:
      Description
    • getEPartLoc

      protected static void getEPartLoc(String pathname, int[] partLocs)
    • getPathnameList

      @Deprecated public String[] getPathnameList(boolean forceUpdate)
      Deprecated.
      Use getCatalog(boolean, String) instead. This will be removed in a future version of hec-monolith
      Description copied from class: HecDSSFileAccess
      DEPRECIATED, use HecDssCatalog class. public String[] getCatalog(boolean sorted, String pathWithWildChars)
      Overrides:
      getPathnameList in class HecDSSFileAccess
      Parameters:
      forceUpdate - not used
      Returns:
      String[] - a sorted list of pathnames. Null or 0 if this function could not get a list
      See Also:
    • getSortedPathnameList

      public String[] getSortedPathnameList(intArrayContainer startDatesContainer, intArrayContainer endDatesContainer, boolean forceUpdate)
    • getPathnameListAndDates

      public String[] getPathnameListAndDates(intArrayContainer startDatesContainer, intArrayContainer endDatesContainer)
    • getPathnameListType

      public String[] getPathnameListType(int statusWantedForList, int typeWantedStart, int typeWantedEnd)
    • setPathnameList

      public void setPathnameList(List<String> pathnames)
    • setPathnameList

      public void setPathnameList(String[] pathnames)
    • numberCatalogedRecords

      public int numberCatalogedRecords()
      Deprecated
    • searchDSSPaths

      public int searchDSSPaths(String aPart, String bPart, String cPart, String dPart, String ePart, String fPart, Vector pathnameList)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • searchDSSCatalog

      public int searchDSSCatalog(String aPart, String bPart, String cPart, String dPart, String ePart, String fPart, Vector pathnameList)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • searchDSSPaths

      public int searchDSSPaths(String scanString, List<String> pathnameList)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • searchDSSCatalog

      public int searchDSSCatalog(String scanString, List<String> pathnameList)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • processSearchParts

      protected String processSearchParts(String aPart, String bPart, String cPart, String dPart, String ePart, String fPart)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • getMaximumPartLengths

      protected int[] getMaximumPartLengths()
    • getMaximumPartLengths

      protected int[] getMaximumPartLengths(String[] paths)
    • buildSortedCatalog

      public String[] buildSortedCatalog()
    • getPathnameList

      protected int getPathnameList(String instructions, List<String> pathnameList)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • getPathnameList6

      protected int getPathnameList6(String instructions, Vector<String> pathnameList)
    • getPathnameList7

      protected int getPathnameList7(String instructions, List<String> pathnameList)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead NOT THREAD SAFE (only one thread can call this at a time)
    • getCatalogName

      public String getCatalogName(int catalogType)
    • createNewCatalog

      public int createNewCatalog(int catalogType)
      Deprecated use String[] getPathnameList(boolean forceUpdate) instead
    • isCatalogValid

      public boolean isCatalogValid()
    • readCatalog

      public String[] readCatalog()
    • writeCatalog

      public boolean writeCatalog(String dssFileName, String catalogName, String[] pathnames)
    • cleanCatalogPart

      protected int cleanCatalogPart(String inPart, StringBuffer outPart)
    • expandPathname

      public String[] expandPathname(String pathWithWild)
      Takes either a pathname with wild charaters, or a time series pathname with a implied time window (date span in D part) and returns the full list of pathnames for the input. If wild character(s) are used, the records must exist in the file If a time-series dataset, the pathnames do not have to exist (assuming no wild characters) If you have time-series datasets and want to use a wild character, it is much more efficient to do this (without blanks around *) /Basin/Location/ * / * /1Day/Obs/ If you have time-series without wild characters, this is more efficient /Basin/Location/Flow/02Jan1975 - 30Oct2012/1Day/Obs/ Can also be a regular pathname, which will be returned if it does not need to be expanded
      Parameters:
      pathWithWild -
      Returns:
    • clone

      public Object clone()
      Overrides:
      clone in class HecDSSFileAccess
    • fireHecDssEvent

      protected void fireHecDssEvent(HecDssEventType event)
    • addHecDssListener

      public void addHecDssListener(HecDssListener listener)
    • addHecDssListener

      public void addHecDssListener(HecDssListener listener, HecDssEventType requestedChangeType)
    • addHecDssListener

      public void addHecDssListener(HecDssListener listener, String pathWithWild)
    • addHecDssListener

      public void addHecDssListener(HecDssListener listener, String[] pathnames)
    • addHecDssListener

      public void addHecDssListener(HecDssListener listener, String[] pathnames, HecDssEventType requestedEventType)
    • addHecDssListener

      public void addHecDssListener(HecDssListener listener, String pathWithWild, HecDssEventType requestedEventType)
    • addHecDssListener

      protected void addHecDssListener(HecDssListener listener, String pathWithWild, String[] pathnames, HecDssEventType requestedEventType)
    • removeHecDssListener

      public void removeHecDssListener(HecDssListener listener)
    • hecDssEventPerformed

      public void hecDssEventPerformed(HecDssEventType source)
      Specified by:
      hecDssEventPerformed in interface HecDssListener
    • startObserverThread

      protected Thread startObserverThread(String pathWithWildChars, String[] pathnameList, HecDssEventType requestedEventType)