wyvern.lib
Class Kernel

java.lang.Object
  extended bywyvern.lib.Kernel
All Implemented Interfaces:
RPCConstants

public final class Kernel
extends java.lang.Object
implements RPCConstants

Has the most commonly used game engine functions in one convenient location. Reduces the number of kernel classes that game classes have to import.

The Kernel is an example of the Facade pattern, and delegates most of its calls to other kernel objects. You can call these objects directly in many cases, if you like.

Version:
1.0, Nov 26, 1999
Author:
Steve Yegge

Nested Class Summary
 
Nested classes inherited from class wyvern.common.net.RPCConstants
RPCConstants.ImageAlign, RPCConstants.ImageFlags, RPCConstants.ImageFormat, RPCConstants.OutputView, RPCConstants.TextStyle
 
Field Summary
static java.lang.String DATE_FORMAT
          The format string that the Kernel uses for formatting dates used in properties such as "last-login".
static int ONE_DAY
          Number of milliseconds in one day (24 hours)
static int ONE_HOUR
          Number of milliseconds in one hour.
static int ONE_MINUTE
          Number of milliseconds in one minute.
static int ONE_MONTH
          Approx. number of milliseconds in one month (30 days).
static int ONE_SECOND
          Number of milliseconds in one minute.
static int ONE_WEEK
          Number of milliseconds in one week (7 days)
static int ONE_YEAR
          Approx. number of milliseconds in one year (365 days).
 
Fields inherited from interface wyvern.common.net.RPCConstants
ALERT_EVENT, CHAR_BANISHED, CHAR_BANNED, CHARACTER_NOT_FOUND, CLIENT_END_MUSIC_COMMAND, CLIENT_END_SOUND_COMMAND, CONNECT_RESULT, FLUSH_GRAPHICS, GND_ADD, GND_MODIFY, GND_REMOVE, GND_RESEND, INV_ADD, INV_MODIFY, INV_REMOVE, INV_RESEND, INVALID_PASSWORD, IP_BANISHED, LOGIN_FAILURE, LOGIN_SUCCESS, LOGINS_DISABLED, MAX_IMAGE_SIZE, MUSIC_EVENT, OTHER_LOGIN_ERROR, PAUSE_SOUND, PLAY_ALERT, PLAY_MUSIC, PLAY_SOUND, PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR, QUIT, REGISTER_EXISTING_PLAYER, RESUME_SOUND, SAME_EMAIL_ONLINE, SEND_FILE, SEND_IMAGE, SEND_PICTURE, SEND_TILE, SEND_TILE_MAPPINGS, SERVER_TRANSFER, SET_GAIN, SOUND_EVENT, STAT_SEND_SPELLS, STAT_SET_FOOD, STAT_SET_GOLD, STAT_SET_HP, STAT_SET_LEVEL, STAT_SET_LOAD, STAT_SET_NAME, STAT_SET_RANGE, STAT_SET_SP, STAT_SET_XP, STAT_START_POISON, STAT_STOP_POISON, STAT_UPDATE_ALL, STOP_ALL_SOUNDS, STOP_MUSIC, STOP_SOUND, TEXT_OUT, TOO_MANY_PLAYERS, UNCACHE_IMAGE, XML_COMMAND, XML_COMMAND_WITH_COMPRESSED_DATA, XML_COMMAND_WITH_DATA, ZIP_PARTIAL_SCREEN, ZIP_SCREEN, ZIP_TEXT_OUT
 
Constructor Summary
Kernel()
           
 
Method Summary
static boolean adjacentTo(GameObject o1, GameObject o2)
          Returns true if two objects are adjacent to one another.
static boolean adjacentTo(GameObject obj, Point p)
          Returns true if the specified Point is adjacent to the specified GameObject.
static boolean canPK(GameObject agent, GameObject target)
          Implements rules for Player Killing.
