summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java60
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java41
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java41
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java40
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java51
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java38
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java40
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java38
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java40
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java50
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java71
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/package-info.java20
12 files changed, 0 insertions, 530 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java
deleted file mode 100644
index 31d9f634..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.ui.table.CellComparator;
-
-/**
- * Base implementation of a {@link CellComparator}. This class takes care
- * of dealing with null inputs; subclasses should implement their comparison
- * knowing that both inputs are guaranteed to be non-null.
- */
-public abstract class AbstractCellComparator implements CellComparator {
-
- @Override
- public int compare(Object o1, Object o2) {
- if (o1 == null && o2 == null) {
- return 0; // o1 == o2
- }
- if (o1 == null) {
- return -1; // o1 < o2
- }
- if (o2 == null) {
- return 1; // o1 > o2
- }
- return nonNullCompare(o1, o2);
- }
-
- /**
- * Compares its two arguments for order. Returns a negative integer,
- * zero, or a positive integer as the first argument is less than, equal
- * to, or greater than the second.<p>
- *
- * Note that both objects are guaranteed to be non-null.
- *
- * @see java.util.Comparator#compare(Object, Object)
- *
- * @param o1 the first object to be compared.
- * @param o2 the second object to be compared.
- * @return a negative integer, zero, or a positive integer as the
- * first argument is less than, equal to, or greater than the
- * second.
- * @throws ClassCastException if the arguments' types prevent them from
- * being compared by this comparator.
- */
- protected abstract int nonNullCompare(Object o1, Object o2);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java
deleted file mode 100644
index 08822b7b..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.ui.table.CellFormatter;
-
-/**
- * Base implementation of a {@link CellFormatter}. This class takes care of
- * dealing with null inputs; subclasses should implement their format method
- * knowing that the input is guaranteed to be non-null.
- */
-public abstract class AbstractCellFormatter implements CellFormatter {
-
- @Override
- public String format(Object value) {
- return value == null ? "" : nonNullFormat(value);
- }
-
- /**
- * Formats the specified value into a string appropriate for displaying
- * in a table cell. Note that value is guaranteed to be non-null.
- *
- * @param value the value
- * @return the formatted string
- */
- protected abstract String nonNullFormat(Object value);
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java
deleted file mode 100644
index f7947a75..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.ui.table.CellFormatter;
-
-/**
- * Formats an application identifier as "(app-id) : (app-name)".
- */
-public final class AppIdFormatter extends AbstractCellFormatter {
-
- // non-instantiable
- private AppIdFormatter() { }
-
- // NOTE: do not change this format; we parse it on the client side.
- @Override
- protected String nonNullFormat(Object value) {
- ApplicationId appId = (ApplicationId) value;
- return appId.id() + " : " + appId.name();
- }
-
- /**
- * An instance of this class.
- */
- public static final CellFormatter INSTANCE = new AppIdFormatter();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java
deleted file mode 100644
index 4af6fe2f..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.ui.table.CellFormatter;
-
-/**
- * Formats a connect point as "(element-id)/(port)".
- */
-public final class ConnectPointFormatter extends AbstractCellFormatter {
-
- // non-instantiable
- private ConnectPointFormatter() { }
-
- @Override
- protected String nonNullFormat(Object value) {
- ConnectPoint cp = (ConnectPoint) value;
- return cp.elementId() + "/" + cp.port();
- }
-
- /**
- * An instance of this class.
- */
- public static final CellFormatter INSTANCE = new ConnectPointFormatter();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java
deleted file mode 100644
index 2386f8f3..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellComparator.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.ui.table.CellComparator;
-
-/**
- * A default cell comparator.
- * <p>
- * Verifies that the objects being compared are the same class.
- * Looks to see if the objects being compared implement comparable and, if so,
- * delegates to that; otherwise, implements a lexicographical compare function
- * (i.e. string sorting). Uses the objects' toString() method and then
- * compares the resulting strings. Note that null values are acceptable and
- * are considered "smaller" than any non-null value.
- */
-public final class DefaultCellComparator extends AbstractCellComparator {
-
- // non-instantiable
- private DefaultCellComparator() { }
-
- @Override
- @SuppressWarnings("unchecked")
- protected int nonNullCompare(Object o1, Object o2) {
- if (o1 instanceof Comparable) {
- // if o2 is not the same class as o1, then compareTo will
- // throw ClassCastException for us
- return ((Comparable) o1).compareTo(o2);
- }
- return o1.toString().compareTo(o2.toString());
- }
-
- /**
- * An instance of this class.
- */
- public static final CellComparator INSTANCE = new DefaultCellComparator();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java
deleted file mode 100644
index 8309c545..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/DefaultCellFormatter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.ui.table.CellFormatter;
-
-/**
- * A default cell formatter. Uses the object's toString() method.
- */
-public final class DefaultCellFormatter extends AbstractCellFormatter {
-
- // non-instantiable
- private DefaultCellFormatter() { }
-
- @Override
- public String nonNullFormat(Object value) {
- return value.toString();
- }
-
- /**
- * An instance of this class.
- */
- public static final CellFormatter INSTANCE = new DefaultCellFormatter();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java
deleted file mode 100644
index 5b89a0b7..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.ui.table.CellFormatter;
-
-import static org.apache.commons.lang.WordUtils.capitalizeFully;
-
-/**
- * Formats enum types to be readable strings.
- */
-public final class EnumFormatter extends AbstractCellFormatter {
-
- // non-instantiable
- private EnumFormatter() { }
-
- @Override
- protected String nonNullFormat(Object value) {
- return capitalizeFully(value.toString().replace("_", " "));
- }
-
- /**
- * An instance of this class.
- */
- public static final CellFormatter INSTANCE = new EnumFormatter();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java
deleted file mode 100644
index 981a81bb..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.ui.table.CellFormatter;
-
-/**
- * Formats integer values as hex strings with a "0x" prefix.
- */
-public final class HexFormatter extends AbstractCellFormatter {
-
- // non-instantiable
- private HexFormatter() { }
-
- @Override
- protected String nonNullFormat(Object value) {
- return "0x" + Integer.toHexString((Integer) value);
- }
-
- /**
- * An instance of this class.
- */
- public static final CellFormatter INSTANCE = new HexFormatter();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java
deleted file mode 100644
index 95a7cc23..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.onosproject.net.HostLocation;
-import org.onosproject.ui.table.CellFormatter;
-
-/**
- * Formats a host location as "(device-id)/(port)".
- */
-public final class HostLocationFormatter extends AbstractCellFormatter {
-
- // non-instantiable
- private HostLocationFormatter() { }
-
- @Override
- protected String nonNullFormat(Object value) {
- HostLocation loc = (HostLocation) value;
- return loc.deviceId() + "/" + loc.port();
- }
-
- /**
- * An instance of this class.
- */
- public static final CellFormatter INSTANCE = new HostLocationFormatter();
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java
deleted file mode 100644
index 76f42466..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-
-/**
- * Formats number using the specified format string".
- */
-public final class NumberFormatter extends AbstractCellFormatter {
-
- private final NumberFormat format;
-
- /**
- * Creates a formatter using a default decimal format.
- */
- public NumberFormatter() {
- this(new DecimalFormat("#,##0.00000"));
- }
-
- /**
- * Creates a formatter using the specified format.
- *
- * @param format number format
- */
- public NumberFormatter(NumberFormat format) {
- this.format = format;
- }
-
- @Override
- protected String nonNullFormat(Object value) {
- return format.format(value);
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java
deleted file mode 100644
index 58c70930..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.onosproject.ui.table.cell;
-
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-
-import java.util.Locale;
-
-/**
- * Formats time values using {@link DateTimeFormatter}.
- */
-public final class TimeFormatter extends AbstractCellFormatter {
-
- private DateTimeFormatter dtf;
-
- // NOTE: Unlike other formatters in this package, this one is not
- // implemented as a Singleton, because instances may be
- // decorated with alternate locale and/or timezone.
-
- /**
- * Constructs a time formatter that uses the default locale and timezone.
- */
- public TimeFormatter() {
- dtf = DateTimeFormat.longTime();
- }
-
- /**
- * Sets the locale to use for formatting the time.
- *
- * @param locale locale to use for formatting
- * @return self, for chaining
- */
- public TimeFormatter withLocale(Locale locale) {
- dtf = dtf.withLocale(locale);
- return this;
- }
-
- /**
- * Sets the time zone to use for formatting the time.
- *
- * @param zone time zone to use
- * @return self, for chaining
- */
- public TimeFormatter withZone(DateTimeZone zone) {
- dtf = dtf.withZone(zone);
- return this;
- }
-
- @Override
- protected String nonNullFormat(Object value) {
- return dtf.print((DateTime) value);
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/package-info.java
deleted file mode 100644
index c25bcb06..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/table/cell/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed 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.
- */
-
-/**
- * Set of table cell renderers and comparators for use by GUI apps.
- */
-package org.onosproject.ui.table.cell; \ No newline at end of file