org.gvsig.remoteclient.utils
Class Utilities

java.lang.Object
  extended by org.gvsig.remoteclient.utils.Utilities

public class Utilities
extends java.lang.Object

Clase con métodos de utilidad en el protocolo WMS


Constructor Summary
Utilities()
           
 
Method Summary
static void cleanUpTempFiles()
          Cleans every temporal file previously downloaded.
static void createTemp(java.lang.String fileName, java.lang.String data)
          Crea un fichero temporal con un nombre concreto y unos datos pasados por parámetro.
static java.util.Vector createVector(java.lang.String str, java.lang.String c)
          Parses the String containing different items [character] separated and creates a vector with them.
static java.io.File downloadFile(java.net.URL url, java.lang.String name, org.gvsig.compat.net.ICancellable cancel)
          Downloads an URL into a temporary file that is removed the next time the tempFileManager class is called, which means the next time gvSIG is launched.
static java.io.File downloadFile(java.net.URL url, java.lang.String data, java.lang.String name, org.gvsig.compat.net.ICancellable cancel)
          Downloads a URL using the HTTP Post protocol
static byte[] eliminarDTD(byte[] bytes, java.lang.String startTag)
          Elimina del xml la declaración del DTD
static boolean isNumber(java.lang.String s)
          Checks if a String is a number or not
static boolean isTextData(byte[] data)
          Deprecated.  
static boolean isTextFile(java.io.File file)
          Checks a File and tries to figure if the file is a text or a binary file.
static boolean isTextFile(java.io.File file, int byteAmount)
          Checks a File and tries to figure if the file is a text or a binary file.
static boolean isValidVersion(java.lang.String version)
           
static void removeURL(java.lang.Object url)
          Remove an URL from the system cache.
static void removeURL(java.net.URL url)
          Remove an URL from the system cache.
static void serializar(java.io.InputStream in, java.io.OutputStream out)
          Copia el contenido de un InputStream en un OutputStream
static java.lang.String Vector2CS(java.util.Vector v)
          Converts the contents of a Vector to a comma separated list
static java.lang.String Vector2URLParamString(java.util.Vector v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

isTextFile

public static boolean isTextFile(java.io.File file)
Checks a File and tries to figure if the file is a text or a binary file.
Keep in mind that binary files are those that contains at least one non-printable character.

Parameters:
file -
Returns:
true when the file is pretty problably text, false if the file is binary.

isTextFile

public static boolean isTextFile(java.io.File file,
                                 int byteAmount)
Checks a File and tries to figure if the file is a text or a binary file.
Keep in mind that binary files are those that contains at least one non-printable character.

Parameters:
file -
byteAmount, - number of bytes to check.
Returns:
true when the file is pretty problably text, false if the file is binary.

isTextData

public static boolean isTextData(byte[] data)
Deprecated. 

Checks a byte array and tells if it contains only text or contains any binary data.

Parameters:
file -
Returns:
true when the data is only text, false otherwise.

serializar

public static void serializar(java.io.InputStream in,
                              java.io.OutputStream out)
Copia el contenido de un InputStream en un OutputStream

Parameters:
in - InputStream
out - OutputStream

eliminarDTD

public static byte[] eliminarDTD(byte[] bytes,
                                 java.lang.String startTag)
Elimina del xml la declaración del DTD

Parameters:
bytes - bytes del fichero XML de respuesta a getCapabilities
startTag - Tag raiz del xml respuesta a getCapabilities
Returns:
bytes del fichero XML sin la declaración del DTD

Vector2CS

public static java.lang.String Vector2CS(java.util.Vector v)
Converts the contents of a Vector to a comma separated list


isValidVersion

public static boolean isValidVersion(java.lang.String version)

createTemp

public static void createTemp(java.lang.String fileName,
                              java.lang.String data)
                       throws java.io.IOException
Crea un fichero temporal con un nombre concreto y unos datos pasados por parámetro.

Parameters:
fileName - Nombre de fichero
data - datos a guardar en el fichero
Throws:
java.io.IOException

isNumber

public static boolean isNumber(java.lang.String s)
Checks if a String is a number or not

Parameters:
String, - s
Returns:
boolean, true if s is a number

createVector

public static java.util.Vector createVector(java.lang.String str,
                                            java.lang.String c)
Parses the String containing different items [character] separated and creates a vector with them.

Parameters:
str - String contains item1[c]item2[c]item3...
c - is the string value for separating the items
Returns:
Vector containing all the items

Vector2URLParamString

public static java.lang.String Vector2URLParamString(java.util.Vector v)
Parameters:
dimensions -
Returns:

downloadFile

public static java.io.File downloadFile(java.net.URL url,
                                        java.lang.String name,
                                        org.gvsig.compat.net.ICancellable cancel)
                                 throws java.io.IOException,
                                        java.net.ConnectException,
                                        java.net.UnknownHostException
Downloads an URL into a temporary file that is removed the next time the tempFileManager class is called, which means the next time gvSIG is launched.

Parameters:
url -
name -
Returns:
Throws:
java.io.IOException
ServerErrorResponseException
java.net.ConnectException
java.net.UnknownHostException

downloadFile

public static java.io.File downloadFile(java.net.URL url,
                                        java.lang.String data,
                                        java.lang.String name,
                                        org.gvsig.compat.net.ICancellable cancel)
                                 throws java.io.IOException,
                                        java.net.ConnectException,
                                        java.net.UnknownHostException
Downloads a URL using the HTTP Post protocol

Parameters:
url - The server URL
data - The data to send in the request
name - A common name for all the retrieved files
cancel - Used to cancel the downloads
Returns:
The retrieved file
Throws:
java.io.IOException
java.net.ConnectException
java.net.UnknownHostException

cleanUpTempFiles

public static void cleanUpTempFiles()
Cleans every temporal file previously downloaded.


removeURL

public static void removeURL(java.net.URL url)
Remove an URL from the system cache. The file will remain in the file system for further eventual uses.

Parameters:
request -

removeURL

public static void removeURL(java.lang.Object url)
Remove an URL from the system cache. The file will remain in the file system for further eventual uses.

Parameters:
request -


Copyright © 2004-2013 gvSIG. All Rights Reserved.