Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package sk.iway.iwcm.doc;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.struts.util.ResponseUtils;
import sk.iway.iwcm.DB;
import sk.iway.iwcm.DBPool;
import sk.iway.iwcm.Logger;
import sk.iway.iwcm.Tools;
import sk.iway.iwcm.tags.SelectTag;
/**
* Bean popisujuci atribut stranky (vratane definicii)
*
*@Title WebJET 4.0
*@Company Interway s.r.o. (www.interway.sk)
*@Copyright Interway s.r.o. (c) 2001-2002
*@author $Author: jeeff $
*@version $Revision: 1.2 $
*@created Streda, 2003, október 15
*@modified $Date: 2003/10/24 15:33:30 $
*/
@SuppressWarnings("java:S1659")
public class AtrBean implements Serializable
{
private int atrId;
private String atrName;
private String atrDescription;
private String atrDefaultValue;
private int atrType;
private int docId;
private double valueNumber;
private boolean valueBool;
private String valueString;
private int orderPriority;
private String atrGroup;
private String trueValue;
private String falseValue;
/**
* vygeneruje HTML podobu atributu
* @return
*/
public String getHtml()
{
return getHtml(false);
}
/**
* vygeneruje HTML podobu atributu
* @return
*/
public String getHtml(boolean onWebPage)
{
if (atrDefaultValue == null) atrDefaultValue = "";
StringBuilder ret = null;
String actualValue = "";
//ak mame docid, znamena to, ze uz to ma v DB nejaku hodnotu
if (docId > 0)
{
actualValue = getValue();
}
String delimeter = ",";
if(atrDefaultValue.indexOf("|") != -1 )
{
delimeter = "|"; //ak najdem '|', parsujem podla '|'
}
StringTokenizer st = new StringTokenizer(atrDefaultValue, delimeter);
if (st.countTokens()>1)
{
if(onWebPage)
{
ret = new StringBuilder("");
}
else
{
ret = new StringBuilder("");
}
}
else
{
if (atrDefaultValue.startsWith("multiline"))
{
int cols=40;
int rows=4;
st = new StringTokenizer(atrDefaultValue, "-");
if (st.countTokens() == 3)
{
st.nextToken();
//pocet stlpcov
cols = Tools.getIntValue(st.nextToken(), cols);
rows = Tools.getIntValue(st.nextToken(), rows);
}
if (docId < 1)
{
actualValue = "";
}
ret = new StringBuilder("");
}
else if (atrDefaultValue.equals("autoSelect"))
{
if(onWebPage)
{
ret = new StringBuilder("");
}
else
{
ret = new StringBuilder("");
}
}
else
{
if (docId < 1)
{
actualValue = atrDefaultValue;
}
if (getAtrType()==AtrDB.TYPE_BOOL)
{
ret = new StringBuilder(" "+getFalseValue());
ret.append( " ");
ret.append( " "+getTrueValue());
}
else
{
ret = new StringBuilder("");
}
}
}
return (ret.toString());
}
/**
* ziska hodnotu ako string
* @return
*/
public String getValue()
{
if (atrType==AtrDB.TYPE_INT)
{
return(Long.toString(Math.round(valueNumber)));
}
else if (atrType==AtrDB.TYPE_DOUBLE)
{
return(Double.toString(valueNumber));
}
else if (atrType==AtrDB.TYPE_BOOL)
{
return(Boolean.toString(valueBool));
}
return(valueString);
}
public String getValueHtml()
{
if (atrType==AtrDB.TYPE_INT)
{
return(Long.toString(Math.round(valueNumber)));
}
else if (atrType==AtrDB.TYPE_DOUBLE)
{
return(Tools.replace(Double.toString(valueNumber), ".", ","));
}
else if (atrType==AtrDB.TYPE_BOOL)
{
if (valueBool == true)
{
if (trueValue!=null && trueValue.length()>0)
{
return(trueValue);
}
}
else
{
if (falseValue!=null && falseValue.length()>0)
{
return(falseValue);
}
}
return(Boolean.toString(valueBool));
}
return(valueString);
}
/**
* Gets the atrId attribute of the AtrBean object
*
*@return The atrId value
*/
public int getAtrId()
{
return atrId;
}
/**
* Sets the atrId attribute of the AtrBean object
*
*@param atrId The new atrId value
*/
public void setAtrId(int atrId)
{
this.atrId = atrId;
}
/**
* Sets the atrName attribute of the AtrBean object
*
*@param atrName The new atrName value
*/
public void setAtrName(String atrName)
{
this.atrName = atrName;
}
/**
* Gets the atrName attribute of the AtrBean object
*
*@return The atrName value
*/
public String getAtrName()
{
return atrName;
}
public String getAtrName(String lang)
{
return parse(atrName,lang);
}
/**
* Sets the atrDescription attribute of the AtrBean object
*
*@param atrDescription The new atrDescription value
*/
public void setAtrDescription(String atrDescription)
{
this.atrDescription = atrDescription;
}
/**
* Gets the atrDescription attribute of the AtrBean object
*
*@return The atrDescription value
*/
public String getAtrDescription()
{
return atrDescription;
}
public String getAtrDescription(String lang)
{
return parse(atrDescription,lang);
}
/**
* Sets the atrDefaultValue attribute of the AtrBean object
*
*@param atrDefaultValue The new atrDefaultValue value
*/
public void setAtrDefaultValue(String atrDefaultValue)
{
this.atrDefaultValue = atrDefaultValue;
}
/**
* Gets the atrDefaultValue attribute of the AtrBean object
*
*@return The atrDefaultValue value
*/
public String getAtrDefaultValue()
{
if (atrDefaultValue == null) {
return "";
}
return atrDefaultValue;
}
/**
* Gets the atrDefaultValue attribute of the AtrBean object
*
*@return The atrDefaultValue value
*/
public String getAtrDefaultValue(String lang)
{
return parse(atrDefaultValue,lang);
}
/**
* Sets the atrType attribute of the AtrBean object
*
*@param atrType The new atrType value
*/
public void setAtrType(int atrType)
{
this.atrType = atrType;
}
/**
* Gets the atrType attribute of the AtrBean object
*
*@return The atrType value
*/
public int getAtrType()
{
return atrType;
}
/**
* Sets the docId attribute of the AtrBean object
*
*@param docId The new docId value
*/
public void setDocId(int docId)
{
this.docId = docId;
}
/**
* Gets the docId attribute of the AtrBean object
*
*@return The docId value
*/
public int getDocId()
{
return docId;
}
/**
* Sets the valueString attribute of the AtrBean object
*
*@param valueString The new valueString value
*/
public void setValueString(String valueString)
{
this.valueString = valueString;
}
/**
* Gets the valueString attribute of the AtrBean object
*
*@return The valueString value
*/
public String getValueString()
{
return valueString;
}
/**
* Sets the valueInt attribute of the AtrBean object
*
*@param valueInt The new valueInt value
*/
public void setValueNumber(double valueNumber)
{
this.valueNumber = valueNumber;
}
/**
* Gets the valueInt attribute of the AtrBean object
*
*@return The valueInt value
*/
public double getValueNumber()
{
return valueNumber;
}
public void setValueInt(int valueInt)
{
valueNumber = valueInt;
}
public int getValueInt()
{
return((int)Math.round(valueNumber));
}
/**
* Sets the valueBool attribute of the AtrBean object
*
*@param valueBool The new valueBool value
*/
public void setValueBool(boolean valueBool)
{
this.valueBool = valueBool;
}
/**
* Gets the valueBool attribute of the AtrBean object
*
*@return The valueBool value
*/
public boolean isValueBool()
{
return valueBool;
}
public void setOrderPriority(int orderPriority)
{
this.orderPriority = orderPriority;
}
public int getOrderPriority()
{
return orderPriority;
}
public void setAtrGroup(String atrGroup)
{
this.atrGroup = atrGroup;
}
public String getAtrGroup()
{
return atrGroup;
}
public String getAtrGroup(String lang)
{
return parse(atrGroup, lang);
}
public String getTrueValue()
{
return trueValue;
}
public void setTrueValue(String trueValue)
{
this.trueValue = trueValue;
}
public String getFalseValue()
{
return falseValue;
}
public void setFalseValue(String falseValue)
{
this.falseValue = falseValue;
}
/**
* vygeneruje HTML podobu atributu
* @param onWebPage HTML kod pre webovu stranku
* @return
*/
public String getHtml(String lang)
{
StringBuilder ret;
String actualValue = "";
//ak mame docid, znamena to, ze uz to ma v DB nejaku hodnotu
if (docId > 0)
{
actualValue = getValue();
}
String delimeter = ",";
if(getAtrDefaultValue() != null && getAtrDefaultValue().indexOf("|") != -1)
{
delimeter = "|"; //ak najdem '|', parsujem podla '|'
}
StringTokenizer st = new StringTokenizer(getAtrDefaultValue(), delimeter);
if (st.countTokens()>1)
{
ret = new StringBuilder("");
}
else
{
if (getAtrDefaultValue(lang)!=null && getAtrDefaultValue(lang).startsWith("multiline"))
{
int cols=40;
int rows=4;
st = new StringTokenizer(getAtrDefaultValue(lang), "-");
if (st.countTokens() == 3)
{
st.nextToken();
//pocet stlpcov
cols = Tools.getIntValue(st.nextToken(), cols);
rows = Tools.getIntValue(st.nextToken(), rows);
}
if (docId < 1)
{
actualValue = "";
}
ret = new StringBuilder("");
}
else if (getAtrDefaultValue(lang)!=null && getAtrDefaultValue(lang).equals("autoSelect"))
{
ret = new StringBuilder("");
}
else
{
if (docId < 1)
{
actualValue = getAtrDefaultValue(lang);
}
if (getAtrType()==AtrDB.TYPE_BOOL)
{
ret = new StringBuilder(" ").append(getFalseValue());
ret.append(" ");
ret.append(" ").append(getTrueValue());
}
else
{
ret = new StringBuilder("");
}
}
}
return (ret.toString());
}
public static String parse(String str, String lang)
{
if (str == null)
return null;
String[] tokens = str.split("\\|");
if (tokens != null && tokens.length > 1)
{
for (String s : tokens)
{
if (s.indexOf(':') != -1)
{
if (s.substring(0, s.indexOf(':')).equalsIgnoreCase(lang))
{
return s.substring(s.indexOf(':') + 1, s.length());
}
}
}
}
else
{
if (tokens!=null && tokens.length==1){
if (tokens[0].indexOf(':') != -1){
return tokens[0].substring(tokens[0].indexOf(':') + 1, tokens[0].length());
}
}
return str;
}
return str;
}
}