App-Office-Contacts-Import-vCards

 view release on metacpan or  search on metacpan

lib/App/Office/Contacts/Import/vCards/Util/vCards.pm  view on Meta::CPAN

package App::Office::Contacts::Import::vCards::Util::vCards;

# Purpose:
#	Read vCards in XML format.

use JSON::XS;

use XML::SAX::ParserFactory;

use Moose;

extends (qw/Moose::Object XML::SAX::Base/);

has callback    => (is => 'rw', isa => 'CodeRef');
has caller      => (is => 'rw', isa => 'Any');
has email_type  => (is => 'rw', isa => 'Str');
has phone_type  => (is => 'rw', isa => 'Str');
has status      => (is => 'rw', isa => 'Str', default => 'OK');
has text        => (is => 'rw', isa => 'Str');
has vcard       => (is => 'rw', isa => 'HashRef');
has vcard_count => (is => 'rw', isa => 'Int', default => 0);
has xml         => (is => 'rw', isa => 'Str');

use namespace::autoclean;

our $VERSION = '1.12';

# -----------------------------------------------

sub characters
{
	my($self, $characters) = @_;

	$self -> text($self -> text . $$characters{Data});

}	# End of characters.

# -----------------------------------------------

sub end_document
{
	my($self) = @_;

}	# End of end_document.

# -----------------------------------------------

sub end_element
{
	my($self, $element) = @_;
	my($text)           = $self -> text;
	$text               =~ s/^\s+//;
	$text               =~ s/\s+$//;

	# Process text.

	my(@field);
	my($vcard);

	if ($$element{Name} eq 'vcard')
	{
		$self -> callback -> ($self -> caller, $self -> vcard_count, $self -> vcard);
	}
	elsif ($$element{Name} eq 'email')
	{
		$vcard = $self -> vcard;



( run in 2.483 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )