Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToShortPrimitiveConverter.java')
-rw-r--r--bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToShortPrimitiveConverter.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToShortPrimitiveConverter.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToShortPrimitiveConverter.java
new file mode 100644
index 00000000000..b3ed66a6305
--- /dev/null
+++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToShortPrimitiveConverter.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * db4objects - Initial API and implementation
+ */
+package org.eclipse.core.internal.databinding.conversion;
+
+import org.eclipse.core.databinding.conversion.IConverter;
+
+
+
+
+/**
+ * StringToShortPrimitiveConverter.
+ */
+public class StringToShortPrimitiveConverter implements IConverter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
+ */
+ public Object convert(Object source) {
+ try {
+ return new Short(Short.parseShort((String) source));
+ } catch (Exception e) {
+ throw new IllegalArgumentException("String2Short: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public Object getFromType() {
+ return String.class;
+ }
+
+ public Object getToType() {
+ return Short.TYPE;
+ }
+
+}

Back to the top