Author: Niall <chrisniallathotmaildotcom>     Reply to Message
Date: 7/25/2003 5:07:59 AM
Subject: RE: flare grenades.

package com.att.pricerx.common;

/**
* Class: Feature.java
* Description: Represents a phone line feature associated with a service area.
* Copyright: Copyright (c) 2002
* Company: OAOT
* @author Jamie Cornick
* @version 1.0
*/


import java.util.*;
import java.text.*;

import com.att.pricerx.reports.HTMLCodeFactory;


public class Feature {
private String name;
private Double mrc;
private String mrcDate;
private Double nrc;
private String nrcDate;
private Double perCall;
private Integer order;
private Integer featureOrder;
private String localCategory;
private String mrcEffectiveDate; //P4211 replaces effectiveDate property - Doug Tompkins
private Integer classOfService; //PMANUEL P2921 22-Apr-2003
private Vector featureColl;
private boolean mrcFlag;
//private Integer featureId;

/**
* Feature Constructor
* P4211 - Doug Tompkins
*/
public Feature(String name, Double mrc, Double nrc, String mrcDate, String nrcDate){
super();
this.name = name;
this.mrc = mrc;
this.nrc = nrc;
this.mrcDate = mrcDate;
this.nrcDate = nrcDate;
this.featureColl = new Vector(5);
}

/**
* Feature Constructor.
*/
public Feature(String name, Double mrc, Double nrc, String date) {
super();
this.name = name;
this.mrc = mrc;
this.nrc = nrc;
this.mrcEffectiveDate = date;
this.featureColl = new Vector(5);
}

/**
* Feature Constructor.
*/
public Feature(String name, Double mrc, Double nrc, String date, boolean mrcFlag) {
super();
this.name = name;
this.mrc = mrc;
this.nrc = nrc;
this.mrcEffectiveDate = date;
this.featureColl = new Vector(5);
this.mrcFlag = mrcFlag;
}

/**
* Feature Constructor.
*/
public Feature(String name, Double mrc, String mrcDate, Double nrc, String nrcDate, String date) {
super();
this.name = name;
this.mrc = mrc;
this.mrcDate = mrcDate;
this.nrc = nrc;
this.nrcDate = nrcDate;
this.mrcEffectiveDate = date;
this.featureColl = new Vector(5);
}


/**
* Feature Constructor, used for adding new features to a bundle.
*/
public Feature(String name) {
super();
this.name = name;
this.mrc = new Double(0.0);
this.nrc = new Double(0.0);
this.mrcEffectiveDate = "";
this.featureColl = new Vector(0);
}

/**
* Feature Constructor, used for a mrc/nrc feature in the local pricing report.
*/
public Feature(String name, String localCategory, Integer catOrder, Integer featureOrder, Double mrc, Double nrc) {
super();
this.name = name;
this.mrc = mrc;
this.nrc = nrc;
this.perCall = null;
this.localCategory = localCategory;
this.order = catOrder;
this.featureOrder = featureOrder;
this.mrcEffectiveDate = "";
this.featureColl = new Vector(0);
}


/**
* Feature Constructor, used for a feature bundle in the local pricing report.
*/
public Feature(String name, String localCategory, Integer catOrder, Integer featureOrder, Double mrc, Double nrc, String features) {
super();
this.name = name;
this.mrc = mrc;
this.nrc = nrc;
this.perCall = null;
this.localCategory = localCategory;
this.order = catOrder;
this.featureOrder = featureOrder;
this.mrcEffectiveDate = "";
this.featureColl = new Vector(5);
StringTokenizer st = new StringTokenizer(features, "|");
while (st.hasMoreTokens()) {
featureColl.add(new Feature(st.nextToken().trim()));
}
}


/**
* Feature Constructor, used for a per call feature in the local pricing report.
*/
public Feature(String name, String localCategory, Integer catOrder, Integer featureOrder, Double perCall) {
super();
this.name = name;
this.mrc = null;
this.nrc = null;
this.perCall = perCall;
this.localCategory = localCategory;
this.order = catOrder;
this.featureOrder = featureOrder;
this.mrcEffectiveDate = "";
this.featureColl = new Vector(0);
//this.featureId = featureId;

}

/**
* Feature Constructor. Use for a mrc/nrc feature and pass in the class of Service -- PMANUEL P2921 22-Apr-2003
*/
public Feature(String name, String localCategory, Integer catOrder, Integer featureOrder, Double mrc, Double nrc, Integer classOfService) {
super();
this.name = name;
this.mrc = mrc;
this.nrc = nrc;
this.perCall = null;
this.localCategory = localCategory;
this.order = catOrder;
this.featureOrder = featureOrder;
this.classOfService = classOfService;
this.mrcEffectiveDate = "";
this.featureColl = new Vector(0);
}

/**
* Method: addFeatureToBundle
* Allows public access to add a feature to any other feature that may be a bundle.
* Used in building feature bundles for the XML report.
*
*/
public void addFeatureToBundle(Feature inFeature) {
featureColl.add(inFeature);
}

/**
* Method: adds a vector of feature names when
* the feature is a bundle.
* P4211 - Doug Tompkins
* @param bundledFeatureNames
*/
public void addBundleNames(String bundledFeatureNames){
this.featureColl = new Vector(5);
StringTokenizer st = new StringTokenizer(bundledFeatureNames, "|");
while (st.hasMoreTokens()) {
featureColl.add(new Feature(st.nextToken().trim()));
}
}

/**
* Method: equals
* Overridden from Object.
* Allows for comparision of a Feature object and a String.
* Returns true if the String passed in is equal (exactly) to the
* name of this feature.
*/
public boolean equals(String inName) {
return name.equals(inName);
}

/**
* Method: toString
* Overridden from Object.
* Returns the String representation of a Feature Object.
*/
public String toString() {
return name.trim();
}

/**
* Method: getLocalCategory
* Returns the local catrgory of this feature when it is being used in a local pricing report.
*/
public String getLocalCategory() {
return localCategory;
}

/**
* Method: getFeatureOrder
* Returns the feature order of this feature when it is being used in a local pricing report.
*/
public int getFeatureOrder() {
return featureOrder.intValue();
}

public String getName(){
return name;
}

/**
* Method: getCatOrder
* Returns the local catrgory order of this feature when it is being used in a local pricing report.
*/
public int getCatOrder() {
return order.intValue();
}

/**
* Method: isBundle
* Returns true if this feature represents a bundle of features, otherwise returns false.
*/
public boolean isBundle() {
return !(featureColl.isEmpty());
}

/**
* Format a date to YYYYMMDD
* P4211 - Doug Tompkins
* @param xmlDate
* @return String
*/
private String formatXMLDate(String xmlDate){
String fmtdDate = new String("");
try{
fmtdDate = xmlDate.substring(0,4)+
xmlDate.substring(5,7)+
xmlDate.substring(8,10);
}
catch(Exception e){
fmtdDate = "";
}
finally{
return fmtdDate;
}
}

/**
* Method: toXML
* Returns a string representing a feature in XML format
* P4211 - Doug Tompkins
* @return
*/
public String toXML(){
StringBuffer xmlOut = new StringBuffer(1000);
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(2);
df.setMaximumFractionDigits(2);
UsageRate ur = new UsageRate();

xmlOut.append("n");
xmlOut.append("");

int iAmp = name.indexOf("&");
while(iAmp != -1){
String start = name.substring(0,iAmp);
String end = name.substring(iAmp+1,name.length());
name = start + "&" + end;
iAmp = name.indexOf("&",iAmp+1);
}
xmlOut.append(name);
xmlOut.append("n");
xmlOut.append("");
if(mrc.doubleValue() != 0){
xmlOut.append(df.format(mrc.doubleValue()));
}
else{
xmlOut.append("");
}
xmlOut.append("n");
xmlOut.append("");
if(nrc.doubleValue() != 0){
xmlOut.append(df.format(nrc.doubleValue()));
}
else{
xmlOut.append("");
}
xmlOut.append("n");
xmlOut.append("");
xmlOut.append(formatXMLDate(mrcDate));
xmlOut.append("n");
xmlOut.append("");
xmlOut.append(formatXMLDate(nrcDate));
xmlOut.append("n");
xmlOut.append("n");
xmlOut.append("n");

if (this.isBundle()) {
xmlOut.append("n");
for (int i=0; in");
}
else {
xmlOut.append("n");
}
xmlOut.append("n");



return xmlOut.toString();

}


/**
* Method: toAIOXML
* Will return a String representing this AIO Feature in XML format.
* Will recursively represent each Feature associated to this FeatureBundle in XML
* format as well (if this Object represents a FeatureBundle).
* added for 4211 by Chris O'Neill
*/
public String toAIOXML(UsageRate ur) {

java.text.DecimalFormat df = new java.text.DecimalFormat();
df.setMinimumFractionDigits(2);
df.setMaximumFractionDigits(2);
StringBuffer xmlOut = new StringBuffer(10000);
xmlOut.append("n");
xmlOut.append("");
xmlOut.append(name);
xmlOut.append("n");
xmlOut.append("");
if (mrcFlag) {
xmlOut.append(df.format(mrc.doubleValue()));
}
xmlOut.append("n");
xmlOut.append("");
if (! mrcFlag) {
xmlOut.append(df.format(nrc.doubleValue()));
}
xmlOut.append("n");
// If this object is a bundle we have
// to call toXML() on all the features in this bundle.
if (this.isBundle()) {
xmlOut.append("n");
for (int i=0; in");
}
else {
xmlOut.append("n");
}
xmlOut.append("");
xmlOut.append(mrcEffectiveDate);
xmlOut.append("n");
xmlOut.append("");
xmlOut.append("n");
xmlOut.append("");
xmlOut.append("n");

////// -------------------------------- new code --------------------------- ////// PMANUEL P2921 20-Apr-2003

if(ur != null){
System.out.println("Plan is equal to nothing");
if(nrc.doubleValue()== 0.0){
xmlOut.append("");
xmlOut.append(ur.toXML());
xmlOut.append("n");
}
}
////// ------------------------------ end of new code ----------------------- //////


/* ****** -------------------------- Commented Original Code ------------------- ******


if(name.trim().equals("LOCAL PLAN B FLAT RATE") || name.trim().equals("LOCAL PLAN A FLAT RATE") || name.trim().equals("LOCAL PLAN C MEASURED RATE")){
if(nrc.doubleValue()== 0.0){
xmlOut.append("");
xmlOut.append(ur.toXML());
xmlOut.append("n");
}
}
xmlOut.append("n");
*/
return xmlOut.toString();
}

/**
* Method: toXML
* Will return a String representing this Feature in XML format.
* Will recursively represent each Feature associated to this FeatureBundle in XML
* format as well (if this Object represents a FeatureBundle).
*/
public String toXML(UsageRate ur) {

DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(2);
df.setMaximumFractionDigits(2);
StringBuffer xmlOut = new StringBuffer(10000);
xmlOut.append("n");
xmlOut.append("");
xmlOut.append(name);
xmlOut.append("n");
xmlOut.append("");
if (mrcFlag) {
xmlOut.append(df.format(mrc.doubleValue()));
}
xmlOut.append("n");
xmlOut.append("");
if (! mrcFlag) {
xmlOut.append(df.format(nrc.doubleValue()));
}
xmlOut.append("n");
// If this object is a bundle we have
// to call toXML() on all the features in this bundle.

xmlOut.append("");
xmlOut.append(formatXMLDate(mrcDate));
xmlOut.append("n");
xmlOut.append("");
xmlOut.append(formatXMLDate(nrcDate));
xmlOut.append("n");

xmlOut.append("n");
xmlOut.append("n");

////// -------------------------------- new code --------------------------- ////// PMANUEL P2921 20-Apr-2003

if(ur != null){
System.out.println("Plan is equal to nothing");
if(nrc.doubleValue()== 0.0){
xmlOut.append("");
xmlOut.append(ur.toXML());
xmlOut.append("n");
}
}
////// ------------------------------ end of new code ----------------------- //////


/* ****** -------------------------- Commented Original Code ------------------- ******


if(name.trim().equals("LOCAL PLAN B FLAT RATE") || name.trim().equals("LOCAL PLAN A FLAT RATE")){
if(nrc.doubleValue()== 0.0){
System.out.println("-- nrc = " + nrc + " --");
xmlOut.append("");
xmlOut.append(ur.toXML());
xmlOut.append("n");
}
}
*/
//moved this from above the tag, so that those tags appear
//before the bundle. chriso 4211
if (this.isBundle()) {
xmlOut.append("n");
for (int i=0; in");
}
else {
xmlOut.append("n");
}
xmlOut.append("n");
return xmlOut.toString();
}

/**
* Method: toHTML
* Will return a String representing this Feature in HTML format.
* Will recursively represent each Feature associated to this FeatureBundle in HTML
* format as well (if this Object represents a FeatureBundle).
*/
public String toHTML() {
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(2);
df.setMaximumFractionDigits(2);
StringBuffer htmlString = new StringBuffer(200);
if (perCall != null) {
htmlString.append("");
htmlString.append(name);
htmlString.append("
");
htmlString.append("$" + df.format(perCall.doubleValue()));
htmlString.append("
n");
}
else if (! (featureColl.isEmpty())) {
htmlString.append("");
htmlString.append(name);
htmlString.append("");
// If this object is a bundle we have
// to add all if the features in this bundle to the HTML table.
if (this.isBundle()) {
for (int i=0; i");
htmlString.append(((Feature) featureColl.elementAt(i)).toString());
if (i != (featureColl.size() - 1)) {
htmlString.append("");
}
}
}
htmlString.append("
");
htmlString.append("$" + df.format(mrc.doubleValue()));
htmlString.append("
");
htmlString.append("$" + df.format(nrc.doubleValue()));
htmlString.append("
");
}
else {
htmlString.append("");
htmlString.append(name);
htmlString.append("");
if(this.getCatOrder()==HTMLCodeFactory.VOICE_MAIL_TYPE_ORDER) {
if(classOfService.intValue() != 0){
htmlString.append("
");
htmlString.append(classOfService); // PMANUEL P2921 22-Apr-2003
/* ****** ------------------ Commented Original Code ----------------------- ******

switch(this.getFeatureOrder()) {
case 1:
htmlString.append("201"); // Voice Mail
break;
case 2:
htmlString.append("202"); // Voice Mail With Paging
break;
case 3:
htmlString.append("301"); // Deluxe Voice Mail
break;
case 4:
htmlString.append("302"); // Deluxe Voice Mail With Paging
break;
case 5:
htmlString.append("401"); // Deluxe Voice Multi Mail
break;
case 6:
htmlString.append("111"); // Voice mail forwarding
break;
default:
htmlString.append("N/A ");
} // end switch

*/
htmlString.append("
");
}
} // end if
htmlString.append("
");
htmlString.append("$" + df.format(mrc.doubleValue()));
htmlString.append("
");
htmlString.append("$" + df.format(nrc.doubleValue()));
htmlString.append("
n");
} // end else
return htmlString.toString().trim();
}
}
_