static void config(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a CONFIG message.
static void config(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a CONFIG message.
static EventQueue createEventQueue(Commandable owner)
          Creates an EventQueue to associated with a Commandable object.
static void entering(java.lang.Class sourceClass, java.lang.String sourceMethod)
          Logs a method entry.
static void entering(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
          Logs a method entry.
static void entering(java.lang.String sourceClass, java.lang.String sourceMethod)
          Logs a method entry.
static void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
          Logs a method entry.
static void exiting(java.lang.Class sourceClass, java.lang.String sourceMethod)
          Logs a method return.
static void exiting(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.Object result)
          Logs a method return.
static void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)
          Logs a method return.
static void exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)
          Logs a method return.
static java.lang.String extractWizNameFromClass(java.lang.String path)
          Given a java classname, such as "wyvern.wiz.foobar.whatever.Thing", extracts the wizard name from the classname, if present.
static java.lang.String extractWizNameFromPath(java.lang.String path)
          Given a relative path, e.g.
static void fine(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a FINE message.
static void fine(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a FINE message.
static void finer(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a FINER message.
static void finer(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a FINER message.
static void finest(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a FINEST message.
static void finest(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a FINEST message.
static java.lang.String formatDate(java.util.Date date)
          Formats the specified Date in the format we use for date properties.
static java.lang.String getDate()
          Returns the current date and time, formatted as a String suitable for writing into a property value.
static java.util.logging.Logger getLog(java.lang.String path)
          Gets a Logger for a file under admin/logs.
static java.lang.String getLogLevel(java.lang.String name)
          Returns the java.util.logging.Level for a Logger specified by name.
static Predicate getNameMatchPredicate(java.lang.String name)
          Takes an object description and returns a predicate suitable for finding it.
static java.lang.String getTime()
          Returns the current time, formatted as hours and minutes.
static java.util.logging.Logger getWizLogger(java.lang.String wizname)
          Returns a Logger that writes to a specified wizard logfile.
static java.util.logging.Logger getWizLogger(java.lang.String wizname, java.lang.String path)
          Returns a Logger for the specified file in a wiz directory.
static void info(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs an INFO message.
static void info(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs an INFO message.
static GameObject instantiate(Archetype arch)
          Instantiates an archetype by instantiating the class, then copying all the properties from the archetype to the new object.
 GameObject instantiate(Archetype arch, boolean moveProps)
          Instantiates an archetype by instantiating the class, then setting the new object's parent pointer to point to the passed archetype.
static GameObject instantiate(java.lang.String archname)
          A high-level utility for that loads an archetype, instantiates its class, and initializes the resulting object from the archetype definition.
static GameObject instantiatePyGameObject(java.lang.String filename)
          Instantiates a python-based GameObject implementation.
static java.lang.Object instantiatePython(java.lang.String path, java.lang.Class type)
          Instantiates a Python object by loading it from a python file.
static boolean isInstance(GameObject obj, java.lang.String type)
          Returns true if the passed object derives from a specific archetype.
static boolean isInstance(PropertyList list, java.lang.String type)
          Returns true if the passed object derives from a specific archetype.
static void killTimer(Timer timer)
          Kills a timer.
static Archetype loadArchetype(java.lang.String name)
          Finds or loads the specified archetype, given its name.
static void log(java.lang.String log, java.lang.String msg)
          Logs a message to the specified logfile under admin/logs.
static void logError(java.lang.String msg)
          Logs an error to the system logfile.
static void logError(java.lang.String msg, java.lang.Throwable t)
          Logs an error message, with a stack trace included after the message.
static void logEvent(java.lang.String msg)
          Writes an event message to the system event log.
static boolean onKernelThread()
          Returns true if we're running on the "Kernel thread", meaning we have the map-exclusive.
static java.util.Date parseDate(java.lang.String date)
          Parses a date string in the format returned by Kernel.getDate().
static Point pointAdjacentTo(GameObject o1, GameObject o2)
          Fast check to see whether one object is adjacent to another.
static void println(java.lang.String msg)
          Alias for System.out.println, for debugging convenience.
static void publish(java.lang.String subject)
          Publishes a message with no Body or attachments.
static void publish(java.lang.String subject, java.util.Map attachments)
          Publishes a message with attachments, but no Body.
static void publish(java.lang.String subject, java.lang.Object body)
          Publishes a message with a body, but no attachments.
static void publish(java.lang.String subject, java.lang.Object body, java.util.Map attachments)
          Publishes a message with attachments, but no Body.
static void setLogLevel(java.lang.String name, java.util.logging.Level level)
          Sets the log level for a given Logger, specified by its name.
static void setLogLevel(java.lang.String name, java.lang.String level)
          Sets the log level for a given Logger, specified by its name.
static Timer setRepeatingTimer(long delay, long period, Timed callback)
          Registers a repeating timer to start after the specified delay.
static Timer setRepeatingTimer(long period, Timed callback)
          Registers a repeating timer.
static Timer setTimer(long delay, Timed callback)
          Registers a one-shot timer.
static void severe(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a SEVERE message.
static void severe(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a SEVERE message.
static void subscribe(Subscriber subscriber, java.lang.String subject)
          Registers a Subscriber for a particular subject.
static void throwing(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.Throwable t)
          Logs throwing an exception.
static void throwing(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable t)
          Logs throwing an exception to all registered Handlers for the source class that are enabled for the passed log level.
static void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable t)
          Logs throwing an exception.
static void unsubscribe(Subscriber subscriber, java.lang.String subject)
          De-registers a Subscriber for a particular subject.
static void warning(java.lang.Class sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a WARNING message.
static void warning(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Logs a WARNING message.
static void writeWizLog(java.lang.String wizname, java.lang.String path, java.lang.String msg)
          Logs a message into a specific logfile in a wiz directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
The format string that the Kernel uses for formatting dates used in properties such as "last-login".

See Also:
Constant Field Values

ONE_SECOND

public static final int ONE_SECOND
Number of milliseconds in one minute.

See Also:
Constant Field Values

ONE_MINUTE

public static final int ONE_MINUTE
Number of milliseconds in one minute.

See Also:
Constant Field Values

ONE_HOUR

public static final int ONE_HOUR
Number of milliseconds in one hour.

See Also:
Constant Field Values

ONE_DAY

public static final int ONE_DAY
Number of milliseconds in one day (24 hours)

See Also:
Constant Field Values

ONE_WEEK

public static final int ONE_WEEK
Number of milliseconds in one week (7 days)

See Also:
Constant Field Values

ONE_MONTH

public static final int ONE_MONTH
Approx. number of milliseconds in one month (30 days).

See Also:
Constant Field Values

ONE_YEAR

public static final int ONE_YEAR
Approx. number of milliseconds in one year (365 days).

See Also:
Constant Field Values
Constructor Detail

Kernel

public Kernel()
Method Detail

canPK

public static boolean canPK(GameObject agent,
                            GameObject target)
Implements rules for Player Killing.

Parameters:
agent - player doing the attack
target - target getting attacked
Returns:
true if the agent is allowed to kill the target. For 2 players, it's if they're both in the PK guild, or the map is a PK map. If either is a non-player, it's always true.

createEventQueue

public static EventQueue createEventQueue(Commandable owner)
Creates an EventQueue to associated with a Commandable object.

Returns:
a new EventQueue

loadArchetype

public static Archetype loadArchetype(java.lang.String name)
                               throws java.lang.Exception
Finds or loads the specified archetype, given its name.

Parameters:
name - the local path to the archetype file (e.g. terrain/dirt1)
Returns:
the Archetype
Throws:
java.lang.Exception
See Also:
ArchetypeManager.loadArchetype(java.lang.String)

instantiate

public static GameObject instantiate(java.lang.String archname)
                              throws java.lang.Exception
A high-level utility for that loads an archetype, instantiates its class, and initializes the resulting object from the archetype definition.

Parameters:
archname - the archetype to load (e.g. "spells/medium_fireball")
Returns:
an instance of the archetype
Throws:
java.lang.Exception
See Also:
ArchetypeManager.instantiate(java.lang.String)

instantiate

public static GameObject instantiate(Archetype arch)
                              throws java.lang.Exception
Instantiates an archetype by instantiating the class, then copying all the properties from the archetype to the new object. This is almost always the right way to instantiate an Archetype (the other way being to call Archetype.instantiate()). Archetype.instantiate() is currently under investigation to see if we should keep it.

Parameters:
arch - the archetype to instantiate
Returns:
the new object
Throws:
java.lang.Exception
See Also:
ArchetypeManager.instantiate(wyvern.lib.Archetype)

instantiate

public GameObject instantiate(Archetype arch,
                              boolean moveProps)
                       throws java.lang.Exception
Instantiates an archetype by instantiating the class, then setting the new object's parent pointer to point to the passed archetype.

Parameters:
arch - the archetype to instantiate
Throws:
java.lang.Exception

instantiatePyGameObject

public static GameObject instantiatePyGameObject(java.lang.String filename)
                                          throws java.lang.Exception
Instantiates a python-based GameObject implementation. Such objects are tagged with a "@python" property, for any game code that needs to know they were originally a python object. The value of the "@python" property is the relative path to the python file, using the same conventions as those used for archetype files.

Parameters:
filename - the absolute or relative path to a python file, e.g. "wiz/rhialto/python/foo.py" or "/games/wyvern/wiz/rhialto/python/foo.py". The method assumes that if the path starts with "/", it's an absolute path.
Returns:
the python-instantiated object
Throws:
java.lang.Exception
See Also:
ArchetypeManager.instantiatePyGameObject(java.lang.String)

instantiatePython

public static java.lang.Object instantiatePython(java.lang.String path,
                                                 java.lang.Class type)
                                          throws java.lang.Exception
Instantiates a Python object by loading it from a python file.

This method will automatically detect whether there is a jythonc-compiled version of the python class in the same directory. It will instantiate whichever one has been modified more recently. Note, however, that the game can only load a compiled version once per session, so if you make a change and recompile it, your compiled version won't be used until the next game reset.

You can get the path to the python file that was used for loading a particular python object by calling one of the getPythonFilePath() methods. Additionally, if type parameter to instantiatePython() is PropertyList.class, or a subclass of PropertyList (including GameObject and its sub-interfaces and implementation classes), then the returned object will be tagged with a "@python" PList property holding the relative path of the python file.

Parameters:
path - the absolute or relative path to a python file, e.g. "wiz/rhialto/python/foo.py" or "/games/wyvern/wiz/rhialto/python/foo.py". The method assumes that if the path starts with "/", it's an absolute path.
type - an instance of the java class which the python class inherits from. You need to pass this if you're going to cast the returned object into a Java class or interface. Required because of some complexities in the Jython software. You can cast the return value to an instance of this class. If you pass null, you'll be stuck with treating it as an Object.
Returns:
the instantiated object, which can be used (by casting) as whatever class you passed in for the type.
Throws:
an - exception if jython couldn't parse it, or it's not an instance of the passed type.
java.lang.Exception

isInstance

public static boolean isInstance(GameObject obj,
                                 java.lang.String type)
Returns true if the passed object derives from a specific archetype. Looks up the object's archetype-inheritance chain to see if the passed archetype is one of the parent archetypes for the object.

Note: GameObjects implement the PropertyList interface, so calling this method is the same as calling ArchetypeManager.isInstance(PropertyList, String). This version is just a convenience wrapper that calls that version.

See Also:
ArchetypeManager.isInstance(wyvern.lib.GameObject, java.lang.String)

isInstance

public static boolean isInstance(PropertyList list,
                                 java.lang.String type)
Returns true if the passed object derives from a specific archetype. Looks up the object's archetype-inheritance chain to see if the passed archetype is one of the parent archetypes for the object.

Parameters:
list - the property list to check (a GameObject or Archetype)
type - the path to the archetype, e.g. "objects/treasure/coins" or "wiz/foobar/misc/quest_item".
Returns:
true if the object inherits from the archetype
See Also:
ArchetypeManager.isInstance(wyvern.lib.PropertyList, java.lang.String)

setTimer

public static Timer setTimer(long delay,
                             Timed callback)
Registers a one-shot timer. This method will throw an IllegalArgumentException if any of the following conditions is true:

Parameters:
delay - the timer delay, in milliseconds.
callback - a Timed object to call when the time elapses
Returns:
a Timer object that can be used to kill the timer.
See Also:
Timers.setTimer(long, wyvern.lib.Timed)

setRepeatingTimer

public static Timer setRepeatingTimer(long period,
                                      Timed callback)
Registers a repeating timer. Note: this is almost never what you want. You usually want to use a wyvern.lib.properties.SuspendableTimer, so your timer will shut off if the map suspends or unloads.

This method will throw an IllegalArgumentException if any of the following conditions is true:

Parameters:
period - the timer interval, in milliseconds.
callback - a Timed object to call when the time elapses
Returns:
a token representing the timer
See Also:
Timers.setRepeatingTimer(wyvern.lib.Timed, long)

setRepeatingTimer

public static Timer setRepeatingTimer(long delay,
                                      long period,
                                      Timed callback)
Registers a repeating timer to start after the specified delay. Note: this is almost never what you want. You usually want to use a wyvern.lib.properties.SuspendableTimer, so your timer will shut off if the map suspends or unloads.

* This method will throw an IllegalArgumentException if any of the following conditions is true:

Parameters:
delay - how long to wait before the first timer is delivered
period - the timer interval, in milliseconds.
callback - a Timed object to call when the time elapses
Returns:
a token representing the timer
See Also:
Timers.setRepeatingTimer(wyvern.lib.Timed, long, long)

killTimer

public static void killTimer(Timer timer)
Kills a timer. If the timer isn't found in the queue, no exception is thrown; this is because the timer may have expired while this message was being processed.

Parameters:
timer - the Timer returned by setTimer.
See Also:
Timers.killTimer(wyvern.lib.Timer)

getNameMatchPredicate

public static Predicate getNameMatchPredicate(java.lang.String name)
Takes an object description and returns a predicate suitable for finding it. If the description is "ordinary", in that it doesn't have a number at the end, then this method just returns a NameMatchPredicate for the description. If the description is in the format "desc NN", where NN is some positive integer >= 1, then the method returns a CounterPredicate with count set to N and the predicate set to a NameMatchPredicate on the "desc" part of the description.

Parameters:
name - an object description, which may or may not have an item number at the end.
Returns:
a predicate suitable for finding the object.
See Also:
ItemDesc.getNameMatchPredicate(java.lang.String)

pointAdjacentTo

public static final Point pointAdjacentTo(GameObject o1,
                                          GameObject o2)
Fast check to see whether one object is adjacent to another.

Parameters:
o1 - first object
o2 - second object
Returns:
point in o1 adjacent to o2 if they're adjacent (or overlapping) returns null if objects not adjacent.

adjacentTo

public static final boolean adjacentTo(GameObject o1,
                                       GameObject o2)
Returns true if two objects are adjacent to one another.

Parameters:
o1 - the first object
o2 - the second object
Returns:
true if they have any points that are adjacent

adjacentTo

public static final boolean adjacentTo(GameObject obj,
                                       Point p)
Returns true if the specified Point is adjacent to the specified GameObject.

Parameters:
obj - the game object
p - the point to compare
Returns:
true if p is adjacent to any point in the object

println

public static void println(java.lang.String msg)
Alias for System.out.println, for debugging convenience. Won't be much help to you, though.


logError

public static void logError(java.lang.String msg)
Logs an error to the system logfile. Always writes it at log level java.util.logging.Level.SEVERE - you can call getLog() to return a Logger that lets you write messages at other log levels.

Parameters:
msg - a the message to write

logError

public static void logError(java.lang.String msg,
                            java.lang.Throwable t)
Logs an error message, with a stack trace included after the message.

Equivalent to Logging.getSytemLogger().throwing(msg, t)

Parameters:
msg - the message to log
t - the exception to print

logEvent

public static void logEvent(java.lang.String msg)
Writes an event message to the system event log. It's only used for startup, shutdown and reboot messages. You probably don't have any reason to call this method. Always logs at log level java.util.logging.Level.INFO.

Parameters:
msg - a message to log

log

public static void log(java.lang.String log,
                       java.lang.String msg)
Logs a message to the specified logfile under admin/logs. Always logs it at log level java.util.logging.Level.INFO. If you don't like that, you can call getLog() and call its methods directly.

Parameters:
log - the name of the logfile - it will have ".log" appended and go into the log directory. Don't create new logs unless you have specific approval for it.
msg - the message to log - it automatically has a timestamp put in front of it.

writeWizLog

public static void writeWizLog(java.lang.String wizname,
                               java.lang.String path,
                               java.lang.String msg)
Logs a message into a specific logfile in a wiz directory. Always logs it at log level java.util.logging.Level.INFO. If you don't like that, you can call getWizLogger() and call its methods directly.

Parameters:
wizname - the wizard's name
path - the path to the logfile under their wiz directory, such as "logs/quest.log"
msg - the message to write

getLog

public static java.util.logging.Logger getLog(java.lang.String path)
Gets a Logger for a file under admin/logs.

Parameters:
path - the path, relative to Wyvern.getLogDir()
Returns:
a Logger that can append to that log. Returns the system root logger,if we couldn't create a logger for the specified log.

getWizLogger

public static java.util.logging.Logger getWizLogger(java.lang.String wizname)
Returns a Logger that writes to a specified wizard logfile.

Parameters:
wizname - the wizard's name
Returns:
a Logger object that writes to wiz/wizname/error.log Its log level is set to the level for wyvern.kernel.maps.MapLoader, but you can change it to whatever you want.

getWizLogger

public static java.util.logging.Logger getWizLogger(java.lang.String wizname,
                                                    java.lang.String path)
Returns a Logger for the specified file in a wiz directory.

Parameters:
wizname - the wizard name
path - the relative path under the wiz dir, including the log filename. E.g. "logs/quest.log"

config

public static void config(java.lang.String sourceClass,
                          java.lang.String sourceMethod,
                          java.lang.String msg)
Logs a CONFIG message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

config

public static void config(java.lang.Class sourceClass,
                          java.lang.String sourceMethod,
                          java.lang.String msg)
Logs a CONFIG message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

fine

public static void fine(java.lang.String sourceClass,
                        java.lang.String sourceMethod,
                        java.lang.String msg)
Logs a FINE message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

fine

public static void fine(java.lang.Class sourceClass,
                        java.lang.String sourceMethod,
                        java.lang.String msg)
Logs a FINE message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

finer

public static void finer(java.lang.String sourceClass,
                         java.lang.String sourceMethod,
                         java.lang.String msg)
Logs a FINER message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

finer

public static void finer(java.lang.Class sourceClass,
                         java.lang.String sourceMethod,
                         java.lang.String msg)
Logs a FINER message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

finest

public static void finest(java.lang.String sourceClass,
                          java.lang.String sourceMethod,
                          java.lang.String msg)
Logs a FINEST message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

finest

public static void finest(java.lang.Class sourceClass,
                          java.lang.String sourceMethod,
                          java.lang.String msg)
Logs a FINEST message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

info

public static void info(java.lang.String sourceClass,
                        java.lang.String sourceMethod,
                        java.lang.String msg)
Logs an INFO message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the log message to write

info

public static void info(java.lang.Class sourceClass,
                        java.lang.String sourceMethod,
                        java.lang.String msg)
Logs an INFO message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the log message to write

severe

public static void severe(java.lang.String sourceClass,
                          java.lang.String sourceMethod,
                          java.lang.String msg)
Logs a SEVERE message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

severe

public static void severe(java.lang.Class sourceClass,
                          java.lang.String sourceMethod,
                          java.lang.String msg)
Logs a SEVERE message.

Parameters:
sourceClass - the class doing the logging
sourceMethod - the method where it's thrown
msg - the message to log

throwing

public static void throwing(java.util.logging.Level level,
                            java.lang.String sourceClass,
                            java.lang.String sourceMethod,
                            java.lang.String msg,
                            java.lang.Throwable t)
Logs throwing an exception to all registered Handlers for the source class that are enabled for the passed log level.

Parameters:
level - the level at which we care about the exception
sourceClass - the class you're logging from
sourceMethod - the method you're logging from
msg - the log message to print
t - the exception being thrown - the stack trace may or may not be logged, depending on the logger configuration for sourceClass

throwing

public static void throwing(java.lang.String sourceClass,
                            java.lang.String sourceMethod,
                            java.lang.Throwable t)
Logs throwing an exception.

Parameters:
sourceClass - the class you're logging from
sourceMethod - the method you're logging from
t - the exception to log

throwing

public static void throwing(java.lang.Class sourceClass,
                            java.lang.String sourceMethod,
                            java.lang.Throwable t)
Logs throwing an exception.

Parameters:
sourceClass - the class you're logging from
sourceMethod - the method you're logging from
t - the exception to log

warning

public static void warning(java.lang.String sourceClass,
                           java.lang.String sourceMethod,
                           java.lang.String msg)
Logs a WARNING message.

Parameters:
sourceClass - the class you're logging from
sourceMethod - the method you're logging from

warning

public static void warning(java.lang.Class sourceClass,
                           java.lang.String sourceMethod,
                           java.lang.String msg)
Logs a WARNING message.

Parameters:
sourceClass - the class you're logging from
sourceMethod - the method you're logging from

entering

public static void entering(java.lang.String sourceClass,
                            java.lang.String sourceMethod)
Logs a method entry. Done at log level FINER.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being entered

entering

public static void entering(java.lang.Class sourceClass,
                            java.lang.String sourceMethod)
Logs a method entry. Done at log level FINER.

Convenient use: "Log.entering(getClass(), "myMethod");"

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being entered

entering

public static void entering(java.lang.String sourceClass,
                            java.lang.String sourceMethod,
                            java.lang.Object[] params)
Logs a method entry. Done at log level FINER.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being entered
params - array of parameters to the method being entered

entering

public static void entering(java.lang.Class sourceClass,
                            java.lang.String sourceMethod,
                            java.lang.Object[] params)
Logs a method entry. Done at log level FINER.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being entered
params - array of parameters to the method being entered

exiting

public static void exiting(java.lang.String sourceClass,
                           java.lang.String sourceMethod)
Logs a method return.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being exited

exiting

public static void exiting(java.lang.Class sourceClass,
                           java.lang.String sourceMethod)
Logs a method return.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being exited

exiting

public static void exiting(java.lang.String sourceClass,
                           java.lang.String sourceMethod,
                           java.lang.Object result)
Logs a method return. Done at log level FINER.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being exited
result - Object that's being returned from the method

exiting

public static void exiting(java.lang.Class sourceClass,
                           java.lang.String sourceMethod,
                           java.lang.Object result)
Logs a method return. Done at log level FINER.

Parameters:
sourceClass - name of the class that issued the logging request
sourceMethod - name of the method being exited
result - Object that's being returned from the method

setLogLevel

public static void setLogLevel(java.lang.String name,
                               java.util.logging.Level level)
Sets the log level for a given Logger, specified by its name.

Parameters:
name - an identifier for a Logger - almost always a fully-qualified class name or a package name, such as "wyvern.kernel.maps.MapLoader", or "wyvern.wiz.legolas.jungle". If you specify a package name, the new logging level is set for every class in that package.
level - the new log level

setLogLevel

public static void setLogLevel(java.lang.String name,
                               java.lang.String level)
Sets the log level for a given Logger, specified by its name.

Parameters:
name - an identifier for a Logger - almost always a fully-qualified class name or a package name, such as "wyvern.kernel.maps.MapLoader", or "wyvern.wiz.legolas.jungle". If you specify a package name, the new logging level is set for every class in that package.
level - the new log level: "severe", "warning", "info", "config", "fine", "finer", "finest", "all", or "off"
Throws:
java.lang.IllegalArgumentException - if the passed level isn't one of the predefined java.util.logger.Level objects.

getLogLevel

public static java.lang.String getLogLevel(java.lang.String name)
Returns the java.util.logging.Level for a Logger specified by name.

Parameters:
name - the logger - usually a fully-qualified class name, or a package name.
Returns:
the parsed level name string, such as "SEVERE" or "756".

getDate

public static java.lang.String getDate()
Returns the current date and time, formatted as a String suitable for writing into a property value. The result can be parsed with parseDate().


formatDate

public static java.lang.String formatDate(java.util.Date date)
Formats the specified Date in the format we use for date properties.

Parameters:
date - the date to format
Returns:
the date string, formatted for setProperty()

parseDate

public static java.util.Date parseDate(java.lang.String date)
Parses a date string in the format returned by Kernel.getDate().

Parameters:
date - a date string created by Kernel.getDate()
Returns:
a Date object, or null if it couldn't be parsed

getTime

public static java.lang.String getTime()
Returns the current time, formatted as hours and minutes. Format is "h:mma" ("8:57am").


extractWizNameFromPath

public static java.lang.String extractWizNameFromPath(java.lang.String path)
Given a relative path, e.g. "wiz/rhialto/python/foo.py", "wiz/foo/bar", "local/trees", or "monsters/goblin/goblin", extracts the wizard name from the path, if present.

Parameters:
path - a path in any format (relative or absolute), as long as it uses forward-slashes as the path component separator.
Returns:
the component of the path immediately following the first instance of "wiz/", up to the next slash, or null if it didn't match.

extractWizNameFromClass

public static java.lang.String extractWizNameFromClass(java.lang.String path)
Given a java classname, such as "wyvern.wiz.foobar.whatever.Thing", extracts the wizard name from the classname, if present.

Parameters:
path - a java class
Returns:
the component of the path immediately following the first instance of "wiz.", up to the next dot, or null if it didn't match.

subscribe

public static void subscribe(Subscriber subscriber,
                             java.lang.String subject)
Registers a Subscriber for a particular subject. The Subscriber will continue to receive messages for that subject until it calls unsubscribe. Invokes wyvern.kernel.kernel.PubSub.subscribe().

Parameters:
subject - the subject to unregister for. Can be a single subject ( "foo.bar.whatever") or a set of subjects ("foo.bar."). If it ends with ".", it's considered to be a subject space for all subjects that start with that string.
subscriber - the Subscriber to receive notifications when messages are published to subject

unsubscribe

public static void unsubscribe(Subscriber subscriber,
                               java.lang.String subject)
De-registers a Subscriber for a particular subject. Invokes wyvern.kernel.kernel.PubSub.unsubscribe().

Parameters:
subject - the subject to unregister for. Can be a single subject ( "foo.bar.whatever") or a set of subjects ("foo.bar."). If it ends with ".", it's considered to be a subject space for all subjects that start with that string.
subscriber - the Subscriber to receive notifications when messages are published to subject

publish

public static void publish(java.lang.String subject)
Publishes a message with no Body or attachments. Invokes wyvern.kernel.kernel.PubSub.publish()


publish

public static void publish(java.lang.String subject,
                           java.lang.Object body)
Publishes a message with a body, but no attachments. This is the fastest publish mechanism if you have exactly one argument object to publish with the message - pass it in as the body.

Invokes wyvern.kernel.kernel.PubSub.publishBody(). If you have trouble invoking this method from Jython, try using the PubSub versions instead, which have non-overloaded names to make it easier for Jython.

Parameters:
subject - the subject for the message.
body - the body of the message

publish

public static void publish(java.lang.String subject,
                           java.util.Map attachments)
Publishes a message with attachments, but no Body. Use this when you need to publish a message with multiple data parameters. Invokes wyvern.kernel.kernel.PubSub.publish()

Parameters:
subject - the subject for the message.
attachments - a java.util.Map (usually a HashMap) containing the attachments objects.

publish

public static void publish(java.lang.String subject,
                           java.lang.Object body,
                           java.util.Map attachments)
Publishes a message with attachments, but no Body. Invokes wyvern.kernel.kernel.PubSub.publish()

Parameters:
subject - the subject for the message.
body - the body of the message
attachments - a java.util.Map (usually a HashMap) containing the attachments objects.

onKernelThread

public static boolean onKernelThread()
Returns true if we're running on the "Kernel thread", meaning we have the map-exclusive.