The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Repository::Simple::Type::Node - Types for content repository nodes

SYNOPSIS

An example using this subroutine can be found in ex/print_types.pl of the original source distribution.

  sub print_node_type {
      my $node = shift;
  
      my $type = $node->type;
  
      print $node->name, ' : ', $type->name;
      print ' [AC]' if $type->auto_created;
      print ' [UP]' if $type->updatable;
      print ' [RM]' if $type->removable;
      print "\n";
  
      my %property_types = $type->property_types;
      while (my ($name, $ptype_name) = each %property_types) {
          my $ptype = $node->repository->property_type($ptype_name);
  
          printf ' * %-10s : %-16s', $name, $ptype->name;
  
          print ' [AC]' if $ptype->auto_created;
          print ' [UP]' if $ptype->updatable;
          print ' [RM]' if $ptype->removable;
          print "\n";
      }
  }

DESCRIPTION

Node types are used to determine information about what kind of information is expected and required to be part of a node instance. A node type may also inherit features from one or more node types.

Most developers will not need to create node types, but may use node types to discover information about how a node can be manipulated and what kind of information can be expected from a given node.

METHODS

$type = Repository::Simple::Type::Node->new(%args)

Create a new node type with the given arguments, %args.

The following arguments are used:

engine (required)

This is the storage engine to which the node type belongs.

name (required)

This is the short identifying name for the type. This is should be a fully qualified name, e.g., "ns:name".

super_types

This option may be set to an array of node type names representing the node types that this node type inherits from. Only the possible/required child node types and property types are inheritable

If this option is not given, then the node type inherits nothing.

node_types

This option is set to a hash where the keys are node names and the values are either node type names or arrays of node type names. The string "*" is special for the keys, it means that a node of any name may be contained with the given type.

For example,

  node_types => {
      foo => 'my:typeX',
      bar => [ 'my:typeY', 'my:typeZ' ],
      '*' => [ 'my:typeX', 'my:typeZ' ],
  },

allows the nodes of the defined node type to have a child node named "foo" with type "my:typeX", a node named "bar" with either the type "my:typeY" or the type "my:typeZ", and any number of other nodes named anything with type "my:typeX" or "my:typeZ".

property_types

This option is set to a hash where the keys are property names and the values are either property type names or arrays of property type names.

auto_created

This option is set to true if this node will be created automatically when its parent is created.

By default, this value is false.

updatable

This is a property for all node types stating whether or not the node may be updated, i.e., renamed. This only affects the node itself and does not affect any of its properties or child nodes.

By default, this value is false.

removable

When this property is set to a true value, this node may not be removed from its parent node.

By default, this value is false.

$name = $type->name

This method returns the name of the type.

@super_types = $type->super_types

This method returns the direct super types of the type or an empty list if there are no direct super types.

%node_types = $type->node_types

Returns all the child nodes of this node type, including all nodes inherited from super_types. The keys of the returned nodes will be the node names. The values will be the names of the node type that node is expected to have.

%property_types = $type->property_types

This method returns all properties that may be added to this node, including those inherited from super_types. The keys of the returned hash represent the names of those properties and the values represent the property types of those nodes.

$auto_created = $type->auto_created

This method returns true if nodes of this type should be automatically created with their parent.

$updatable = $type->updatable

This method returns true if nodes of this type may be changed. A nodes mutability or immutability doesn't have any bearing on the mutability of child nodes or child properties.

$removable = $type->removable

This method returns true if nodes of this type may be removed from their parent.

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

LICENSE AND COPYRIGHT

Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This program 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.