summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/ui
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-12-19 16:03:41 +0200
committerNoel Grandin <noel@peralex.com>2015-01-05 08:23:29 +0200
commit43cc8ad33e815522e2b23ac87a4a9c4526cd85c9 (patch)
treeb042266508f8b084bc7bbe9cc57250a971311099 /wizards/com/sun/star/wizards/ui
parentcfcbe2e44e33f4a60e70006ff5e1cbb9aa2adceb (diff)
java: remove dead code
found by UCDetector Change-Id: I6b0f49529379072da566e927b86815f173e7a90b
Diffstat (limited to 'wizards/com/sun/star/wizards/ui')
-rw-r--r--wizards/com/sun/star/wizards/ui/AggregateComponent.java7
-rw-r--r--wizards/com/sun/star/wizards/ui/ButtonList.java81
-rw-r--r--wizards/com/sun/star/wizards/ui/CommandFieldSelection.java2
-rw-r--r--wizards/com/sun/star/wizards/ui/FieldSelection.java5
-rw-r--r--wizards/com/sun/star/wizards/ui/UnoDialog.java11
-rw-r--r--wizards/com/sun/star/wizards/ui/WizardDialog.java37
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAware.java170
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAwareFields.java488
8 files changed, 1 insertions, 800 deletions
diff --git a/wizards/com/sun/star/wizards/ui/AggregateComponent.java b/wizards/com/sun/star/wizards/ui/AggregateComponent.java
index 4e2102f9ba2d..6957bdb2d62a 100644
--- a/wizards/com/sun/star/wizards/ui/AggregateComponent.java
+++ b/wizards/com/sun/star/wizards/ui/AggregateComponent.java
@@ -48,7 +48,6 @@ public class AggregateComponent extends ControlScroller
private String slblAggregate;
private String slblFieldNames;
private String sDuplicateAggregateFunction;
- private int Count;
private static final int SOADDROW = 1;
private static final int SOREMOVEROW = 2;
private ArrayList<ControlRow> ControlRowVector;
@@ -61,7 +60,6 @@ public class AggregateComponent extends ControlScroller
try
{
this.CurDBMetaData = _CurDBMetaData;
- Count = 1;
CurUnoDialog.insertRadioButton("optDetailQuery", 0, new ActionListenerImpl(),
new String[]
{
@@ -177,11 +175,6 @@ public class AggregateComponent extends ControlScroller
}
}
- public int getCount()
- {
- return Count;
- }
-
protected void insertControlGroup(int i, int ypos)
{
if (i == 0)
diff --git a/wizards/com/sun/star/wizards/ui/ButtonList.java b/wizards/com/sun/star/wizards/ui/ButtonList.java
index 6fab9de4a712..51a7c84a2481 100644
--- a/wizards/com/sun/star/wizards/ui/ButtonList.java
+++ b/wizards/com/sun/star/wizards/ui/ButtonList.java
@@ -52,7 +52,6 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
private int rows = 3;
private Size m_aButtonSize = new Size(20, 20);
private Size pos;
- private Size selectionGap = new Size(2, 2);
private boolean showButtons = true;
private Short step;
private static final boolean refreshOverNull = true;
@@ -68,14 +67,6 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
private IRenderer counterRenderer = new SimpleCounterRenderer();
private final static int LINE_HEIGHT = 8;
- /** Getter for property m_aButtonSize.
- * @return Value of property m_aButtonSize.
- *
- */
- public Size getButtonSize()
- {
- return this.m_aButtonSize;
- }
public void setName(String _sName)
{
m_aControlName = _sName;
@@ -410,61 +401,16 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
}
}
- public int getCols()
- {
- return cols;
- }
-
- public Size getGap()
- {
- return gap;
- }
-
private ListModel getListModel()
{
return listModel;
}
- public Short getStep()
- {
- return step;
- }
-
- public int getPageStart()
- {
- return pageStart;
- }
-
- public Size getPos()
- {
- return pos;
- }
-
- public IImageRenderer getRenderer()
- {
- return renderer;
- }
-
- public int getRows()
- {
- return rows;
- }
-
public int getSelected()
{
return m_nCurrentSelection;
}
- public Size getSelectionGap()
- {
- return selectionGap;
- }
-
- public boolean isShowButtons()
- {
- return showButtons;
- }
-
public void setCols(int i)
{
cols = i;
@@ -540,7 +486,6 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
public void setSelectionGap(Size size)
{
- selectionGap = size;
}
public void setShowButtons(boolean b)
@@ -586,15 +531,6 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
return UnoRuntime.queryInterface(XControl.class, control).getModel();
}
- public Object[] getSelectedObjects()
- {
- return new Object[]
- {
- getListModel().getElementAt(m_nCurrentSelection)
- };
- }
-
-
public interface IImageRenderer extends IRenderer
{
@@ -627,23 +563,6 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
}
}
- public Object getSelectedObject()
- {
- return m_nCurrentSelection >= 0 ? getListModel().getElementAt(m_nCurrentSelection) : null;
- }
-
-
- public void setRowSelect(boolean b)
- {
- rowSelect = b;
- }
-
- public boolean isRowSelect()
- {
- return rowSelect;
- }
-
-
public boolean isenabled()
{
return benabled;
diff --git a/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java
index 59bd1c770644..5638da4f5fbf 100644
--- a/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java
+++ b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java
@@ -245,7 +245,7 @@ public class CommandFieldSelection extends FieldSelection implements Comparator<
* @return
* @throws com.sun.star.wizards.common.TerminateWizardException
*/
- private short fillupCommandListBox() throws com.sun.star.wizards.common.TerminateWizardException
+ private short fillupCommandListBox()
{
short[] iSelArray = new short[0];
boolean bgetFields = false;
diff --git a/wizards/com/sun/star/wizards/ui/FieldSelection.java b/wizards/com/sun/star/wizards/ui/FieldSelection.java
index f20007434f60..88dea0fe9f14 100644
--- a/wizards/com/sun/star/wizards/ui/FieldSelection.java
+++ b/wizards/com/sun/star/wizards/ui/FieldSelection.java
@@ -139,11 +139,6 @@ public class FieldSelection
AppendMode = _AppendMode;
}
- public boolean getAppendMode()
- {
- return AppendMode;
- }
-
public FieldSelection(UnoDialog CurUnoDialog, int _iStep, int CompPosX, int CompPosY, int CompWidth, int CompHeight, String slblFields, String slblSelFields, int _FirstHelpIndex, boolean bshowFourButtons)
{
try
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.java b/wizards/com/sun/star/wizards/ui/UnoDialog.java
index 0587e0cc32e5..07560e0a12cd 100644
--- a/wizards/com/sun/star/wizards/ui/UnoDialog.java
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog.java
@@ -541,17 +541,6 @@ public class UnoDialog
return xDialog.execute();
}
- public void setVisible(UnoDialog parent) throws com.sun.star.uno.Exception
- {
- calculateDialogPosition(parent.xWindow.getPosSize());
- if (xWindowPeer == null)
- {
- createWindowPeer();
- }
- xDialog = UnoRuntime.queryInterface(XDialog.class, xUnoDialog);
- this.xWindow.setVisible(true);
- }
-
/**
* @return 0 for cancel, 1 for ok.
*/
diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java
index 523673ab5a5b..615429872884 100644
--- a/wizards/com/sun/star/wizards/ui/WizardDialog.java
+++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java
@@ -102,26 +102,6 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
nMaxStep = i;
}
- public int getMaxStep()
- {
- return nMaxStep;
- }
-
- public void setOldStep(int i)
- {
- nOldStep = i;
- }
-
- public int getOldStep()
- {
- return nOldStep;
- }
-
- public void setNewStep(int i)
- {
- nNewStep = i;
- }
-
public int getNewStep()
{
return nNewStep;
@@ -252,18 +232,6 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
sRMItemLabels = _oResource.getResArray(StartResID, nMaxStep);
}
- public String[] getRMItemLabels()
- {
- return sRMItemLabels;
- }
-
- /* public void insertRoadmapItems(int StartIndex, int RMCount)
- {
- Object oRoadmapItem;
- boolean bEnabled;
- for (int i = StartIndex; i < (StartIndex + RMCount); i++)
- insertSingleRoadmapItem(i, true, sRMItemLabels[i], i);
- }*/
public int insertRoadmapItem(int _Index, boolean _bEnabled, int _LabelID, int _CurItemID)
{
return insertRoadmapItem(_Index, _bEnabled, sRMItemLabels[_LabelID], _CurItemID);
@@ -614,11 +582,6 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
removeTerminateListener();
}
- public int getMaximalStep()
- {
- return this.nMaxStep;
- }
-
public int getCurrentStep()
{
try
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.java b/wizards/com/sun/star/wizards/ui/event/DataAware.java
deleted file mode 100644
index 61e5e3f8b478..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/DataAware.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * 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 .
- */
-package com.sun.star.wizards.ui.event;
-
-import java.util.Arrays;
-
-/**
- * DataAware objects are used to live-synchronize UI and DataModel/DataObject.
- * It is used as listener on UI events, to keep the DataObject up to date.
- * This class, as a base abstract class, sets a frame of functionality,
- * delegating the data Object get/set methods to a Value object,
- * and leaving the UI get/set methods abstract.
- * Note that event listenning is *not* a part of this model.
- * the updateData() or updateUI() methods should be porogramatically called.
- * in child classes, the updateData() will be binded to UI event calls.
- * <br><br>
- * This class holds references to a Data Object and a Value object.
- * The Value object "knows" how to get and set a value from the
- * Data Object.
- */
-public abstract class DataAware {
-
- /**
- * this is the data object.
- */
- private Object dataObject;
- /**
- * A Value Object knows how to get/set a value
- * from/to the data object.
- */
- private Value value;
-
- /**
- * creates a DataAware object for the given data object and Value object.
- * @param dataObject_
- * @param value_
- */
- protected DataAware(Object dataObject_, Value value_) {
- dataObject = dataObject_;
- value = value_;
- }
-
- /**
- * returns the data object.
- */
- private Object getDataObject() {
- return dataObject;
- }
-
- /**
- * Sets the given value to the data object.
- * this method delegates the job to the
- * Value object, but can be overwritten if
- * another kind of Data is needed.
- * @param newValue the new value to set to the DataObject.
- */
- private void setToData(Object newValue) {
- value.set(newValue,getDataObject());
- }
-
- /**
- * gets the current value from the data object.
- * this method delegates the job to
- * the value object.
- * @return the current value of the data object.
- */
- private Object getFromData() {
- return value.get(getDataObject());
- }
-
- /**
- * sets the given value to the UI control
- * @param newValue the value to set to the ui control.
- */
- protected abstract void setToUI(Object newValue);
-
- /**
- * gets the current value from the UI control.
- * @return the current value from the UI control.
- */
- protected abstract Object getFromUI();
-
- /**
- * enables
- * @param currentValue
- */
- private void enableControls(Object currentValue) {
- }
-
- /**
- * updates the DataObject according to
- * the current state of the UI control.
- */
- public void updateData() {
- Object data = getFromData();
- Object ui = getFromUI();
- if (!equals(data, ui))
- setToData(ui);
- enableControls(ui);
- }
-
- /**
- * compares the two given objects.
- * This method is null safe and returns true also if both are null...
- * If both are arrays, treats them as array of short and compares them.
- * @param a first object to compare
- * @param b second object to compare.
- * @return true if both are null or both are equal.
- */
- private boolean equals(Object a, Object b) {
- if (a == null && b == null)
- return true;
- if (a == null || b == null)
- return false;
- if (a.getClass().isArray()) {
- if (b.getClass().isArray())
- return Arrays.equals((short[]) a, (short[]) b);
- else
- return false;
- }
- return a.equals(b);
- }
-
-
-
-
-
-
-
- /**
- * Value objects read and write a value from and
- * to an object. Typically using reflection and JavaBeans properties
- * or directly using member reflection API.
- * DataAware delegates the handling of the DataObject
- * to a Value object.
- * 2 implementations currently exist: PropertyValue,
- * using JavaBeans properties reflection, and DataAwareFields classes
- * which implement different member types.
- */
- interface Value {
- /**
- * gets a value from the given object.
- * @param target the object to get the value from.
- * @return the value from the given object.
- */
- Object get(Object target);
- /**
- * sets a value to the given object.
- * @param value the value to set to the object.
- * @param target the object to set the value to.
- */
- void set(Object value, Object target);
- }
-
-}
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.java b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.java
deleted file mode 100644
index ee5ba4df539c..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * 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 .
- */
-package com.sun.star.wizards.ui.event;
-
-import java.lang.reflect.Field;
-
-import com.sun.star.wizards.common.PropertyNames;
-import com.sun.star.uno.Any;
-
-/**
- * This class is a factory for Value objects for different types of
- * members.
- * Other than some Value implementations classes this class contains static
- * type conversion methods and factory methods.
- *
- * @see com.sun.star.wizards.ui.event.DataAware.Value
- */
-public class DataAwareFields
-{
-
- private static final String TRUE = "true";
-
- /**
- * returns a Value Object which sets and gets values
- * and converting them to other types, according to the "value" argument.
- */
- public static DataAware.Value getFieldValueFor(Object owner, String fieldname, Object value)
- {
- try
- {
- Field f = owner.getClass().getField(fieldname);
-
- Class<?> c = f.getType();
- Class<?> c2 = value.getClass();
- if (c.equals(Boolean.TYPE))
- {
- return new BooleanFieldValue(f, c2);
- }
- else if (c.equals(Integer.TYPE))
- {
- return new IntFieldValue(f, c2);
- }
- else if (c.equals(Double.TYPE))
- {
- return new DoubleFieldValue(f, c2);
- }
- else if (c.equals(String.class) && c2.equals(Integer.class))
- {
- return new ConvertedStringValue(f, c2);
- }
- else
- {
- return new SimpleFieldValue(f);
- }
- }
- catch (NoSuchFieldException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- /**
- * an abstract implementation of DataAware.Value to access
- * object members (fields) using reflection.
- */
- private static abstract class FieldValue implements DataAware.Value
- {
-
- Field field;
-
- public FieldValue(Field field_)
- {
- field = field_;
- }
-
- }
-
- private static class BooleanFieldValue extends FieldValue
- {
-
- private final Class<?> convertTo;
-
- public BooleanFieldValue(Field f, Class<?> convertTo_)
- {
- super(f);
- convertTo = convertTo_;
- }
-
- /* (non-Javadoc)
- * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
- */
- public Object get(Object target)
- {
- try
- {
- boolean b = field.getBoolean(target);
- if (convertTo.equals(Boolean.class))
- {
- return b ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (Number.class.isAssignableFrom(convertTo))
- {
- return toNumber(b ? 1 : 0, convertTo);
- }
- else if (convertTo.equals(String.class))
- {
- return String.valueOf(b);
- }
- else if (convertTo.isArray())
- {
- return toShortArray(toInt(b));
- }
- else
- {
- throw new IllegalArgumentException("Cannot convert boolean value to given type (" + convertTo.getName() + ").");
- }
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- public void set(Object value, Object target)
- {
- try
- {
- field.setBoolean(target, toBoolean(value));
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- }
- }
- }
-
- private static class IntFieldValue extends FieldValue
- {
-
- private final Class<?> convertTo;
-
- public IntFieldValue(Field f, Class<?> convertTo_)
- {
- super(f);
- convertTo = convertTo_;
- }
-
- /* (non-Javadoc)
- * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
- */
- public Object get(Object target)
- {
- try
- {
- int i = field.getInt(target);
- if (convertTo.equals(Boolean.class))
- {
- return i != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (Number.class.isAssignableFrom(convertTo))
- {
- return toNumber(i, convertTo);
- }
- else if (convertTo.equals(String.class))
- {
- return String.valueOf(i);
- }
- else if (convertTo.isArray())
- {
- return toShortArray(i);
- }
- else
- {
- throw new IllegalArgumentException("Cannot convert int value to given type (" + convertTo.getName() + ").");
- }
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- public void set(Object value, Object target)
- {
- try
- {
- field.setInt(target, (int) toDouble(value));
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- }
- }
- }
-
- private static class DoubleFieldValue extends FieldValue
- {
-
- private final Class<?> convertTo;
-
- public DoubleFieldValue(Field f, Class<?> convertTo_)
- {
- super(f);
- convertTo = convertTo_;
- }
-
- /* (non-Javadoc)
- * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
- */
- public Object get(Object target)
- {
- try
- {
- double d = field.getDouble(target);
- if (convertTo.equals(Boolean.class))
- {
- return d != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (Number.class.isAssignableFrom(convertTo))
- {
- return toNumber(d, convertTo);
- }
- else if (convertTo.equals(String.class))
- {
- return String.valueOf(d);
- }
- else if (convertTo.isArray())
- {
- return toShortArray(d);
- }
- else
- {
- throw new IllegalArgumentException("Cannot convert int value to given type (" + convertTo.getName() + ").");
- }
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- public void set(Object value, Object target)
- {
- try
- {
- field.setDouble(target, toDouble(value));
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- }
- }
- }
-
- private static class ConvertedStringValue extends FieldValue
- {
-
- private final Class<?> convertTo;
-
- public ConvertedStringValue(Field f, Class<?> convertTo_)
- {
- super(f);
- convertTo = convertTo_;
- }
-
- /* (non-Javadoc)
- * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
- */
- public Object get(Object target)
- {
- try
- {
- String s = (String) field.get(target);
-
- if (convertTo.equals(Boolean.class))
- {
- return (s != null && !s.equals(PropertyNames.EMPTY_STRING) && s.equals("true")) ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (convertTo.equals(Integer.class))
- {
- if (s == null || s.equals(PropertyNames.EMPTY_STRING))
- {
- return Any.VOID;
- }
- else
- {
- return Integer.valueOf(s);
- }
- }
- else if (convertTo.equals(Double.class))
- {
- if (s == null || s.equals(PropertyNames.EMPTY_STRING))
- {
- return Any.VOID;
- }
- else
- {
- return new Double(s);
- }
- }
- else
- {
- throw new IllegalArgumentException("Cannot convert int value to given type (" + convertTo.getName() + ").");
- }
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- public void set(Object value, Object target)
- {
- try
- {
- field.set(target, value == null || (value.equals(Any.VOID)) ? PropertyNames.EMPTY_STRING : value.toString());
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- }
- }
- }
-
- private static class SimpleFieldValue extends FieldValue
- {
-
- public SimpleFieldValue(Field f)
- {
- super(f);
- }
- /* (non-Javadoc)
- * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
- */
-
- public Object get(Object target)
- {
- try
- {
- if (target == null)
- {
- if (field.getType().equals(String.class))
- {
- return PropertyNames.EMPTY_STRING;
- }
- if (field.getType().equals(Short.class))
- {
- return Short.valueOf((short) 0);
- }
- if (field.getType().equals(Integer.class))
- {
- return 0;
- }
- if (field.getType().equals(short[].class))
- {
- return new short[0];
- }
- else
- {
- return null;
- }
- }
- else
- {
- return field.get(target);
- }
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- public void set(Object value, Object target)
- {
- try
- {
- field.set(target, value);
- }
- catch (IllegalAccessException ex)
- {
- ex.printStackTrace();
- }
- }
- }
-
- private static double toDouble(Object value)
- {
- if (value instanceof Boolean)
- {
- return ((Boolean) value).booleanValue() ? 1 : 0;
- }
- else if (value instanceof Number)
- {
- return ((Number) value).doubleValue();
- }
- else if (value instanceof String)
- {
- return Double.parseDouble((String) value);
- }
- else if (value instanceof short[])
- {
- return ((short[]) value).length == 0 ? 0 : ((short[]) value)[0];
- }
- else
- {
- throw new IllegalArgumentException("Can't convert value to double." + value.getClass().getName());
- }
- }
-
- private static boolean toBoolean(Object value)
- {
- if (value instanceof Boolean)
- {
- return ((Boolean) value).booleanValue();
- }
- else if (value instanceof Number)
- {
- return ((Number) value).intValue() != 0;
- }
- else if (value instanceof String)
- {
- return value.equals(TRUE);
- }
- else if (value instanceof short[])
- {
- return ((short[]) value).length != 0 && ((short[]) value)[0] != 0;
- }
- else
- {
- throw new IllegalArgumentException("Can't convert value to boolean." + value.getClass().getName());
- }
- }
-
- private static int toInt(boolean b)
- {
- return b ? 1 : 0;
- }
-
- private static short[] toShortArray(double i)
- {
- return new short[]
- {
- (short) i
- };
- }
-
- private static Number toNumber(double i, Class<?> c)
- {
- if (c.equals(Integer.class))
- {
- return Integer.valueOf((int) i);
- }
- else if (c.equals(Short.class))
- {
- return Short.valueOf((short) i);
- }
- else if (c.equals(Double.class))
- {
- return new Double(i);
- }
- else
- {
- throw new IllegalArgumentException("Cannot convert to the given Number type.");
- }
- }
-}