You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/07/11 12:56:36 UTC
[24/61] [partial] ISIS-831: digression: moving progmodel/facets into
metamodel/facets
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoublePrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoublePrimitiveValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoublePrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..dda60d3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoublePrimitiveValueSemanticsProvider.java
@@ -0,0 +1,53 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.doubles;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class DoublePrimitiveValueSemanticsProvider extends DoubleValueSemanticsProviderAbstract implements PropertyDefaultFacet {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public DoublePrimitiveValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public DoublePrimitiveValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, double.class, configuration, context);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // PropertyDefaultFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public ObjectAdapter getDefault(final ObjectAdapter inObject) {
+ return createAdapter(double.class, new Double(0.0));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleValueSemanticsProviderAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..c1f5db1
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleValueSemanticsProviderAbstract.java
@@ -0,0 +1,112 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.doubles;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public abstract class DoubleValueSemanticsProviderAbstract extends ValueSemanticsProviderAndFacetAbstract<Double> implements DoubleFloatingPointValueFacet {
+
+ private static Class<? extends Facet> type() {
+ return DoubleFloatingPointValueFacet.class;
+ }
+
+ private static final Double DEFAULT_VALUE = new Double(0.0d);
+ private static final int TYPICAL_LENGTH = 10;
+
+ private final NumberFormat format;
+
+ public DoubleValueSemanticsProviderAbstract(final FacetHolder holder, final Class<Double> adaptedClass, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(type(), holder, adaptedClass, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE, configuration, context);
+ format = determineNumberFormat("value.format.double");
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Double doParse(final Object context, final String entry) {
+ try {
+ return new Double(format.parse(entry).doubleValue());
+ } catch (final ParseException e) {
+ throw new TextEntryParseException("Not floating point number " + entry, e);
+ }
+ }
+
+ // ///////////////////////////////////////////////////////////////////////////
+ // TitleProvider
+ // ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public String titleString(final Object value, final Localization localization) {
+ return titleString(format, value);
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return titleString(new DecimalFormat(usingMask), value);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ return object.toString();
+ }
+
+ @Override
+ protected Double doRestore(final String data) {
+ return new Double(data);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // DoubleValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public Double doubleValue(final ObjectAdapter object) {
+ return (Double) (object == null ? null : object.getObject());
+ }
+
+ @Override
+ public ObjectAdapter createValue(final Double value) {
+ return getAdapterManager().adapterFor(value);
+ }
+
+ // /////// toString ///////
+ @Override
+ public String toString() {
+ return "DoubleValueSemanticsProvider: " + format;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..820cc4a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.doubles;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class DoubleWrapperValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Double> {
+
+ public DoubleWrapperValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != Double.class) {
+ return;
+ }
+ addFacets(new DoubleWrapperValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueSemanticsProvider.java
new file mode 100644
index 0000000..2e35fb2
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/doubles/DoubleWrapperValueSemanticsProvider.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.doubles;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class DoubleWrapperValueSemanticsProvider extends DoubleValueSemanticsProviderAbstract {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public DoubleWrapperValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public DoubleWrapperValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, Double.class, configuration, context);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..cd378af
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.floats;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class FloatPrimitiveValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Float> {
+
+ public FloatPrimitiveValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != float.class) {
+ return;
+ }
+ addFacets(new FloatPrimitiveValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..55759d0
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatPrimitiveValueSemanticsProvider.java
@@ -0,0 +1,53 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.floats;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class FloatPrimitiveValueSemanticsProvider extends FloatValueSemanticsProviderAbstract implements PropertyDefaultFacet {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public FloatPrimitiveValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public FloatPrimitiveValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, float.class, configuration, context);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // PropertyDefaultFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public ObjectAdapter getDefault(final ObjectAdapter adapter) {
+ return createAdapter(float.class, new Float(0.0f));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatValueSemanticsProviderAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..f4fc025
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatValueSemanticsProviderAbstract.java
@@ -0,0 +1,109 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.floats;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class FloatValueSemanticsProviderAbstract extends ValueSemanticsProviderAndFacetAbstract<Float> implements FloatingPointValueFacet {
+
+ public static Class<? extends Facet> type() {
+ return FloatingPointValueFacet.class;
+ }
+
+ private static final Float DEFAULT_VALUE = new Float(0.0f);
+ private static final int TYPICAL_LENGTH = 12;
+
+ private final NumberFormat format;
+
+ public FloatValueSemanticsProviderAbstract(final FacetHolder holder, final Class<Float> adaptedClass, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(type(), holder, adaptedClass, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE, configuration, context);
+ format = determineNumberFormat("value.format.float");
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Float doParse(final Object context, final String entry) {
+ try {
+ return new Float(format.parse(entry).floatValue());
+ } catch (final ParseException e) {
+ throw new TextEntryParseException("Not a floating point number " + entry, e);
+ }
+ }
+
+ @Override
+ public String titleString(final Object value, final Localization localization) {
+ return titleString(format, value);
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return titleString(new DecimalFormat(usingMask), value);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ return object.toString();
+ }
+
+ @Override
+ protected Float doRestore(final String data) {
+ return new Float(data);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // FloatingPointValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public Float floatValue(final ObjectAdapter object) {
+ return object == null ? null : (Float) object.getObject();
+ }
+
+ @Override
+ public ObjectAdapter createValue(final Float value) {
+ return getAdapterManager().adapterFor(value);
+ }
+
+ // /////// toString ///////
+
+ @Override
+ public String toString() {
+ return "FloatValueSemanticsProvider: " + format;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..4019e96
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.floats;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class FloatWrapperValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Float> {
+
+ public FloatWrapperValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != Float.class) {
+ return;
+ }
+ addFacets(new FloatWrapperValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueSemanticsProvider.java
new file mode 100644
index 0000000..2ab548a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatWrapperValueSemanticsProvider.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.floats;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class FloatWrapperValueSemanticsProvider extends FloatValueSemanticsProviderAbstract {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public FloatWrapperValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public FloatWrapperValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, Float.class, configuration, context);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatingPointValueFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatingPointValueFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatingPointValueFacet.java
new file mode 100644
index 0000000..1c5b15c
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/floats/FloatingPointValueFacet.java
@@ -0,0 +1,30 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.floats;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface FloatingPointValueFacet extends Facet {
+
+ Float floatValue(ObjectAdapter object);
+
+ ObjectAdapter createValue(Float value);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacet.java
new file mode 100644
index 0000000..c16d60b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacet.java
@@ -0,0 +1,34 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.image;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface ImageValueFacet extends Facet {
+
+ ObjectAdapter createValue(java.awt.Image image);
+
+ java.awt.Image getImage(ObjectAdapter object);
+
+ int getHeight(ObjectAdapter object);
+
+ int getWidth(ObjectAdapter object);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..9b000e5
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.image;
+
+import org.apache.isis.applib.value.Image;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class ImageValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Image> {
+
+ public ImageValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != org.apache.isis.applib.value.Image.class) {
+ return;
+ }
+ addFacets(new ImageValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProvider.java
new file mode 100644
index 0000000..526266a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProvider.java
@@ -0,0 +1,101 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.image;
+
+import org.apache.isis.applib.value.Image;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class ImageValueSemanticsProvider extends ImageValueSemanticsProviderAbstract<Image> {
+
+ public ImageValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, Image.class, configuration, context);
+ }
+
+ @Override
+ public int getHeight(final ObjectAdapter object) {
+ return image(object).getHeight();
+ }
+
+ private Image image(final ObjectAdapter object) {
+ return (Image) object.getObject();
+ }
+
+ @Override
+ public java.awt.Image getImage(final ObjectAdapter object) {
+ return createImage(image(object).getImage());
+ }
+
+ @Override
+ protected int[][] getPixels(final Object object) {
+ return ((Image) object).getImage();
+ }
+
+ public Class<?> getValueClass() {
+ return Image.class;
+ }
+
+ @Override
+ public int getWidth(final ObjectAdapter object) {
+ return image(object).getWidth();
+ }
+
+ @Override
+ protected Image setPixels(final int[][] pixels) {
+ return new Image(pixels);
+ }
+
+ @Override
+ public Facet getUnderlyingFacet() {
+ return null;
+ }
+
+ /**
+ * Not required because {@link #alwaysReplace()} is <tt>false</tt>.
+ */
+ @Override
+ public void setUnderlyingFacet(final Facet underlyingFacet) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean alwaysReplace() {
+ return false;
+ }
+
+ @Override
+ public boolean isNoop() {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "ImageValueSemanticsProvider: ";
+ }
+
+ @Override
+ public ObjectAdapter createValue(final java.awt.Image image) {
+ return getAdapterManager().adapterFor(new Image(grabPixels(image)));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProviderAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..486b372
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/image/ImageValueSemanticsProviderAbstract.java
@@ -0,0 +1,299 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.image;
+
+import java.awt.Image;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.MemoryImageSource;
+import java.awt.image.PixelGrabber;
+
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.exceptions.UnexpectedCallException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public abstract class ImageValueSemanticsProviderAbstract<T> extends ValueSemanticsProviderAndFacetAbstract<T> implements ImageValueFacet {
+
+ private static final int TYPICAL_LENGTH = 18;
+ private static final Object DEFAULT_VALUE = null; // no default
+
+ private static final char[] BASE_64_CHARS = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
+ 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', };
+
+ protected static final byte[] REVERSE_BASE_64_CHARS = new byte[0x100];
+
+ static {
+ for (int i = 0; i < REVERSE_BASE_64_CHARS.length; i++) {
+ REVERSE_BASE_64_CHARS[i] = -1;
+ }
+ for (byte i = 0; i < BASE_64_CHARS.length; i++) {
+ REVERSE_BASE_64_CHARS[BASE_64_CHARS[i]] = i;
+ }
+ }
+
+ private FacetHolder facetHolder;
+
+ @SuppressWarnings("unchecked")
+ public ImageValueSemanticsProviderAbstract(final FacetHolder holder, final Class<T> adaptedClass, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(ImageValueFacet.class, holder, adaptedClass, TYPICAL_LENGTH, Immutability.NOT_IMMUTABLE, EqualByContent.NOT_HONOURED, (T) DEFAULT_VALUE, configuration, context);
+ }
+
+ /**
+ * Returns null to indicate that this value does not parse entry strings
+ */
+ @Override
+ public Parser<T> getParser() {
+ return null;
+ }
+
+ @Override
+ protected T doParse(final Object original, final String entry) {
+ throw new UnexpectedCallException();
+ }
+
+ public byte[] getAsByteArray(final ObjectAdapter object) {
+ final int[] flatIntArray = flatten(object);
+ final byte[] byteArray = new byte[flatIntArray.length * 4];
+ for (int i = 0; i < flatIntArray.length; i++) {
+ final int value = flatIntArray[i];
+ byteArray[i * 4] = (byte) ((value >> 24) & 0xff);
+ byteArray[i * 4 + 1] = (byte) ((value >> 16) & 0xff);
+ byteArray[i * 4 + 2] = (byte) ((value >> 8) & 0xff);
+ byteArray[i * 4 + 3] = (byte) (value & 0xff);
+ }
+ return byteArray;
+ }
+
+ private static int byteArrayToInt(final byte[] byteArray, final int offset) {
+ int value = 0;
+ for (int i = 0; i < 4; i++) {
+ final int shift = (4 - 1 - i) * 8;
+ value += (byteArray[i + offset] & 0x000000FF) << shift;
+ }
+ return value;
+ }
+
+ @Override
+ public boolean alwaysReplace() {
+ return false;
+ }
+
+ @Override
+ public Facet getUnderlyingFacet() {
+ return null;
+ }
+
+ /**
+ * Not required because {@link #alwaysReplace()} is <tt>false</tt>.
+ */
+ @Override
+ public void setUnderlyingFacet(final Facet underlyingFacet) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isDerived() {
+ return false;
+ }
+
+ public T restoreFromByteArray(final byte[] byteArray) {
+ final int[] flatIntArray = new int[byteArray.length / 4];
+ for (int i = 0; i < flatIntArray.length; i++) {
+ flatIntArray[i] = byteArrayToInt(byteArray, i * 4);
+ }
+ return setPixels(inflate(flatIntArray));
+ }
+
+ private int[] flatten(final ObjectAdapter object) {
+ final int[][] image = getPixels(object);
+ final int[] flatArray = new int[(getHeight(object) * getWidth(object)) + 2];
+ int flatIndex = 0;
+ flatArray[flatIndex++] = getHeight(object);
+ flatArray[flatIndex++] = getWidth(object);
+ for (int i = 0; i < getHeight(object); i++) {
+ for (int j = 0; j < getWidth(object); j++) {
+ flatArray[flatIndex++] = image[i][j];
+ }
+ }
+ return flatArray;
+ }
+
+ private static int[][] inflate(final int[] flatIntArray) {
+ int flatIndex = 0;
+ final int height = flatIntArray[flatIndex++];
+ final int width = flatIntArray[flatIndex++];
+
+ final int[][] newImage = new int[height][width];
+
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ newImage[i][j] = flatIntArray[flatIndex++];
+ }
+ }
+ return newImage;
+ }
+
+ @Override
+ protected String doEncode(final Object object) {
+ final int[][] image = getPixels(object);
+ final int lines = image.length;
+ final int width = image[0].length;
+ final StringBuffer encodeData = new StringBuffer(lines * width * 4);
+ encodePixel(lines, encodeData);
+ encodePixel(width, encodeData);
+ for (int line = 0; line < lines; line++) {
+ for (int pixel = 0; pixel < width; pixel++) {
+ encodePixel(image[line][pixel], encodeData);
+ }
+ }
+ return encodeData.toString();
+ }
+
+ protected Image createImage(final int[][] pixels) {
+ final int lines = pixels.length;
+ final int width = pixels[0].length;
+ final int[] pix = new int[lines * width];
+ int offset = 0;
+ for (int line = 0; line < lines; line++) {
+ System.arraycopy(pixels[line], 0, pix, offset, width);
+ offset += width;
+ }
+ final MemoryImageSource source = new MemoryImageSource(width, lines, pix, 0, width);
+ return java.awt.Toolkit.getDefaultToolkit().createImage(source);
+ }
+
+ private int decodePixel(final String data, final int item) {
+ final int offset = item * 4;
+ int pixel = 0;
+ for (int i = 0; i < 4; i++) {
+ final char c = data.charAt(offset + i);
+ final byte b = REVERSE_BASE_64_CHARS[c];
+ if (i == 0 && b >= 32) {
+ pixel = 0xff;
+ }
+ pixel = (pixel << 6) + b;
+ }
+ return pixel;
+ }
+
+ private void encodePixel(final int pixel, final StringBuffer encodeData) {
+ // TODO the encoding is poor as the negative numbers are not dealt with
+ // properly because the 6 MSBs
+ // are not included.
+ if (pixel > 0x7FFFFF || pixel < -0x7FFFFF) {
+ // throw new IsisException("" + pixel);
+ }
+ for (int i = 3; i >= 0; i--) {
+ final int bitsToShift = i * 6;
+ final int c = pixel >> bitsToShift;
+ final char cc = BASE_64_CHARS[c & 0x3F];
+ encodeData.append(cc);
+ }
+ }
+
+ public String getIconName() {
+ return null;
+ }
+
+ protected abstract int[][] getPixels(Object object);
+
+ protected int[][] grabPixels(final Image image) {
+ final int width = image.getWidth(null);
+ final int lines = image.getHeight(null);
+ final int pixels[] = new int[width * lines];
+ final PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, lines, pixels, 0, width);
+ grabber.setColorModel(ColorModel.getRGBdefault());
+ try {
+ if (grabber.grabPixels() && (grabber.status() & ImageObserver.ALLBITS) != 0) {
+ final int[][] array = new int[lines][width];
+ int srcPos = 0;
+ for (int line = 0; line < lines; line++) {
+ array[line] = new int[width];
+ System.arraycopy(pixels, srcPos, array[line], 0, width);
+ for (int pixel = 0; pixel < array[line].length; pixel++) {
+ array[line][pixel] = array[line][pixel] | 0xFF000000;
+ }
+ srcPos += width;
+ }
+ return array;
+ }
+ // TODO what happens if the grab fails?
+ return new int[lines][width];
+ } catch (final InterruptedException e) {
+ throw new IsisException(e);
+ }
+ }
+
+ @Override
+ public T doRestore(final String data) {
+ final int lines = decodePixel(data, 0);
+ final int width = decodePixel(data, 1);
+ final int[][] imageData = new int[lines][width];
+ int offset = 2;
+ for (int line = 0; line < lines; line++) {
+ for (int pixel = 0; pixel < width; pixel++) {
+ imageData[line][pixel] = decodePixel(data, offset++);
+ imageData[line][pixel] = imageData[line][pixel] | 0xFF000000;
+ }
+ }
+ final T image = setPixels(imageData);
+ return image;
+ }
+
+ protected abstract T setPixels(int[][] pixels);
+
+ public void setMask(final String mask) {
+ }
+
+ @Override
+ public String titleString(final Object value, final Localization localization) {
+ return "image";
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return "image";
+ }
+
+ @Override
+ public FacetHolder getFacetHolder() {
+ return facetHolder;
+ }
+
+ @Override
+ public void setFacetHolder(final FacetHolder facetHolder) {
+ this.facetHolder = facetHolder;
+ }
+
+ // /////// toString ///////
+
+ @Override
+ public String toString() {
+ return "ImageValueSemanticsProvider";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..ad2b553
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.imageawt;
+
+import java.awt.Image;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class JavaAwtImageValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Image> {
+
+ public JavaAwtImageValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != java.awt.Image.class) {
+ return;
+ }
+ addFacets(new JavaAwtImageValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueSemanticsProvider.java
new file mode 100644
index 0000000..4b3e918
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/imageawt/JavaAwtImageValueSemanticsProvider.java
@@ -0,0 +1,84 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.imageawt;
+
+import java.awt.Image;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+import org.apache.isis.core.metamodel.facets.value.image.ImageValueSemanticsProviderAbstract;
+
+public class JavaAwtImageValueSemanticsProvider extends ImageValueSemanticsProviderAbstract<Image> {
+
+ public JavaAwtImageValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, Image.class, configuration, context);
+ }
+
+ @Override
+ public int getHeight(final ObjectAdapter object) {
+ return image(object).getHeight(null);
+ }
+
+ private Image image(final ObjectAdapter object) {
+ return (Image) object.getObject();
+ }
+
+ @Override
+ public Image getImage(final ObjectAdapter object) {
+ return image(object);
+ }
+
+ @Override
+ protected int[][] getPixels(final Object object) {
+ return grabPixels((Image) object);
+ }
+
+ public Class<?> getValueClass() {
+ return Image.class;
+ }
+
+ @Override
+ public int getWidth(final ObjectAdapter object) {
+ return image(object).getWidth(null);
+ }
+
+ @Override
+ protected Image setPixels(final int[][] pixels) {
+ return createImage(pixels);
+ }
+
+ @Override
+ public boolean isNoop() {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "JavaAwtImageValueSemanticsProvider: ";
+ }
+
+ @Override
+ public ObjectAdapter createValue(final Image image) {
+ return getAdapterManager().adapterFor(image);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..9b1cf47
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.integer;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class IntPrimitiveValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Integer> {
+
+ public IntPrimitiveValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != int.class) {
+ return;
+ }
+ addFacets(new IntPrimitiveValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..8ddf987
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java
@@ -0,0 +1,53 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.integer;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class IntPrimitiveValueSemanticsProvider extends IntValueSemanticsProviderAbstract implements PropertyDefaultFacet {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public IntPrimitiveValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public IntPrimitiveValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, int.class, configuration, context);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // PropertyDefaultFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public ObjectAdapter getDefault(final ObjectAdapter inObject) {
+ return createAdapter(int.class, Integer.valueOf(0));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntValueSemanticsProviderAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..8414df0
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntValueSemanticsProviderAbstract.java
@@ -0,0 +1,109 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.integer;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public abstract class IntValueSemanticsProviderAbstract extends ValueSemanticsProviderAndFacetAbstract<Integer> implements IntegerValueFacet {
+
+ public static Class<? extends Facet> type() {
+ return IntegerValueFacet.class;
+ }
+
+ private static final Integer DEFAULT_VALUE = Integer.valueOf(0);
+ private static final int TYPICAL_LENGTH = 9;
+
+ private final NumberFormat format;
+
+ public IntValueSemanticsProviderAbstract(final FacetHolder holder, final Class<Integer> adaptedClass, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(type(), holder, adaptedClass, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE, configuration, context);
+ format = determineNumberFormat("value.format.int");
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Integer doParse(final Object context, final String entry) {
+ try {
+ return Integer.valueOf(format.parse(entry).intValue());
+ } catch (final ParseException e) {
+ throw new TextEntryParseException("Not an whole number " + entry, e);
+ }
+ }
+
+ @Override
+ public String titleString(final Object value, final Localization localization) {
+ return titleString(format, value);
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return titleString(new DecimalFormat(usingMask), value);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ return object.toString();
+ }
+
+ @Override
+ protected Integer doRestore(final String data) {
+ return new Integer(data);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // IntegerValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public Integer integerValue(final ObjectAdapter object) {
+ return (Integer) (object == null ? null : object.getObject());
+ }
+
+ @Override
+ public ObjectAdapter createValue(final Integer value) {
+ return value == null ? null : getAdapterManager().adapterFor(value);
+ }
+
+ // /////// toString ///////
+
+ @Override
+ public String toString() {
+ return "IntegerValueSemanticsProvider: " + format;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..1e73a9d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.integer;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class IntWrapperValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Integer> {
+
+ public IntWrapperValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != Integer.class) {
+ return;
+ }
+ addFacets(new IntWrapperValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueSemanticsProvider.java
new file mode 100644
index 0000000..2ee07a9
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntWrapperValueSemanticsProvider.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.integer;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class IntWrapperValueSemanticsProvider extends IntValueSemanticsProviderAbstract {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public IntWrapperValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public IntWrapperValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, Integer.class, configuration, context);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntegerValueFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntegerValueFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntegerValueFacet.java
new file mode 100644
index 0000000..f87c3d7
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/integer/IntegerValueFacet.java
@@ -0,0 +1,29 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.integer;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface IntegerValueFacet extends Facet {
+ Integer integerValue(ObjectAdapter object);
+
+ ObjectAdapter createValue(Integer value);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..4a3246d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class LongPrimitiveValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Long> {
+
+ public LongPrimitiveValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != long.class) {
+ return;
+ }
+ addFacets(new LongPrimitiveValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..07a987b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java
@@ -0,0 +1,53 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.longs;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class LongPrimitiveValueSemanticsProvider extends LongValueSemanticsProviderAbstract implements PropertyDefaultFacet {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public LongPrimitiveValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public LongPrimitiveValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, long.class, configuration, context);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // PropertyDefaultFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public ObjectAdapter getDefault(final ObjectAdapter inObject) {
+ return createAdapter(long.class, Long.valueOf(0L));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueFacet.java
new file mode 100644
index 0000000..97f6758
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueFacet.java
@@ -0,0 +1,29 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface LongValueFacet extends Facet {
+ Long longValue(ObjectAdapter object);
+
+ ObjectAdapter createValue(Long value);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueSemanticsProviderAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..96e1014
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongValueSemanticsProviderAbstract.java
@@ -0,0 +1,108 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.longs;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public abstract class LongValueSemanticsProviderAbstract extends ValueSemanticsProviderAndFacetAbstract<Long> implements LongValueFacet {
+
+ public static Class<? extends Facet> type() {
+ return LongValueFacet.class;
+ }
+
+ private static final Long DEFAULT_VALUE = Long.valueOf(0L);
+ private static final int TYPICAL_LENGTH = 18;
+
+ private final NumberFormat format;
+
+ public LongValueSemanticsProviderAbstract(final FacetHolder holder, final Class<Long> adaptedClass, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(type(), holder, adaptedClass, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE, configuration, context);
+ format = determineNumberFormat("value.format.long");
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Long doParse(final Object context, final String entry) {
+ try {
+ return Long.valueOf(format.parse(entry).longValue());
+ } catch (final ParseException e) {
+ throw new TextEntryParseException("Not a whole number " + entry, e);
+ }
+ }
+
+ @Override
+ public String titleString(final Object value, final Localization localization) {
+ return titleString(format, value);
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return titleString(new DecimalFormat(usingMask), value);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ return object.toString();
+ }
+
+ @Override
+ protected Long doRestore(final String data) {
+ return new Long(data);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // LongValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public Long longValue(final ObjectAdapter object) {
+ return (Long) (object == null ? null : object.getObject());
+ }
+
+ @Override
+ public ObjectAdapter createValue(final Long value) {
+ return value == null ? null : getAdapterManager().adapterFor(value);
+ }
+
+ // // ///// toString ///////
+ @Override
+ public String toString() {
+ return "LongValueSemanticsProvider: " + format;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongWrapperValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongWrapperValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongWrapperValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..cd71582
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/value/longs/LongWrapperValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class LongWrapperValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Long> {
+
+ public LongWrapperValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> type = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (type != Long.class) {
+ return;
+ }
+ addFacets(new LongWrapperValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}