uk.ac.rdg.resc.jstyx
Class StyxUtils

java.lang.Object
  extended by uk.ac.rdg.resc.jstyx.StyxUtils

public class StyxUtils
extends java.lang.Object

Set of constants and useful static methods for the Styx protocol

Author:
Jon Blower $Revision: 604 $ $Date: 2006-03-21 14:58:42 +0000 (Tue, 21 Mar 2006) $ $Log$ Revision 1.12 2006/03/21 14:58:40 jonblower Implemented clear-text password-based authentication and did some simple tests Revision 1.11 2006/01/04 16:45:29 jonblower Implemented automatic termination of SGS instances using Quartz scheduler Revision 1.10 2006/01/04 11:24:56 jonblower Implemented time directory in the SGS instance namespace Revision 1.8 2005/03/18 13:55:55 jonblower Improved freeing of ByteBuffers, and bug fixes Revision 1.7 2005/03/16 22:16:41 jonblower Added Styx Grid Service classes to core module Revision 1.6 2005/03/16 17:55:46 jonblower Replaced use of java.nio.ByteBuffer with MINA's ByteBuffer to minimise copying of buffers Revision 1.5 2005/03/15 15:52:17 jonblower Added constant for maximum allowable message size Revision 1.4 2005/03/11 13:58:24 jonblower Merged MINA-Test_20059309 into main line of development Revision 1.3.2.1 2005/03/10 20:54:55 jonblower Removed references to Netty Revision 1.3 2005/03/09 16:59:51 jonblower Added HEADER_LENGTH Revision 1.2 2005/02/24 07:39:39 jonblower Added getDataSummary() Revision 1.1.1.1 2005/02/16 18:58:16 jonblower Initial import

Field Summary
static java.lang.String ANONYMOUS_USER
          The username for an anonymous user
static java.lang.String DEFAULT_GROUP
          When a client creates a file on the Styx server, this is the default group for the file.
static long DMAPPEND
           
static long DMAUTH
           
static long DMDIR
           
static long DMEXCL
           
static int HEADER_LENGTH
          The header length of a StyxMessage
static int MAX_MESSAGE_SIZE
          The maximum length of a single Styx message.
static int MAXPATHELEMENTS
           
static int MAXUBYTE
           
static long MAXUINT
           
static long MAXULONG
           
static int MAXUSHORT
           
static java.lang.String NEWLINE
           
static long NOFID
           
static int NOTAG
           
static int OEXEC
           
static int ORCLOSE
           
static int ORDWR
           
static int OREAD
           
static int OTRUNC
           
static int OWRITE
           
static java.lang.String SYSTEM_FILE_SEPARATOR
           
static java.lang.String SYSTEM_NEWLINE
           
