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 2012/12/05 00:41:11 UTC
[34/52] [partial] ISIS-188: consolidating isis-core
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/imageawt/JavaAwtImageValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/imageawt/JavaAwtImageValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/imageawt/JavaAwtImageValueTypeFacetFactory.java
new file mode 100644
index 0000000..678dc80
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/imageawt/JavaAwtImageValueTypeFacetFactory.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.progmodel.facets.value.imageawt;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class JavaAwtImageValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<java.awt.Image> {
+
+ public JavaAwtImageValueTypeFacetFactory() {
+ 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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..c7248f2
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueTypeFacetFactory.java
new file mode 100644
index 0000000..57ee3e0
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntPrimitiveValueTypeFacetFactory.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.progmodel.facets.value.integer;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class IntPrimitiveValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<Integer> {
+
+ public IntPrimitiveValueTypeFacetFactory() {
+ 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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntValueSemanticsProviderAbstract.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..0fd9284
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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.progmodel.facets.object.value.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueSemanticsProvider.java
new file mode 100644
index 0000000..0533305
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueTypeFacetFactory.java
new file mode 100644
index 0000000..946f314
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntWrapperValueTypeFacetFactory.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.progmodel.facets.value.integer;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class IntWrapperValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<Integer> {
+
+ public IntWrapperValueTypeFacetFactory() {
+ 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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntegerValueFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntegerValueFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/integer/IntegerValueFacet.java
new file mode 100644
index 0000000..7a3c718
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleFloatingPointValueFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleFloatingPointValueFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleFloatingPointValueFacet.java
new file mode 100644
index 0000000..9539356
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleFloatingPointValueFacet.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.progmodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface DoubleFloatingPointValueFacet extends Facet {
+ Double doubleValue(ObjectAdapter object);
+
+ ObjectAdapter createValue(Double value);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..dd609eb
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/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.progmodel.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.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueTypeFacetFactory.java
new file mode 100644
index 0000000..d1e7a2e
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoublePrimitiveValueTypeFacetFactory.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.progmodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class DoublePrimitiveValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<Double> {
+
+ public DoublePrimitiveValueTypeFacetFactory() {
+ 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 DoublePrimitiveValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleValueSemanticsProviderAbstract.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..aaec3fb
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/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.progmodel.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.progmodel.facets.object.value.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueSemanticsProvider.java
new file mode 100644
index 0000000..aa88c73
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/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.progmodel.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.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueTypeFacetFactory.java
new file mode 100644
index 0000000..9720e6a
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/DoubleWrapperValueTypeFacetFactory.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.progmodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class DoubleWrapperValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<Double> {
+
+ public DoubleWrapperValueTypeFacetFactory() {
+ 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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueSemanticsProvider.java
new file mode 100644
index 0000000..07cdf5e
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueTypeFacetFactory.java
new file mode 100644
index 0000000..0b77943
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongPrimitiveValueTypeFacetFactory.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.progmodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class LongPrimitiveValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<Long> {
+
+ public LongPrimitiveValueTypeFacetFactory() {
+ 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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongValueFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongValueFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongValueFacet.java
new file mode 100644
index 0000000..56cbef7
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongValueSemanticsProviderAbstract.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongValueSemanticsProviderAbstract.java
new file mode 100644
index 0000000..4f20590
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/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.progmodel.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.progmodel.facets.object.value.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.progmodel.facets.object.value.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/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueSemanticsProvider.java
new file mode 100644
index 0000000..1628eb0
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueSemanticsProvider.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.progmodel.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.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderContext;
+
+public class LongWrapperValueSemanticsProvider extends LongValueSemanticsProviderAbstract {
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public LongWrapperValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public LongWrapperValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(holder, Long.class, configuration, context);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueTypeFacetFactory.java
new file mode 100644
index 0000000..2ec40ae
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/longs/LongWrapperValueTypeFacetFactory.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.progmodel.facets.value.longs;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class LongWrapperValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<Long> {
+
+ public LongWrapperValueTypeFacetFactory() {
+ 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()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueFacet.java
new file mode 100644
index 0000000..c0a6ec8
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueFacet.java
@@ -0,0 +1,33 @@
+/*
+ * 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.progmodel.facets.value.money;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface MoneyValueFacet extends Facet {
+
+ float getAmount(ObjectAdapter object);
+
+ String getCurrencyCode(ObjectAdapter object);
+
+ ObjectAdapter createValue(float amount, String currencyCode);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueSemanticsProvider.java
new file mode 100644
index 0000000..57860fc
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueSemanticsProvider.java
@@ -0,0 +1,228 @@
+/*
+ * 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.progmodel.facets.value.money;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Currency;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.applib.value.Money;
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+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.properties.defaults.PropertyDefaultFacet;
+import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderContext;
+
+public class MoneyValueSemanticsProvider extends ValueSemanticsProviderAndFacetAbstract<Money> implements MoneyValueFacet {
+
+ private static Class<? extends Facet> type() {
+ return MoneyValueFacet.class;
+ }
+
+ private static final NumberFormat DEFAULT_NUMBER_FORMAT;
+ private static final NumberFormat DEFAULT_CURRENCY_FORMAT;
+ private static final String LOCAL_CURRENCY_CODE;
+ private static final int TYPICAL_LENGTH = 18;
+ private static final Money DEFAULT_VALUE = null; // no default
+
+ private final String defaultCurrencyCode;
+
+ static {
+ DEFAULT_NUMBER_FORMAT = NumberFormat.getNumberInstance();
+ DEFAULT_CURRENCY_FORMAT = NumberFormat.getCurrencyInstance();
+ DEFAULT_NUMBER_FORMAT.setMinimumFractionDigits(DEFAULT_CURRENCY_FORMAT.getMinimumFractionDigits());
+ DEFAULT_NUMBER_FORMAT.setMaximumFractionDigits(DEFAULT_CURRENCY_FORMAT.getMaximumFractionDigits());
+ LOCAL_CURRENCY_CODE = getDefaultCurrencyCode();
+ }
+
+ static final boolean isAPropertyDefaultFacet() {
+ return PropertyDefaultFacet.class.isAssignableFrom(MoneyValueSemanticsProvider.class);
+ }
+
+ private static String getDefaultCurrencyCode() {
+ try {
+ return DEFAULT_CURRENCY_FORMAT.getCurrency().getCurrencyCode();
+ } catch (final UnsupportedOperationException e) {
+ return "";
+ }
+ }
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public MoneyValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public MoneyValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(type(), holder, Money.class, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE, configuration, context);
+
+ final String property = ConfigurationConstants.ROOT + "value.money.currency";
+ defaultCurrencyCode = configuration.getString(property, LOCAL_CURRENCY_CODE);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Money doParse(final Object context, final String text) {
+ final String entry = text.trim();
+ final int pos = entry.lastIndexOf(' ');
+ if (endsWithCurrencyCode(entry, pos)) {
+ final String value = entry.substring(0, pos);
+ final String code = entry.substring(pos + 1);
+ return parseNumberAndCurrencyCode(value, code);
+ } else {
+ return parseDerivedValue(context, entry);
+ }
+ }
+
+ private boolean endsWithCurrencyCode(final String entry, final int pos) {
+ final String suffix = entry.substring(pos + 1);
+ final boolean isCurrencyCode = suffix.length() == 3 && Character.isLetter(suffix.charAt(0)) && Character.isLetter(suffix.charAt(1)) && Character.isLetter(suffix.charAt(2));
+ return isCurrencyCode;
+ }
+
+ private Money parseDerivedValue(final Object original, final String entry) {
+ Money money = (Money) original;
+ if (money == null || money.getCurrency().equals(LOCAL_CURRENCY_CODE)) {
+ try {
+ final double value = DEFAULT_CURRENCY_FORMAT.parse(entry).doubleValue();
+ money = new Money(value, LOCAL_CURRENCY_CODE);
+ return money;
+ } catch (final ParseException ignore) {
+ }
+ }
+
+ try {
+ final double value = DEFAULT_NUMBER_FORMAT.parse(entry).doubleValue();
+ final String currencyCode = money == null ? defaultCurrencyCode : money.getCurrency();
+ money = new Money(value, currencyCode);
+ return money;
+ } catch (final ParseException ex) {
+ throw new TextEntryParseException("Not a distinguishable money value " + entry, ex);
+ }
+ }
+
+ private Money parseNumberAndCurrencyCode(final String amount, final String code) {
+ final String currencyCode = code.toUpperCase();
+ try {
+ Currency.getInstance(currencyCode.toUpperCase());
+ } catch (final IllegalArgumentException e) {
+ throw new TextEntryParseException("Invalid currency code " + currencyCode, e);
+ }
+ try {
+ final Money money = new Money(DEFAULT_NUMBER_FORMAT.parse(amount).doubleValue(), currencyCode);
+ return money;
+ } catch (final ParseException e) {
+ throw new TextEntryParseException("Invalid money entry", e);
+ }
+ }
+
+ @Override
+ public String titleString(final Object object, final Localization localization) {
+ if (object == null) {
+ return "";
+ }
+ final Money money = (Money) object;
+ final boolean localCurrency = LOCAL_CURRENCY_CODE.equals(money.getCurrency());
+ if (localCurrency) {
+ return DEFAULT_CURRENCY_FORMAT.format(money.doubleValue());
+ } else {
+ return DEFAULT_NUMBER_FORMAT.format(money.doubleValue()) + " " + money.getCurrency();
+ }
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ if (value == null) {
+ return "";
+ }
+ final Money money = (Money) value;
+ return new DecimalFormat(usingMask).format(money.doubleValue());
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ final Money money = (Money) object;
+ final String value = String.valueOf(money.doubleValue()) + " " + money.getCurrency();
+ return value;
+ }
+
+ @Override
+ protected Money doRestore(final String data) {
+ final String dataString = data;
+ final int pos = dataString.indexOf(' ');
+ final String amount = dataString.substring(0, pos);
+ final String currency = dataString.substring(pos + 1);
+ return new Money(Double.valueOf(amount).doubleValue(), currency);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // MoneyValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public float getAmount(final ObjectAdapter object) {
+ final Money money = (Money) object.getObject();
+ if (money == null) {
+ return 0.0f;
+ } else {
+ return money.floatValue();
+ }
+ }
+
+ @Override
+ public String getCurrencyCode(final ObjectAdapter object) {
+ final Money money = (Money) object.getObject();
+ if (money == null) {
+ return "";
+ } else {
+ return money.getCurrency();
+ }
+ }
+
+ @Override
+ public ObjectAdapter createValue(final float amount, final String currencyCode) {
+ return getAdapterManager().adapterFor(new Money(amount, currencyCode));
+ }
+
+ // /////// toString ///////
+
+ @Override
+ public String toString() {
+ return "MoneyValueSemanticsProvider: " + getDefaultCurrencyCode();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueTypeFacetFactory.java
new file mode 100644
index 0000000..c1687ea
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/money/MoneyValueTypeFacetFactory.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.progmodel.facets.value.money;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class MoneyValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<org.apache.isis.applib.value.Money> {
+
+ public MoneyValueTypeFacetFactory() {
+ 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.Money.class) {
+ return;
+ }
+ addFacets(new MoneyValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueFacet.java
new file mode 100644
index 0000000..06f0cd8
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueFacet.java
@@ -0,0 +1,33 @@
+/*
+ * 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.progmodel.facets.value.password;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface PasswordValueFacet extends Facet {
+
+ boolean checkPassword(ObjectAdapter object, String password);
+
+ String getEditText(ObjectAdapter object);
+
+ ObjectAdapter createValue(String value);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueSemanticsProvider.java
new file mode 100644
index 0000000..d0e1dde
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueSemanticsProvider.java
@@ -0,0 +1,123 @@
+/*
+ * 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.progmodel.facets.value.password;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.applib.value.Password;
+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.progmodel.facets.object.value.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderContext;
+
+public class PasswordValueSemanticsProvider extends ValueSemanticsProviderAndFacetAbstract<Password> implements
+ PasswordValueFacet {
+
+ public static Class<? extends Facet> type() {
+ return PasswordValueFacet.class;
+ }
+
+ private static final Password DEFAULT_VALUE = null; // no default
+ private static final int TYPICAL_LENGTH = 12;
+
+ /**
+ * Required because implementation of {@link Parser} and {@link EncoderDecoder}.
+ */
+ public PasswordValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public PasswordValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration,
+ final ValueSemanticsProviderContext context) {
+ super(type(), holder, Password.class, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE,
+ configuration, context);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Password doParse(final Object context, final String text) {
+ return new Password(text);
+ }
+
+ @Override
+ public String titleString(final Object object, final Localization localization) {
+ return object == null ? "" : password(object).toString();
+ }
+
+ @Override
+ public String titleStringWithMask(final Object object, final String usingMask) {
+ return titleString(object, null);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ return password(object).getPassword();
+ }
+
+ @Override
+ protected Password doRestore(final String data) {
+ return new Password(data);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // PasswordValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public boolean checkPassword(final ObjectAdapter object, final String password) {
+ return password(object.getObject()).checkPassword(password);
+ }
+
+ @Override
+ public String getEditText(final ObjectAdapter object) {
+ return object == null ? "" : password(object).getPassword();
+ }
+
+ @Override
+ public ObjectAdapter createValue(final String password) {
+ return getAdapterManager().adapterFor(new Password(password));
+ }
+
+ private Password password(final Object object) {
+ if (object instanceof ObjectAdapter) {
+ return (Password) ((ObjectAdapter) object).getObject();
+ } else {
+ return (Password) object;
+ }
+ }
+
+ // /////// toString ///////
+
+ @Override
+ public String toString() {
+ return "PasswordValueSemanticsProvider";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueTypeFacetFactory.java
new file mode 100644
index 0000000..234ee99
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/password/PasswordValueTypeFacetFactory.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.progmodel.facets.value.password;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class PasswordValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<org.apache.isis.applib.value.Password> {
+
+ public PasswordValueTypeFacetFactory() {
+ 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.Password.class) {
+ return;
+ }
+ addFacets(new PasswordValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueSemanticsProvider.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueSemanticsProvider.java
new file mode 100644
index 0000000..982caed
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueSemanticsProvider.java
@@ -0,0 +1,153 @@
+/*
+ * 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.progmodel.facets.value.percentage;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.applib.value.Percentage;
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+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.progmodel.facets.object.value.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderContext;
+import org.apache.isis.core.progmodel.facets.value.floats.FloatingPointValueFacet;
+
+public class PercentageValueSemanticsProvider extends ValueSemanticsProviderAndFacetAbstract<Percentage> implements FloatingPointValueFacet {
+
+ private static final NumberFormat PERCENTAGE_FORMAT = NumberFormat.getPercentInstance();
+ private static final NumberFormat DECIMAL_FORMAT = NumberFormat.getNumberInstance();
+
+ private static final Percentage DEFAULT_VALUE = new Percentage(0.0f);
+ private static final int TYPICAL_LENGTH = 12;
+
+ public static Class<? extends Facet> type() {
+ return FloatingPointValueFacet.class;
+ }
+
+ private NumberFormat format = PERCENTAGE_FORMAT;
+
+ /**
+ * Required because implementation of {@link Parser} and
+ * {@link EncoderDecoder}.
+ */
+ public PercentageValueSemanticsProvider() {
+ this(null, null, null);
+ }
+
+ public PercentageValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(type(), holder, Percentage.class, TYPICAL_LENGTH, Immutability.IMMUTABLE, EqualByContent.HONOURED, DEFAULT_VALUE, configuration, context);
+
+ final String formatRequired = configuration.getString(ConfigurationConstants.ROOT + "value.format.percentage");
+ if (formatRequired == null) {
+ format = PERCENTAGE_FORMAT;
+ } else {
+ format = new DecimalFormat(formatRequired);
+ }
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // Parser
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Percentage doParse(final Object context, final String text) {
+ try {
+ return new Percentage(new Float(format.parse(text).floatValue()));
+ } catch (final ParseException e) {
+ try {
+ return new Percentage(asFloat(text));
+ } catch (final ParseException ee) {
+ throw new TextEntryParseException("Not a number " + text, ee);
+ }
+ }
+ }
+
+ private Float asFloat(final String text) throws ParseException {
+ return new Float(DECIMAL_FORMAT.parse(text).floatValue());
+ }
+
+ @Override
+ public String titleString(final Object value, final Localization localization) {
+ return titleString(format, value);
+ }
+
+ private String titleString(final NumberFormat formatter, final Object value) {
+ return value == null ? "" : format.format(((Percentage) value).floatValue());
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return titleString(new DecimalFormat(usingMask), value);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // EncoderDecoder
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ protected String doEncode(final Object object) {
+ final Percentage per = (Percentage) object;
+ return String.valueOf(per.floatValue());
+ }
+
+ @Override
+ protected Percentage doRestore(final String data) {
+ return new Percentage(Float.valueOf(data).floatValue());
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // FloatingPointValueFacet
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public Float floatValue(final ObjectAdapter object) {
+ final Percentage per = (Percentage) object.getObject();
+ return new Float(per.floatValue());
+ }
+
+ @Override
+ public ObjectAdapter createValue(final Float value) {
+ return getAdapterManager().adapterFor(value);
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // PropertyDefaultFacet
+ // //////////////////////////////////////////////////////////////////
+
+ public Object getDefault(final ObjectAdapter inObject) {
+ return Float.valueOf(0.0f);
+ }
+
+ // //// toString ////////////////////////////////////////////////////
+
+ @Override
+ public String toString() {
+ return "PercentageValueSemanticsProvider: " + format;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueTypeFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueTypeFacetFactory.java
new file mode 100644
index 0000000..1ad1626
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/percentage/PercentageValueTypeFacetFactory.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.progmodel.facets.value.percentage;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.object.value.ValueUsingValueSemanticsProviderFacetFactory;
+
+public class PercentageValueTypeFacetFactory extends ValueUsingValueSemanticsProviderFacetFactory<org.apache.isis.applib.value.Percentage> {
+
+ public PercentageValueTypeFacetFactory() {
+ 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.Percentage.class) {
+ return;
+ }
+ addFacets(new PercentageValueSemanticsProvider(holder, getConfiguration(), getContext()));
+ }
+
+}