com.wewebu.ow.server.util
Class OwResourceProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by com.wewebu.ow.server.util.OwResourceProperties
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class OwResourceProperties
extends Properties

Class which upgrades the java.util.Properties with several methods. Also needed to read .properties files with different encoding, if there are saved in using a unicode encoding.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com

Since:
2.2.0.0
See Also:
Serialized Form

Field Summary
static int BOM_SIZE
          Bytes to be read for analyze UNICODE (UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE) information [Byte Order Mark].
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
OwResourceProperties()
           
 
Method Summary
static String getResourceEncoding(byte[] analyse_p)
          Static function for analyzing the BOM of a file, and returning an encoding or null if no valid BOM is defined.
static String getResourceEncoding(PushbackInputStream pushStream)
          Reads encoding type and skips BOM bits
static String getResourceEncoding(URL url_p)
          Static function for analyzing resource defined by the URL.
 void load(Reader reader_p)
          Since the Alfresco Workdesk is supporting also the JRE 1.4.2, the java.util.Properties are also upgraded with a load(Reader) method - like in java 6.
 void load(URL resource_p)
          Upgrade of standard java.util.Properties, so we can analyze the encoding of the file.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BOM_SIZE

public static final int BOM_SIZE
Bytes to be read for analyze UNICODE (UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE) information [Byte Order Mark].

For more Information read: http://unicode.org/faq/utf_bom.html#BOM

See Also:
Constant Field Values
Constructor Detail

OwResourceProperties

public OwResourceProperties()
Method Detail

load

public void load(URL resource_p)
          throws IOException
Upgrade of standard java.util.Properties, so we can analyze the encoding of the file. If resource_p is a unicode file, we use the load(Reader) method and a reader with the specified character encoding to read and convert the contained strings.

Parameters:
resource_p - URL to the specific resource
Throws:
IOException - throws if as example the resource was not found.

load

public void load(Reader reader_p)
          throws IOException
Since the Alfresco Workdesk is supporting also the JRE 1.4.2, the java.util.Properties are also upgraded with a load(Reader) method - like in java 6. This method reads a properties file, using the specified character encoding of the Reader.

Overrides:
load in class Properties
Parameters:
reader_p - Any Reader extending the java.io.Reader class.
Throws:
IOException

getResourceEncoding

public static String getResourceEncoding(URL url_p)
                                  throws IOException
Static function for analyzing resource defined by the URL. This method try to open a stream using the given URL, and read the first 4 bytes of the resource.

Parameters:
url_p - URL to the specific resource
Returns:
String representing the unicode character set, or null if no BOM defined.
Throws:
IOException
See Also:
getResourceEncoding(byte[])

getResourceEncoding

public static String getResourceEncoding(byte[] analyse_p)
Static function for analyzing the BOM of a file, and returning an encoding or null if no valid BOM is defined.

Parameters:
analyse_p - byte[4] BOM (= Byte Order Mark) - the first 4 bytes of a file or resource.
Returns:
String representing the encoding of the unicode file, or null if BOM is not valid.

getResourceEncoding

public static String getResourceEncoding(PushbackInputStream pushStream)
                                  throws IOException
Reads encoding type and skips BOM bits

Parameters:
pushStream - PushbackInputStream
Returns:
Encoding String
Throws:
IOException
Since:
3.2.0.2


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.