OpenNMS API 1.1.4

org.opennms.netmgt.config
Class PollOutagesConfigFactory

java.lang.Object
  extended byorg.opennms.netmgt.config.PollOutagesConfigFactory

public final class PollOutagesConfigFactory
extends java.lang.Object

This is the singleton class used to load the configuration for the poller outages from the poll-outages xml file. Note:Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods.

Author:
Sowmya Nataraj, OpenNMS

Field Summary
private static java.lang.String FORMAT1
           
private static java.lang.String FORMAT2
           
private  Outages m_config
          The config class loaded from the config file
private static java.util.Map m_dayOfWeekMap
          The day of the week values to name mapping
private static boolean m_loaded
          This member is set to true if the configuration file has been loaded.
private static PollOutagesConfigFactory m_singleton
          The singleton instance of this factory
 
Constructor Summary
private PollOutagesConfigFactory(java.lang.String configFile)
          Private constructor
 
Method Summary
private static void createDayOfWeekMapping()
          Create the day of week mapping
static PollOutagesConfigFactory getInstance()
          Return the singleton instance of this factory.
 Interface[] getInterfaces(java.lang.String name)
          Return the interfaces for specified outage.
 Outage getOutage(java.lang.String name)
          Return the specified outage.
 Outage[] getOutages()
          Return the outages configured.
 Time[] getOutageTimes(java.lang.String name)
          Return the outage times for specified outage.
 java.lang.String getOutageType(java.lang.String name)
          Return the type for specified outage.
static void init()
          Load the config from the default config file and create the singleton instance of this factory.
 boolean isCurTimeInOutage(Outage out)
          Return if current time is part of specified outage.
 boolean isCurTimeInOutage(java.lang.String outName)
          Return if current time is part of specified outage.
 boolean isInterfaceInOutage(java.lang.String linterface, Outage out)
          Return if interfaces is part of specified outage.
 boolean isInterfaceInOutage(java.lang.String linterface, java.lang.String outName)
          Return if interfaces is part of specified outage.
 boolean isTimeInOutage(java.util.Calendar cal, Outage out)
          Return if time is part of specified outage.
 boolean isTimeInOutage(java.util.Calendar cal, java.lang.String outName)
          Return if time is part of specified outage.
static void reload()
          Reload the config from the default config file
private  void setOutCalTime(java.util.Calendar outCal, java.lang.String timeStr)
          Set the time in outCal from timeStr.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_singleton

private static PollOutagesConfigFactory m_singleton
The singleton instance of this factory


m_config

private Outages m_config
The config class loaded from the config file


m_loaded

private static boolean m_loaded
This member is set to true if the configuration file has been loaded.


m_dayOfWeekMap

private static java.util.Map m_dayOfWeekMap
The day of the week values to name mapping


FORMAT1

private static java.lang.String FORMAT1

FORMAT2

private static java.lang.String FORMAT2
Constructor Detail

PollOutagesConfigFactory

private PollOutagesConfigFactory(java.lang.String configFile)
                          throws java.io.IOException,
                                 org.exolab.castor.xml.MarshalException,
                                 org.exolab.castor.xml.ValidationException
Private constructor

Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.
Method Detail

createDayOfWeekMapping

private static void createDayOfWeekMapping()
Create the day of week mapping


setOutCalTime

private void setOutCalTime(java.util.Calendar outCal,
                           java.lang.String timeStr)
Set the time in outCal from timeStr. 'timeStr'is in either the 'dd-MMM-yyyy HH:mm:ss' or the 'HH:mm:ss' formats

Parameters:
outCal - the calendar in which time is to be set
timeStr - the time string

init

public static void init()
                 throws java.io.IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Load the config from the default config file and create the singleton instance of this factory.

Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

reload

public static void reload()
                   throws java.io.IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Reload the config from the default config file

Throws:
java.io.IOException - Thrown if the specified config file cannot be read/loaded
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

getInstance

public static PollOutagesConfigFactory getInstance()
Return the singleton instance of this factory.

Returns:
The current factory instance.
Throws:
java.lang.IllegalStateException - Thrown if the factory has not yet been initialized.

getOutages

public Outage[] getOutages()
Return the outages configured.

Returns:
the outages configured

getOutage

public Outage getOutage(java.lang.String name)
Return the specified outage.

Parameters:
name - the outage that is to be looked up
Returns:
the specified outage, null if not found

getOutageType

public java.lang.String getOutageType(java.lang.String name)
Return the type for specified outage.

Parameters:
name - the outage that is to be looked up
Returns:
the type for the specified outage, null if not found

getOutageTimes

public Time[] getOutageTimes(java.lang.String name)
Return the outage times for specified outage.

Parameters:
name - the outage that is to be looked up
Returns:
the outage times for the specified outage, null if not found

getInterfaces

public Interface[] getInterfaces(java.lang.String name)
Return the interfaces for specified outage.

Parameters:
name - the outage that is to be looked up
Returns:
the interfaces for the specified outage, null if not found

isInterfaceInOutage

public boolean isInterfaceInOutage(java.lang.String linterface,
                                   java.lang.String outName)
Return if interfaces is part of specified outage.

Parameters:
linterface - the interface to be looked up
outName - the outage name
Returns:
the interface is part of the specified outage

isInterfaceInOutage

public boolean isInterfaceInOutage(java.lang.String linterface,
                                   Outage out)
Return if interfaces is part of specified outage.

Parameters:
linterface - the interface to be looked up
out - the outage
Returns:
the interface is part of the specified outage

isTimeInOutage

public boolean isTimeInOutage(java.util.Calendar cal,
                              java.lang.String outName)
Return if time is part of specified outage.

Parameters:
cal - the calendar to lookup
outName - the outage name
Returns:
true if time is in outage

isTimeInOutage

public boolean isTimeInOutage(java.util.Calendar cal,
                              Outage out)
Return if time is part of specified outage.

Parameters:
cal - the calendar to lookup
out - the outage
Returns:
true if time is in outage

isCurTimeInOutage

public boolean isCurTimeInOutage(java.lang.String outName)
Return if current time is part of specified outage.

Parameters:
outName - the outage name
Returns:
true if current time is in outage

isCurTimeInOutage

public boolean isCurTimeInOutage(Outage out)
Return if current time is part of specified outage.

Parameters:
out - the outage
Returns:
true if current time is in outage

OpenNMS API 1.1.4

Generated by eevans on November 12 2004 1715.