static java.nio.charset.Charset UTF8
           
 
Constructor Summary
StyxUtils()
           
 
Method Summary
static java.lang.String dataToString(org.apache.mina.common.ByteBuffer buf)
          Gets the remaining contents of the given ByteBuffer (i.e.
static java.lang.String dataToString(java.nio.ByteBuffer buf)
          Gets the remaining contents of the given java.nio.ByteBuffer (i.e.
static java.lang.String formatAsXsdDateTime(java.util.Date date)
          Returns a date formatted according to the xsd:dateTime data type
static java.lang.String getDataSummary(int n, byte[] bytes)
           
static java.lang.String getDataSummary(int n, org.apache.mina.common.ByteBuffer data)
           
static void main(java.lang.String[] args)
          Simple test routine for the date parsing routines
static long now()
           
static java.util.Date parseXsdDateTime(java.lang.String date)
          Parses a String that is formatted according to the xsd:dateTime data type and returns it as a Date
static byte[] strToUTF8(java.lang.String str)
          Converts a string to a byte array in UTF-8
static java.lang.String utf8ToString(byte[] bytes)
          Converts an array of bytes in UTF-8 to a String
static java.lang.String utf8ToString(byte[] bytes, int offset, int length)
          Converts an array of bytes in UTF-8 to a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER_LENGTH

public static final int HEADER_LENGTH
The header length of a StyxMessage

See Also:
Constant Field Values

MAX_MESSAGE_SIZE

public static final int MAX_MESSAGE_SIZE
The maximum length of a single Styx message. This is actually an arbitrary figure; there is no reason why messages can't be larger than this

See Also:
Constant Field Values

MAXUBYTE

public static final int MAXUBYTE
See Also:
Constant Field Values

MAXUSHORT

public static final int MAXUSHORT
See Also:
Constant Field Values

MAXUINT

public static final long MAXUINT
See Also:
Constant Field Values

MAXULONG

public static final long MAXULONG
See Also:
Constant Field Values

NOTAG

public static final int NOTAG
See Also:
Constant Field Values

NOFID

public static final long NOFID
See Also:
Constant Field Values

MAXPATHELEMENTS

public static final int MAXPATHELEMENTS
See Also:
Constant Field Values

OREAD

public static final int OREAD
See Also:
Constant Field Values

OWRITE

public static final int OWRITE
See Also:
Constant Field Values

ORDWR

public static final int ORDWR
See Also:
Constant Field Values

OEXEC

public static final int OEXEC
See Also:
Constant Field Values

OTRUNC

public static final int OTRUNC
See Also:
Constant Field Values

ORCLOSE

public static final int ORCLOSE
See Also:
Constant Field Values

DMDIR

public static final long DMDIR
See Also:
Constant Field Values

DMAPPEND

public static final long DMAPPEND
See Also:
Constant Field Values

DMEXCL

public static final long DMEXCL
See Also:
Constant Field Values

DMAUTH

public static final long DMAUTH
See Also:
Constant Field Values

UTF8

public static final java.nio.charset.Charset UTF8

NEWLINE

public static final java.lang.String NEWLINE
See Also:
Constant Field Values

SYSTEM_NEWLINE

public static final java.lang.String SYSTEM_NEWLINE

SYSTEM_FILE_SEPARATOR

public static final java.lang.String SYSTEM_FILE_SEPARATOR

ANONYMOUS_USER

public static final java.lang.String ANONYMOUS_USER
The username for an anonymous user

See Also:
Constant Field Values

DEFAULT_GROUP

public static final java.lang.String DEFAULT_GROUP
When a client creates a file on the Styx server, this is the default group for the file. All users belong to this group.

See Also:
Constant Field Values
Constructor Detail

StyxUtils

public StyxUtils()
Method Detail

strToUTF8

public static byte[] strToUTF8(java.lang.String str)
Converts a string to a byte array in UTF-8


utf8ToString

public static java.lang.String utf8ToString(byte[] bytes)
Converts an array of bytes in UTF-8 to a String


utf8ToString

public static java.lang.String utf8ToString(byte[] bytes,
                                            int offset,
                                            int length)
Converts an array of bytes in UTF-8 to a String

Parameters:
bytes - The array of bytes to convert
offset - The index of the first byte in the array to convert
length - The number of bytes to convert

dataToString

public static java.lang.String dataToString(org.apache.mina.common.ByteBuffer buf)
Gets the remaining contents of the given ByteBuffer (i.e. the bytes between its position and limit) as a String. Leaves the position of the ByteBuffer unchanged.


dataToString

public static java.lang.String dataToString(java.nio.ByteBuffer buf)
Gets the remaining contents of the given java.nio.ByteBuffer (i.e. the bytes between its position and limit) as a String. Leaves the position of the ByteBuffer unchanged.


getDataSummary

public static java.lang.String getDataSummary(int n,
                                              org.apache.mina.common.ByteBuffer data)
Returns:
the first n bytes of the data in the given buffer as a String (in quotes), then the number of bytes remaining. Leaves the position of the ByteBuffer unchanged.

getDataSummary

public static java.lang.String getDataSummary(int n,
                                              byte[] bytes)
Returns:
the first n bytes of the data in the given byte array as a String (in quotes), then the number of bytes remaining.

now

public static long now()
Returns:
the current time in seconds since the epoch (Jan 1 00:00 1970 GMT), suitable for use in stat messages

formatAsXsdDateTime

public static java.lang.String formatAsXsdDateTime(java.util.Date date)
Returns a date formatted according to the xsd:dateTime data type

Parameters:
date - the date to format.
Returns:
the formatted date.

parseXsdDateTime

public static java.util.Date parseXsdDateTime(java.lang.String date)
                                       throws java.text.ParseException
Parses a String that is formatted according to the xsd:dateTime data type and returns it as a Date

Parameters:
date - the String to format.
Returns:
the parse date.
Throws:
java.text.ParseException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Simple test routine for the date parsing routines

Throws:
java.lang.Exception


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.