【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-AddressType.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
/* -*- mode: Java; fill-column: 72 -*-
* The contents of this file are subject to the ClickBlocks Public
* License Version 1.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.clickblocks.org
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied, including, but not limited to, the implied warranties of
* merchantability, fitness for a particular purpose and
* non-infringement. See the License for the specific language
* governing rights and limitations under the License.
*
* ClickBlocks, the ClickBlocks logo and combinations thereof are
* trademarks of ClickBlocks, LLC in the United States and other
* countries.
*
* The Initial Developer of the Original Code is ClickBlocks, LLC.
* Portions created by ClickBlocks, LLC are Copyright (C) 2000.
* All Rights Reserved.
*/
/**
* $Log: AddressType.java,v $
* Revision 1.2 2000/11/03 10:25:44 mgrand
* moved to clickblocks package structure.
*
* Revision 1.1.1.1 2000/10/30 01:37:38 mgrand
* reestablished local repository
*/
package org.clickblocks.entity;
import org.clickblocks.persistence.PersistableIF;
import org.clickblocks.time.Interval;
import org.clickblocks.time.IntervalMap;
import org.clickblocks.time.TemporalValidityIF;
import org.clickblocks.util.NotFoundException;
import java.util.Calendar;
/**
* Identify the role in which an address is being used.
* @stereotype role
* @author Mark Grand
*/
public class AddressType implements PersistableIF {
// Symbolic names for common address types
/** Symbolic name for physical address type */
public static final String PHYSICAL = "physical";
/** Symbolic name for ship-from address type */
public static final String SHIP_FROM = "ship-from";
/** Symbolic name for ship-to address type */
public static final String SHIP_TO = "ship-to";
/** Symbolic name for bill-to address type */
public static final String BILL_TO = "bill-to";
/** Symbolic name for receipt-to address type */
public static final String RECEIPT_TO = "receipt-to";
/**
* An IntervalMap to map this address type to addresses over time.
* @link aggregation
* @associates <b>org.clickblocks.entity.Address</b>
* @clientCardinality 1
* @supplierCardinality 0..*
* @label Addresses
* @directed
* @associationAsClass Interval
*/
private IntervalMap addressMap;
private String type; // physical, shipping, billing, ...
/**
* @supplierCardinality 1
* @clientCardinality 1
* @directed
*/
private Address lnkAddress;
/**
* constructor
* @param The name of the address type that this object encapsulates.
*/
public AddressType(String type) {
this.type = type;
addressMap = new IntervalMap();
} // constructor(String)
/**
* Return the type of address role. i.e. physical, shipping, billing, ...
*/
public String getType(){ return type; }
/**
* Return the current address that is used for this address type.
* @exception NotFoundException
* If there is currently no address used for this address
* type.
*/
public Address getAddress() throws NotFoundException {
return getAddress(Calendar.getInstance());
} // getAddress()
/**
* Return the address that is used for this address type at the given
* point in time.
* @param when The point in time to get an address for.
* @exception NotFoundException
* If there is no address used for this address type at
* the given point in time.
*/
public Address getAddress(Calendar when) throws NotFoundException {
return (Address)addressMap.get(when);
} // getAddress(Calendar)
/**
* Set the address that is used for this address type diring the
* given interval.
* @param thisAddress The address to use for this type.
* @param thisInterval
* The interval when the given address should be used for
* this type.
*/
public void setAddress(Address thisAddress, Interval thisInterval){
addressMap.add(thisInterval, thisAddress);
} // setAddress(Address)
/**
* Return the <code>IntervalMap</code> object encapsulated in this
* object. This method is intended for use by classes responsible for
* persisting <code>AddressType</code> objects.
*/
IntervalMap getAddressMap() {
return addressMap;
} // getAddressMap()
/**
* Return a class object that represents the sub-interface of
* <code>PersistenceIF</code> that should be used to manage the
* persistence of this class.
*/
public Class getPersistenceInterface() {
return AddressPersisterIF.class;
} // getPersistenceInterface()
} // class AddressType
上一篇:
AddressTable1.java
下一篇:
遥远的牵挂