xmlBlaster 2.2.0 API

org.xmlBlaster.util.def
Class PriorityEnum

java.lang.Object
  extended by org.xmlBlaster.util.def.PriorityEnum
All Implemented Interfaces:
java.io.Serializable

public final class PriorityEnum
extends java.lang.Object
implements java.io.Serializable

This class simulates an enumeration for queue priorities, it ensures that only valid priorities are used.

Note that this implementation has a fixed number of priorities, namely from 0 (lowest) to 9 (highest). For performance reasons we have not used an interface in the queue implementation to hide this priority implementation (calling a method through an interface takes 20 CPU cycles instead of 2).

If you need a different set of priorities, replace this implementation or change it to support an adjustable amount of priorities.

Author:
xmlBlaster@marcelruff.info
See Also:
Serialized Form

Nested Class Summary
private static class PriorityEnum.SerializedForm
           
 
Field Summary
static PriorityEnum HIGH_PRIORITY
          The higher priority of a message (7 or HIGH).
static PriorityEnum HIGH8_PRIORITY
          The higher priority of a message (8).
private static java.lang.Integer[] integerArr
          Create Integer instances for each priority, for performance reasons only.
static PriorityEnum LOW_PRIORITY
          The lower priority of a message (3 or LOW).
static PriorityEnum LOW4_PRIORITY
          The lower priority of a message (4).
static PriorityEnum MAX_PRIORITY
          The maximum priority of a message (9 or MAX).
static PriorityEnum MIN_PRIORITY
          The minimum priority of a message (0 or MIN).
static PriorityEnum MIN1_PRIORITY
          The minimum priority of a message (1).
static PriorityEnum MIN2_PRIORITY
          The minimum priority of a message (2).
static PriorityEnum NORM_PRIORITY
          The default priority of a message (5 or NORM).
static PriorityEnum NORM6_PRIORITY
          The default priority of a message (6).
private  int priority
           
private static PriorityEnum[] priorityEnumArr
          For good performance have a static array of all priorities
private static long serialVersionUID
           
 
Constructor Summary
private PriorityEnum()
           
private PriorityEnum(int priority)
           
 
Method Summary
 int getInt()
          Returns the int representation of this priority
 java.lang.Integer getInteger()
          Returns the Integer representation of this priority
static void main(java.lang.String[] args)
          java org.xmlBlaster.util.def.PriorityEnum
static PriorityEnum parsePriority(java.lang.String prio)
          Parses given string to extract the priority of a message
static PriorityEnum parsePriority(java.lang.String priority, PriorityEnum defaultPriority)
          Parses given string to extract the priority of a message
static PriorityEnum toPriorityEnum(int priority)
          Checks the given int and returns the corresponding PriorityEnum instance.
 java.lang.String toString()
          Return a human readable string of the priority
 java.lang.Object writeReplace()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

priority

private final int priority

MIN_PRIORITY

public static final PriorityEnum MIN_PRIORITY
The minimum priority of a message (0 or MIN).


MIN1_PRIORITY

public static final PriorityEnum MIN1_PRIORITY
The minimum priority of a message (1).


MIN2_PRIORITY

public static final PriorityEnum MIN2_PRIORITY
The minimum priority of a message (2).


LOW_PRIORITY

public static final PriorityEnum LOW_PRIORITY
The lower priority of a message (3 or LOW).


LOW4_PRIORITY

public static final PriorityEnum LOW4_PRIORITY
The lower priority of a message (4).


NORM_PRIORITY

public static final PriorityEnum NORM_PRIORITY
The default priority of a message (5 or NORM).


NORM6_PRIORITY

public static final PriorityEnum NORM6_PRIORITY
The default priority of a message (6).


HIGH_PRIORITY

public static final PriorityEnum HIGH_PRIORITY
The higher priority of a message (7 or HIGH).


HIGH8_PRIORITY

public static final PriorityEnum HIGH8_PRIORITY
The higher priority of a message (8).


MAX_PRIORITY

public static final PriorityEnum MAX_PRIORITY
The maximum priority of a message (9 or MAX).


priorityEnumArr

private static final PriorityEnum[] priorityEnumArr
For good performance have a static array of all priorities


integerArr

private static final java.lang.Integer[] integerArr
Create Integer instances for each priority, for performance reasons only.

Constructor Detail

PriorityEnum

private PriorityEnum(int priority)

PriorityEnum

private PriorityEnum()
Method Detail

toString

public java.lang.String toString()
Return a human readable string of the priority

Overrides:
toString in class java.lang.Object

getInt

public final int getInt()
Returns the int representation of this priority


getInteger

public final java.lang.Integer getInteger()
Returns the Integer representation of this priority


toPriorityEnum

public static final PriorityEnum toPriorityEnum(int priority)
                                         throws java.lang.IllegalArgumentException
Checks the given int and returns the corresponding PriorityEnum instance.

Parameters:
prio - For example 7
Returns:
The enumeration object for this priority
Throws:
java.lang.IllegalArgumentException - if the given priority is invalid

parsePriority

public static final PriorityEnum parsePriority(java.lang.String prio)
                                        throws java.lang.IllegalArgumentException
Parses given string to extract the priority of a message

Parameters:
prio - For example "HIGH" or 7
Returns:
The PriorityEnum instance for the message priority
Throws:
java.lang.IllegalArgumentException - if the given priority is invalid

parsePriority

public static final PriorityEnum parsePriority(java.lang.String priority,
                                               PriorityEnum defaultPriority)
Parses given string to extract the priority of a message

Parameters:
prio - For example "HIGH" or 7
defaultPriority - Value to use if not parsable
Returns:
The PriorityEnum instance for the message priority

writeReplace

public java.lang.Object writeReplace()
                              throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

main

public static void main(java.lang.String[] args)
java org.xmlBlaster.util.def.PriorityEnum


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.