public class EntryTransforms extends java.lang.Object
AddeServer
to a
RemoteAddeEntry
.Modifier and Type | Field and Description |
---|---|
static Function<ucar.unidata.idv.chooser.adde.AddeServer,RemoteAddeEntry> |
convertIdvServer
|
private static java.lang.String |
cygwinPrefix |
private static int |
cygwinPrefixLength |
private static java.util.regex.Matcher |
hostMatcher
No sense in rebuilding things that don't need to be rebuilt.
|
private static java.util.regex.Pattern |
hostPattern
Matches "host" declarations in a MCTABLE file.
|
private static org.slf4j.Logger |
logger
Logger object.
|
private static java.util.regex.Matcher |
routeMatcher
No sense in rebuilding things that don't need to be rebuilt.
|
private static java.util.regex.Pattern |
routePattern
Matches dataset routing information in a MCTABLE file.
|
Modifier | Constructor and Description |
---|---|
private |
EntryTransforms()
This is a utility class.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addeFormatToStr(LocalAddeEntry.AddeFormat format) |
static void |
appendResolvFile(java.lang.String filename,
java.util.Collection<LocalAddeEntry> entries)
Writes a
Collection of LocalAddeEntries
to a "RESOLV.SRV" file. |
static java.util.List<java.lang.String> |
asResolvEntries(java.util.Collection<LocalAddeEntry> entries)
|
static java.lang.String |
asResolvEntry(LocalAddeEntry entry)
Converts a given
LocalAddeEntry into a String that is
suitable for including in a "RESOLV.SRV" file. |
protected static java.util.Set<AddeEntry> |
convertAddeServerXml(org.w3c.dom.Element root,
AddeEntry.EntrySource source)
|
static java.util.Set<RemoteAddeEntry> |
convertIdvServers(java.util.List<ucar.unidata.idv.chooser.adde.AddeServer> idvServers)
Converts given
idvServers to a
RemoteAddeEntries . |
static java.util.Set<ucar.unidata.idv.chooser.adde.AddeServer> |
convertMcvServers(java.util.Collection<AddeEntry> entries)
Converts given
AddeEntries to
AddeServers . |
protected static java.util.Set<RemoteAddeEntry> |
convertUserXml(org.w3c.dom.Element root)
|
static java.util.Set<RemoteAddeEntry> |
createEntriesFrom(RemoteAddeEntry entry) |
static java.lang.String |
demungeFileMask(java.lang.String path)
De-munges file mask strings.
|
static java.lang.String |
entryTypeToStr(AddeEntry.EntryType type)
Converts a given
AddeEntry.EntryType to its String representation. |
protected static java.util.Set<RemoteAddeEntry> |
extractMctableEntries(java.lang.String path,
java.lang.String username,
java.lang.String project) |
static java.util.Set<AddeEntry.EntryType> |
findEntryTypes(java.util.Collection<? extends AddeEntry> entries) |
private static java.util.Map<java.lang.String,java.lang.String> |
mapDatasetsToIp(java.util.Map<java.lang.String,java.lang.String> datasets,
java.util.Map<java.lang.String,java.lang.String> hostMap) |
private static java.util.List<RemoteAddeEntry> |
mapDatasetsToName(java.util.Map<java.lang.String,java.lang.String> datasetToHost,
java.util.Map<java.lang.String,java.lang.String> hostToIp,
java.lang.String username,
java.lang.String project)
This method is slightly confusing, sorry!
|
private static java.util.Map<java.lang.String,java.lang.String> |
mapIpToName(java.util.Map<java.lang.String,java.util.Set<java.lang.String>> map) |
static java.lang.String |
mungeFileMask(java.lang.String mask)
Munges a file mask
String into something "RESOLV.SRV"
expects. |
static java.util.Set<LocalAddeEntry> |
readResolvFile(java.lang.String filename)
Reads a "RESOLV.SRV" file and converts the contents into a
Set of LocalAddeEntries . |
static LocalAddeEntry |
readResolvLine(java.lang.String line)
Converts a
String containing a "RESOLV.SRV" entry
into a LocalAddeEntry . |
static java.util.Set<LocalAddeEntry> |
removeTemporaryEntriesFromResolvFile(java.lang.String filename,
java.util.Collection<LocalAddeEntry> entries) |
static java.lang.String |
serverNameToStr(LocalAddeEntry.ServerName serverName)
Converts a given
LocalAddeEntry.ServerName to its String representation. |
static LocalAddeEntry.AddeFormat |
strToAddeFormat(java.lang.String s)
Attempts to convert a
String into a member of LocalAddeEntry.AddeFormat . |
static AddeEntry.EntrySource |
strToEntrySource(java.lang.String s)
Attempts to convert a
String to an AddeEntry.EntrySource . |
static AddeEntry.EntryStatus |
strToEntryStatus(java.lang.String s)
Attempts to convert a
String into an AddeEntry.EntryStatus . |
static AddeEntry.EntryType |
strToEntryType(java.lang.String s)
Attempts to convert a
String to a AddeEntry.EntryType . |
static AddeEntry.EntryValidity |
strToEntryValidity(java.lang.String s)
Attempts to convert a
String to an AddeEntry.EntryValidity . |
static LocalAddeEntry.ServerName |
strToServerName(java.lang.String s)
Attempts to convert a
String to a LocalAddeEntry.ServerName . |
private static void |
writeResolvFile(java.lang.String filename,
boolean append,
java.util.Collection<LocalAddeEntry> entries)
Writes a
Collection of LocalAddeEntries
to a "RESOLV.SRV" file. |
static void |
writeResolvFile(java.lang.String filename,
java.util.Collection<LocalAddeEntry> entries)
Writes a
Collection of LocalAddeEntries
to a "RESOLV.SRV" file. |
private static final org.slf4j.Logger logger
private static final java.util.regex.Pattern routePattern
private static final java.util.regex.Pattern hostPattern
private static final java.util.regex.Matcher routeMatcher
private static final java.util.regex.Matcher hostMatcher
private static final java.lang.String cygwinPrefix
private static final int cygwinPrefixLength
public static final Function<ucar.unidata.idv.chooser.adde.AddeServer,RemoteAddeEntry> convertIdvServer
private EntryTransforms()
public static java.util.Set<AddeEntry.EntryType> findEntryTypes(java.util.Collection<? extends AddeEntry> entries)
public static java.util.Set<RemoteAddeEntry> convertIdvServers(java.util.List<ucar.unidata.idv.chooser.adde.AddeServer> idvServers)
idvServers
to a
RemoteAddeEntries
.idvServers
- "IDV-style" ADDE servers to convert.Set
of remote ADDE entries that corresponds to the unique
objects in idvServers
.public static java.util.Set<ucar.unidata.idv.chooser.adde.AddeServer> convertMcvServers(java.util.Collection<AddeEntry> entries)
AddeEntries
to
AddeServers
.entries
- "McIDAS-V style" ADDE entries to convert.Set
of AddeServer
objects that corresponds to
the ones found in entries
.protected static java.util.Set<RemoteAddeEntry> convertUserXml(org.w3c.dom.Element root)
root
- "Root" of the XML to convert.Set
of remote ADDE entries described by
root
.public static java.util.Set<RemoteAddeEntry> createEntriesFrom(RemoteAddeEntry entry)
protected static java.util.Set<AddeEntry> convertAddeServerXml(org.w3c.dom.Element root, AddeEntry.EntrySource source)
root
- XML to convert.source
- Used to "bulk set" the origin of whatever
remote ADDE entries get created.Set
of remote ADDE entries contained within root
.public static java.lang.String serverNameToStr(LocalAddeEntry.ServerName serverName)
LocalAddeEntry.ServerName
to its String
representation.
Note that the resulting String
is lowercase.serverName
- The server name to convert. Cannot be null
.serverName
converted to a lowercase String
.java.lang.NullPointerException
- if serverName
is null
.public static LocalAddeEntry.ServerName strToServerName(java.lang.String s)
String
to a LocalAddeEntry.ServerName
.s
- Value whose ServerName
is wanted.
Cannot be null
.ServerName
. If there was no "sensible"
conversion, the method returns LocalAddeEntry.ServerName.INVALID
.java.lang.NullPointerException
- if s
is null
.public static java.lang.String entryTypeToStr(AddeEntry.EntryType type)
AddeEntry.EntryType
to its String
representation.
Note that the resulting String
is lowercase.type
- The type to convert. Cannot be null
.type
converted to a lowercase String
.java.lang.NullPointerException
- if type
is null
.public static AddeEntry.EntryType strToEntryType(java.lang.String s)
String
to a AddeEntry.EntryType
.s
- Value whose EntryType
is wanted. Cannot be null
.EntryType
. If there was no "sensible"
conversion, the method returns AddeEntry.EntryType.UNKNOWN
.java.lang.NullPointerException
- if s
is null
.public static AddeEntry.EntrySource strToEntrySource(java.lang.String s)
String
to an AddeEntry.EntrySource
.s
- String
representation of an EntrySource
.
Cannot be null
.AddeEntry.EntrySource.valueOf(String)
to convert s
to an EntrySource
and returns. If no conversion was possible,
returns AddeEntry.EntrySource.USER
.java.lang.NullPointerException
- if s
is null
.public static AddeEntry.EntryValidity strToEntryValidity(java.lang.String s)
String
to an AddeEntry.EntryValidity
.s
- String
representation of an EntryValidity
.
Cannot be null
.AddeEntry.EntryValidity.valueOf(String)
to convert
s
to an EntryValidity
and returns. If no conversion
was possible, returns AddeEntry.EntryValidity.UNVERIFIED
.java.lang.NullPointerException
- if s
is null
.public static AddeEntry.EntryStatus strToEntryStatus(java.lang.String s)
String
into an AddeEntry.EntryStatus
.s
- String
representation of an EntryStatus
.
Cannot be null
.AddeEntry.EntryStatus.valueOf(String)
to convert s
into an EntryStatus
and returns. If no conversion was possible,
returns AddeEntry.EntryStatus.DISABLED
.java.lang.NullPointerException
- if s
is null
.public static LocalAddeEntry.AddeFormat strToAddeFormat(java.lang.String s)
String
into a member of LocalAddeEntry.AddeFormat
.
This method does a little bit of magic with the incoming String
:
s
- String
representation of an AddeFormat
. Cannot
be null
.LocalAddeEntry.AddeFormat.valueOf(String)
to convert
the modified String
into an AddeFormat
and
returns. If no conversion was possible, returns
LocalAddeEntry.AddeFormat.INVALID
.java.lang.NullPointerException
- if s
is null
.public static java.lang.String addeFormatToStr(LocalAddeEntry.AddeFormat format)
protected static java.util.Set<RemoteAddeEntry> extractMctableEntries(java.lang.String path, java.lang.String username, java.lang.String project)
private static java.util.List<RemoteAddeEntry> mapDatasetsToName(java.util.Map<java.lang.String,java.lang.String> datasetToHost, java.util.Map<java.lang.String,java.lang.String> hostToIp, java.lang.String username, java.lang.String project)
Basically create RemoteAddeEntries
by using
a hostname to determine which dataset belongs to which IP.
datasetToHost
- Map
of ADDE groups to host names.hostToIp
- Map
of host names to IP addresses.username
- ADDE username.project
- ADDE project number (as a String
).List
of RemoteAddeEntry
instances. Each hostname
will have a value from datasetToHost
and the accounting information
is formed from username
and project
.private static java.util.Map<java.lang.String,java.lang.String> mapIpToName(java.util.Map<java.lang.String,java.util.Set<java.lang.String>> map)
private static java.util.Map<java.lang.String,java.lang.String> mapDatasetsToIp(java.util.Map<java.lang.String,java.lang.String> datasets, java.util.Map<java.lang.String,java.lang.String> hostMap)
public static java.util.Set<LocalAddeEntry> readResolvFile(java.lang.String filename) throws java.io.IOException
Set
of LocalAddeEntries
.filename
- Filename containing desired local ADDE entries.
Cannot be null
.Set
of local ADDE entries contained within
filename
.java.io.IOException
- if there was a problem reading from filename
.readResolvLine(String)
public static LocalAddeEntry readResolvLine(java.lang.String line)
String
containing a "RESOLV.SRV" entry
into a LocalAddeEntry
.line
- Line from RESOLV.SRV
.LocalAddeEntry
that represents the given line
from RESOLV.SRV
.public static void writeResolvFile(java.lang.String filename, java.util.Collection<LocalAddeEntry> entries) throws java.io.IOException
Collection
of LocalAddeEntries
to a "RESOLV.SRV" file. This method discards the current
contents of filename
!filename
- Filename that will contain the local ADDE entries
within entries
. Cannot be null
.entries
- Set
of entries to be written to filename
.
Cannot be null
.java.io.IOException
- if there was a problem writing to filename
.appendResolvFile(String, Collection)
public static void appendResolvFile(java.lang.String filename, java.util.Collection<LocalAddeEntry> entries) throws java.io.IOException
Collection
of LocalAddeEntries
to a "RESOLV.SRV" file. This method will append the
contents of entries
to filename
.filename
- Filename that will contain the local ADDE entries within
entries
. Cannot be null
.entries
- Collection
of entries to be written to filename
.
Cannot be null
.java.io.IOException
- if there was a problem writing to filename
.writeResolvFile(String, Collection)
private static void writeResolvFile(java.lang.String filename, boolean append, java.util.Collection<LocalAddeEntry> entries) throws java.io.IOException
Collection
of LocalAddeEntries
to a "RESOLV.SRV" file.filename
- Filename that will contain the local ADDE entries within
entries
. Cannot be null
.append
- If true
, append entries
to
filename
. Otherwise discards contents of filename
.entries
- Collection
of entries to be written to
filename
. Cannot be null
.java.io.IOException
- if there was a problem writing to filename
.appendResolvFile(String, Collection)
,
asResolvEntry(LocalAddeEntry)
public static java.util.Set<LocalAddeEntry> removeTemporaryEntriesFromResolvFile(java.lang.String filename, java.util.Collection<LocalAddeEntry> entries) throws java.io.IOException
java.io.IOException
public static java.lang.String demungeFileMask(java.lang.String path)
This process is largely used to generate "Windows-friendly" masks.
path
- File path to fix.path
with Windows fixes applied.java.lang.NullPointerException
- if path
is null
.public static java.lang.String mungeFileMask(java.lang.String mask)
String
into something "RESOLV.SRV"
expects.
Munging is only needed for Windows users--the process converts back slashes into forward slashes and prefixes with "/cygdrive/".
mask
- File mask that may need to be fixed before storing in
RESOLV.SRV
.RESOLV.SRV
.java.lang.NullPointerException
- if mask
is null
.public static java.util.List<java.lang.String> asResolvEntries(java.util.Collection<LocalAddeEntry> entries)
entries
- Collection
of entries to convert. Should not be
null
.entries
represented as strings.asResolvEntry(LocalAddeEntry)
public static java.lang.String asResolvEntry(LocalAddeEntry entry)
LocalAddeEntry
into a String
that is
suitable for including in a "RESOLV.SRV" file. This method
does not append a newline to the end of the String
.entry
- The LocalAddeEntry
to convert. Should not be
null
.entry
as a "RESOLV.SRV" entry.