Package org.astrogrid.samp.bridge
Class UrlExporter
- java.lang.Object
-
- org.astrogrid.samp.bridge.UrlExporter
-
class UrlExporter extends java.lang.Object
Exports SAMP data objects which have been created on a given host for use in a remote context. The job that needs doing is to convert URLs which reference the host in a way that only makes sense locally (as a loopback address 127.0.0.1 or localhost) to a form which can be used on remote hosts.This is not an exact science; a best effort is made.
- Since:
- 29 Jul 2009
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
exportFiles_
private static java.util.regex.Pattern
FILE_REGEX
private java.lang.String
host_
private static java.util.regex.Pattern
LOCALHOST_REGEX
private static java.util.logging.Logger
logger_
-
Constructor Summary
Constructors Constructor Description UrlExporter(java.lang.String host, boolean exportFiles)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
doExportString(java.lang.String text)
Does the work forexportString(java.lang.String)
.void
exportList(java.util.List list)
Exports a list for remote usage by changing its contents in place.void
exportMap(java.util.Map map)
Exports a map for remote usage by changing its contents in place.java.lang.String
exportString(java.lang.String text)
Exports a single string for remote usage.
-
-
-
Field Detail
-
host_
private final java.lang.String host_
-
exportFiles_
private final boolean exportFiles_
-
logger_
private static final java.util.logging.Logger logger_
-
LOCALHOST_REGEX
private static final java.util.regex.Pattern LOCALHOST_REGEX
-
FILE_REGEX
private static final java.util.regex.Pattern FILE_REGEX
-
-
Constructor Detail
-
UrlExporter
public UrlExporter(java.lang.String host, boolean exportFiles)
Constructor.- Parameters:
host
- public name of the host to which loopback addresses referexportFiles
- whether to export file-protocol URLs by turning them into http ones; this only makes sense if the current JVM is running on a machine which can seehost
's filesystem(s)
-
-
Method Detail
-
exportString
public java.lang.String exportString(java.lang.String text)
Exports a single string for remote usage. If it looks like a URL, it's changed. Not foolproof.- Parameters:
text
- string to assess- Returns:
- copy of text if it's not a URL, otherwise a possibly edited URL with the same content
-
doExportString
private java.lang.String doExportString(java.lang.String text)
Does the work forexportString(java.lang.String)
.- Parameters:
text
- string to assess- Returns:
- copy of text if it's not a URL, otherwise a URL with a possibly edited host part
-
exportList
public void exportList(java.util.List list)
Exports a list for remote usage by changing its contents in place.- Parameters:
list
- list to edit
-
exportMap
public void exportMap(java.util.Map map)
Exports a map for remote usage by changing its contents in place.- Parameters:
map
- map to edit
-
-