~ubuntu-branches/ubuntu/maverick/libcommons-digester-java/maverick

« back to all changes in this revision

Viewing changes to src/java/org/apache/commons/digester/xmlrules/DigesterRuleParser.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath, Kumar Appaiah, Varun Hiremath
  • Date: 2007-09-20 22:02:53 UTC
  • mfrom: (0.1.3 upstream) (2.1.3 gutsy)
  • Revision ID: james.westby@ubuntu.com-20070920220253-y7hrhgzfb6ha150y
Tags: 1.8-1
[ Kumar Appaiah ]
* debian/control:
  + Add XS-Vcs-{Svn,Browser}.
  + Add Homepage field.
* Add watch file.

[ Varun Hiremath ]
* New upstream release
* debian/control:
  + Add myself and Kumar Appaiah to Uploaders.
  + move cdbs and debhelper to Build-Depends.
  + modify Description.
* debian/compat: switch to 5
* remove links file from debian/
* debian/rules:
  + Use DEB_UPSTREAM_VERSION to install jar
  + Create a versioned symbolic link to the jar.
  + implement get-orig-source
* Add debian/orig-tar.sh to remove CRLF line terminators from upstream files.
* Update debian/watch to call debian/orig-tar.sh

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: DigesterRuleParser.java 155412 2005-02-26 12:58:36Z dirkv $
 
1
/* $Id: DigesterRuleParser.java 471661 2006-11-06 08:09:25Z skitching $
2
2
 *
3
 
 * Copyright 2001-2004 The Apache Software Foundation.
4
 
 * 
5
 
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 
 * you may not use this file except in compliance with the License.
7
 
 * You may obtain a copy of the License at
 
3
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
4
 * contributor license agreements.  See the NOTICE file distributed with
 
5
 * this work for additional information regarding copyright ownership.
 
6
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
7
 * (the "License"); you may not use this file except in compliance with
 
8
 * the License.  You may obtain a copy of the License at
8
9
 * 
9
10
 *      http://www.apache.org/licenses/LICENSE-2.0
10
11
 * 
38
39
import org.apache.commons.digester.CallParamRule;
39
40
import org.apache.commons.digester.Digester;
40
41
import org.apache.commons.digester.FactoryCreateRule;
 
42
import org.apache.commons.digester.NodeCreateRule;
41
43
import org.apache.commons.digester.ObjectCreateRule;
42
44
import org.apache.commons.digester.Rule;
43
45
import org.apache.commons.digester.RuleSetBase;
50
52
import org.apache.commons.digester.SetTopRule;
51
53
import org.apache.commons.digester.ObjectParamRule;
52
54
 
 
55
import org.w3c.dom.Node;
53
56
import org.xml.sax.Attributes;
54
57
import org.xml.sax.SAXException;
55
58
 
246
249
        digester.addRule("*/object-create-rule", new PatternRule("pattern"));
247
250
        digester.addSetNext("*/object-create-rule", "add", ruleClassName);
248
251
        
 
252
        digester.addFactoryCreate("*/node-create-rule", new NodeCreateRuleFactory());
 
253
        digester.addRule("*/node-create-rule", new PatternRule("pattern"));
 
254
        digester.addSetNext("*/node-create-rule", "add", ruleClassName);
 
255
        
249
256
        digester.addFactoryCreate("*/set-properties-rule", new SetPropertiesRuleFactory());
250
257
        digester.addRule("*/set-properties-rule", new PatternRule("pattern"));
251
258
        digester.addSetNext("*/set-properties-rule", "add", ruleClassName);
660
667
            return objectParamRule;
661
668
        }
662
669
     }
663
 
 
 
670
    
 
671
        /**
 
672
         * Factory for creating a NodeCreateRule
 
673
         */
 
674
    protected class NodeCreateRuleFactory extends AbstractObjectCreationFactory {
 
675
 
 
676
        public Object createObject(Attributes attributes) throws Exception {
 
677
 
 
678
            String nodeType = attributes.getValue("type");
 
679
            if (nodeType == null || "".equals(nodeType)) {
 
680
 
 
681
                // uses Node.ELEMENT_NODE
 
682
                return new NodeCreateRule();
 
683
            } else if ("element".equals(nodeType)) {
 
684
 
 
685
                return new NodeCreateRule(Node.ELEMENT_NODE);
 
686
            } else if ("fragment".equals(nodeType)) {
 
687
 
 
688
                return new NodeCreateRule(Node.DOCUMENT_FRAGMENT_NODE);
 
689
            } else {
 
690
 
 
691
                throw new RuntimeException(
 
692
                        "Unrecognized node type: "
 
693
                                + nodeType
 
694
                                + ".  This attribute is optional or can have a value of element|fragment.");
 
695
            }
 
696
        }
 
697
    }    
664
698
    
665
699
    /**
666
700
     * Factory for creating a FactoryCreateRule