common/tools/raptor/RaptorSAXHandler.pm
author Brendan Donegan brendand@symbian.org
Mon, 21 Sep 2009 16:17:41 +0100
changeset 479 b6c4098af3f0
parent 242 51e429810aba
permissions -rw-r--r--
added my machine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# SAX Handler for the Raptor log
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
package RaptorSAXHandler;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
use base qw(XML::SAX::Base);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
sub new
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
    my ($type) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
    
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
    return bless {}, $type;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    25
sub add_observer
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
{
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    27
	my ($self, $name, $initialstatus) = @_;
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
	
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    29
	$self->{observers} = {} if (!defined $self->{observers});
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    30
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    31
	$self->{observers}->{$name} = $initialstatus;
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
sub start_document
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
	my ($self, $doc) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
	# process document start event
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
	#print "start_document\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
  
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
sub start_element
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
	my ($self, $el) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
	# process element start event
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	my $tagname = $el->{LocalName};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
	#print "start_element($tagname)\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
	
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    51
	for my $observer (keys %{$self->{observers}})
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
	{
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    53
		#print "processing observer $observer: $self->{observers}->{$observer} $self->{observers}->{$observer}->{name}\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    54
		#for (keys %{$self->{observers}->{$observer}->{next_status}}) {print "$_\n";}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    55
		
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    56
		if (defined $self->{observers}->{$observer}->{next_status}->{$tagname})
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    57
		{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    58
			#print "processing observer $observer\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    59
			my $oldstatus = $self->{observers}->{$observer};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    60
			$self->{observers}->{$observer} = $self->{observers}->{$observer}->{next_status}->{$tagname};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    61
			#print "$observer: status is now $self->{observers}->{$observer}->{name}\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    62
			$self->{observers}->{$observer}->{next_status}->{$tagname} = $oldstatus;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    63
			&{$self->{observers}->{$observer}->{on_start}}($el) if (defined $self->{observers}->{$observer}->{on_start});
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    64
		}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    65
		elsif (defined $self->{observers}->{$observer}->{next_status}->{'?default?'})
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    66
		{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    67
			#print "processing observer $observer\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    68
			#print "changing to default status\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    69
			my $oldstatus = $self->{observers}->{$observer};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    70
			$self->{observers}->{$observer} = $self->{observers}->{$observer}->{next_status}->{'?default?'};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    71
			#print "status is now ?default?\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    72
			$self->{observers}->{$observer}->{next_status}->{$tagname} = $oldstatus;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    73
			&{$self->{observers}->{$observer}->{on_start}}($el) if (defined $self->{observers}->{$observer}->{on_start});
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    74
		}
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
	}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
sub end_element
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
	my ($self, $el) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
	# process element start event
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
	my $tagname = $el->{LocalName};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
	#print "end_element($tagname)\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
	
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    87
	for my $observer (keys %{$self->{observers}})
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
	{
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    89
		if (defined $self->{observers}->{$observer}->{next_status}->{$tagname})
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    90
		{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    91
			&{$self->{observers}->{$observer}->{on_end}}($el) if (defined $self->{observers}->{$observer}->{on_end});
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    92
			$self->{observers}->{$observer} = $self->{observers}->{$observer}->{next_status}->{$tagname};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    93
			#print "status is now $self->{observers}->{$observer}->{name}\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
    94
		}
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
	}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    98
sub characters
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    99
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   100
	my ($self, $ch) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
	
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
   102
	for my $observer (keys %{$self->{observers}})
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
   103
	{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
   104
		&{$self->{observers}->{$observer}->{on_chars}}($ch) if (defined $self->{observers}->{$observer}->{on_chars});
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 222
diff changeset
   105
	}
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   106
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
1;