NAME
Siebel::Srvrmgr::ListParser::Output - base class of srvrmgr output
SYNOPSIS
use Siebel::Srvrmgr::ListParser::Output;
my $output = Siebel::Srvrmgr::ListParser::Output->new({ data_type => 'sometype',
raw_data => \@data,
cmd_line => 'list something from somewhere'});
print 'Fields pattern: ', $output->get_fields_pattern(), "\n";
$output->store($complete_pathname);
DESCRIPTION
Siebel::Srvrmgr::ListParser::Output is a superclass of output types classes.
It contains only basic attributes and methods that enable specific parsing and serializable methods.
The parse
method must be overrided by subclasses or a exception will be raised during object creation.
ATTRIBUTES
data_type
Identifies which kind of data is being given to the class. This is usually used by abstract factory classes to identify which subclass of Siebel::Srvrmgr::ListParser::Output must be created.
This attribute is required during object creation.
raw_data
An array reference with the lines to be processed.
This attribute is required during object creation.
data_parsed
An hash reference with the data parsed from raw_data
attribute.
cmd_line
A string of the command that originates from the output (the data of raw_data
attribute).
This attribute is required during object creation.
fields_pattern
When starting processing the output of list comp
command, the header is read and the size of each column is taken from the header of each column. With this information a pattern is build to match each value foreach line read. This attribute will hold the string that describes this pattern (that latter will be used with the unpack()
builtin function).
Therefore is really important that the header of srvrmgr
program is not removed or the parser will not work properly and probably an exception will be raised by it.
header_regex
The regular expression used to match the header of the list <command> output (the sequence of column names). This is a regular expression reference as returned by qr
operator, which means that the regular expression is already optimized.
col_sep
The regular expression used to match the columns separator. Even thought the output has (or should have) a fixed size, the columns are separated by a string. This is a regular expression reference as returned by qr
operator, which means that the regular expression is already optimized. col_sep has a builder sub
that can be override if the regular expression is different of \s{2,}
.
header_cols
An array reference with all the header columns names, in the exact sequence their appear in the output.
METHODS
get_fields_pattern
Returns an string of the attribute fields_pattern
.
get_cmd_line
Returns an string of the attribute get_cmd_line
.
get_data_parsed
Retuns an hash reference of data_parsed
attribute.
set_data_parsed
Sets the data_parsed
attribute. It is expected an hash reference as parameter of the method.
get_raw_data
Returns an array reference of the attribute raw_data
.
set_raw_data
Sets the raw_data
attribute. An array reference is expected as parameter of the method.
load
Method inherited from MooseX::Storage::IO::StorableFile role. It loads a previously serialized Siebel::Srvrmgr::ListParser:Output object into memory.
store
Method inherited from MooseX::Storage::IO::StorableFile role. It stores (serializes) a Siebel::Srvrmgr::ListParser:Output object into a file. A a string of the filename (with complete or not full path) is expected as a parameter.
BUILD
All subclasses of Siebel::Srvrmgr::ListParser::Object will call the method parse
right after object instatiation.
parse
The method that actually does the parse of raw_data
attribute.
This method should be overrided by subclasses which output does not have a defined header, since this method expects to find a header in the data to be parsed.
_define_pattern
Defines and sets the attribute fields_pattern
. This method is invoked automatically from the parse
method.
You probably don't want to mess around with this method (that is "private") but will want to override it in subclasses if their schema of fields is different from defining them from the lenght of "------" header lines present in all output from commands of srvrmgr program.
_set_col_sep
This is a builder sub
to define col_sep
attribute. It is quite unlike it will be necessary to change that, but one can override it in subclasses if needed.
This is a "private" method and should be used internally only.
get_col_sep
Getter of col_sep
attribute.
_split_fields
Split a output line into fields as defined by get_col_sep
method. It expects a string as parameter.
Returns an array reference.
This is a "private" method and should be used internally only.
_set_header
Used to split and define the header fields (see attribute header_cols
).
This is a "private" method and should be used internally only but could be overrided by subclasses if it is necessary to change any field before setting the header_cols
attribute.
It expects the header line as a parameter, setting the header_cols
attribute and returning true in the case of success.
_parse_data
This method is responsible to parse the data from a list command output, after the header was parsed successfully.
This method must be overrided by subclasses since Siebel::Srvrmgr::Output doesn't know anything about how to parse it.
This method in "private" and should be used internally only (more specific, inside the parse
method).
The method expects the following parameters:
- fields
-
An array reference with the fields recovered from the output of the list command.
- parsed data
-
An hash reference with all the data already parsed by the
parse
method.
The method must return true or false depending on the result of parsing the fields and incrementing the parsed data as expected.
_set_header_regex
Expects no parameter. It sets the header_regex
attribute.
This method is the builder method of header_regex
attribute and must be overrided by subclasses of Siebel::Srvrmgr::ListParser::Output since the superclass knows nothing about the format of the header from the list command output.
CAVEATS
All subclasses of Siebel::Srvrmgr::ListParser::Output expect to have both the header and trailer of executed commands in srvrmgr
program. Removing one or both of them will result in parsing errors and probably exceptions.
SEE ALSO
AUTHOR
Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.
This file is part of Siebel Monitoring Tools.
Siebel Monitoring Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Siebel Monitoring Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Siebel Monitoring Tools. If not, see http://www.gnu.org/licenses/.