home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Digester example source code file (Person.java)

This example Commons Digester source code file (Person.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Digester tags/keywords

beanpropertysetter, callmethod, callparam, hashmap, map, map, objectcreate, override, override, person, person, setproperty, string, string, util

The Commons Digester Person.java source code

/* $Id: Person.java 992060 2010-09-02 19:09:47Z simonetripodi $
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.apache.commons.digester.annotations.person;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.digester.annotations.rules.AttributeCallParam;
import org.apache.commons.digester.annotations.rules.BeanPropertySetter;
import org.apache.commons.digester.annotations.rules.CallMethod;
import org.apache.commons.digester.annotations.rules.CallParam;
import org.apache.commons.digester.annotations.rules.ObjectCreate;
import org.apache.commons.digester.annotations.rules.SetProperty;

 * @since 2.1
@ObjectCreate(pattern = "person")
public class Person {

    private final Map<String, String> emails = new HashMap();

    @SetProperty(pattern = "person")
    private int id;

    @SetProperty(pattern = "person")
    private String category;

    @BeanPropertySetter(pattern = "person/name")
    private String name;

    @CallMethod(pattern = "person/email")
    public void addEmail(@AttributeCallParam(pattern = "person/email", attribute = "type") String type,
            @CallParam(pattern = "person/email") String address) {
        this.emails.put(type, address);

    public int getId() {
        return id;

    public void setId(int id) {
        this.id = id;

    public String getCategory() {
        return category;

    public void setCategory(String category) {
        this.category = category;

    public String getName() {
        return name;

    public void setName(String name) {
        this.name = name;

    public Map<String, String> getEmails() {
        return emails;

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Person other = (Person) obj;
        if (category == null) {
            if (other.category != null)
                return false;
        } else if (!category.equals(other.category))
            return false;
        if (emails == null) {
            if (other.emails != null)
                return false;
        } else if (!emails.equals(other.emails))
            return false;
        if (id != other.id)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;

    public String toString() {
        return "Person [category="
            + category
            + ", emails="
            + emails
            + ", id="
            + id
            + ", name="
            + name
            + "]";


Other Commons Digester examples (source code examples)

Here is a short list of links related to this Commons Digester Person.java source code file:

new blog posts


Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.