parent
c8486db1a0
commit
485a65e739
|
@ -10,29 +10,28 @@ package org.openhab.core.autoupdate;
|
|||
|
||||
import org.openhab.core.binding.BindingProvider;
|
||||
|
||||
|
||||
/**
|
||||
* This interface is implemented by classes that can provide configuration
|
||||
* information of the AutoUpdate feature.
|
||||
*
|
||||
* Implementing classes should register themselves as a service in order to be
|
||||
* This interface is implemented by classes that can provide configuration
|
||||
* information of the AutoUpdate feature.
|
||||
*
|
||||
* Implementing classes should register themselves as a service in order to be
|
||||
* taken into account.
|
||||
*
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public interface AutoUpdateBindingProvider extends BindingProvider {
|
||||
|
||||
/**
|
||||
* Indicates whether an Item with the given <code>itemName</code> is
|
||||
* configured to automatically update it's State after receiving a Command
|
||||
* or not.
|
||||
*
|
||||
* @param itemName the name of the Item for which to find the configuration
|
||||
* @return <code>false</code> to disable the automatic update,
|
||||
* <code>true</code> to enable the automatic update and <code>null</code>
|
||||
* if there is no configuration for this item.
|
||||
*/
|
||||
Boolean autoUpdate(String itemName);
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether an Item with the given <code>itemName</code> is
|
||||
* configured to automatically update it's State after receiving a Command
|
||||
* or not.
|
||||
*
|
||||
* @param itemName the name of the Item for which to find the configuration
|
||||
* @return <code>false</code> to disable the automatic update,
|
||||
* <code>true</code> to enable the automatic update and <code>null</code>
|
||||
* if there is no configuration for this item.
|
||||
*/
|
||||
Boolean autoUpdate(String itemName);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,30 +16,30 @@ import org.eclipse.smarthome.core.autoupdate.AutoUpdateBindingConfigProvider;
|
|||
/**
|
||||
* This class serves as a mapping from the "old" org.openhab namespace to the new org.eclipse.smarthome
|
||||
* namespace for the auto update provider. It gathers all services that implement the old interface
|
||||
* and makes them available as single provider of the new interface.
|
||||
*
|
||||
* and makes them available as single provider of the new interface.
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution and API
|
||||
*/
|
||||
public class AutoUpdateProviderDelegate implements AutoUpdateBindingConfigProvider {
|
||||
|
||||
private Set<org.openhab.core.autoupdate.AutoUpdateBindingProvider> providers = new CopyOnWriteArraySet<>();
|
||||
private Set<org.openhab.core.autoupdate.AutoUpdateBindingProvider> providers = new CopyOnWriteArraySet<>();
|
||||
|
||||
public void addAutoUpdateBindingProvider(org.openhab.core.autoupdate.AutoUpdateBindingProvider provider) {
|
||||
providers.add(provider);
|
||||
}
|
||||
public void addAutoUpdateBindingProvider(org.openhab.core.autoupdate.AutoUpdateBindingProvider provider) {
|
||||
providers.add(provider);
|
||||
}
|
||||
|
||||
public void removeAutoUpdateBindingProvider(org.openhab.core.autoupdate.AutoUpdateBindingProvider provider) {
|
||||
providers.remove(provider);
|
||||
}
|
||||
public void removeAutoUpdateBindingProvider(org.openhab.core.autoupdate.AutoUpdateBindingProvider provider) {
|
||||
providers.remove(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean autoUpdate(String itemName) {
|
||||
for(org.openhab.core.autoupdate.AutoUpdateBindingProvider provider : providers) {
|
||||
Boolean autoUpdate = provider.autoUpdate(itemName);
|
||||
if(autoUpdate!=null) {
|
||||
return autoUpdate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Boolean autoUpdate(String itemName) {
|
||||
for (org.openhab.core.autoupdate.AutoUpdateBindingProvider provider : providers) {
|
||||
Boolean autoUpdate = provider.autoUpdate(itemName);
|
||||
if (autoUpdate != null) {
|
||||
return autoUpdate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
|
|||
|
||||
/** to keep track of all binding providers */
|
||||
|
||||
protected Collection<P> providers = new CopyOnWriteArraySet<P>();
|
||||
protected Collection<P> providers = new CopyOnWriteArraySet<>();
|
||||
|
||||
protected EventPublisher eventPublisher = null;
|
||||
|
||||
|
@ -51,7 +51,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
|
|||
* adds <code>this</code> as {@link BindingConfigChangeListener}. If
|
||||
* <code>provider</code> contains any binding an the refresh-Thread is
|
||||
* stopped it will be started.
|
||||
*
|
||||
*
|
||||
* @param provider the new {@link BindingProvider} to add
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -64,7 +64,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
|
|||
/**
|
||||
* Removes <code>provider</code> from the list of providers. If there is no
|
||||
* provider left the refresh thread is getting interrupted.
|
||||
*
|
||||
*
|
||||
* @param provider the {@link BindingProvider} to remove
|
||||
*/
|
||||
public void removeBindingProvider(BindingProvider provider) {
|
||||
|
@ -100,7 +100,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
|
|||
/**
|
||||
* Is called by <code>receiveCommand()</code> only if one of the
|
||||
* {@link BindingProvider}s provide a binding for <code>itemName</code>.
|
||||
*
|
||||
*
|
||||
* @param itemName the item on which <code>command</code> will be executed
|
||||
* @param command the {@link Command} to be executed on <code>itemName</code>
|
||||
*/
|
||||
|
@ -122,7 +122,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
|
|||
/**
|
||||
* Is called by <code>receiveUpdate()</code> only if one of the
|
||||
* {@link BindingProvider}s provide a binding for <code>itemName</code>.
|
||||
*
|
||||
*
|
||||
* @param itemName the item on which <code>command</code> will be executed
|
||||
* @param newState the {@link State} to be update
|
||||
*/
|
||||
|
@ -131,7 +131,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
|
|||
|
||||
/**
|
||||
* checks if any of the bindingProviders contains an adequate mapping
|
||||
*
|
||||
*
|
||||
* @param itemName the itemName to check
|
||||
* @return <code>true</code> if any of the bindingProviders contains an
|
||||
* adequate mapping for <code>itemName</code> and <code>false</code>
|
||||
|
|
|
@ -8,30 +8,29 @@
|
|||
*/
|
||||
package org.openhab.core.binding;
|
||||
|
||||
|
||||
/**
|
||||
* This interface must be implemented by classes which want to be notified by a
|
||||
* {@link BindingProvider} about changes in the binding configuration.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.3.0
|
||||
*/
|
||||
public interface BindingChangeListener {
|
||||
|
||||
/**
|
||||
* Called, if a single binding has changed. The given item could have been
|
||||
* added or removed.
|
||||
*
|
||||
* @param provider the binding provider where the binding has changed
|
||||
* @param itemName the item name for which the binding has changed
|
||||
*/
|
||||
public void bindingChanged(BindingProvider provider, String itemName);
|
||||
|
||||
/**
|
||||
* Called, if all bindings (might) have changed.
|
||||
*
|
||||
* @param provider the binding provider whose bindings have changed
|
||||
*/
|
||||
public void allBindingsChanged(BindingProvider provider);
|
||||
|
||||
|
||||
/**
|
||||
* Called, if a single binding has changed. The given item could have been
|
||||
* added or removed.
|
||||
*
|
||||
* @param provider the binding provider where the binding has changed
|
||||
* @param itemName the item name for which the binding has changed
|
||||
*/
|
||||
public void bindingChanged(BindingProvider provider, String itemName);
|
||||
|
||||
/**
|
||||
* Called, if all bindings (might) have changed.
|
||||
*
|
||||
* @param provider the binding provider whose bindings have changed
|
||||
*/
|
||||
public void allBindingsChanged(BindingProvider provider);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ package org.openhab.core.binding;
|
|||
/**
|
||||
* This is a simple marker interface to define data structures that are
|
||||
* used as binding configurations.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.6.0
|
||||
*
|
||||
|
|
|
@ -10,7 +10,6 @@ package org.openhab.core.binding;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @author Kai Kreuzer
|
||||
|
@ -18,45 +17,46 @@ import java.util.Collection;
|
|||
*/
|
||||
public interface BindingProvider {
|
||||
|
||||
/**
|
||||
* Adds a binding change listener, which gets notified whenever there
|
||||
* are changes in the binding configuration
|
||||
*
|
||||
* @param listener the binding change listener to add
|
||||
*/
|
||||
public void addBindingChangeListener(BindingChangeListener listener);
|
||||
/**
|
||||
* Adds a binding change listener, which gets notified whenever there
|
||||
* are changes in the binding configuration
|
||||
*
|
||||
* @param listener the binding change listener to add
|
||||
*/
|
||||
public void addBindingChangeListener(BindingChangeListener listener);
|
||||
|
||||
/**
|
||||
* Removes a binding change listener again.
|
||||
* Does nothing, if this listener has not been added before.
|
||||
*
|
||||
* @param listener the binding listener to remove
|
||||
*/
|
||||
public void removeBindingChangeListener(BindingChangeListener listener);
|
||||
|
||||
/**
|
||||
* Indicates whether this binding provider contains a binding for the given
|
||||
* <code>itemName</code>
|
||||
*
|
||||
* @param itemName the itemName to check
|
||||
*
|
||||
* @return <code>true</code> if this provider contains an adequate mapping
|
||||
* for <code>itemName</code> and <code>false</code> otherwise.
|
||||
*/
|
||||
boolean providesBindingFor(String itemName);
|
||||
/**
|
||||
* Removes a binding change listener again.
|
||||
* Does nothing, if this listener has not been added before.
|
||||
*
|
||||
* @param listener the binding listener to remove
|
||||
*/
|
||||
public void removeBindingChangeListener(BindingChangeListener listener);
|
||||
|
||||
/**
|
||||
* Indicates whether this binding provider contains any binding
|
||||
*
|
||||
* @return <code>true</code> if this provider contains any binding
|
||||
* configuration and <code>false</code> otherwise
|
||||
*/
|
||||
boolean providesBinding();
|
||||
|
||||
/**
|
||||
* Returns all items which are mapped to this binding
|
||||
* @return items which are mapped to this binding
|
||||
*/
|
||||
Collection<String> getItemNames();
|
||||
/**
|
||||
* Indicates whether this binding provider contains a binding for the given
|
||||
* <code>itemName</code>
|
||||
*
|
||||
* @param itemName the itemName to check
|
||||
*
|
||||
* @return <code>true</code> if this provider contains an adequate mapping
|
||||
* for <code>itemName</code> and <code>false</code> otherwise.
|
||||
*/
|
||||
boolean providesBindingFor(String itemName);
|
||||
|
||||
/**
|
||||
* Indicates whether this binding provider contains any binding
|
||||
*
|
||||
* @return <code>true</code> if this provider contains any binding
|
||||
* configuration and <code>false</code> otherwise
|
||||
*/
|
||||
boolean providesBinding();
|
||||
|
||||
/**
|
||||
* Returns all items which are mapped to this binding
|
||||
*
|
||||
* @return items which are mapped to this binding
|
||||
*/
|
||||
Collection<String> getItemNames();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,61 +22,62 @@ import org.osgi.framework.ServiceRegistration;
|
|||
/**
|
||||
* This class listens for services that implement the old binding config reader interface and registers
|
||||
* an according service for each under the new interface.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution and API
|
||||
*/
|
||||
public class BindingConfigReaderFactory {
|
||||
|
||||
private Map<String, ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader>> delegates = new HashMap<>();
|
||||
private BundleContext context;
|
||||
|
||||
private Set<BindingConfigReader> readers = new HashSet<>();
|
||||
|
||||
public void activate(BundleContext context) {
|
||||
this.context = context;
|
||||
for(BindingConfigReader reader : readers) {
|
||||
registerDelegateService(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
for(ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg : delegates.values()) {
|
||||
serviceReg.unregister();
|
||||
}
|
||||
delegates.clear();
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
public void addBindingConfigReader(BindingConfigReader reader) {
|
||||
if(context!=null) {
|
||||
registerDelegateService(reader);
|
||||
} else {
|
||||
readers.add(reader);
|
||||
}
|
||||
}
|
||||
private Map<String, ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader>> delegates = new HashMap<>();
|
||||
private BundleContext context;
|
||||
|
||||
public void removeBindingConfigReader(BindingConfigReader reader) {
|
||||
if(context!=null) {
|
||||
unregisterDelegateService(reader);
|
||||
}
|
||||
}
|
||||
private Set<BindingConfigReader> readers = new HashSet<>();
|
||||
|
||||
private void registerDelegateService(BindingConfigReader reader) {
|
||||
if(!delegates.containsKey(reader.getBindingType())) {
|
||||
BindingConfigReaderDelegate service = new BindingConfigReaderDelegate(reader);
|
||||
Dictionary<String, Object> props = new Hashtable<String, Object>();
|
||||
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg =
|
||||
context.registerService(org.eclipse.smarthome.model.item.BindingConfigReader.class, service, props);
|
||||
delegates.put(reader.getBindingType(), serviceReg);
|
||||
}
|
||||
}
|
||||
public void activate(BundleContext context) {
|
||||
this.context = context;
|
||||
for (BindingConfigReader reader : readers) {
|
||||
registerDelegateService(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterDelegateService(BindingConfigReader reader) {
|
||||
if(delegates.containsKey(reader.getBindingType())) {
|
||||
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg =
|
||||
delegates.get(reader.getBindingType());
|
||||
delegates.remove(reader.getBindingType());
|
||||
serviceReg.unregister();
|
||||
}
|
||||
}
|
||||
public void deactivate() {
|
||||
for (ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg : delegates
|
||||
.values()) {
|
||||
serviceReg.unregister();
|
||||
}
|
||||
delegates.clear();
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
public void addBindingConfigReader(BindingConfigReader reader) {
|
||||
if (context != null) {
|
||||
registerDelegateService(reader);
|
||||
} else {
|
||||
readers.add(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBindingConfigReader(BindingConfigReader reader) {
|
||||
if (context != null) {
|
||||
unregisterDelegateService(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDelegateService(BindingConfigReader reader) {
|
||||
if (!delegates.containsKey(reader.getBindingType())) {
|
||||
BindingConfigReaderDelegate service = new BindingConfigReaderDelegate(reader);
|
||||
Dictionary<String, Object> props = new Hashtable<>();
|
||||
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg = context
|
||||
.registerService(org.eclipse.smarthome.model.item.BindingConfigReader.class, service, props);
|
||||
delegates.put(reader.getBindingType(), serviceReg);
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterDelegateService(BindingConfigReader reader) {
|
||||
if (delegates.containsKey(reader.getBindingType())) {
|
||||
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg = delegates
|
||||
.get(reader.getBindingType());
|
||||
delegates.remove(reader.getBindingType());
|
||||
serviceReg.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ public class CompatibilityActivator implements BundleActivator {
|
|||
public void start(BundleContext bundleContext) throws Exception {
|
||||
CompatibilityActivator.context = bundleContext;
|
||||
|
||||
itemRegistryTracker = new ServiceTracker<ItemRegistry, ItemRegistry>(bundleContext, ItemRegistry.class, null);
|
||||
itemRegistryTracker = new ServiceTracker<>(bundleContext, ItemRegistry.class, null);
|
||||
itemRegistryTracker.open();
|
||||
|
||||
eventPublisherTracker = new ServiceTracker<EventPublisher, EventPublisher>(bundleContext, EventPublisher.class,
|
||||
eventPublisherTracker = new ServiceTracker<>(bundleContext, EventPublisher.class,
|
||||
null);
|
||||
eventPublisherTracker.open();
|
||||
|
||||
scriptEngineTracker = new ServiceTracker<ScriptEngine, ScriptEngine>(bundleContext, ScriptEngine.class, null);
|
||||
scriptEngineTracker = new ServiceTracker<>(bundleContext, ScriptEngine.class, null);
|
||||
scriptEngineTracker.open();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,53 +8,57 @@
|
|||
*/
|
||||
package org.openhab.core.events;
|
||||
|
||||
import static org.openhab.core.events.EventConstants.TOPIC_PREFIX;
|
||||
import static org.openhab.core.events.EventConstants.TOPIC_SEPERATOR;
|
||||
import static org.openhab.core.events.EventConstants.*;
|
||||
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.EventType;
|
||||
import org.openhab.core.types.State;
|
||||
import org.osgi.service.event.Event;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
|
||||
abstract public class AbstractEventSubscriber implements EventHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void handleEvent(Event event) {
|
||||
String itemName = (String) event.getProperty("item");
|
||||
|
||||
String topic = event.getTopic();
|
||||
String[] topicParts = topic.split(TOPIC_SEPERATOR);
|
||||
|
||||
if(!(topicParts.length > 2) || !topicParts[0].equals(TOPIC_PREFIX)) {
|
||||
return; // we have received an event with an invalid topic
|
||||
}
|
||||
String operation = topicParts[1];
|
||||
|
||||
if(operation.equals(EventType.UPDATE.toString())) {
|
||||
State newState = (State) event.getProperty("state");
|
||||
if(newState!=null) receiveUpdate(itemName, newState);
|
||||
}
|
||||
if(operation.equals(EventType.COMMAND.toString())) {
|
||||
Command command = (Command) event.getProperty("command");
|
||||
if(command!=null) receiveCommand(itemName, command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void receiveCommand(String itemName, Command command) {
|
||||
// default implementation: do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void receiveUpdate(String itemName, State newState) {
|
||||
// default implementation: do nothing
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
String itemName = (String) event.getProperty("item");
|
||||
|
||||
String topic = event.getTopic();
|
||||
String[] topicParts = topic.split(TOPIC_SEPERATOR);
|
||||
|
||||
if (!(topicParts.length > 2) || !topicParts[0].equals(TOPIC_PREFIX)) {
|
||||
return; // we have received an event with an invalid topic
|
||||
}
|
||||
String operation = topicParts[1];
|
||||
|
||||
if (operation.equals(EventType.UPDATE.toString())) {
|
||||
State newState = (State) event.getProperty("state");
|
||||
if (newState != null) {
|
||||
receiveUpdate(itemName, newState);
|
||||
}
|
||||
}
|
||||
if (operation.equals(EventType.COMMAND.toString())) {
|
||||
Command command = (Command) event.getProperty("command");
|
||||
if (command != null) {
|
||||
receiveCommand(itemName, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void receiveCommand(String itemName, Command command) {
|
||||
// default implementation: do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void receiveUpdate(String itemName, State newState) {
|
||||
// default implementation: do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ package org.openhab.core.events;
|
|||
|
||||
/**
|
||||
* This interface defines constants required for using the OSGi Event Admin service.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public interface EventConstants {
|
||||
|
||||
public static final String TOPIC_PREFIX = "openhab";
|
||||
public static final String TOPIC_PREFIX = "openhab";
|
||||
|
||||
public static final String TOPIC_SEPERATOR = "/";
|
||||
|
||||
public static final String TOPIC_SEPERATOR = "/";
|
||||
|
||||
}
|
||||
|
|
|
@ -13,37 +13,37 @@ import org.openhab.core.types.State;
|
|||
|
||||
/**
|
||||
* An EventPublisher is used to send commands or status updates to the openHAB event bus.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public interface EventPublisher {
|
||||
|
||||
/**
|
||||
* Initiate synchronous sending of a command.
|
||||
* This method does not return to the caller until all subscribers have processed the command.
|
||||
*
|
||||
* @param itemName name of the item to send the command for
|
||||
* @param command the command to send
|
||||
*/
|
||||
public abstract void sendCommand(String itemName, Command command);
|
||||
/**
|
||||
* Initiate synchronous sending of a command.
|
||||
* This method does not return to the caller until all subscribers have processed the command.
|
||||
*
|
||||
* @param itemName name of the item to send the command for
|
||||
* @param command the command to send
|
||||
*/
|
||||
public abstract void sendCommand(String itemName, Command command);
|
||||
|
||||
/**
|
||||
* Initiate asynchronous sending of a command.
|
||||
* This method returns immediately to the caller.
|
||||
*
|
||||
* @param itemName name of the item to send the command for
|
||||
* @param command the command to send
|
||||
*/
|
||||
public abstract void postCommand(String itemName, Command command);
|
||||
/**
|
||||
* Initiate asynchronous sending of a command.
|
||||
* This method returns immediately to the caller.
|
||||
*
|
||||
* @param itemName name of the item to send the command for
|
||||
* @param command the command to send
|
||||
*/
|
||||
public abstract void postCommand(String itemName, Command command);
|
||||
|
||||
/**
|
||||
* Initiate asynchronous sending of a status update.
|
||||
* This method returns immediately to the caller.
|
||||
*
|
||||
* @param itemName name of the item to send the update for
|
||||
* @param newState the new state to send
|
||||
*/
|
||||
public abstract void postUpdate(String itemName, State newState);
|
||||
/**
|
||||
* Initiate asynchronous sending of a status update.
|
||||
* This method returns immediately to the caller.
|
||||
*
|
||||
* @param itemName name of the item to send the update for
|
||||
* @param newState the new state to send
|
||||
*/
|
||||
public abstract void postUpdate(String itemName, State newState);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,26 +13,26 @@ import org.openhab.core.types.State;
|
|||
|
||||
/**
|
||||
* An EventSubscriber receives events from the openHAB event bus for further processing.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public interface EventSubscriber {
|
||||
|
||||
/**
|
||||
* Callback method if a command was sent on the event bus
|
||||
*
|
||||
* @param itemName the item for which a command was sent
|
||||
* @param command the command that was sent
|
||||
*/
|
||||
public void receiveCommand(String itemName, Command command);
|
||||
|
||||
/**
|
||||
* Callback method if a state update was sent on the event bus
|
||||
*
|
||||
* @param itemName the item for which a state update was sent
|
||||
* @param state the state that was sent
|
||||
*/
|
||||
public void receiveUpdate(String itemName, State newStatus);
|
||||
/**
|
||||
* Callback method if a command was sent on the event bus
|
||||
*
|
||||
* @param itemName the item for which a command was sent
|
||||
* @param command the command that was sent
|
||||
*/
|
||||
public void receiveCommand(String itemName, Command command);
|
||||
|
||||
/**
|
||||
* Callback method if a state update was sent on the event bus
|
||||
*
|
||||
* @param itemName the item for which a state update was sent
|
||||
* @param state the state that was sent
|
||||
*/
|
||||
public void receiveUpdate(String itemName, State newStatus);
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.osgi.service.event.EventHandler;
|
|||
* This class acts as a bridge between events from openHAB 1.x (using "openhab" as a topic prefix) and
|
||||
* Eclipse SmartHome (using "smarthome" as a topic prefix).
|
||||
* It simply duplicates events with an updated topic prefix and works both ways.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution and API
|
||||
*
|
||||
*/
|
||||
|
@ -86,21 +86,21 @@ public class EventBridge implements EventHandler, EventSubscriber {
|
|||
Map<String, Object> properties = new HashMap<>();
|
||||
if (event instanceof ItemCommandEvent) {
|
||||
ItemCommandEvent icEvent = (ItemCommandEvent) event;
|
||||
String itemName = (String) icEvent.getItemName();
|
||||
String itemName = icEvent.getItemName();
|
||||
properties.put("item", itemName);
|
||||
Type eshType = TypeMapper.mapToOpenHABType(icEvent.getItemCommand());
|
||||
if (eshType instanceof Command) {
|
||||
properties.put("command", (Command) eshType);
|
||||
properties.put("command", eshType);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
ItemStateEvent isEvent = (ItemStateEvent) event;
|
||||
String itemName = (String) isEvent.getItemName();
|
||||
String itemName = isEvent.getItemName();
|
||||
properties.put("item", itemName);
|
||||
Type eshType = TypeMapper.mapToOpenHABType(isEvent.getItemState());
|
||||
if (eshType instanceof State) {
|
||||
properties.put("state", (State) eshType);
|
||||
properties.put("state", eshType);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,159 +20,170 @@ import org.openhab.core.types.Command;
|
|||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.UnDefType;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The abstract base class for all items. It provides all relevant logic
|
||||
* for the infrastructure, such as publishing updates to the event bus
|
||||
* or notifying listeners.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
abstract public class GenericItem implements Item {
|
||||
|
||||
protected EventPublisher eventPublisher;
|
||||
|
||||
protected Set<StateChangeListener> listeners = new CopyOnWriteArraySet<StateChangeListener>(Collections.newSetFromMap(new WeakHashMap<StateChangeListener, Boolean>()));
|
||||
|
||||
protected List<String> groupNames = new ArrayList<String>();
|
||||
|
||||
final protected String name;
|
||||
|
||||
protected State state = UnDefType.NULL;
|
||||
|
||||
public GenericItem(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
protected EventPublisher eventPublisher;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if(typeClass!=null && typeClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {}
|
||||
|
||||
public void dispose() {
|
||||
this.eventPublisher = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<String> getGroupNames() {
|
||||
return groupNames;
|
||||
}
|
||||
protected Set<StateChangeListener> listeners = new CopyOnWriteArraySet<>(
|
||||
Collections.newSetFromMap(new WeakHashMap<StateChangeListener, Boolean>()));
|
||||
|
||||
public void setEventPublisher(EventPublisher eventPublisher) {
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
|
||||
protected void internalSend(Command command) {
|
||||
// try to send the command to the bus
|
||||
if(eventPublisher!=null) {
|
||||
eventPublisher.sendCommand(this.getName(), command);
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
State oldState = this.state;
|
||||
this.state = state;
|
||||
notifyListeners(oldState, state);
|
||||
}
|
||||
protected List<String> groupNames = new ArrayList<>();
|
||||
|
||||
private void notifyListeners(State oldState, State newState) {
|
||||
// if nothing has changed, we send update notifications
|
||||
Set<StateChangeListener> clonedListeners = null;
|
||||
clonedListeners = new CopyOnWriteArraySet<StateChangeListener>(listeners);
|
||||
for(StateChangeListener listener : clonedListeners) {
|
||||
listener.stateUpdated(this, newState);
|
||||
}
|
||||
if(!oldState.equals(newState)) {
|
||||
for(StateChangeListener listener : clonedListeners) {
|
||||
listener.stateChanged(this, oldState, newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " (" +
|
||||
"Type=" + getClass().getSimpleName() + ", " +
|
||||
"State=" + getState() + ")";
|
||||
}
|
||||
final protected String name;
|
||||
|
||||
public void addStateChangeListener(StateChangeListener listener) {
|
||||
synchronized(listeners) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeStateChangeListener(StateChangeListener listener) {
|
||||
synchronized(listeners) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
protected State state = UnDefType.NULL;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((groupNames == null) ? 0 : groupNames.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||
return result;
|
||||
}
|
||||
public GenericItem(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if (typeClass != null && typeClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
this.eventPublisher = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getGroupNames() {
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
public void setEventPublisher(EventPublisher eventPublisher) {
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
|
||||
protected void internalSend(Command command) {
|
||||
// try to send the command to the bus
|
||||
if (eventPublisher != null) {
|
||||
eventPublisher.sendCommand(this.getName(), command);
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
State oldState = this.state;
|
||||
this.state = state;
|
||||
notifyListeners(oldState, state);
|
||||
}
|
||||
|
||||
private void notifyListeners(State oldState, State newState) {
|
||||
// if nothing has changed, we send update notifications
|
||||
Set<StateChangeListener> clonedListeners = null;
|
||||
clonedListeners = new CopyOnWriteArraySet<>(listeners);
|
||||
for (StateChangeListener listener : clonedListeners) {
|
||||
listener.stateUpdated(this, newState);
|
||||
}
|
||||
if (!oldState.equals(newState)) {
|
||||
for (StateChangeListener listener : clonedListeners) {
|
||||
listener.stateChanged(this, oldState, newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " (" + "Type=" + getClass().getSimpleName() + ", " + "State=" + getState() + ")";
|
||||
}
|
||||
|
||||
public void addStateChangeListener(StateChangeListener listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeStateChangeListener(StateChangeListener listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((groupNames == null) ? 0 : groupNames.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
GenericItem other = (GenericItem) obj;
|
||||
if (groupNames == null) {
|
||||
if (other.groupNames != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!groupNames.equals(other.groupNames)) {
|
||||
return false;
|
||||
}
|
||||
if (name == null) {
|
||||
if (other.name != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (state == null) {
|
||||
if (other.state != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!state.equals(other.state)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
GenericItem other = (GenericItem) obj;
|
||||
if (groupNames == null) {
|
||||
if (other.groupNames != null)
|
||||
return false;
|
||||
} else if (!groupNames.equals(other.groupNames))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (state == null) {
|
||||
if (other.state != null)
|
||||
return false;
|
||||
} else if (!state.equals(other.state))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,69 +16,70 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* Group functions are used by active group items to calculate a state for the group
|
||||
* out of the states of all its member items.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
abstract public interface GroupFunction {
|
||||
|
||||
/**
|
||||
* Determines the current state of a group based on a list of items
|
||||
*
|
||||
* @param items the items to calculate a group state for
|
||||
* @return the calculated group state
|
||||
*/
|
||||
public State calculate(List<Item> items);
|
||||
|
||||
/**
|
||||
* Calculates the group state and returns it as a state of the requested type.
|
||||
*
|
||||
* @param items the items to calculate a group state for
|
||||
* @param stateClass the type in which the state should be returned
|
||||
* @return the calculated group state of the requested type or null, if type is not supported
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass);
|
||||
/**
|
||||
* Determines the current state of a group based on a list of items
|
||||
*
|
||||
* @param items the items to calculate a group state for
|
||||
* @return the calculated group state
|
||||
*/
|
||||
public State calculate(List<Item> items);
|
||||
|
||||
/**
|
||||
* This is the default group function that does nothing else than to check if all member items
|
||||
* have the same state. If this is the case, this state is returned, otherwise UNDEF is returned.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Equality implements GroupFunction {
|
||||
/**
|
||||
* Calculates the group state and returns it as a state of the requested type.
|
||||
*
|
||||
* @param items the items to calculate a group state for
|
||||
* @param stateClass the type in which the state should be returned
|
||||
* @return the calculated group state of the requested type or null, if type is not supported
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass);
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
if(items.size()>0) {
|
||||
State state = items.get(0).getState();
|
||||
for(int i=1; i<items.size(); i++) {
|
||||
if(!state.equals(items.get(i).getState())) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
} else {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is the default group function that does nothing else than to check if all member items
|
||||
* have the same state. If this is the case, this state is returned, otherwise UNDEF is returned.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Equality implements GroupFunction {
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items,
|
||||
Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
if (items.size() > 0) {
|
||||
State state = items.get(0).getState();
|
||||
for (int i = 1; i < items.size(); i++) {
|
||||
if (!state.equals(items.get(i).getState())) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
} else {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,202 +21,204 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GroupItem extends GenericItem implements StateChangeListener {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupItem.class);
|
||||
|
||||
protected final GenericItem baseItem;
|
||||
|
||||
protected final List<Item> members;
|
||||
|
||||
protected GroupFunction function;
|
||||
|
||||
public GroupItem(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupItem.class);
|
||||
|
||||
public GroupItem(String name, GenericItem baseItem) {
|
||||
this(name, baseItem, new GroupFunction.Equality());
|
||||
}
|
||||
protected final GenericItem baseItem;
|
||||
|
||||
public GroupItem(String name, GenericItem baseItem, GroupFunction function) {
|
||||
super(name);
|
||||
members = new CopyOnWriteArrayList<Item>();
|
||||
this.function = function;
|
||||
this.baseItem = baseItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base item of this {@link GroupItem}. This method is only
|
||||
* intended to allow instance checks of the underlying BaseItem. It must
|
||||
* not be changed in any way.
|
||||
*
|
||||
* @return the base item of this GroupItem
|
||||
*/
|
||||
public GenericItem getBaseItem() {
|
||||
return baseItem;
|
||||
}
|
||||
protected final List<Item> members;
|
||||
|
||||
/**
|
||||
* Returns the direct members of this {@link GroupItem} regardless if these
|
||||
* members are {@link GroupItem}s as well.
|
||||
*
|
||||
* @return the direct members of this {@link GroupItem}
|
||||
*/
|
||||
public List<Item> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direct members of this {@link GroupItem} and recursively all
|
||||
* members of the potentially contained {@link GroupItem}s as well. The
|
||||
* {@link GroupItem}s itself aren't contained. The returned items are unique.
|
||||
*
|
||||
* @return all members of this and all contained {@link GroupItem}s
|
||||
*/
|
||||
public List<Item> getAllMembers() {
|
||||
Set<Item> allMembers = new HashSet<Item>();
|
||||
collectMembers(allMembers, members);
|
||||
return new ArrayList<Item>(allMembers);
|
||||
}
|
||||
|
||||
private void collectMembers(Set<Item> allMembers, List<Item> members) {
|
||||
for (Item member : members) {
|
||||
if (member instanceof GroupItem) {
|
||||
collectMembers(allMembers, ((GroupItem) member).members);
|
||||
}
|
||||
else {
|
||||
allMembers.add(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected GroupFunction function;
|
||||
|
||||
public void addMember(Item item) {
|
||||
members.add(item);
|
||||
if (item instanceof GenericItem) {
|
||||
GenericItem genericItem = (GenericItem) item;
|
||||
genericItem.addStateChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMember(Item item) {
|
||||
members.remove(item);
|
||||
if (item instanceof GenericItem) {
|
||||
GenericItem genericItem = (GenericItem) item;
|
||||
genericItem.removeStateChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The accepted data types of a group item is the same as of the underlying base item.
|
||||
* If none is defined, the intersection of all sets of accepted data types of all group
|
||||
* members is used instead.
|
||||
*
|
||||
* @return the accepted data types of this group item
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
if(baseItem!=null) {
|
||||
return baseItem.getAcceptedDataTypes();
|
||||
} else {
|
||||
List<Class<? extends State>> acceptedDataTypes = null;
|
||||
|
||||
for(Item item : members) {
|
||||
if(acceptedDataTypes==null) {
|
||||
acceptedDataTypes = item.getAcceptedDataTypes();
|
||||
} else {
|
||||
acceptedDataTypes = ListUtils.intersection(acceptedDataTypes, item.getAcceptedDataTypes());
|
||||
}
|
||||
}
|
||||
return acceptedDataTypes == null ? ListUtils.EMPTY_LIST : acceptedDataTypes;
|
||||
}
|
||||
}
|
||||
public GroupItem(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The accepted command types of a group item is the same as of the underlying base item.
|
||||
* If none is defined, the intersection of all sets of accepted command types of all group
|
||||
* members is used instead.
|
||||
*
|
||||
* @return the accepted command types of this group item
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
if(baseItem!=null) {
|
||||
return baseItem.getAcceptedCommandTypes();
|
||||
} else {
|
||||
List<Class<? extends Command>> acceptedCommandTypes = null;
|
||||
|
||||
for(Item item : members) {
|
||||
if(acceptedCommandTypes==null) {
|
||||
acceptedCommandTypes = item.getAcceptedCommandTypes();
|
||||
} else {
|
||||
acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes());
|
||||
}
|
||||
}
|
||||
return acceptedCommandTypes == null ? ListUtils.EMPTY_LIST : acceptedCommandTypes;
|
||||
}
|
||||
}
|
||||
|
||||
public void send(Command command) {
|
||||
if(getAcceptedCommandTypes().contains(command.getClass())) {
|
||||
internalSend(command);
|
||||
} else {
|
||||
logger.warn("Command '{}' has been ignored for group '{}' as it is not accepted.", command.toString(), getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected void internalSend(Command command) {
|
||||
if(eventPublisher!=null) {
|
||||
for(Item member : members) {
|
||||
// try to send the command to the bus
|
||||
eventPublisher.sendCommand(member.getName(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
State newState = function.getStateAs(getAllMembers(), typeClass);
|
||||
if(newState==null && baseItem!=null) {
|
||||
// we use the transformation method from the base item
|
||||
baseItem.setState(state);
|
||||
newState = baseItem.getStateAs(typeClass);
|
||||
}
|
||||
if(newState==null) {
|
||||
newState = super.getStateAs(typeClass);
|
||||
}
|
||||
return newState;
|
||||
}
|
||||
public GroupItem(String name, GenericItem baseItem) {
|
||||
this(name, baseItem, new GroupFunction.Equality());
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " (" +
|
||||
"Type=" + getClass().getSimpleName() + ", " +
|
||||
(baseItem != null ? "BaseType=" + baseItem.getClass().getSimpleName() + ", " : "") +
|
||||
"Members=" + members.size() + ", " +
|
||||
"State=" + getState() + ")";
|
||||
}
|
||||
public GroupItem(String name, GenericItem baseItem, GroupFunction function) {
|
||||
super(name);
|
||||
members = new CopyOnWriteArrayList<>();
|
||||
this.function = function;
|
||||
this.baseItem = baseItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public void stateChanged(Item item, State oldState, State newState) {
|
||||
setState(function.calculate(members));
|
||||
}
|
||||
/**
|
||||
* Returns the base item of this {@link GroupItem}. This method is only
|
||||
* intended to allow instance checks of the underlying BaseItem. It must
|
||||
* not be changed in any way.
|
||||
*
|
||||
* @return the base item of this GroupItem
|
||||
*/
|
||||
public GenericItem getBaseItem() {
|
||||
return baseItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public void stateUpdated(Item item, State state) {
|
||||
setState(function.calculate(members));
|
||||
}
|
||||
/**
|
||||
* Returns the direct members of this {@link GroupItem} regardless if these
|
||||
* members are {@link GroupItem}s as well.
|
||||
*
|
||||
* @return the direct members of this {@link GroupItem}
|
||||
*/
|
||||
public List<Item> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direct members of this {@link GroupItem} and recursively all
|
||||
* members of the potentially contained {@link GroupItem}s as well. The
|
||||
* {@link GroupItem}s itself aren't contained. The returned items are unique.
|
||||
*
|
||||
* @return all members of this and all contained {@link GroupItem}s
|
||||
*/
|
||||
public List<Item> getAllMembers() {
|
||||
Set<Item> allMembers = new HashSet<>();
|
||||
collectMembers(allMembers, members);
|
||||
return new ArrayList<>(allMembers);
|
||||
}
|
||||
|
||||
private void collectMembers(Set<Item> allMembers, List<Item> members) {
|
||||
for (Item member : members) {
|
||||
if (member instanceof GroupItem) {
|
||||
collectMembers(allMembers, ((GroupItem) member).members);
|
||||
} else {
|
||||
allMembers.add(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMember(Item item) {
|
||||
members.add(item);
|
||||
if (item instanceof GenericItem) {
|
||||
GenericItem genericItem = (GenericItem) item;
|
||||
genericItem.addStateChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMember(Item item) {
|
||||
members.remove(item);
|
||||
if (item instanceof GenericItem) {
|
||||
GenericItem genericItem = (GenericItem) item;
|
||||
genericItem.removeStateChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The accepted data types of a group item is the same as of the underlying base item.
|
||||
* If none is defined, the intersection of all sets of accepted data types of all group
|
||||
* members is used instead.
|
||||
*
|
||||
* @return the accepted data types of this group item
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
if (baseItem != null) {
|
||||
return baseItem.getAcceptedDataTypes();
|
||||
} else {
|
||||
List<Class<? extends State>> acceptedDataTypes = null;
|
||||
|
||||
for (Item item : members) {
|
||||
if (acceptedDataTypes == null) {
|
||||
acceptedDataTypes = item.getAcceptedDataTypes();
|
||||
} else {
|
||||
acceptedDataTypes = ListUtils.intersection(acceptedDataTypes, item.getAcceptedDataTypes());
|
||||
}
|
||||
}
|
||||
return acceptedDataTypes == null ? ListUtils.EMPTY_LIST : acceptedDataTypes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The accepted command types of a group item is the same as of the underlying base item.
|
||||
* If none is defined, the intersection of all sets of accepted command types of all group
|
||||
* members is used instead.
|
||||
*
|
||||
* @return the accepted command types of this group item
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
if (baseItem != null) {
|
||||
return baseItem.getAcceptedCommandTypes();
|
||||
} else {
|
||||
List<Class<? extends Command>> acceptedCommandTypes = null;
|
||||
|
||||
for (Item item : members) {
|
||||
if (acceptedCommandTypes == null) {
|
||||
acceptedCommandTypes = item.getAcceptedCommandTypes();
|
||||
} else {
|
||||
acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes());
|
||||
}
|
||||
}
|
||||
return acceptedCommandTypes == null ? ListUtils.EMPTY_LIST : acceptedCommandTypes;
|
||||
}
|
||||
}
|
||||
|
||||
public void send(Command command) {
|
||||
if (getAcceptedCommandTypes().contains(command.getClass())) {
|
||||
internalSend(command);
|
||||
} else {
|
||||
logger.warn("Command '{}' has been ignored for group '{}' as it is not accepted.", command.toString(),
|
||||
getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected void internalSend(Command command) {
|
||||
if (eventPublisher != null) {
|
||||
for (Item member : members) {
|
||||
// try to send the command to the bus
|
||||
eventPublisher.sendCommand(member.getName(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
State newState = function.getStateAs(getAllMembers(), typeClass);
|
||||
if (newState == null && baseItem != null) {
|
||||
// we use the transformation method from the base item
|
||||
baseItem.setState(state);
|
||||
newState = baseItem.getStateAs(typeClass);
|
||||
}
|
||||
if (newState == null) {
|
||||
newState = super.getStateAs(typeClass);
|
||||
}
|
||||
return newState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " (" + "Type=" + getClass().getSimpleName() + ", "
|
||||
+ (baseItem != null ? "BaseType=" + baseItem.getClass().getSimpleName() + ", " : "") + "Members="
|
||||
+ members.size() + ", " + "State=" + getState() + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void stateChanged(Item item, State oldState, State newState) {
|
||||
setState(function.calculate(members));
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void stateUpdated(Item item, State state) {
|
||||
setState(function.calculate(members));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,62 +14,73 @@ import org.openhab.core.types.Command;
|
|||
import org.openhab.core.types.State;
|
||||
|
||||
/**
|
||||
* <p>This interface defines the core features of an openHAB item.</p>
|
||||
* <p>Item instances are used for all stateful services and are especially
|
||||
* important for the {@link ItemRegistry}.</p>
|
||||
*
|
||||
* <p>
|
||||
* This interface defines the core features of an openHAB item.
|
||||
* </p>
|
||||
* <p>
|
||||
* Item instances are used for all stateful services and are especially
|
||||
* important for the {@link ItemRegistry}.
|
||||
* </p>
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
*
|
||||
*/
|
||||
public interface Item {
|
||||
|
||||
/**
|
||||
* returns the current state of the item
|
||||
*
|
||||
* @return the current state
|
||||
*/
|
||||
public State getState();
|
||||
/**
|
||||
* returns the current state of the item
|
||||
*
|
||||
* @return the current state
|
||||
*/
|
||||
public State getState();
|
||||
|
||||
/**
|
||||
* returns the current state of the item as a specific type
|
||||
*
|
||||
* @return the current state in the requested type or
|
||||
* null, if state cannot be provided as the requested type
|
||||
*/
|
||||
public State getStateAs(Class<? extends State> typeClass);
|
||||
/**
|
||||
* returns the current state of the item as a specific type
|
||||
*
|
||||
* @return the current state in the requested type or
|
||||
* null, if state cannot be provided as the requested type
|
||||
*/
|
||||
public State getStateAs(Class<? extends State> typeClass);
|
||||
|
||||
/**
|
||||
* returns the name of the item
|
||||
*
|
||||
* @return the name of the item
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* <p>This method provides a list of all data types that can be used to update the item state</p>
|
||||
* <p>Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and
|
||||
* maybe UNDEFINED. So the accepted data types would be in this case {@link PercentType}, {@link OnOffType}
|
||||
* and {@link UnDefType}</p>
|
||||
*
|
||||
* @return a list of data types that can be used to update the item state
|
||||
*/
|
||||
public List<Class<? extends State>> getAcceptedDataTypes();
|
||||
|
||||
|
||||
/**
|
||||
* <p>This method provides a list of all command types that can be used for this item</p>
|
||||
* <p>Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but
|
||||
* also to turn OFF or ON. So the accepted command types would be in this case {@link PercentType},
|
||||
* {@link OnOffType}</p>
|
||||
*
|
||||
* @return a list of all command types that can be used for this item
|
||||
*/
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes();
|
||||
/**
|
||||
* returns the name of the item
|
||||
*
|
||||
* @return the name of the item
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns a list of the names of the groups this item belongs to.
|
||||
*
|
||||
* @return list of item group names
|
||||
*/
|
||||
public List<String> getGroupNames();
|
||||
/**
|
||||
* <p>
|
||||
* This method provides a list of all data types that can be used to update the item state
|
||||
* </p>
|
||||
* <p>
|
||||
* Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and
|
||||
* maybe UNDEFINED. So the accepted data types would be in this case {@link PercentType}, {@link OnOffType}
|
||||
* and {@link UnDefType}
|
||||
* </p>
|
||||
*
|
||||
* @return a list of data types that can be used to update the item state
|
||||
*/
|
||||
public List<Class<? extends State>> getAcceptedDataTypes();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method provides a list of all command types that can be used for this item
|
||||
* </p>
|
||||
* <p>
|
||||
* Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but
|
||||
* also to turn OFF or ON. So the accepted command types would be in this case {@link PercentType},
|
||||
* {@link OnOffType}
|
||||
* </p>
|
||||
*
|
||||
* @return a list of all command types that can be used for this item
|
||||
*/
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes();
|
||||
|
||||
/**
|
||||
* Returns a list of the names of the groups this item belongs to.
|
||||
*
|
||||
* @return list of item group names
|
||||
*/
|
||||
public List<String> getGroupNames();
|
||||
}
|
|
@ -8,31 +8,30 @@
|
|||
*/
|
||||
package org.openhab.core.items;
|
||||
|
||||
|
||||
/**
|
||||
* This Factory creates concrete instances of the known ItemTypes.
|
||||
*
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 0.9.0
|
||||
*/
|
||||
public interface ItemFactory {
|
||||
|
||||
/**
|
||||
* Creates a new Item instance of type <code>itemTypeName</code> and the name
|
||||
* <code>itemName</code>
|
||||
*
|
||||
* @param itemTypeName
|
||||
* @param itemName
|
||||
*
|
||||
* @return a new Item of type <code>itemTypeName</code> or
|
||||
* <code>null</code> if no matching class is known.
|
||||
*/
|
||||
GenericItem createItem(String itemTypeName, String itemName);
|
||||
|
||||
/**
|
||||
* Returns the list of all supported ItemTypes of this Factory.
|
||||
*
|
||||
* @return the supported ItemTypes
|
||||
*/
|
||||
String[] getSupportedItemTypes();
|
||||
|
||||
/**
|
||||
* Creates a new Item instance of type <code>itemTypeName</code> and the name
|
||||
* <code>itemName</code>
|
||||
*
|
||||
* @param itemTypeName
|
||||
* @param itemName
|
||||
*
|
||||
* @return a new Item of type <code>itemTypeName</code> or
|
||||
* <code>null</code> if no matching class is known.
|
||||
*/
|
||||
GenericItem createItem(String itemTypeName, String itemName);
|
||||
|
||||
/**
|
||||
* Returns the list of all supported ItemTypes of this Factory.
|
||||
*
|
||||
* @return the supported ItemTypes
|
||||
*/
|
||||
String[] getSupportedItemTypes();
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ package org.openhab.core.items;
|
|||
/**
|
||||
* This is an abstract parent exception to be extended by any exceptions
|
||||
* related to item lookups in the item registry.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public abstract class ItemLookupException extends Exception {
|
||||
|
||||
public ItemLookupException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -4617708589675048859L;
|
||||
public ItemLookupException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -4617708589675048859L;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ package org.openhab.core.items;
|
|||
/**
|
||||
* This exception is thrown by the {@link ItemRegistry} if an item could
|
||||
* not be found.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
*
|
||||
*/
|
||||
public class ItemNotFoundException extends ItemLookupException {
|
||||
|
||||
public ItemNotFoundException(String name) {
|
||||
super("Item '" + name + "' could not be found in the item registry");
|
||||
}
|
||||
public ItemNotFoundException(String name) {
|
||||
super("Item '" + name + "' could not be found in the item registry");
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -3720784568250902711L;
|
||||
private static final long serialVersionUID = -3720784568250902711L;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,29 +13,29 @@ import java.util.Collection;
|
|||
/**
|
||||
* This exception can be thrown whenever a search pattern does not uniquely identify
|
||||
* an item. The list of matching items must be made available through this exception.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class ItemNotUniqueException extends ItemLookupException {
|
||||
|
||||
private static final long serialVersionUID = 5154625234283910124L;
|
||||
private static final long serialVersionUID = 5154625234283910124L;
|
||||
|
||||
private final Collection<Item> matchingItems;
|
||||
|
||||
public ItemNotUniqueException(String string, Collection<Item> items) {
|
||||
super("Item cannot be uniquely identified by '" + string + "'");
|
||||
this.matchingItems = items;
|
||||
}
|
||||
private final Collection<Item> matchingItems;
|
||||
|
||||
/**
|
||||
* Returns all items that match the search pattern
|
||||
*
|
||||
* @return collection of items matching the search pattern
|
||||
*/
|
||||
public Collection<Item> getMatchingItems() {
|
||||
return matchingItems;
|
||||
}
|
||||
public ItemNotUniqueException(String string, Collection<Item> items) {
|
||||
super("Item cannot be uniquely identified by '" + string + "'");
|
||||
this.matchingItems = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all items that match the search pattern
|
||||
*
|
||||
* @return collection of items matching the search pattern
|
||||
*/
|
||||
public Collection<Item> getMatchingItems() {
|
||||
return matchingItems;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,21 +14,21 @@ import java.util.Collection;
|
|||
* An item provider provides instances of {@link GenericItem}. These
|
||||
* items can be constructed from some static configuration files or
|
||||
* they can be derived from some dynamic logic.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public interface ItemProvider {
|
||||
|
||||
/**
|
||||
* Provides an array of items.
|
||||
*
|
||||
* @return a collection of items
|
||||
*/
|
||||
Collection<Item> getItems();
|
||||
|
||||
public void addItemChangeListener(ItemsChangeListener listener);
|
||||
|
||||
public void removeItemChangeListener(ItemsChangeListener listener);
|
||||
|
||||
/**
|
||||
* Provides an array of items.
|
||||
*
|
||||
* @return a collection of items
|
||||
*/
|
||||
Collection<Item> getItems();
|
||||
|
||||
public void addItemChangeListener(ItemsChangeListener listener);
|
||||
|
||||
public void removeItemChangeListener(ItemsChangeListener listener);
|
||||
}
|
||||
|
|
|
@ -14,62 +14,62 @@ import java.util.Collection;
|
|||
* The ItemRegistry is the central place, where items are kept in memory and their state
|
||||
* is permanently tracked. So any code that requires the current state of items should use
|
||||
* this service (instead of trying to keep their own local copy of the items).
|
||||
*
|
||||
*
|
||||
* Items are registered by {@link ItemProvider}s, which can provision them from any source
|
||||
* they like and also dynamically remove or add items.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public interface ItemRegistry {
|
||||
|
||||
/**
|
||||
* This method retrieves a single item from the registry.
|
||||
*
|
||||
* @param name the item name
|
||||
* @return the uniquely identified item
|
||||
* @throws ItemNotFoundException if no item matches the input
|
||||
*/
|
||||
public Item getItem(String name) throws ItemNotFoundException;
|
||||
/**
|
||||
* This method retrieves a single item from the registry.
|
||||
*
|
||||
* @param name the item name
|
||||
* @return the uniquely identified item
|
||||
* @throws ItemNotFoundException if no item matches the input
|
||||
*/
|
||||
public Item getItem(String name) throws ItemNotFoundException;
|
||||
|
||||
/**
|
||||
* This method retrieves a single item from the registry.
|
||||
* Search patterns and shortened versions are supported, if they uniquely identify an item
|
||||
*
|
||||
* @param name the item name, a part of the item name or a search pattern
|
||||
* @return the uniquely identified item
|
||||
* @throws ItemNotFoundException if no item matches the input
|
||||
* @throws ItemNotUniqueException if multiply items match the input
|
||||
*/
|
||||
public Item getItemByPattern(String name) throws ItemNotFoundException, ItemNotUniqueException;
|
||||
/**
|
||||
* This method retrieves a single item from the registry.
|
||||
* Search patterns and shortened versions are supported, if they uniquely identify an item
|
||||
*
|
||||
* @param name the item name, a part of the item name or a search pattern
|
||||
* @return the uniquely identified item
|
||||
* @throws ItemNotFoundException if no item matches the input
|
||||
* @throws ItemNotUniqueException if multiply items match the input
|
||||
*/
|
||||
public Item getItemByPattern(String name) throws ItemNotFoundException, ItemNotUniqueException;
|
||||
|
||||
/**
|
||||
* This method retrieves all items that are currently available in the registry
|
||||
*
|
||||
* @return a collection of all available items
|
||||
*/
|
||||
public Collection<Item> getItems();
|
||||
/**
|
||||
* This method retrieves all items that are currently available in the registry
|
||||
*
|
||||
* @return a collection of all available items
|
||||
*/
|
||||
public Collection<Item> getItems();
|
||||
|
||||
/**
|
||||
* This method retrieves all items that match a given search pattern
|
||||
*
|
||||
* @return a collection of all items matching the search pattern
|
||||
*/
|
||||
public Collection<Item> getItems(String pattern);
|
||||
/**
|
||||
* This method retrieves all items that match a given search pattern
|
||||
*
|
||||
* @return a collection of all items matching the search pattern
|
||||
*/
|
||||
public Collection<Item> getItems(String pattern);
|
||||
|
||||
/**
|
||||
* Checks whether itemName matches the item name conventions.
|
||||
* Item names must only consist out of alpha-numerical characters and
|
||||
* underscores (_).
|
||||
*
|
||||
* @param itemName the item name to validate
|
||||
* @return true, if the name is valid
|
||||
*/
|
||||
public boolean isValidItemName(String itemName);
|
||||
/**
|
||||
* Checks whether itemName matches the item name conventions.
|
||||
* Item names must only consist out of alpha-numerical characters and
|
||||
* underscores (_).
|
||||
*
|
||||
* @param itemName the item name to validate
|
||||
* @return true, if the name is valid
|
||||
*/
|
||||
public boolean isValidItemName(String itemName);
|
||||
|
||||
public void addItemRegistryChangeListener(ItemRegistryChangeListener listener);
|
||||
|
||||
public void removeItemRegistryChangeListener(ItemRegistryChangeListener listener);
|
||||
public void addItemRegistryChangeListener(ItemRegistryChangeListener listener);
|
||||
|
||||
public void removeItemRegistryChangeListener(ItemRegistryChangeListener listener);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,32 +13,32 @@ import java.util.Collection;
|
|||
/**
|
||||
* This is a listener interface which should be implemented where ever the item registry is
|
||||
* used in order to be notified of any dynamic changes in the provided items.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.4.0
|
||||
*
|
||||
*/
|
||||
public interface ItemRegistryChangeListener {
|
||||
|
||||
/**
|
||||
* Notifies the listener that all items in the registry have changed and thus should be reloaded.
|
||||
*
|
||||
* @param oldItemNames a collection of all previous item names, so that references can be removed
|
||||
*/
|
||||
public void allItemsChanged(Collection<String> oldItemNames);
|
||||
/**
|
||||
* Notifies the listener that all items in the registry have changed and thus should be reloaded.
|
||||
*
|
||||
* @param oldItemNames a collection of all previous item names, so that references can be removed
|
||||
*/
|
||||
public void allItemsChanged(Collection<String> oldItemNames);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been added
|
||||
*
|
||||
* @param item the item that has been added
|
||||
*/
|
||||
public void itemAdded(Item item);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been removed
|
||||
*
|
||||
* @param item the item that has been removed
|
||||
*/
|
||||
public void itemRemoved(Item item);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been added
|
||||
*
|
||||
* @param item the item that has been added
|
||||
*/
|
||||
public void itemAdded(Item item);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been removed
|
||||
*
|
||||
* @param item the item that has been removed
|
||||
*/
|
||||
public void itemRemoved(Item item);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,35 +13,35 @@ import java.util.Collection;
|
|||
/**
|
||||
* This is a listener interface which should be implemented where ever item providers or
|
||||
* the item registry are used in order to be notified of any dynamic changes in the provided items.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public interface ItemsChangeListener {
|
||||
|
||||
/**
|
||||
* Notifies the listener that all items of a provider have changed and thus should be reloaded.
|
||||
*
|
||||
* @param provider the concerned item provider
|
||||
* @param oldItemNames a collection of all previous item names, so that references can be removed
|
||||
*/
|
||||
public void allItemsChanged(ItemProvider provider, Collection<String> oldItemNames);
|
||||
/**
|
||||
* Notifies the listener that all items of a provider have changed and thus should be reloaded.
|
||||
*
|
||||
* @param provider the concerned item provider
|
||||
* @param oldItemNames a collection of all previous item names, so that references can be removed
|
||||
*/
|
||||
public void allItemsChanged(ItemProvider provider, Collection<String> oldItemNames);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been added
|
||||
*
|
||||
* @param provider the concerned item provider
|
||||
* @param item the item that has been added
|
||||
*/
|
||||
public void itemAdded(ItemProvider provider, Item item);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been removed
|
||||
*
|
||||
* @param provider the concerned item provider
|
||||
* @param item the item that has been removed
|
||||
*/
|
||||
public void itemRemoved(ItemProvider provider, Item item);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been added
|
||||
*
|
||||
* @param provider the concerned item provider
|
||||
* @param item the item that has been added
|
||||
*/
|
||||
public void itemAdded(ItemProvider provider, Item item);
|
||||
|
||||
/**
|
||||
* Notifies the listener that a single item has been removed
|
||||
*
|
||||
* @param provider the concerned item provider
|
||||
* @param item the item that has been removed
|
||||
*/
|
||||
public void itemRemoved(ItemProvider provider, Item item);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,31 +11,35 @@ package org.openhab.core.items;
|
|||
import org.openhab.core.types.State;
|
||||
|
||||
/**
|
||||
* <p>This interface must be implemented by all classes that want to be notified
|
||||
* about changes in the state of an item.</p>
|
||||
* <p>The {@link GenericItem} class provides the possibility to register such
|
||||
* listeners.</p>
|
||||
*
|
||||
* <p>
|
||||
* This interface must be implemented by all classes that want to be notified
|
||||
* about changes in the state of an item.
|
||||
* </p>
|
||||
* <p>
|
||||
* The {@link GenericItem} class provides the possibility to register such
|
||||
* listeners.
|
||||
* </p>
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
*
|
||||
*/
|
||||
public interface StateChangeListener {
|
||||
|
||||
/**
|
||||
* This method is called, if a state has changed.
|
||||
*
|
||||
* @param item the item whose state has changed
|
||||
* @param oldState the previous state
|
||||
* @param newState the new state
|
||||
*/
|
||||
public void stateChanged(Item item, State oldState, State newState);
|
||||
|
||||
/**
|
||||
* This method is called, if a state was updated, but has not changed
|
||||
*
|
||||
* @param item the item whose state was updated
|
||||
* @param state the current state, same before and after the update
|
||||
*/
|
||||
public void stateUpdated(Item item, State state);
|
||||
/**
|
||||
* This method is called, if a state has changed.
|
||||
*
|
||||
* @param item the item whose state has changed
|
||||
* @param oldState the previous state
|
||||
* @param newState the new state
|
||||
*/
|
||||
public void stateChanged(Item item, State oldState, State newState);
|
||||
|
||||
/**
|
||||
* This method is called, if a state was updated, but has not changed
|
||||
*
|
||||
* @param item the item whose state was updated
|
||||
* @param state the current state, same before and after the update
|
||||
*/
|
||||
public void stateUpdated(Item item, State state);
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ItemUIRegistryDelegate
|
|||
@Override
|
||||
public Collection<Item> getItems() {
|
||||
Collection<org.eclipse.smarthome.core.items.Item> eshItems = itemUIRegistry.getItems();
|
||||
Collection<Item> ohItems = new HashSet<Item>(eshItems.size());
|
||||
Collection<Item> ohItems = new HashSet<>(eshItems.size());
|
||||
|
||||
for (org.eclipse.smarthome.core.items.Item eshItem : eshItems) {
|
||||
ohItems.add(ItemMapper.mapToOpenHABItem(eshItem));
|
||||
|
@ -79,7 +79,7 @@ public class ItemUIRegistryDelegate
|
|||
@Override
|
||||
public Collection<Item> getItems(String pattern) {
|
||||
Collection<org.eclipse.smarthome.core.items.Item> eshItems = itemUIRegistry.getItems(pattern);
|
||||
Collection<Item> ohItems = new HashSet<Item>(eshItems.size());
|
||||
Collection<Item> ohItems = new HashSet<>(eshItems.size());
|
||||
|
||||
for (org.eclipse.smarthome.core.items.Item eshItem : eshItems) {
|
||||
ohItems.add(ItemMapper.mapToOpenHABItem(eshItem));
|
||||
|
|
|
@ -24,96 +24,100 @@ import org.openhab.core.types.UnDefType;
|
|||
|
||||
/**
|
||||
* A ColorItem can be used for color values, e.g. for LED lights
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.2.0
|
||||
*
|
||||
*/public class ColorItem extends DimmerItem {
|
||||
*/
|
||||
public class ColorItem extends DimmerItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(OnOffType.class);
|
||||
acceptedDataTypes.add(PercentType.class);
|
||||
acceptedDataTypes.add(HSBType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
static {
|
||||
acceptedDataTypes.add(OnOffType.class);
|
||||
acceptedDataTypes.add(PercentType.class);
|
||||
acceptedDataTypes.add(HSBType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
|
||||
acceptedCommandTypes.add(OnOffType.class);
|
||||
acceptedCommandTypes.add(IncreaseDecreaseType.class);
|
||||
acceptedCommandTypes.add(PercentType.class);
|
||||
acceptedCommandTypes.add(HSBType.class);
|
||||
}
|
||||
|
||||
public ColorItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
acceptedCommandTypes.add(OnOffType.class);
|
||||
acceptedCommandTypes.add(IncreaseDecreaseType.class);
|
||||
acceptedCommandTypes.add(PercentType.class);
|
||||
acceptedCommandTypes.add(HSBType.class);
|
||||
}
|
||||
|
||||
public void send(HSBType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
public ColorItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
public void send(HSBType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
State currentState = this.state;
|
||||
|
||||
if(currentState instanceof HSBType) {
|
||||
DecimalType hue = ((HSBType) currentState).getHue();
|
||||
PercentType saturation = ((HSBType) currentState).getSaturation();
|
||||
// we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed
|
||||
if(state==OnOffType.OFF) {
|
||||
super.setState(new HSBType(hue, saturation, PercentType.ZERO));
|
||||
} else if(state==OnOffType.ON) {
|
||||
super.setState(new HSBType(hue, saturation, PercentType.HUNDRED));
|
||||
} else if(state instanceof PercentType && !(state instanceof HSBType)) {
|
||||
super.setState(new HSBType(hue, saturation, (PercentType) state));
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
} else {
|
||||
// we map ON/OFF values to black/white and percentage values to grey scale
|
||||
if(state==OnOffType.OFF) {
|
||||
super.setState(HSBType.BLACK);
|
||||
} else if(state==OnOffType.ON) {
|
||||
super.setState(HSBType.WHITE);
|
||||
} else if(state instanceof PercentType && !(state instanceof HSBType)) {
|
||||
super.setState(new HSBType(DecimalType.ZERO, PercentType.ZERO, (PercentType) state));
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if(typeClass==HSBType.class) {
|
||||
return this.state;
|
||||
} else if(typeClass==OnOffType.class) {
|
||||
if(state instanceof HSBType) {
|
||||
HSBType hsbState = (HSBType) state;
|
||||
// if brightness is not completely off, we consider the state to be on
|
||||
return hsbState.getBrightness().equals(PercentType.ZERO) ? OnOffType.OFF : OnOffType.ON;
|
||||
}
|
||||
} else if(typeClass==DecimalType.class) {
|
||||
if(state instanceof HSBType) {
|
||||
HSBType hsbState = (HSBType) state;
|
||||
return new DecimalType(hsbState.getBrightness().toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
|
||||
}
|
||||
}
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
State currentState = this.state;
|
||||
|
||||
if (currentState instanceof HSBType) {
|
||||
DecimalType hue = ((HSBType) currentState).getHue();
|
||||
PercentType saturation = ((HSBType) currentState).getSaturation();
|
||||
// we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed
|
||||
if (state == OnOffType.OFF) {
|
||||
super.setState(new HSBType(hue, saturation, PercentType.ZERO));
|
||||
} else if (state == OnOffType.ON) {
|
||||
super.setState(new HSBType(hue, saturation, PercentType.HUNDRED));
|
||||
} else if (state instanceof PercentType && !(state instanceof HSBType)) {
|
||||
super.setState(new HSBType(hue, saturation, (PercentType) state));
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
} else {
|
||||
// we map ON/OFF values to black/white and percentage values to grey scale
|
||||
if (state == OnOffType.OFF) {
|
||||
super.setState(HSBType.BLACK);
|
||||
} else if (state == OnOffType.ON) {
|
||||
super.setState(HSBType.WHITE);
|
||||
} else if (state instanceof PercentType && !(state instanceof HSBType)) {
|
||||
super.setState(new HSBType(DecimalType.ZERO, PercentType.ZERO, (PercentType) state));
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if (typeClass == HSBType.class) {
|
||||
return this.state;
|
||||
} else if (typeClass == OnOffType.class) {
|
||||
if (state instanceof HSBType) {
|
||||
HSBType hsbState = (HSBType) state;
|
||||
// if brightness is not completely off, we consider the state to be on
|
||||
return hsbState.getBrightness().equals(PercentType.ZERO) ? OnOffType.OFF : OnOffType.ON;
|
||||
}
|
||||
} else if (typeClass == DecimalType.class) {
|
||||
if (state instanceof HSBType) {
|
||||
HSBType hsbState = (HSBType) state;
|
||||
return new DecimalType(
|
||||
hsbState.getBrightness().toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
|
||||
}
|
||||
}
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,48 +22,50 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* A ContactItem can be used for sensors that return an "open" or "close" as a state.
|
||||
* This is useful for doors, windows, etc.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class ContactItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(OpenClosedType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public ContactItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void send(OpenClosedType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(OpenClosedType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
public ContactItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if(typeClass==DecimalType.class) {
|
||||
return state==OpenClosedType.OPEN ? new DecimalType(1) : DecimalType.ZERO;
|
||||
} else if(typeClass==PercentType.class) {
|
||||
return state==OpenClosedType.OPEN ? PercentType.HUNDRED : PercentType.ZERO;
|
||||
} else {
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
public void send(OpenClosedType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if (typeClass == DecimalType.class) {
|
||||
return state == OpenClosedType.OPEN ? new DecimalType(1) : DecimalType.ZERO;
|
||||
} else if (typeClass == PercentType.class) {
|
||||
return state == OpenClosedType.OPEN ? PercentType.HUNDRED : PercentType.ZERO;
|
||||
} else {
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,31 +19,33 @@ import org.openhab.core.types.UnDefType;
|
|||
|
||||
/**
|
||||
* A DateTimeItem stores a timestamp including a valid time zone.
|
||||
*
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @author Kai Kreuzer
|
||||
*
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
public class DateTimeItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add((DateTimeType.class));
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public DateTimeItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add((DateTimeType.class));
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
public DateTimeItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,57 +24,59 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* A DimmerItem can be used as a switch (ON/OFF), but it also accepts percent values
|
||||
* to reflect the dimmed state.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class DimmerItem extends SwitchItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(OnOffType.class);
|
||||
acceptedDataTypes.add(PercentType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
static {
|
||||
acceptedDataTypes.add(OnOffType.class);
|
||||
acceptedDataTypes.add(PercentType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
|
||||
acceptedCommandTypes.add(OnOffType.class);
|
||||
acceptedCommandTypes.add(IncreaseDecreaseType.class);
|
||||
acceptedCommandTypes.add(PercentType.class);
|
||||
}
|
||||
|
||||
public DimmerItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
acceptedCommandTypes.add(OnOffType.class);
|
||||
acceptedCommandTypes.add(IncreaseDecreaseType.class);
|
||||
acceptedCommandTypes.add(PercentType.class);
|
||||
}
|
||||
|
||||
public void send(PercentType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
public DimmerItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
public void send(PercentType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
// we map ON/OFF values to the percent values 0 and 100
|
||||
if (state == OnOffType.OFF) {
|
||||
super.setState(PercentType.ZERO);
|
||||
} else if (state == OnOffType.ON) {
|
||||
super.setState(PercentType.HUNDRED);
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
// we map ON/OFF values to the percent values 0 and 100
|
||||
if(state==OnOffType.OFF) {
|
||||
super.setState(PercentType.ZERO);
|
||||
} else if(state==OnOffType.ON) {
|
||||
super.setState(PercentType.HUNDRED);
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -21,53 +21,59 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* A LocationItem can be used to store GPS related informations, addresses...
|
||||
* This is useful for location awareness related functions
|
||||
*
|
||||
*
|
||||
* @author Gaël L'hopital
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class LocationItem extends GenericItem {
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(PointType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public LocationItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(PointType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public LocationItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the distance with another Point type,
|
||||
* http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java
|
||||
*
|
||||
* @return distance between the two points in meters
|
||||
*/
|
||||
public DecimalType distanceFrom(PointType away) {
|
||||
|
||||
double dist = -1;
|
||||
|
||||
if ((away != null) && (this.state instanceof PointType)) {
|
||||
|
||||
PointType me = (PointType) this.state;
|
||||
|
||||
double dLat = Math.pow(
|
||||
Math.sin(Math.toRadians(away.getLatitude().doubleValue() - me.getLatitude().doubleValue()) / 2), 2);
|
||||
double dLng = Math.pow(
|
||||
Math.sin(Math.toRadians(away.getLongitude().doubleValue() - me.getLongitude().doubleValue()) / 2),
|
||||
2);
|
||||
double a = dLat + Math.cos(Math.toRadians(me.getLatitude().doubleValue()))
|
||||
* Math.cos(Math.toRadians(away.getLatitude().doubleValue())) * dLng;
|
||||
|
||||
dist = PointType.WGS84_a * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
}
|
||||
|
||||
return new DecimalType(dist);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the distance with another Point type,
|
||||
* http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java
|
||||
* @return distance between the two points in meters
|
||||
*/
|
||||
public DecimalType distanceFrom(PointType away){
|
||||
|
||||
double dist = -1;
|
||||
|
||||
if ((away != null) && (this.state instanceof PointType)) {
|
||||
|
||||
PointType me = (PointType) this.state;
|
||||
|
||||
double dLat = Math.pow(Math.sin(Math.toRadians(away.getLatitude().doubleValue() - me.getLatitude().doubleValue()) / 2),2);
|
||||
double dLng = Math.pow(Math.sin(Math.toRadians(away.getLongitude().doubleValue() - me.getLongitude().doubleValue()) / 2),2);
|
||||
double a = dLat + Math.cos(Math.toRadians(me.getLatitude().doubleValue()))
|
||||
* Math.cos(Math.toRadians(away.getLatitude().doubleValue())) * dLng;
|
||||
|
||||
dist = PointType.WGS84_a * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
}
|
||||
|
||||
return new DecimalType(dist);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,32 +22,34 @@ import org.openhab.core.types.UnDefType;
|
|||
* of sensors, like temperature, brightness, wind, etc.
|
||||
* It can also be used as a counter or as any other thing that can be expressed
|
||||
* as a number.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class NumberItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(DecimalType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
acceptedCommandTypes.add(DecimalType.class);
|
||||
}
|
||||
|
||||
public NumberItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(DecimalType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
acceptedCommandTypes.add(DecimalType.class);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
public NumberItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,73 +23,76 @@ import org.openhab.core.types.State;
|
|||
import org.openhab.core.types.UnDefType;
|
||||
|
||||
/**
|
||||
* A RollershutterItem allows the control of roller shutters, i.e.
|
||||
* A RollershutterItem allows the control of roller shutters, i.e.
|
||||
* moving them up, down, stopping or setting it to close to a certain percentage.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
*
|
||||
*/
|
||||
public class RollershutterItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
acceptedDataTypes.add(UpDownType.class);
|
||||
acceptedDataTypes.add(PercentType.class);
|
||||
|
||||
acceptedCommandTypes.add(UpDownType.class);
|
||||
acceptedCommandTypes.add(StopMoveType.class);
|
||||
acceptedCommandTypes.add(PercentType.class);
|
||||
}
|
||||
|
||||
public RollershutterItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
// we map UP/DOWN values to the percent values 0 and 100
|
||||
if(state==UpDownType.UP) {
|
||||
super.setState(PercentType.ZERO);
|
||||
} else if(state==UpDownType.DOWN) {
|
||||
super.setState(PercentType.HUNDRED);
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
acceptedDataTypes.add(UpDownType.class);
|
||||
acceptedDataTypes.add(PercentType.class);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if(typeClass==UpDownType.class) {
|
||||
if(state.equals(PercentType.ZERO)) {
|
||||
return UpDownType.UP;
|
||||
} else if(state.equals(PercentType.HUNDRED)) {
|
||||
return UpDownType.DOWN;
|
||||
} else {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
} else if(typeClass==DecimalType.class) {
|
||||
if(state instanceof PercentType) {
|
||||
return new DecimalType(((PercentType) state).toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
|
||||
}
|
||||
}
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
acceptedCommandTypes.add(UpDownType.class);
|
||||
acceptedCommandTypes.add(StopMoveType.class);
|
||||
acceptedCommandTypes.add(PercentType.class);
|
||||
}
|
||||
|
||||
public RollershutterItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
// we map UP/DOWN values to the percent values 0 and 100
|
||||
if (state == UpDownType.UP) {
|
||||
super.setState(PercentType.ZERO);
|
||||
} else if (state == UpDownType.DOWN) {
|
||||
super.setState(PercentType.HUNDRED);
|
||||
} else {
|
||||
super.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if (typeClass == UpDownType.class) {
|
||||
if (state.equals(PercentType.ZERO)) {
|
||||
return UpDownType.UP;
|
||||
} else if (state.equals(PercentType.HUNDRED)) {
|
||||
return UpDownType.DOWN;
|
||||
} else {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
} else if (typeClass == DecimalType.class) {
|
||||
if (state instanceof PercentType) {
|
||||
return new DecimalType(
|
||||
((PercentType) state).toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
|
||||
}
|
||||
}
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,45 +22,47 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* A StringItem can be used for any kind of string to either send or receive
|
||||
* from a device.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class StringItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(StringType.class);
|
||||
acceptedDataTypes.add((DateTimeType.class));
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
acceptedCommandTypes.add(StringType.class);
|
||||
}
|
||||
|
||||
public StringItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(StringType.class);
|
||||
acceptedDataTypes.add((DateTimeType.class));
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
acceptedCommandTypes.add(StringType.class);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
ArrayList<Class<? extends State>> list = new ArrayList<Class<? extends State>>();
|
||||
list.add(typeClass);
|
||||
State convertedState = TypeParser.parseState(list, state.toString());
|
||||
if(convertedState!=null) {
|
||||
return convertedState;
|
||||
} else {
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
public StringItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
ArrayList<Class<? extends State>> list = new ArrayList<>();
|
||||
list.add(typeClass);
|
||||
State convertedState = TypeParser.parseState(list, state.toString());
|
||||
if (convertedState != null) {
|
||||
return convertedState;
|
||||
} else {
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,47 +22,49 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* A SwitchItem represents a normal switch that can be ON or OFF.
|
||||
* Useful for normal lights, presence detection etc.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class SwitchItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(OnOffType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
acceptedCommandTypes.add(OnOffType.class);
|
||||
}
|
||||
|
||||
public SwitchItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(OnOffType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
|
||||
public void send(OnOffType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
acceptedCommandTypes.add(OnOffType.class);
|
||||
}
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
public SwitchItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if(typeClass==DecimalType.class) {
|
||||
return state==OnOffType.ON ? new DecimalType(1) : DecimalType.ZERO;
|
||||
} else if(typeClass==PercentType.class) {
|
||||
return state==OnOffType.ON ? PercentType.HUNDRED : PercentType.ZERO;
|
||||
} else {
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
public void send(OnOffType command) {
|
||||
internalSend(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getStateAs(Class<? extends State> typeClass) {
|
||||
if (typeClass == DecimalType.class) {
|
||||
return state == OnOffType.ON ? new DecimalType(1) : DecimalType.ZERO;
|
||||
} else if (typeClass == PercentType.class) {
|
||||
return state == OnOffType.ON ? PercentType.HUNDRED : PercentType.ZERO;
|
||||
} else {
|
||||
return super.getStateAs(typeClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,378 +20,393 @@ import org.openhab.core.types.UnDefType;
|
|||
/**
|
||||
* This interface is only a container for functions that require the core type library
|
||||
* for its calculations.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
public interface ArithmeticGroupFunction extends GroupFunction {
|
||||
|
||||
/**
|
||||
* This does a logical 'and' operation. Only if all items are of 'activeState' this
|
||||
* is returned, otherwise the 'passiveState' is returned.
|
||||
*
|
||||
* Through the getStateAs() method, it can be determined, how many
|
||||
* items actually are not in the 'activeState'.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class And implements GroupFunction {
|
||||
|
||||
protected final State activeState;
|
||||
protected final State passiveState;
|
||||
|
||||
public And(State activeValue, State passiveValue) {
|
||||
if(activeValue==null || passiveValue==null) {
|
||||
throw new IllegalArgumentException("Parameters must not be null!");
|
||||
}
|
||||
this.activeState = activeValue;
|
||||
this.passiveState = passiveValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
if(items!=null && items.size()>0) {
|
||||
for(Item item : items) {
|
||||
if(!activeState.equals(item.getStateAs(activeState.getClass()))) {
|
||||
return passiveState;
|
||||
}
|
||||
}
|
||||
return activeState;
|
||||
} else {
|
||||
// if we do not have any items, we return the passive state
|
||||
return passiveState;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This does a logical 'and' operation. Only if all items are of 'activeState' this
|
||||
* is returned, otherwise the 'passiveState' is returned.
|
||||
*
|
||||
* Through the getStateAs() method, it can be determined, how many
|
||||
* items actually are not in the 'activeState'.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class And implements GroupFunction {
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
if(stateClass == DecimalType.class) {
|
||||
if(items!=null) {
|
||||
return new DecimalType(items.size() - count(items, activeState));
|
||||
} else {
|
||||
return DecimalType.ZERO;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int count(List<Item> items, State state) {
|
||||
int count = 0;
|
||||
if(items!=null && state!=null) {
|
||||
for(Item item : items) {
|
||||
if(state.equals(item.getStateAs(state.getClass()))) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
}
|
||||
protected final State activeState;
|
||||
protected final State passiveState;
|
||||
|
||||
/**
|
||||
* This does a logical 'or' operation. If at least one item is of 'activeState' this
|
||||
* is returned, otherwise the 'passiveState' is returned.
|
||||
*
|
||||
* Through the getStateAs() method, it can be determined, how many
|
||||
* items actually are in the 'activeState'.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Or implements GroupFunction {
|
||||
public And(State activeValue, State passiveValue) {
|
||||
if (activeValue == null || passiveValue == null) {
|
||||
throw new IllegalArgumentException("Parameters must not be null!");
|
||||
}
|
||||
this.activeState = activeValue;
|
||||
this.passiveState = passiveValue;
|
||||
}
|
||||
|
||||
protected final State activeState;
|
||||
protected final State passiveState;
|
||||
|
||||
public Or(State activeValue, State passiveValue) {
|
||||
if(activeValue==null || passiveValue==null) {
|
||||
throw new IllegalArgumentException("Parameters must not be null!");
|
||||
}
|
||||
this.activeState = activeValue;
|
||||
this.passiveState = passiveValue;
|
||||
}
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
if (items != null && items.size() > 0) {
|
||||
for (Item item : items) {
|
||||
if (!activeState.equals(item.getStateAs(activeState.getClass()))) {
|
||||
return passiveState;
|
||||
}
|
||||
}
|
||||
return activeState;
|
||||
} else {
|
||||
// if we do not have any items, we return the passive state
|
||||
return passiveState;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
if(items!=null) {
|
||||
for(Item item : items) {
|
||||
if(activeState.equals(item.getStateAs(activeState.getClass()))) {
|
||||
return activeState;
|
||||
}
|
||||
}
|
||||
}
|
||||
return passiveState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
if(stateClass == DecimalType.class) {
|
||||
return new DecimalType(count(items, activeState));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int count(List<Item> items, State state) {
|
||||
int count = 0;
|
||||
if(items!=null && state!=null) {
|
||||
for(Item item : items) {
|
||||
if(state.equals(item.getStateAs(state.getClass()))) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This does a logical 'nand' operation. The state is 'calculated' by
|
||||
* the normal 'and' operation and than negated by returning the opposite
|
||||
* value. E.g. when the 'and' operation calculates the activeValue the
|
||||
* passiveValue will be returned and vice versa.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.0.0
|
||||
*/
|
||||
static class NAnd extends And {
|
||||
|
||||
public NAnd(State activeValue, State passiveValue) {
|
||||
super(activeValue, passiveValue);
|
||||
}
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
if (stateClass == DecimalType.class) {
|
||||
if (items != null) {
|
||||
return new DecimalType(items.size() - count(items, activeState));
|
||||
} else {
|
||||
return DecimalType.ZERO;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public State calculate(List<Item> items) {
|
||||
State result = super.calculate(items);
|
||||
State notResult =
|
||||
result.equals(activeState) ? passiveState : activeState;
|
||||
return notResult;
|
||||
}
|
||||
|
||||
}
|
||||
private int count(List<Item> items, State state) {
|
||||
int count = 0;
|
||||
if (items != null && state != null) {
|
||||
for (Item item : items) {
|
||||
if (state.equals(item.getStateAs(state.getClass()))) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
||||
/**
|
||||
* This does a logical 'nor' operation. The state is 'calculated' by
|
||||
* the normal 'or' operation and than negated by returning the opposite
|
||||
* value. E.g. when the 'or' operation calculates the activeValue the
|
||||
* passiveValue will be returned and vice versa.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.0.0
|
||||
*/
|
||||
static class NOr extends Or {
|
||||
|
||||
public NOr(State activeValue, State passiveValue) {
|
||||
super(activeValue, passiveValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public State calculate(List<Item> items) {
|
||||
State result = super.calculate(items);
|
||||
State notResult =
|
||||
result.equals(activeState) ? passiveState : activeState;
|
||||
return notResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the numeric average over all item states of decimal type.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Avg implements GroupFunction {
|
||||
|
||||
public Avg() {}
|
||||
/**
|
||||
* This does a logical 'or' operation. If at least one item is of 'activeState' this
|
||||
* is returned, otherwise the 'passiveState' is returned.
|
||||
*
|
||||
* Through the getStateAs() method, it can be determined, how many
|
||||
* items actually are in the 'activeState'.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Or implements GroupFunction {
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
int count = 0;
|
||||
if(items!=null) {
|
||||
for(Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if(itemState!=null) {
|
||||
sum = sum.add(itemState.toBigDecimal());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count>0) {
|
||||
return new DecimalType(sum.divide(new BigDecimal(count), RoundingMode.HALF_UP));
|
||||
} else {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected final State activeState;
|
||||
protected final State passiveState;
|
||||
|
||||
/**
|
||||
* This calculates the numeric sum over all item states of decimal type.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.1.0
|
||||
*
|
||||
*/
|
||||
static class Sum implements GroupFunction {
|
||||
|
||||
public Sum() {}
|
||||
public Or(State activeValue, State passiveValue) {
|
||||
if (activeValue == null || passiveValue == null) {
|
||||
throw new IllegalArgumentException("Parameters must not be null!");
|
||||
}
|
||||
this.activeState = activeValue;
|
||||
this.passiveState = passiveValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
if(items!=null) {
|
||||
for(Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if(itemState!=null) {
|
||||
sum = sum.add(itemState.toBigDecimal());
|
||||
}
|
||||
}
|
||||
}
|
||||
return new DecimalType(sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the minimum value of all item states of decimal type.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Min implements GroupFunction {
|
||||
|
||||
public Min() {}
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
if (items != null) {
|
||||
for (Item item : items) {
|
||||
if (activeState.equals(item.getStateAs(activeState.getClass()))) {
|
||||
return activeState;
|
||||
}
|
||||
}
|
||||
}
|
||||
return passiveState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
if(items!=null && items.size()>0) {
|
||||
BigDecimal min = null;
|
||||
for(Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if(itemState!=null) {
|
||||
if(min==null || min.compareTo(itemState.toBigDecimal()) > 0) {
|
||||
min = itemState.toBigDecimal();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(min!=null) {
|
||||
return new DecimalType(min);
|
||||
}
|
||||
}
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
if (stateClass == DecimalType.class) {
|
||||
return new DecimalType(count(items, activeState));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int count(List<Item> items, State state) {
|
||||
int count = 0;
|
||||
if (items != null && state != null) {
|
||||
for (Item item : items) {
|
||||
if (state.equals(item.getStateAs(state.getClass()))) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This does a logical 'nand' operation. The state is 'calculated' by
|
||||
* the normal 'and' operation and than negated by returning the opposite
|
||||
* value. E.g. when the 'and' operation calculates the activeValue the
|
||||
* passiveValue will be returned and vice versa.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.0.0
|
||||
*/
|
||||
static class NAnd extends And {
|
||||
|
||||
public NAnd(State activeValue, State passiveValue) {
|
||||
super(activeValue, passiveValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
State result = super.calculate(items);
|
||||
State notResult = result.equals(activeState) ? passiveState : activeState;
|
||||
return notResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This does a logical 'nor' operation. The state is 'calculated' by
|
||||
* the normal 'or' operation and than negated by returning the opposite
|
||||
* value. E.g. when the 'or' operation calculates the activeValue the
|
||||
* passiveValue will be returned and vice versa.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.0.0
|
||||
*/
|
||||
static class NOr extends Or {
|
||||
|
||||
public NOr(State activeValue, State passiveValue) {
|
||||
super(activeValue, passiveValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
State result = super.calculate(items);
|
||||
State notResult = result.equals(activeState) ? passiveState : activeState;
|
||||
return notResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the numeric average over all item states of decimal type.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Avg implements GroupFunction {
|
||||
|
||||
public Avg() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
int count = 0;
|
||||
if (items != null) {
|
||||
for (Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if (itemState != null) {
|
||||
sum = sum.add(itemState.toBigDecimal());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
return new DecimalType(sum.divide(new BigDecimal(count), RoundingMode.HALF_UP));
|
||||
} else {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the numeric sum over all item states of decimal type.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.1.0
|
||||
*
|
||||
*/
|
||||
static class Sum implements GroupFunction {
|
||||
|
||||
public Sum() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
if (items != null) {
|
||||
for (Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if (itemState != null) {
|
||||
sum = sum.add(itemState.toBigDecimal());
|
||||
}
|
||||
}
|
||||
}
|
||||
return new DecimalType(sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the minimum value of all item states of decimal type.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Min implements GroupFunction {
|
||||
|
||||
public Min() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
if (items != null && items.size() > 0) {
|
||||
BigDecimal min = null;
|
||||
for (Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if (itemState != null) {
|
||||
if (min == null || min.compareTo(itemState.toBigDecimal()) > 0) {
|
||||
min = itemState.toBigDecimal();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (min != null) {
|
||||
return new DecimalType(min);
|
||||
}
|
||||
}
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the maximum value of all item states of decimal type.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Max implements GroupFunction {
|
||||
|
||||
public Max() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State calculate(List<Item> items) {
|
||||
if (items != null && items.size() > 0) {
|
||||
BigDecimal max = null;
|
||||
for (Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if (itemState != null) {
|
||||
if (max == null || max.compareTo(itemState.toBigDecimal()) < 0) {
|
||||
max = itemState.toBigDecimal();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (max != null) {
|
||||
return new DecimalType(max);
|
||||
}
|
||||
}
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if (stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This calculates the maximum value of all item states of decimal type.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
static class Max implements GroupFunction {
|
||||
|
||||
public Max() {}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State calculate(List<Item> items) {
|
||||
if(items!=null && items.size()>0) {
|
||||
BigDecimal max = null;
|
||||
for(Item item : items) {
|
||||
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
|
||||
if(itemState!=null) {
|
||||
if(max==null || max.compareTo(itemState.toBigDecimal()) < 0) {
|
||||
max = itemState.toBigDecimal();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(max!=null) {
|
||||
return new DecimalType(max);
|
||||
}
|
||||
}
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc
|
||||
*/
|
||||
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
|
||||
State state = calculate(items);
|
||||
if(stateClass.isInstance(state)) {
|
||||
return state;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,93 +18,94 @@ import org.openhab.core.types.Command;
|
|||
import org.openhab.core.types.PrimitiveType;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
|
||||
public class DateTimeType implements PrimitiveType, State, Command {
|
||||
|
||||
public static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
|
||||
public static final String DATE_PATTERN_WITH_TZ = "yyyy-MM-dd'T'HH:mm:ssz";
|
||||
|
||||
protected Calendar calendar;
|
||||
|
||||
|
||||
public DateTimeType() {
|
||||
this(Calendar.getInstance());
|
||||
}
|
||||
|
||||
public DateTimeType(Calendar calendar) {
|
||||
this.calendar = calendar;
|
||||
}
|
||||
|
||||
public DateTimeType(String calendarValue) {
|
||||
Date date = null;
|
||||
|
||||
try {
|
||||
try {
|
||||
date = new SimpleDateFormat(DATE_PATTERN_WITH_TZ).parse(calendarValue);
|
||||
}
|
||||
catch (ParseException fpe2) {
|
||||
date = new SimpleDateFormat(DATE_PATTERN).parse(calendarValue);
|
||||
}
|
||||
}
|
||||
catch (ParseException fpe) {
|
||||
throw new IllegalArgumentException(calendarValue + " is not in a valid format.", fpe);
|
||||
}
|
||||
|
||||
if (date != null) {
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
}
|
||||
}
|
||||
|
||||
public Calendar getCalendar() {
|
||||
return calendar;
|
||||
}
|
||||
|
||||
|
||||
public static DateTimeType valueOf(String value) {
|
||||
return new DateTimeType(value);
|
||||
}
|
||||
|
||||
public String format(String pattern) {
|
||||
try {
|
||||
return String.format(pattern, calendar);
|
||||
} catch (NullPointerException npe) {
|
||||
return new SimpleDateFormat(DATE_PATTERN).format(calendar.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public String format(Locale locale, String pattern) {
|
||||
return String.format(locale, pattern, calendar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new SimpleDateFormat(DATE_PATTERN).format(calendar.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((calendar == null) ? 0 : calendar.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DateTimeType other = (DateTimeType) obj;
|
||||
if (calendar == null) {
|
||||
if (other.calendar != null)
|
||||
return false;
|
||||
} else if (!calendar.equals(other.calendar))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
|
||||
public static final String DATE_PATTERN_WITH_TZ = "yyyy-MM-dd'T'HH:mm:ssz";
|
||||
|
||||
protected Calendar calendar;
|
||||
|
||||
public DateTimeType() {
|
||||
this(Calendar.getInstance());
|
||||
}
|
||||
|
||||
public DateTimeType(Calendar calendar) {
|
||||
this.calendar = calendar;
|
||||
}
|
||||
|
||||
public DateTimeType(String calendarValue) {
|
||||
Date date = null;
|
||||
|
||||
try {
|
||||
try {
|
||||
date = new SimpleDateFormat(DATE_PATTERN_WITH_TZ).parse(calendarValue);
|
||||
} catch (ParseException fpe2) {
|
||||
date = new SimpleDateFormat(DATE_PATTERN).parse(calendarValue);
|
||||
}
|
||||
} catch (ParseException fpe) {
|
||||
throw new IllegalArgumentException(calendarValue + " is not in a valid format.", fpe);
|
||||
}
|
||||
|
||||
if (date != null) {
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
}
|
||||
}
|
||||
|
||||
public Calendar getCalendar() {
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public static DateTimeType valueOf(String value) {
|
||||
return new DateTimeType(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
try {
|
||||
return String.format(pattern, calendar);
|
||||
} catch (NullPointerException npe) {
|
||||
return new SimpleDateFormat(DATE_PATTERN).format(calendar.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public String format(Locale locale, String pattern) {
|
||||
return String.format(locale, pattern, calendar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new SimpleDateFormat(DATE_PATTERN).format(calendar.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((calendar == null) ? 0 : calendar.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DateTimeType other = (DateTimeType) obj;
|
||||
if (calendar == null) {
|
||||
if (other.calendar != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!calendar.equals(other.calendar)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,104 +17,112 @@ import org.openhab.core.types.State;
|
|||
/**
|
||||
* The decimal type uses a BigDecimal internally and thus can be used for
|
||||
* integers, longs and floating point numbers alike.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DecimalType extends Number implements PrimitiveType, State, Command, Comparable<DecimalType> {
|
||||
|
||||
private static final long serialVersionUID = 4226845847123464690L;
|
||||
private static final long serialVersionUID = 4226845847123464690L;
|
||||
|
||||
final static public DecimalType ZERO = new DecimalType(0);
|
||||
final static public DecimalType ZERO = new DecimalType(0);
|
||||
|
||||
protected BigDecimal value;
|
||||
protected BigDecimal value;
|
||||
|
||||
public DecimalType() {
|
||||
this.value = BigDecimal.ZERO;
|
||||
}
|
||||
public DecimalType() {
|
||||
this.value = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
public DecimalType(BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
public DecimalType(BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public DecimalType(long value) {
|
||||
this.value = new BigDecimal(value);
|
||||
}
|
||||
public DecimalType(long value) {
|
||||
this.value = new BigDecimal(value);
|
||||
}
|
||||
|
||||
public DecimalType(double value) {
|
||||
this.value = new BigDecimal(value);
|
||||
}
|
||||
public DecimalType(double value) {
|
||||
this.value = new BigDecimal(value);
|
||||
}
|
||||
|
||||
public DecimalType(String value) {
|
||||
this.value = new BigDecimal(value);
|
||||
}
|
||||
public DecimalType(String value) {
|
||||
this.value = new BigDecimal(value);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value.toPlainString();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toPlainString();
|
||||
}
|
||||
|
||||
public static DecimalType valueOf(String value) {
|
||||
return new DecimalType(value);
|
||||
}
|
||||
public static DecimalType valueOf(String value) {
|
||||
return new DecimalType(value);
|
||||
}
|
||||
|
||||
public String format(String pattern) {
|
||||
if (pattern.contains("%d")) {
|
||||
return String.format(pattern, value.toBigInteger());
|
||||
} else {
|
||||
return String.format(pattern, value);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
if (pattern.contains("%d")) {
|
||||
return String.format(pattern, value.toBigInteger());
|
||||
} else {
|
||||
return String.format(pattern, value);
|
||||
}
|
||||
}
|
||||
|
||||
public BigDecimal toBigDecimal() {
|
||||
return value;
|
||||
}
|
||||
public BigDecimal toBigDecimal() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof DecimalType))
|
||||
return false;
|
||||
DecimalType other = (DecimalType) obj;
|
||||
if (value == null) {
|
||||
if (other.value != null)
|
||||
return false;
|
||||
} else if (value.compareTo(other.value) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof DecimalType)) {
|
||||
return false;
|
||||
}
|
||||
DecimalType other = (DecimalType) obj;
|
||||
if (value == null) {
|
||||
if (other.value != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (value.compareTo(other.value) != 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int compareTo(DecimalType o) {
|
||||
return value.compareTo(o.toBigDecimal());
|
||||
}
|
||||
@Override
|
||||
public int compareTo(DecimalType o) {
|
||||
return value.compareTo(o.toBigDecimal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
return value.doubleValue();
|
||||
}
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
return value.doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float floatValue() {
|
||||
return value.floatValue();
|
||||
}
|
||||
@Override
|
||||
public float floatValue() {
|
||||
return value.floatValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return value.intValue();
|
||||
}
|
||||
@Override
|
||||
public int intValue() {
|
||||
return value.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long longValue() {
|
||||
return value.longValue();
|
||||
}
|
||||
@Override
|
||||
public long longValue() {
|
||||
return value.longValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,152 +21,148 @@ import org.openhab.core.types.State;
|
|||
/**
|
||||
* The HSBType is a complex type with constituents for hue, saturation and
|
||||
* brightness and can be used for color items.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.2.0
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class HSBType extends PercentType implements ComplexType, State, Command {
|
||||
|
||||
private static final long serialVersionUID = 322902950356613226L;
|
||||
private static final long serialVersionUID = 322902950356613226L;
|
||||
|
||||
// constants for the constituents
|
||||
static final public String KEY_HUE = "h";
|
||||
static final public String KEY_SATURATION = "s";
|
||||
static final public String KEY_BRIGHTNESS = "b";
|
||||
// constants for the constituents
|
||||
static final public String KEY_HUE = "h";
|
||||
static final public String KEY_SATURATION = "s";
|
||||
static final public String KEY_BRIGHTNESS = "b";
|
||||
|
||||
// constants for colors
|
||||
static final public HSBType BLACK = new HSBType(Color.BLACK);
|
||||
static final public HSBType WHITE = new HSBType(Color.WHITE);
|
||||
static final public HSBType RED = new HSBType(Color.RED);
|
||||
static final public HSBType GREEN = new HSBType(Color.GREEN);
|
||||
static final public HSBType BLUE = new HSBType(Color.BLUE);
|
||||
// constants for colors
|
||||
static final public HSBType BLACK = new HSBType(Color.BLACK);
|
||||
static final public HSBType WHITE = new HSBType(Color.WHITE);
|
||||
static final public HSBType RED = new HSBType(Color.RED);
|
||||
static final public HSBType GREEN = new HSBType(Color.GREEN);
|
||||
static final public HSBType BLUE = new HSBType(Color.BLUE);
|
||||
|
||||
protected BigDecimal hue;
|
||||
protected BigDecimal saturation;
|
||||
protected BigDecimal hue;
|
||||
protected BigDecimal saturation;
|
||||
|
||||
// the inherited field "value" of the parent DecimalType corresponds to the
|
||||
// "brightness"
|
||||
// the inherited field "value" of the parent DecimalType corresponds to the
|
||||
// "brightness"
|
||||
|
||||
public HSBType(Color color) {
|
||||
if (color != null) {
|
||||
float[] hsbValues = Color.RGBtoHSB(color.getRed(),
|
||||
color.getGreen(), color.getBlue(), null);
|
||||
this.hue = BigDecimal.valueOf(hsbValues[0] * 360);
|
||||
this.saturation = BigDecimal.valueOf(hsbValues[1] * 100);
|
||||
this.value = BigDecimal.valueOf(hsbValues[2] * 100);
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Constructor argument must not be null");
|
||||
}
|
||||
}
|
||||
public HSBType(Color color) {
|
||||
if (color != null) {
|
||||
float[] hsbValues = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
|
||||
this.hue = BigDecimal.valueOf(hsbValues[0] * 360);
|
||||
this.saturation = BigDecimal.valueOf(hsbValues[1] * 100);
|
||||
this.value = BigDecimal.valueOf(hsbValues[2] * 100);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Constructor argument must not be null");
|
||||
}
|
||||
}
|
||||
|
||||
public HSBType(DecimalType h, PercentType s, PercentType b) {
|
||||
this.hue = h.toBigDecimal();
|
||||
this.saturation = s.toBigDecimal();
|
||||
this.value = b.toBigDecimal();
|
||||
}
|
||||
public HSBType(DecimalType h, PercentType s, PercentType b) {
|
||||
this.hue = h.toBigDecimal();
|
||||
this.saturation = s.toBigDecimal();
|
||||
this.value = b.toBigDecimal();
|
||||
}
|
||||
|
||||
public HSBType(String value) {
|
||||
if (value != null) {
|
||||
String[] constituents = value.split(",");
|
||||
if (constituents.length == 3) {
|
||||
this.hue = new BigDecimal(constituents[0]);
|
||||
this.saturation = new BigDecimal(constituents[1]);
|
||||
this.value = new BigDecimal(constituents[2]);
|
||||
} else {
|
||||
throw new IllegalArgumentException(value
|
||||
+ " is not a valid HSBType syntax");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Constructor argument must not be null");
|
||||
}
|
||||
}
|
||||
public HSBType(String value) {
|
||||
if (value != null) {
|
||||
String[] constituents = value.split(",");
|
||||
if (constituents.length == 3) {
|
||||
this.hue = new BigDecimal(constituents[0]);
|
||||
this.saturation = new BigDecimal(constituents[1]);
|
||||
this.value = new BigDecimal(constituents[2]);
|
||||
} else {
|
||||
throw new IllegalArgumentException(value + " is not a valid HSBType syntax");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Constructor argument must not be null");
|
||||
}
|
||||
}
|
||||
|
||||
public static HSBType valueOf(String value) {
|
||||
return new HSBType(value);
|
||||
}
|
||||
public static HSBType valueOf(String value) {
|
||||
return new HSBType(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<String, PrimitiveType> getConstituents() {
|
||||
TreeMap<String, PrimitiveType> map = new TreeMap<String, PrimitiveType>();
|
||||
map.put(KEY_HUE, getHue());
|
||||
map.put(KEY_SATURATION, getSaturation());
|
||||
map.put(KEY_BRIGHTNESS, getBrightness());
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
public SortedMap<String, PrimitiveType> getConstituents() {
|
||||
TreeMap<String, PrimitiveType> map = new TreeMap<>();
|
||||
map.put(KEY_HUE, getHue());
|
||||
map.put(KEY_SATURATION, getSaturation());
|
||||
map.put(KEY_BRIGHTNESS, getBrightness());
|
||||
return map;
|
||||
}
|
||||
|
||||
public DecimalType getHue() {
|
||||
return new DecimalType(hue);
|
||||
}
|
||||
public DecimalType getHue() {
|
||||
return new DecimalType(hue);
|
||||
}
|
||||
|
||||
public PercentType getSaturation() {
|
||||
return new PercentType(saturation);
|
||||
}
|
||||
public PercentType getSaturation() {
|
||||
return new PercentType(saturation);
|
||||
}
|
||||
|
||||
public PercentType getBrightness() {
|
||||
return new PercentType(value);
|
||||
}
|
||||
public PercentType getBrightness() {
|
||||
return new PercentType(value);
|
||||
}
|
||||
|
||||
public PercentType getRed() {
|
||||
return byteToPercentType(toColor().getRed());
|
||||
}
|
||||
public PercentType getRed() {
|
||||
return byteToPercentType(toColor().getRed());
|
||||
}
|
||||
|
||||
public PercentType getGreen() {
|
||||
return byteToPercentType(toColor().getGreen());
|
||||
}
|
||||
public PercentType getGreen() {
|
||||
return byteToPercentType(toColor().getGreen());
|
||||
}
|
||||
|
||||
public PercentType getBlue() {
|
||||
return byteToPercentType(toColor().getBlue());
|
||||
}
|
||||
public PercentType getBlue() {
|
||||
return byteToPercentType(toColor().getBlue());
|
||||
}
|
||||
|
||||
private PercentType byteToPercentType(int byteValue) {
|
||||
BigDecimal percentValue = new BigDecimal(byteValue).multiply(
|
||||
BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(255), 2,
|
||||
BigDecimal.ROUND_HALF_UP);
|
||||
return new PercentType(percentValue);
|
||||
}
|
||||
private PercentType byteToPercentType(int byteValue) {
|
||||
BigDecimal percentValue = new BigDecimal(byteValue).multiply(BigDecimal.valueOf(100))
|
||||
.divide(BigDecimal.valueOf(255), 2, BigDecimal.ROUND_HALF_UP);
|
||||
return new PercentType(percentValue);
|
||||
}
|
||||
|
||||
public Color toColor() {
|
||||
return Color.getHSBColor(hue.floatValue() / 360,
|
||||
saturation.floatValue() / 100, value.floatValue() / 100);
|
||||
}
|
||||
public Color toColor() {
|
||||
return Color.getHSBColor(hue.floatValue() / 360, saturation.floatValue() / 100, value.floatValue() / 100);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getHue() + "," + getSaturation() + "," + getBrightness();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return getHue() + "," + getSaturation() + "," + getBrightness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int tmp = 10000 * (getHue() == null ? 0 : getHue().hashCode());
|
||||
tmp += 100 * (getSaturation() == null ? 0 : getSaturation().hashCode());
|
||||
tmp += (getBrightness() == null ? 0 : getBrightness().hashCode());
|
||||
return tmp;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int tmp = 10000 * (getHue() == null ? 0 : getHue().hashCode());
|
||||
tmp += 100 * (getSaturation() == null ? 0 : getSaturation().hashCode());
|
||||
tmp += (getBrightness() == null ? 0 : getBrightness().hashCode());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof HSBType))
|
||||
return false;
|
||||
HSBType other = (HSBType) obj;
|
||||
if ((getHue() != null && other.getHue() == null)
|
||||
|| (getHue() == null && other.getHue() != null)
|
||||
|| (getSaturation() != null && other.getSaturation() == null)
|
||||
|| (getSaturation() == null && other.getSaturation() != null)
|
||||
|| (getBrightness() != null && other.getBrightness() == null)
|
||||
|| (getBrightness() == null && other.getBrightness() != null)) {
|
||||
return false;
|
||||
}
|
||||
if (!getHue().equals(other.getHue())
|
||||
|| !getSaturation().equals(other.getSaturation())
|
||||
|| !getBrightness().equals(other.getBrightness())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof HSBType)) {
|
||||
return false;
|
||||
}
|
||||
HSBType other = (HSBType) obj;
|
||||
if ((getHue() != null && other.getHue() == null) || (getHue() == null && other.getHue() != null)
|
||||
|| (getSaturation() != null && other.getSaturation() == null)
|
||||
|| (getSaturation() == null && other.getSaturation() != null)
|
||||
|| (getBrightness() != null && other.getBrightness() == null)
|
||||
|| (getBrightness() == null && other.getBrightness() != null)) {
|
||||
return false;
|
||||
}
|
||||
if (!getHue().equals(other.getHue()) || !getSaturation().equals(other.getSaturation())
|
||||
|| !getBrightness().equals(other.getBrightness())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ import org.openhab.core.types.Command;
|
|||
import org.openhab.core.types.PrimitiveType;
|
||||
|
||||
public enum IncreaseDecreaseType implements PrimitiveType, Command {
|
||||
INCREASE, DECREASE;
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
INCREASE,
|
||||
DECREASE;
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,14 +9,16 @@
|
|||
package org.openhab.core.library.types;
|
||||
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.PrimitiveType;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
public enum OnOffType implements PrimitiveType, State, Command {
|
||||
ON, OFF;
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
ON,
|
||||
OFF;
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,14 +9,16 @@
|
|||
package org.openhab.core.library.types;
|
||||
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.PrimitiveType;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
public enum OpenClosedType implements PrimitiveType, State, Command {
|
||||
OPEN, CLOSED;
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
OPEN,
|
||||
CLOSED;
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,47 +10,47 @@ package org.openhab.core.library.types;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The PercentType extends the {@link DecimalType} by putting constraints for its value on top (0-100).
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class PercentType extends DecimalType {
|
||||
|
||||
private static final long serialVersionUID = -9066279845951780879L;
|
||||
|
||||
final static public PercentType ZERO = new PercentType(0);
|
||||
final static public PercentType HUNDRED = new PercentType(100);
|
||||
|
||||
public PercentType() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PercentType(int value) {
|
||||
super(value);
|
||||
validateValue(this.value);
|
||||
}
|
||||
|
||||
public PercentType(String value) {
|
||||
super(value);
|
||||
validateValue(this.value);
|
||||
}
|
||||
private static final long serialVersionUID = -9066279845951780879L;
|
||||
|
||||
public PercentType(BigDecimal value) {
|
||||
super(value);
|
||||
validateValue(this.value);
|
||||
}
|
||||
|
||||
private void validateValue(BigDecimal value) {
|
||||
if(BigDecimal.ZERO.compareTo(value) > 0 || new BigDecimal(100).compareTo(value) < 0) {
|
||||
throw new IllegalArgumentException("Value must be between 0 and 100");
|
||||
}
|
||||
}
|
||||
|
||||
public static PercentType valueOf(String value) {
|
||||
return new PercentType(value);
|
||||
}
|
||||
final static public PercentType ZERO = new PercentType(0);
|
||||
final static public PercentType HUNDRED = new PercentType(100);
|
||||
|
||||
public PercentType() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PercentType(int value) {
|
||||
super(value);
|
||||
validateValue(this.value);
|
||||
}
|
||||
|
||||
public PercentType(String value) {
|
||||
super(value);
|
||||
validateValue(this.value);
|
||||
}
|
||||
|
||||
public PercentType(BigDecimal value) {
|
||||
super(value);
|
||||
validateValue(this.value);
|
||||
}
|
||||
|
||||
private void validateValue(BigDecimal value) {
|
||||
if (BigDecimal.ZERO.compareTo(value) > 0 || new BigDecimal(100).compareTo(value) < 0) {
|
||||
throw new IllegalArgumentException("Value must be between 0 and 100");
|
||||
}
|
||||
}
|
||||
|
||||
public static PercentType valueOf(String value) {
|
||||
return new PercentType(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public class PointType implements ComplexType, Command, State {
|
|||
|
||||
@Override
|
||||
public SortedMap<String, PrimitiveType> getConstituents() {
|
||||
SortedMap<String, PrimitiveType> result = new TreeMap<String, PrimitiveType>();
|
||||
SortedMap<String, PrimitiveType> result = new TreeMap<>();
|
||||
result.put(KEY_LATITUDE, getLatitude());
|
||||
result.put(KEY_LONGITUDE, getLongitude());
|
||||
result.put(KEY_ALTITUDE, getAltitude());
|
||||
|
|
|
@ -12,10 +12,12 @@ import org.openhab.core.types.Command;
|
|||
import org.openhab.core.types.PrimitiveType;
|
||||
|
||||
public enum StopMoveType implements PrimitiveType, Command {
|
||||
STOP, MOVE;
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
STOP,
|
||||
MOVE;
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,53 +9,57 @@
|
|||
package org.openhab.core.library.types;
|
||||
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.PrimitiveType;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
public class StringType implements PrimitiveType, State, Command {
|
||||
|
||||
public final static StringType EMPTY = new StringType("");
|
||||
|
||||
private final String value;
|
||||
public final static StringType EMPTY = new StringType("");
|
||||
|
||||
public StringType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static StringType valueOf(String value) {
|
||||
return new StringType(value);
|
||||
}
|
||||
private final String value;
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, value);
|
||||
}
|
||||
public StringType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value.hashCode();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if(obj instanceof String) {
|
||||
return obj.equals(value);
|
||||
}
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
StringType other = (StringType) obj;
|
||||
if (!value.equals(other.value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static StringType valueOf(String value) {
|
||||
return new StringType(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
return obj.equals(value);
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
StringType other = (StringType) obj;
|
||||
if (!value.equals(other.value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,14 +9,16 @@
|
|||
package org.openhab.core.library.types;
|
||||
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.PrimitiveType;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
public enum UpDownType implements PrimitiveType, State, Command {
|
||||
UP, DOWN;
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
UP,
|
||||
DOWN;
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,141 +14,147 @@ import org.openhab.core.types.State;
|
|||
|
||||
/**
|
||||
* This class is used to define a filter for queries to a {@link PersistenceService}.
|
||||
*
|
||||
* <p>It is designed as a Java bean, for which the different properties are constraints
|
||||
*
|
||||
* <p>
|
||||
* It is designed as a Java bean, for which the different properties are constraints
|
||||
* on the query result. These properties include the item name, begin and end date and
|
||||
* the item state. A compare operator can be defined to compare not only state equality,
|
||||
* but also its decimal value (<,>).<p>
|
||||
* <p>Additionally, the filter criteria supports ordering and paging of the result, so the
|
||||
* but also its decimal value (<,>).
|
||||
* <p>
|
||||
* <p>
|
||||
* Additionally, the filter criteria supports ordering and paging of the result, so the
|
||||
* caller can ask to only return chunks of the result of a certain size (=pageSize) from a
|
||||
* starting index (pageNumber*pageSize).</p>
|
||||
* <p>All setter methods return the filter criteria instance, so that the methods can be
|
||||
* starting index (pageNumber*pageSize).
|
||||
* </p>
|
||||
* <p>
|
||||
* All setter methods return the filter criteria instance, so that the methods can be
|
||||
* easily chained in order to define a filter.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class FilterCriteria {
|
||||
|
||||
/** Enumeration with all possible compare options */
|
||||
public enum Operator {
|
||||
EQ("="),
|
||||
NEQ("!="),
|
||||
GT(">"),
|
||||
LT("<"),
|
||||
GTE(">="),
|
||||
LTE("<=");
|
||||
|
||||
private final String symbol;
|
||||
|
||||
Operator(String symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
|
||||
/** Enumeration with all ordering options */
|
||||
public enum Ordering {
|
||||
ASCENDING, DESCENDING
|
||||
}
|
||||
|
||||
/** filter result to only contain entries for the given item */
|
||||
private String itemName;
|
||||
/** Enumeration with all possible compare options */
|
||||
public enum Operator {
|
||||
EQ("="),
|
||||
NEQ("!="),
|
||||
GT(">"),
|
||||
LT("<"),
|
||||
GTE(">="),
|
||||
LTE("<=");
|
||||
|
||||
/** filter result to only contain entries that are newer than the given date */
|
||||
private Date beginDate;
|
||||
|
||||
/** filter result to only contain entries that are older than the given date */
|
||||
private Date endDate;
|
||||
private final String symbol;
|
||||
|
||||
/** return the result list from starting index pageNumber*pageSize only */
|
||||
private int pageNumber = 0;
|
||||
|
||||
/** return at most this many results */
|
||||
private int pageSize = Integer.MAX_VALUE;
|
||||
Operator(String symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
/** use this operator to compare the item state */
|
||||
private Operator operator = Operator.EQ;
|
||||
|
||||
/** how to sort the result list by date */
|
||||
private Ordering ordering = Ordering.DESCENDING;
|
||||
String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
|
||||
/** filter result to only contain entries that evaluate to true with the given operator and state */
|
||||
private State state;
|
||||
/** Enumeration with all ordering options */
|
||||
public enum Ordering {
|
||||
ASCENDING,
|
||||
DESCENDING
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
/** filter result to only contain entries for the given item */
|
||||
private String itemName;
|
||||
|
||||
public Date getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
/** filter result to only contain entries that are newer than the given date */
|
||||
private Date beginDate;
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
/** filter result to only contain entries that are older than the given date */
|
||||
private Date endDate;
|
||||
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
/** return the result list from starting index pageNumber*pageSize only */
|
||||
private int pageNumber = 0;
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
/** return at most this many results */
|
||||
private int pageSize = Integer.MAX_VALUE;
|
||||
|
||||
public Operator getOperator() {
|
||||
return operator;
|
||||
}
|
||||
/** use this operator to compare the item state */
|
||||
private Operator operator = Operator.EQ;
|
||||
|
||||
public Ordering getOrdering() {
|
||||
return ordering;
|
||||
}
|
||||
/** how to sort the result list by date */
|
||||
private Ordering ordering = Ordering.DESCENDING;
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
/** filter result to only contain entries that evaluate to true with the given operator and state */
|
||||
private State state;
|
||||
|
||||
public FilterCriteria setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
return this;
|
||||
}
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public FilterCriteria setBeginDate(Date beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
return this;
|
||||
}
|
||||
public Date getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public FilterCriteria setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
}
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public FilterCriteria setPageNumber(int pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
return this;
|
||||
}
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
public FilterCriteria setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return this;
|
||||
}
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public FilterCriteria setOperator(Operator operator) {
|
||||
this.operator = operator;
|
||||
return this;
|
||||
}
|
||||
public Operator getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public FilterCriteria setOrdering(Ordering ordering) {
|
||||
this.ordering = ordering;
|
||||
return this;
|
||||
}
|
||||
public Ordering getOrdering() {
|
||||
return ordering;
|
||||
}
|
||||
|
||||
public FilterCriteria setState(State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public FilterCriteria setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setBeginDate(Date beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setPageNumber(int pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setOperator(Operator operator) {
|
||||
this.operator = operator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setOrdering(Ordering ordering) {
|
||||
this.ordering = ordering;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterCriteria setState(State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,35 +15,37 @@ import org.openhab.core.types.State;
|
|||
/**
|
||||
* This interface is used by persistence services to represent an item
|
||||
* with a certain state at a given point in time.
|
||||
*
|
||||
* <p>Note that this interface does not extend {@link Item} as the persistence
|
||||
*
|
||||
* <p>
|
||||
* Note that this interface does not extend {@link Item} as the persistence
|
||||
* services could not provide an implementation that correctly implement
|
||||
* getAcceptedXTypes() and getGroupNames().</p>
|
||||
*
|
||||
* getAcceptedXTypes() and getGroupNames().
|
||||
* </p>
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface HistoricItem {
|
||||
|
||||
/**
|
||||
* returns the timestamp of the persisted item
|
||||
*
|
||||
* @return the timestamp of the item
|
||||
*/
|
||||
Date getTimestamp();
|
||||
/**
|
||||
* returns the timestamp of the persisted item
|
||||
*
|
||||
* @return the timestamp of the item
|
||||
*/
|
||||
Date getTimestamp();
|
||||
|
||||
/**
|
||||
* returns the current state of the item
|
||||
*
|
||||
* @return the current state
|
||||
*/
|
||||
public State getState();
|
||||
/**
|
||||
* returns the current state of the item
|
||||
*
|
||||
* @return the current state
|
||||
*/
|
||||
public State getState();
|
||||
|
||||
/**
|
||||
* returns the name of the item
|
||||
*
|
||||
* @return the name of the item
|
||||
*/
|
||||
public String getName();
|
||||
/**
|
||||
* returns the name of the item
|
||||
*
|
||||
* @return the name of the item
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
}
|
||||
|
|
|
@ -13,44 +13,50 @@ import org.openhab.core.items.Item;
|
|||
/**
|
||||
* A persistence service which can be used to store data from openHAB.
|
||||
* This must not necessarily be a local database, a persistence service
|
||||
* can also be cloud-based or a simply data-export facility (e.g.
|
||||
* for sending data to an IoT (Internet of Things) service.
|
||||
*
|
||||
* can also be cloud-based or a simply data-export facility (e.g.
|
||||
* for sending data to an IoT (Internet of Things) service.
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface PersistenceService {
|
||||
|
||||
/**
|
||||
* Returns the name of this {@link PersistenceService}.
|
||||
* This name is used to uniquely identify the {@link PersistenceService}.
|
||||
*
|
||||
* @return the name to uniquely identify the {@link PersistenceService}.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Stores the current value of the given item.
|
||||
* <p>Implementors should keep in mind that all registered
|
||||
* {@link PersistenceService}s are called synchronously. Hence long running
|
||||
* operations should be processed asynchronously. E.g. <code>store</code>
|
||||
* adds things to a queue which is processed by some asynchronous workers
|
||||
* (Quartz Job, Thread, etc.).</p>
|
||||
*
|
||||
* @param item the item which state should be persisted.
|
||||
*/
|
||||
void store(Item item);
|
||||
/**
|
||||
* Returns the name of this {@link PersistenceService}.
|
||||
* This name is used to uniquely identify the {@link PersistenceService}.
|
||||
*
|
||||
* @return the name to uniquely identify the {@link PersistenceService}.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* <p>Stores the current value of the given item under a specified alias.</p>
|
||||
* <p>Implementors should keep in mind that all registered
|
||||
* {@link PersistenceService}s are called synchronously. Hence long running
|
||||
* operations should be processed asynchronously. E.g. <code>store</code>
|
||||
* adds things to a queue which is processed by some asynchronous workers
|
||||
* (Quartz Job, Thread, etc.).</p>
|
||||
*
|
||||
* @param item the item which state should be persisted.
|
||||
* @param alias the alias under which the item should be persisted.
|
||||
*/
|
||||
void store(Item item, String alias);
|
||||
/**
|
||||
* Stores the current value of the given item.
|
||||
* <p>
|
||||
* Implementors should keep in mind that all registered
|
||||
* {@link PersistenceService}s are called synchronously. Hence long running
|
||||
* operations should be processed asynchronously. E.g. <code>store</code>
|
||||
* adds things to a queue which is processed by some asynchronous workers
|
||||
* (Quartz Job, Thread, etc.).
|
||||
* </p>
|
||||
*
|
||||
* @param item the item which state should be persisted.
|
||||
*/
|
||||
void store(Item item);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Stores the current value of the given item under a specified alias.
|
||||
* </p>
|
||||
* <p>
|
||||
* Implementors should keep in mind that all registered
|
||||
* {@link PersistenceService}s are called synchronously. Hence long running
|
||||
* operations should be processed asynchronously. E.g. <code>store</code>
|
||||
* adds things to a queue which is processed by some asynchronous workers
|
||||
* (Quartz Job, Thread, etc.).
|
||||
* </p>
|
||||
*
|
||||
* @param item the item which state should be persisted.
|
||||
* @param alias the alias under which the item should be persisted.
|
||||
*/
|
||||
void store(Item item, String alias);
|
||||
}
|
||||
|
|
|
@ -11,18 +11,18 @@ package org.openhab.core.persistence;
|
|||
/**
|
||||
* A queryable persistence service which can be used to store and retrieve
|
||||
* data from openHAB. This is most likely some kind of database system.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface QueryablePersistenceService extends PersistenceService {
|
||||
|
||||
/**
|
||||
* Queries the {@link PersistenceService} for data with a given filter criteria
|
||||
*
|
||||
* @param filter the filter to apply to the query
|
||||
* @return a time series of items
|
||||
*/
|
||||
Iterable<HistoricItem> query(FilterCriteria filter);
|
||||
|
||||
/**
|
||||
* Queries the {@link PersistenceService} for data with a given filter criteria
|
||||
*
|
||||
* @param filter the filter to apply to the query
|
||||
* @return a time series of items
|
||||
*/
|
||||
Iterable<HistoricItem> query(FilterCriteria filter);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,64 +22,64 @@ import org.osgi.framework.ServiceRegistration;
|
|||
/**
|
||||
* This class listens for services that implement the old persistence service interface and registers
|
||||
* an according service for each under the new interface.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution and API
|
||||
*/
|
||||
public class PersistenceServiceFactory {
|
||||
|
||||
private Map<String, ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService>> delegates = new HashMap<>();
|
||||
private BundleContext context;
|
||||
|
||||
private Set<PersistenceService> persistenceServices = new HashSet<>();
|
||||
|
||||
public void activate(BundleContext context) {
|
||||
this.context = context;
|
||||
for(PersistenceService service : persistenceServices) {
|
||||
registerDelegateService(service);
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
for(ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg : delegates.values()) {
|
||||
serviceReg.unregister();
|
||||
}
|
||||
delegates.clear();
|
||||
this.context = null;
|
||||
}
|
||||
private Map<String, ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService>> delegates = new HashMap<>();
|
||||
private BundleContext context;
|
||||
|
||||
public void addPersistenceService(PersistenceService service) {
|
||||
if(context!=null) {
|
||||
registerDelegateService(service);
|
||||
} else {
|
||||
persistenceServices.add(service);
|
||||
}
|
||||
}
|
||||
private Set<PersistenceService> persistenceServices = new HashSet<>();
|
||||
|
||||
public void removePersistenceService(PersistenceService service) {
|
||||
if(context!=null) {
|
||||
unregisterDelegateService(service);
|
||||
}
|
||||
}
|
||||
public void activate(BundleContext context) {
|
||||
this.context = context;
|
||||
for (PersistenceService service : persistenceServices) {
|
||||
registerDelegateService(service);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDelegateService(PersistenceService persistenceService) {
|
||||
if(!delegates.containsKey(persistenceService.getName())) {
|
||||
org.eclipse.smarthome.core.persistence.PersistenceService service =
|
||||
(persistenceService instanceof org.openhab.core.persistence.QueryablePersistenceService) ?
|
||||
new QueryablePersistenceServiceDelegate(persistenceService)
|
||||
: new PersistenceServiceDelegate(persistenceService);
|
||||
Dictionary<String, Object> props = new Hashtable<String, Object>();
|
||||
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg =
|
||||
context.registerService(org.eclipse.smarthome.core.persistence.PersistenceService.class, service, props);
|
||||
delegates.put(persistenceService.getName(), serviceReg);
|
||||
}
|
||||
}
|
||||
public void deactivate() {
|
||||
for (ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg : delegates
|
||||
.values()) {
|
||||
serviceReg.unregister();
|
||||
}
|
||||
delegates.clear();
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
private void unregisterDelegateService(PersistenceService service) {
|
||||
if(delegates.containsKey(service.getName())) {
|
||||
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg =
|
||||
delegates.get(service.getName());
|
||||
delegates.remove(service.getName());
|
||||
serviceReg.unregister();
|
||||
}
|
||||
}
|
||||
public void addPersistenceService(PersistenceService service) {
|
||||
if (context != null) {
|
||||
registerDelegateService(service);
|
||||
} else {
|
||||
persistenceServices.add(service);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePersistenceService(PersistenceService service) {
|
||||
if (context != null) {
|
||||
unregisterDelegateService(service);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDelegateService(PersistenceService persistenceService) {
|
||||
if (!delegates.containsKey(persistenceService.getName())) {
|
||||
org.eclipse.smarthome.core.persistence.PersistenceService service = (persistenceService instanceof org.openhab.core.persistence.QueryablePersistenceService)
|
||||
? new QueryablePersistenceServiceDelegate(persistenceService)
|
||||
: new PersistenceServiceDelegate(persistenceService);
|
||||
Dictionary<String, Object> props = new Hashtable<>();
|
||||
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg = context
|
||||
.registerService(org.eclipse.smarthome.core.persistence.PersistenceService.class, service, props);
|
||||
delegates.put(persistenceService.getName(), serviceReg);
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterDelegateService(PersistenceService service) {
|
||||
if (delegates.containsKey(service.getName())) {
|
||||
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg = delegates
|
||||
.get(service.getName());
|
||||
delegates.remove(service.getName());
|
||||
serviceReg.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.lang.annotation.Target;
|
|||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ActionDoc {
|
||||
String text();
|
||||
String returns() default "";
|
||||
String text();
|
||||
|
||||
String returns() default "";
|
||||
}
|
||||
|
|
|
@ -10,24 +10,24 @@ package org.openhab.core.scriptengine.action;
|
|||
|
||||
/**
|
||||
* This interface must be implemented by services that want to contribute script actions.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public interface ActionService {
|
||||
|
||||
/**
|
||||
* returns the FQCN of the action class.
|
||||
*
|
||||
* @return the FQCN of the action class
|
||||
*/
|
||||
String getActionClassName();
|
||||
|
||||
/**
|
||||
* Returns the action class itself
|
||||
*
|
||||
* @return the action class
|
||||
*/
|
||||
Class<?> getActionClass();
|
||||
|
||||
/**
|
||||
* returns the FQCN of the action class.
|
||||
*
|
||||
* @return the FQCN of the action class
|
||||
*/
|
||||
String getActionClassName();
|
||||
|
||||
/**
|
||||
* Returns the action class itself
|
||||
*
|
||||
* @return the action class
|
||||
*/
|
||||
Class<?> getActionClass();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.lang.annotation.Target;
|
|||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ParamDoc {
|
||||
String name();
|
||||
String text() default "";
|
||||
String name();
|
||||
|
||||
String text() default "";
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ActionServiceFactory {
|
|||
private void registerDelegateService(ActionService actionService) {
|
||||
if (!delegates.containsKey(actionService.getActionClassName())) {
|
||||
ActionServiceDelegate service = new ActionServiceDelegate(actionService);
|
||||
Dictionary<String, Object> props = new Hashtable<String, Object>();
|
||||
Dictionary<String, Object> props = new Hashtable<>();
|
||||
ServiceRegistration<org.eclipse.smarthome.model.script.engine.action.ActionService> serviceReg = context
|
||||
.registerService(org.eclipse.smarthome.model.script.engine.action.ActionService.class, service,
|
||||
props);
|
||||
|
|
|
@ -11,192 +11,187 @@ package org.openhab.core.service;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for services that frequently run some action in a separate thread in the
|
||||
* Base class for services that frequently run some action in a separate thread in the
|
||||
* background.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public abstract class AbstractActiveService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractActiveService.class);
|
||||
|
||||
/** <code>true</code> if this binding is configured properly which means that all necessary data is available */
|
||||
private boolean properlyConfigured = false;
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractActiveService.class);
|
||||
|
||||
/**
|
||||
* indicates that the background thread will shutdown after the current
|
||||
* execution cycle.
|
||||
*/
|
||||
protected boolean shutdown = false;
|
||||
|
||||
/**
|
||||
* holds the instance of the refresh thread or is <code>null</code> if
|
||||
* there is no thread active at the moment
|
||||
*/
|
||||
private Thread refreshThread;
|
||||
|
||||
|
||||
public AbstractActiveService() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** <code>true</code> if this binding is configured properly which means that all necessary data is available */
|
||||
private boolean properlyConfigured = false;
|
||||
|
||||
public void activate() {
|
||||
start();
|
||||
}
|
||||
/**
|
||||
* indicates that the background thread will shutdown after the current
|
||||
* execution cycle.
|
||||
*/
|
||||
protected boolean shutdown = false;
|
||||
|
||||
public void deactivate() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes care about starting the refresh thread. It creates a new
|
||||
* RefreshThread if no instance exists.
|
||||
*/
|
||||
protected void start() {
|
||||
if (!isProperlyConfigured()) {
|
||||
logger.trace("{} won't be started because it isn't yet properly configured.", getName());
|
||||
return;
|
||||
}
|
||||
|
||||
shutdown = false;
|
||||
if (!isRunning()) {
|
||||
this.refreshThread = new RefreshThread(getName(), getRefreshInterval());
|
||||
this.refreshThread.start();
|
||||
} else {
|
||||
logger.trace("{} is already started > calling start() changed nothing.", getName());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* holds the instance of the refresh thread or is <code>null</code> if
|
||||
* there is no thread active at the moment
|
||||
*/
|
||||
private Thread refreshThread;
|
||||
|
||||
/**
|
||||
* Gracefully shuts down the refresh background thread. It will shuts down
|
||||
* after the current execution cycle.
|
||||
*/
|
||||
public void shutdown() {
|
||||
this.shutdown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the refresh thread immediately.
|
||||
*/
|
||||
public void interrupt() {
|
||||
if (isRunning()) {
|
||||
this.refreshThread.interrupt();
|
||||
logger.trace("{} has been interrupted.", getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
if (this.refreshThread != null) {
|
||||
return this.refreshThread.isAlive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if this binding is configured properly which means
|
||||
* that all necessary data is available
|
||||
*/
|
||||
final public boolean isProperlyConfigured() {
|
||||
return properlyConfigured;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to define whether this binding is fully configured so that it can be
|
||||
* activated and used.
|
||||
* Note that the implementation will automatically start the active service if
|
||||
* <code>true</code> is passed as a parameter.
|
||||
*
|
||||
* @param properlyConfigured
|
||||
*/
|
||||
public void setProperlyConfigured(boolean properlyConfigured) {
|
||||
this.properlyConfigured = properlyConfigured;
|
||||
if (properlyConfigured && !isRunning()) {
|
||||
start();
|
||||
} else if (!properlyConfigured && isRunning()) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The working method which is called by the refresh thread frequently.
|
||||
* Developers should put their binding code here.
|
||||
*/
|
||||
protected abstract void execute();
|
||||
public AbstractActiveService() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the refresh interval to be used by the RefreshThread between to
|
||||
* calls of the execute method.
|
||||
*
|
||||
* @return the refresh interval
|
||||
*/
|
||||
protected abstract long getRefreshInterval();
|
||||
public void activate() {
|
||||
start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the Refresh thread.
|
||||
*
|
||||
* @return the name of the refresh thread.
|
||||
*/
|
||||
protected abstract String getName();
|
||||
|
||||
/**
|
||||
* Worker thread which calls the execute method frequently.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
*/
|
||||
class RefreshThread extends Thread {
|
||||
|
||||
private long refreshInterval;
|
||||
|
||||
public RefreshThread(String name, long refreshInterval) {
|
||||
super(name);
|
||||
this.setDaemon(true);
|
||||
this.refreshInterval = refreshInterval;
|
||||
|
||||
// reset 'interrupted' after stopping this refresh thread ...
|
||||
shutdown = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info(getName() + " has been started");
|
||||
|
||||
while (!shutdown) {
|
||||
try {
|
||||
execute();
|
||||
} catch(RuntimeException e) {
|
||||
logger.error("Error while executing background thread " + getName(), e);
|
||||
}
|
||||
pause(refreshInterval);
|
||||
}
|
||||
|
||||
refreshThread = null;
|
||||
logger.info(getName() + " has been shut down");
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause polling for the given <code>refreshInterval</code>. Possible
|
||||
* {@link InterruptedException} is logged with no further action.
|
||||
*
|
||||
* @param refreshInterval
|
||||
*/
|
||||
protected void pause(long refreshInterval) {
|
||||
|
||||
try {
|
||||
Thread.sleep(refreshInterval);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
logger.debug("pausing thread " + super.getName() +" interrupted");
|
||||
}
|
||||
}
|
||||
public void deactivate() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Takes care about starting the refresh thread. It creates a new
|
||||
* RefreshThread if no instance exists.
|
||||
*/
|
||||
protected void start() {
|
||||
if (!isProperlyConfigured()) {
|
||||
logger.trace("{} won't be started because it isn't yet properly configured.", getName());
|
||||
return;
|
||||
}
|
||||
|
||||
shutdown = false;
|
||||
if (!isRunning()) {
|
||||
this.refreshThread = new RefreshThread(getName(), getRefreshInterval());
|
||||
this.refreshThread.start();
|
||||
} else {
|
||||
logger.trace("{} is already started > calling start() changed nothing.", getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gracefully shuts down the refresh background thread. It will shuts down
|
||||
* after the current execution cycle.
|
||||
*/
|
||||
public void shutdown() {
|
||||
this.shutdown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the refresh thread immediately.
|
||||
*/
|
||||
public void interrupt() {
|
||||
if (isRunning()) {
|
||||
this.refreshThread.interrupt();
|
||||
logger.trace("{} has been interrupted.", getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
if (this.refreshThread != null) {
|
||||
return this.refreshThread.isAlive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if this binding is configured properly which means
|
||||
* that all necessary data is available
|
||||
*/
|
||||
final public boolean isProperlyConfigured() {
|
||||
return properlyConfigured;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to define whether this binding is fully configured so that it can be
|
||||
* activated and used.
|
||||
* Note that the implementation will automatically start the active service if
|
||||
* <code>true</code> is passed as a parameter.
|
||||
*
|
||||
* @param properlyConfigured
|
||||
*/
|
||||
public void setProperlyConfigured(boolean properlyConfigured) {
|
||||
this.properlyConfigured = properlyConfigured;
|
||||
if (properlyConfigured && !isRunning()) {
|
||||
start();
|
||||
} else if (!properlyConfigured && isRunning()) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The working method which is called by the refresh thread frequently.
|
||||
* Developers should put their binding code here.
|
||||
*/
|
||||
protected abstract void execute();
|
||||
|
||||
/**
|
||||
* Returns the refresh interval to be used by the RefreshThread between to
|
||||
* calls of the execute method.
|
||||
*
|
||||
* @return the refresh interval
|
||||
*/
|
||||
protected abstract long getRefreshInterval();
|
||||
|
||||
/**
|
||||
* Returns the name of the Refresh thread.
|
||||
*
|
||||
* @return the name of the refresh thread.
|
||||
*/
|
||||
protected abstract String getName();
|
||||
|
||||
/**
|
||||
* Worker thread which calls the execute method frequently.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
*/
|
||||
class RefreshThread extends Thread {
|
||||
|
||||
private long refreshInterval;
|
||||
|
||||
public RefreshThread(String name, long refreshInterval) {
|
||||
super(name);
|
||||
this.setDaemon(true);
|
||||
this.refreshInterval = refreshInterval;
|
||||
|
||||
// reset 'interrupted' after stopping this refresh thread ...
|
||||
shutdown = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info(getName() + " has been started");
|
||||
|
||||
while (!shutdown) {
|
||||
try {
|
||||
execute();
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("Error while executing background thread " + getName(), e);
|
||||
}
|
||||
pause(refreshInterval);
|
||||
}
|
||||
|
||||
refreshThread = null;
|
||||
logger.info(getName() + " has been shut down");
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause polling for the given <code>refreshInterval</code>. Possible
|
||||
* {@link InterruptedException} is logged with no further action.
|
||||
*
|
||||
* @param refreshInterval
|
||||
*/
|
||||
protected void pause(long refreshInterval) {
|
||||
|
||||
try {
|
||||
Thread.sleep(refreshInterval);
|
||||
} catch (InterruptedException e) {
|
||||
logger.debug("pausing thread " + super.getName() + " interrupted");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -8,25 +8,24 @@
|
|||
*/
|
||||
package org.openhab.core.transform;
|
||||
|
||||
|
||||
/**
|
||||
* A TransformationException is thrown when any step of a transformation went
|
||||
* wrong. The originating exception should be attached to increase traceability.
|
||||
*
|
||||
* wrong. The originating exception should be attached to increase traceability.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public class TransformationException extends Exception {
|
||||
|
||||
/** generated serial Version UID */
|
||||
private static final long serialVersionUID = -535237375844795145L;
|
||||
|
||||
public TransformationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TransformationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/** generated serial Version UID */
|
||||
private static final long serialVersionUID = -535237375844795145L;
|
||||
|
||||
public TransformationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TransformationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,51 +18,50 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public class TransformationHelper {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TransformationHelper.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(TransformationHelper.class);
|
||||
|
||||
/**
|
||||
* Queries the OSGi service registry for a service that provides a transformation service of
|
||||
* a given transformation type (e.g. REGEX, XSLT, etc.)
|
||||
*
|
||||
* @param transformationType the desired transformation type
|
||||
* @return a service instance or null, if none could be found
|
||||
*/
|
||||
static public TransformationService getTransformationService(BundleContext context, String transformationType) {
|
||||
if(context!=null) {
|
||||
String filter = "(smarthome.transform=" + transformationType + ")";
|
||||
try {
|
||||
Collection<ServiceReference<org.eclipse.smarthome.core.transform.TransformationService>> refs =
|
||||
context.getServiceReferences(org.eclipse.smarthome.core.transform.TransformationService.class, filter);
|
||||
if(refs!=null && refs.size() > 0) {
|
||||
return new TransformationServiceDelegate(
|
||||
(org.eclipse.smarthome.core.transform.TransformationService) context.getService(refs.iterator().next()));
|
||||
} else {
|
||||
logger.warn("Cannot get service reference for transformation service of type " + transformationType);
|
||||
}
|
||||
} catch (InvalidSyntaxException e) {
|
||||
logger.warn("Cannot get service reference for transformation service of type " + transformationType, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Queries the OSGi service registry for a service that provides a transformation service of
|
||||
* a given transformation type (e.g. REGEX, XSLT, etc.)
|
||||
*
|
||||
* @param transformationType the desired transformation type
|
||||
* @return a service instance or null, if none could be found
|
||||
*/
|
||||
static public TransformationService getTransformationService(BundleContext context, String transformationType) {
|
||||
if (context != null) {
|
||||
String filter = "(smarthome.transform=" + transformationType + ")";
|
||||
try {
|
||||
Collection<ServiceReference<org.eclipse.smarthome.core.transform.TransformationService>> refs = context
|
||||
.getServiceReferences(org.eclipse.smarthome.core.transform.TransformationService.class, filter);
|
||||
if (refs != null && refs.size() > 0) {
|
||||
return new TransformationServiceDelegate(context.getService(refs.iterator().next()));
|
||||
} else {
|
||||
logger.warn(
|
||||
"Cannot get service reference for transformation service of type " + transformationType);
|
||||
}
|
||||
} catch (InvalidSyntaxException e) {
|
||||
logger.warn("Cannot get service reference for transformation service of type " + transformationType, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static private class TransformationServiceDelegate implements TransformationService {
|
||||
static private class TransformationServiceDelegate implements TransformationService {
|
||||
|
||||
org.eclipse.smarthome.core.transform.TransformationService delegate;
|
||||
|
||||
public TransformationServiceDelegate(org.eclipse.smarthome.core.transform.TransformationService delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transform(String function, String source)
|
||||
throws TransformationException {
|
||||
try {
|
||||
return delegate.transform(function, source);
|
||||
} catch (org.eclipse.smarthome.core.transform.TransformationException e) {
|
||||
throw new TransformationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
org.eclipse.smarthome.core.transform.TransformationService delegate;
|
||||
|
||||
public TransformationServiceDelegate(org.eclipse.smarthome.core.transform.TransformationService delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transform(String function, String source) throws TransformationException {
|
||||
try {
|
||||
return delegate.transform(function, source);
|
||||
} catch (org.eclipse.smarthome.core.transform.TransformationException e) {
|
||||
throw new TransformationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
package org.openhab.core.transform;
|
||||
|
||||
|
||||
/**
|
||||
* A TransformationProcessor transforms a given input and returns the transformed
|
||||
* result. Transformations could make sense in various situations, for example:
|
||||
|
@ -17,31 +16,31 @@ package org.openhab.core.transform;
|
|||
* <li>extract the status of your TV which provides it's status on a webpage</li>
|
||||
* <li>postprocess the output from a serial device to be human readable</li>
|
||||
* </ul>
|
||||
* One could provide his own processors by providing a new implementation of this
|
||||
* Interface.
|
||||
*
|
||||
* One could provide his own processors by providing a new implementation of this
|
||||
* Interface.
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* œauthor Kai Kreuzer
|
||||
*
|
||||
* œauthor Kai Kreuzer
|
||||
*
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public interface TransformationService {
|
||||
|
||||
/**
|
||||
* Transforms the input <code>source</code> by means of the given <code>function</code>
|
||||
* and returns the transformed output. If the transformation couldn't be completed
|
||||
* for any reason, one should return the unchanged <code>source</code>. This
|
||||
* method should never return <code>null</code>. In case of any error an
|
||||
* {@link TransformationException} should be thrown.
|
||||
*
|
||||
* @param function the function to be used to transform the input
|
||||
* @param source the input to be transformed
|
||||
*
|
||||
* @return the transformed result or the unchanged <code>source</code> if the
|
||||
* transformation couldn't be completed for any reason.
|
||||
*
|
||||
* @throws TransformationException if any error occurs
|
||||
*/
|
||||
String transform(String function, String source) throws TransformationException;
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the input <code>source</code> by means of the given <code>function</code>
|
||||
* and returns the transformed output. If the transformation couldn't be completed
|
||||
* for any reason, one should return the unchanged <code>source</code>. This
|
||||
* method should never return <code>null</code>. In case of any error an
|
||||
* {@link TransformationException} should be thrown.
|
||||
*
|
||||
* @param function the function to be used to transform the input
|
||||
* @param source the input to be transformed
|
||||
*
|
||||
* @return the transformed result or the unchanged <code>source</code> if the
|
||||
* transformation couldn't be completed for any reason.
|
||||
*
|
||||
* @throws TransformationException if any error occurs
|
||||
*/
|
||||
String transform(String function, String source) throws TransformationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,40 +18,41 @@ import org.slf4j.LoggerFactory;
|
|||
/**
|
||||
* This class holds static "action" methods that can be used from within rules to execute
|
||||
* transformations.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.8.0
|
||||
*
|
||||
*/
|
||||
public class Transformation {
|
||||
|
||||
static private final Logger logger = LoggerFactory.getLogger(Transformation.class);
|
||||
|
||||
/**
|
||||
* Applies a transformation of a given type with some function to a value.
|
||||
*
|
||||
* @param type the transformation type, e.g. REGEX or MAP
|
||||
* @param function the function to call, this value depends on the transformation type
|
||||
* @param value the value to apply the transformation to
|
||||
* @return
|
||||
* the transformed value or the original one, if there was no service registered for the
|
||||
* given type or a transformation exception occurred.
|
||||
*/
|
||||
public static String transform(String type, String function, String value) {
|
||||
String result;
|
||||
TransformationService service = TransformationHelper.getTransformationService(CompatibilityActivator.getContext(), type);
|
||||
if(service!=null) {
|
||||
try {
|
||||
result = service.transform(function, value);
|
||||
} catch (TransformationException e) {
|
||||
logger.error("Error executing the transformation '" + type + "': " + e.getMessage());
|
||||
result = value;
|
||||
}
|
||||
} else {
|
||||
logger.warn("No transformation service '" + type + "' could be found.");
|
||||
result = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static private final Logger logger = LoggerFactory.getLogger(Transformation.class);
|
||||
|
||||
/**
|
||||
* Applies a transformation of a given type with some function to a value.
|
||||
*
|
||||
* @param type the transformation type, e.g. REGEX or MAP
|
||||
* @param function the function to call, this value depends on the transformation type
|
||||
* @param value the value to apply the transformation to
|
||||
* @return
|
||||
* the transformed value or the original one, if there was no service registered for the
|
||||
* given type or a transformation exception occurred.
|
||||
*/
|
||||
public static String transform(String type, String function, String value) {
|
||||
String result;
|
||||
TransformationService service = TransformationHelper
|
||||
.getTransformationService(CompatibilityActivator.getContext(), type);
|
||||
if (service != null) {
|
||||
try {
|
||||
result = service.transform(function, value);
|
||||
} catch (TransformationException e) {
|
||||
logger.error("Error executing the transformation '" + type + "': " + e.getMessage());
|
||||
result = value;
|
||||
}
|
||||
} else {
|
||||
logger.warn("No transformation service '" + type + "' could be found.");
|
||||
result = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
*/
|
||||
package org.openhab.core.types;
|
||||
|
||||
/**
|
||||
/**
|
||||
* This is a marker interface for all command types.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
|
|
|
@ -13,18 +13,18 @@ import java.util.SortedMap;
|
|||
/**
|
||||
* A complex type consists out of a sorted list of primitive constituents.
|
||||
* Each constituent can be referred to by a unique name.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public interface ComplexType extends Type {
|
||||
|
||||
/**
|
||||
* Returns all constituents with their names as a sorted map
|
||||
*
|
||||
* @return all constituents with their names
|
||||
*/
|
||||
public SortedMap<String, PrimitiveType> getConstituents();
|
||||
|
||||
|
||||
/**
|
||||
* Returns all constituents with their names as a sorted map
|
||||
*
|
||||
* @return all constituents with their names
|
||||
*/
|
||||
public SortedMap<String, PrimitiveType> getConstituents();
|
||||
|
||||
}
|
||||
|
|
|
@ -14,20 +14,24 @@ package org.openhab.core.types;
|
|||
* message on the bus is - does "item ON" mean that its state has changed to
|
||||
* ON or that it should turn itself ON? To decide this, we send the event
|
||||
* type as an additional information on the event bus for each message.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public enum EventType {
|
||||
COMMAND, UPDATE;
|
||||
|
||||
public String toString() {
|
||||
switch(this) {
|
||||
case COMMAND: return "command";
|
||||
case UPDATE: return "update";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
COMMAND,
|
||||
UPDATE;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (this) {
|
||||
case COMMAND:
|
||||
return "command";
|
||||
case UPDATE:
|
||||
return "update";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,14 +8,13 @@
|
|||
*/
|
||||
package org.openhab.core.types;
|
||||
|
||||
|
||||
/**
|
||||
* A primitive type consists of a single value like a string, a number, etc.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public interface PrimitiveType extends Type {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
*/
|
||||
package org.openhab.core.types;
|
||||
|
||||
/**
|
||||
/**
|
||||
* This is a marker interface for all state types.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
|
|
|
@ -10,25 +10,26 @@ package org.openhab.core.types;
|
|||
|
||||
import java.util.Formatter;
|
||||
|
||||
/**
|
||||
/**
|
||||
* This is a parent interface for all states and commands.
|
||||
* It was introduced as many states can be commands at the same time and
|
||||
* vice versa. E.g a light can have the state ON or OFF and one can
|
||||
* also send ON and OFF as commands to the device. This duality is
|
||||
* captured by this marker interface and allows implementing classes
|
||||
* to be both state and command at the same time.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public interface Type {
|
||||
|
||||
/**
|
||||
* Formats the value of this type according to a pattern (see {@link Formatter}).
|
||||
* @param pattern the pattern to use
|
||||
* @return the formatted string
|
||||
*/
|
||||
public String format(String pattern);
|
||||
|
||||
/**
|
||||
* Formats the value of this type according to a pattern (see {@link Formatter}).
|
||||
*
|
||||
* @param pattern the pattern to use
|
||||
* @return the formatted string
|
||||
*/
|
||||
public String format(String pattern);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,66 +14,78 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* This is a helper class that helps parsing a string into an openHAB type (state or command).
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public class TypeParser {
|
||||
|
||||
/**
|
||||
* <p>Determines a state from a string. Possible state types are passed as a parameter.
|
||||
* Note that the order matters here; the first type that accepts the string as a valid
|
||||
* value, will be used for the state.</p>
|
||||
* <p>Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
|
||||
* accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType
|
||||
* with value "ON").</p>
|
||||
*
|
||||
* @param types possible types of the state to consider
|
||||
* @param s the string to parse
|
||||
* @return the corresponding State instance or <code>null</code>
|
||||
*/
|
||||
public static State parseState(List<Class<? extends State>> types, String s) {
|
||||
for(Class<? extends Type> type : types) {
|
||||
try {
|
||||
Method valueOf = type.getMethod("valueOf", String.class);
|
||||
State state = (State) valueOf.invoke(type, s);
|
||||
if(state!=null) return state;
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Determines a state from a string. Possible state types are passed as a parameter.
|
||||
* Note that the order matters here; the first type that accepts the string as a valid
|
||||
* value, will be used for the state.
|
||||
* </p>
|
||||
* <p>
|
||||
* Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
|
||||
* accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType
|
||||
* with value "ON").
|
||||
* </p>
|
||||
*
|
||||
* @param types possible types of the state to consider
|
||||
* @param s the string to parse
|
||||
* @return the corresponding State instance or <code>null</code>
|
||||
*/
|
||||
public static State parseState(List<Class<? extends State>> types, String s) {
|
||||
for (Class<? extends Type> type : types) {
|
||||
try {
|
||||
Method valueOf = type.getMethod("valueOf", String.class);
|
||||
State state = (State) valueOf.invoke(type, s);
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Determines a command from a string. Possible command types are passed as a parameter.
|
||||
* Note that the order matters here; the first type that accepts the string as a valid
|
||||
* value, will be used for the command.</p>
|
||||
* <p>Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
|
||||
* accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType
|
||||
* with value "ON").</p>
|
||||
*
|
||||
* @param types possible types of the command to consider
|
||||
* @param s the string to parse
|
||||
* @return the corresponding Command instance or <code>null</code>
|
||||
*/
|
||||
public static Command parseCommand(List<Class<? extends Command>> types, String s) {
|
||||
if(s!=null) {
|
||||
for(Class<? extends Command> type : types) {
|
||||
try {
|
||||
Method valueOf = type.getMethod("valueOf", String.class);
|
||||
Command value = (Command) valueOf.invoke(type, s);
|
||||
if(value!=null) return value;
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Determines a command from a string. Possible command types are passed as a parameter.
|
||||
* Note that the order matters here; the first type that accepts the string as a valid
|
||||
* value, will be used for the command.
|
||||
* </p>
|
||||
* <p>
|
||||
* Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
|
||||
* accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType
|
||||
* with value "ON").
|
||||
* </p>
|
||||
*
|
||||
* @param types possible types of the command to consider
|
||||
* @param s the string to parse
|
||||
* @return the corresponding Command instance or <code>null</code>
|
||||
*/
|
||||
public static Command parseCommand(List<Class<? extends Command>> types, String s) {
|
||||
if (s != null) {
|
||||
for (Class<? extends Command> type : types) {
|
||||
try {
|
||||
Method valueOf = type.getMethod("valueOf", String.class);
|
||||
Command value = (Command) valueOf.invoke(type, s);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,24 +14,29 @@ package org.openhab.core.types;
|
|||
* received an state update so far) or because their state is ambiguous
|
||||
* (e.g. a dimmed light that is treated as a switch (ON/OFF) will have
|
||||
* an undefined state if it is dimmed to 50%).
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.1.0
|
||||
*
|
||||
*/
|
||||
public enum UnDefType implements PrimitiveType, State {
|
||||
UNDEF, NULL;
|
||||
|
||||
public String toString() {
|
||||
switch(this) {
|
||||
case UNDEF: return "Undefined";
|
||||
case NULL: return "Uninitialized";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
UNDEF,
|
||||
NULL;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (this) {
|
||||
case UNDEF:
|
||||
return "Undefined";
|
||||
case NULL:
|
||||
return "Uninitialized";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String pattern) {
|
||||
return String.format(pattern, this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,24 +9,25 @@
|
|||
package org.openhab.io.console;
|
||||
|
||||
/**
|
||||
* This interface must be implemented by consoles which want to use the
|
||||
* This interface must be implemented by consoles which want to use the
|
||||
* {@link ConsoleInterpreter}.
|
||||
* It allows basic output commands.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.4.0
|
||||
*
|
||||
*/
|
||||
public interface Console {
|
||||
|
||||
public void print(String s);
|
||||
|
||||
public void println(String s);
|
||||
|
||||
/** usage output is treated differently from other output as it might
|
||||
* differ between different kinds of consoles
|
||||
*
|
||||
* @param s the main usage string (console independent)
|
||||
*/
|
||||
public void printUsage(String s);
|
||||
public void print(String s);
|
||||
|
||||
public void println(String s);
|
||||
|
||||
/**
|
||||
* usage output is treated differently from other output as it might
|
||||
* differ between different kinds of consoles
|
||||
*
|
||||
* @param s the main usage string (console independent)
|
||||
*/
|
||||
public void printUsage(String s);
|
||||
}
|
||||
|
|
|
@ -17,61 +17,60 @@ import org.openhab.io.net.exec.ExecUtil;
|
|||
/**
|
||||
* This class provides static methods that can be used in automation rules for
|
||||
* executing commands on command line.
|
||||
*
|
||||
*
|
||||
* @author Pauli Anttila
|
||||
* @since 1.3.0
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Exec {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Executes <code>commandLine</code>. Sometimes (especially observed on
|
||||
* MacOS) the commandLine isn't executed properly. In that cases another
|
||||
* exec-method is to be used. To accomplish this please use the special
|
||||
* delimiter '<code>@@</code>'. If <code>commandLine</code> contains this
|
||||
* delimiter it is split into a String[] array and the special exec-method
|
||||
* is used.
|
||||
* </p>
|
||||
* <p>
|
||||
* A possible {@link IOException} gets logged but no further processing is
|
||||
* done.
|
||||
* </p>
|
||||
*
|
||||
* @param commandLine
|
||||
* the command line to execute
|
||||
* @see http://www.peterfriese.de/running-applescript-from-java/
|
||||
*/
|
||||
@ActionDoc(text="Executes <code>commandLine</code>.")
|
||||
static public void executeCommandLine(@ParamDoc(name="commandLine") String commandLine) {
|
||||
ExecUtil.executeCommandLine(commandLine);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Executes <code>commandLine</code>. Sometimes (especially observed on
|
||||
* MacOS) the commandLine isn't executed properly. In that cases another
|
||||
* exec-method is to be used. To accomplish this please use the special
|
||||
* delimiter '<code>@@</code>'. If <code>commandLine</code> contains this
|
||||
* delimiter it is split into a String[] array and the special exec-method
|
||||
* is used.
|
||||
* </p>
|
||||
* <p>
|
||||
* A possible {@link IOException} gets logged but no further processing is
|
||||
* done.
|
||||
* </p>
|
||||
*
|
||||
* @param commandLine
|
||||
* the command line to execute
|
||||
* @see http://www.peterfriese.de/running-applescript-from-java/
|
||||
*/
|
||||
@ActionDoc(text = "Executes <code>commandLine</code>.")
|
||||
static public void executeCommandLine(@ParamDoc(name = "commandLine") String commandLine) {
|
||||
ExecUtil.executeCommandLine(commandLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Executes <code>commandLine</code>. Sometimes (especially observed on
|
||||
* MacOS) the commandLine isn't executed properly. In that cases another
|
||||
* exec-method is to be used. To accomplish this please use the special
|
||||
* delimiter '<code>@@</code>'. If <code>commandLine</code> contains this
|
||||
* delimiter it is split into a String[] array and the special exec-method
|
||||
* is used.
|
||||
* </p>
|
||||
* <p>
|
||||
* A possible {@link IOException} gets logged but no further processing is
|
||||
* done.
|
||||
* </p>
|
||||
*
|
||||
* @param commandLine
|
||||
* the command line to execute
|
||||
* @param timeout
|
||||
* timeout for execution in milliseconds
|
||||
* @return response data from executed command line
|
||||
*/
|
||||
@ActionDoc(text="Executes <code>commandLine</code>.")
|
||||
static public String executeCommandLine(
|
||||
@ParamDoc(name="commandLine")String commandLine,
|
||||
@ParamDoc(name="timeout", text="timeout for execution in milliseconds") int timeout) {
|
||||
return ExecUtil.executeCommandLineAndWaitResponse(commandLine, timeout);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Executes <code>commandLine</code>. Sometimes (especially observed on
|
||||
* MacOS) the commandLine isn't executed properly. In that cases another
|
||||
* exec-method is to be used. To accomplish this please use the special
|
||||
* delimiter '<code>@@</code>'. If <code>commandLine</code> contains this
|
||||
* delimiter it is split into a String[] array and the special exec-method
|
||||
* is used.
|
||||
* </p>
|
||||
* <p>
|
||||
* A possible {@link IOException} gets logged but no further processing is
|
||||
* done.
|
||||
* </p>
|
||||
*
|
||||
* @param commandLine
|
||||
* the command line to execute
|
||||
* @param timeout
|
||||
* timeout for execution in milliseconds
|
||||
* @return response data from executed command line
|
||||
*/
|
||||
@ActionDoc(text = "Executes <code>commandLine</code>.")
|
||||
static public String executeCommandLine(@ParamDoc(name = "commandLine") String commandLine,
|
||||
@ParamDoc(name = "timeout", text = "timeout for execution in milliseconds") int timeout) {
|
||||
return ExecUtil.executeCommandLineAndWaitResponse(commandLine, timeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,84 +11,83 @@ package org.openhab.io.net.actions;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.openhab.io.net.http.HttpUtil;
|
||||
|
||||
/**
|
||||
/**
|
||||
* This class provides static methods that can be used in automation rules
|
||||
* for sending HTTP requests
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.9.0
|
||||
*
|
||||
*/
|
||||
public class HTTP {
|
||||
|
||||
/** Constant which represents the content type <code>application/json</code> */
|
||||
public final static String CONTENT_TYPE_JSON = "application/json";
|
||||
|
||||
|
||||
/**
|
||||
* Send out a GET-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the GET request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpGetRequest(String url) {
|
||||
return HttpUtil.executeUrl("GET", url, 5000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a PUT-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the PUT request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPutRequest(String url) {
|
||||
return HttpUtil.executeUrl("PUT", url, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a PUT-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the PUT request.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPutRequest(String url, String contentType, String content) {
|
||||
return HttpUtil.executeUrl("PUT", url, IOUtils.toInputStream(content), contentType, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a POST-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the POST request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPostRequest(String url) {
|
||||
return HttpUtil.executeUrl("POST", url, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a POST-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the POST request.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPostRequest(String url, String contentType, String content) {
|
||||
return HttpUtil.executeUrl("POST", url, IOUtils.toInputStream(content), contentType, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a DELETE-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the DELETE request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpDeleteRequest(String url) {
|
||||
return HttpUtil.executeUrl("DELETE", url, 1000);
|
||||
}
|
||||
/** Constant which represents the content type <code>application/json</code> */
|
||||
public final static String CONTENT_TYPE_JSON = "application/json";
|
||||
|
||||
/**
|
||||
* Send out a GET-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the GET request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpGetRequest(String url) {
|
||||
return HttpUtil.executeUrl("GET", url, 5000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a PUT-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the PUT request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPutRequest(String url) {
|
||||
return HttpUtil.executeUrl("PUT", url, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a PUT-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the PUT request.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPutRequest(String url, String contentType, String content) {
|
||||
return HttpUtil.executeUrl("PUT", url, IOUtils.toInputStream(content), contentType, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a POST-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the POST request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPostRequest(String url) {
|
||||
return HttpUtil.executeUrl("POST", url, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a POST-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the POST request.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpPostRequest(String url, String contentType, String content) {
|
||||
return HttpUtil.executeUrl("POST", url, IOUtils.toInputStream(content), contentType, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a DELETE-HTTP request. Errors will be logged, returned values just ignored.
|
||||
*
|
||||
* @param url the URL to be used for the DELETE request.
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
static public String sendHttpDeleteRequest(String url) {
|
||||
return HttpUtil.executeUrl("DELETE", url, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,52 +15,49 @@ import java.net.Socket;
|
|||
import java.net.SocketAddress;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
|
||||
/**
|
||||
* This Action checks the vitality of the given host.
|
||||
*
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Ping {
|
||||
|
||||
/**
|
||||
* Checks the vitality of <code>host</code>. If <code>port</code> '0'
|
||||
* is specified (which is the default when configuring just the host), a
|
||||
* regular ping is issued. If other ports are specified we try open a new
|
||||
* Socket with the given <code>timeout</code>.
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @param timeout
|
||||
*
|
||||
* @return <code>true</code> when <code>host</code> is reachable on <code>port</code>
|
||||
* within the given <code>timeout</code> and <code>false</code> in all other
|
||||
* cases.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws SocketTimeoutException
|
||||
*/
|
||||
public static boolean checkVitality(String host, int port, int timeout) throws IOException, SocketTimeoutException {
|
||||
boolean success = false;
|
||||
|
||||
if (host != null && timeout > 0) {
|
||||
if (port == 0) {
|
||||
success = InetAddress.getByName(host).isReachable(timeout);
|
||||
}
|
||||
else {
|
||||
SocketAddress socketAddress = new InetSocketAddress(host, port);
|
||||
|
||||
/**
|
||||
* Checks the vitality of <code>host</code>. If <code>port</code> '0'
|
||||
* is specified (which is the default when configuring just the host), a
|
||||
* regular ping is issued. If other ports are specified we try open a new
|
||||
* Socket with the given <code>timeout</code>.
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @param timeout
|
||||
*
|
||||
* @return <code>true</code> when <code>host</code> is reachable on <code>port</code>
|
||||
* within the given <code>timeout</code> and <code>false</code> in all other
|
||||
* cases.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws SocketTimeoutException
|
||||
*/
|
||||
public static boolean checkVitality(String host, int port, int timeout) throws IOException, SocketTimeoutException {
|
||||
boolean success = false;
|
||||
|
||||
if (host != null && timeout > 0) {
|
||||
if (port == 0) {
|
||||
success = InetAddress.getByName(host).isReachable(timeout);
|
||||
} else {
|
||||
SocketAddress socketAddress = new InetSocketAddress(host, port);
|
||||
|
||||
try (Socket socket = new Socket()) {
|
||||
socket.connect(socketAddress, timeout);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,294 +38,289 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Some common methods to be used in both HTTP-In-Binding and HTTP-Out-Binding
|
||||
*
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.6.0
|
||||
*/
|
||||
public class HttpUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
|
||||
|
||||
/** {@link Pattern} which matches the credentials out of an URL */
|
||||
private static final Pattern URL_CREDENTIALS_PATTERN = Pattern.compile("http://(.*?):(.*?)@.*");
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
|
||||
* Furthermore the <code>http.proxyXXX</code> System variables are read and
|
||||
* set into the {@link HttpClient}.
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param timeout the socket timeout to wait for data
|
||||
*
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, int timeout) {
|
||||
return executeUrl(httpMethod, url, null, null, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
|
||||
* Furthermore the <code>http.proxyXXX</code> System variables are read and
|
||||
* set into the {@link HttpClient}.
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param timeout the socket timeout to wait for data
|
||||
*
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, InputStream content, String contentType, int timeout) {
|
||||
|
||||
return executeUrl(httpMethod, url, null, content, contentType, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
|
||||
* Furthermore the <code>http.proxyXXX</code> System variables are read and
|
||||
* set into the {@link HttpClient}.
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param httpHeaders optional http request headers which has to be sent within request
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param timeout the socket timeout to wait for data
|
||||
*
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content, String contentType, int timeout) {
|
||||
String proxySet = System.getProperty("http.proxySet");
|
||||
|
||||
String proxyHost = null;
|
||||
int proxyPort = 80;
|
||||
String proxyUser = null;
|
||||
String proxyPassword = null;
|
||||
String nonProxyHosts = null;
|
||||
|
||||
if ("true".equalsIgnoreCase(proxySet)) {
|
||||
proxyHost = System.getProperty("http.proxyHost");
|
||||
String proxyPortString = System.getProperty("http.proxyPort");
|
||||
if (StringUtils.isNotBlank(proxyPortString)) {
|
||||
try {
|
||||
proxyPort = Integer.valueOf(proxyPortString);
|
||||
} catch(NumberFormatException e) {
|
||||
logger.warn("'{}' is not a valid proxy port - using port 80 instead");
|
||||
}
|
||||
}
|
||||
proxyUser = System.getProperty("http.proxyUser");
|
||||
proxyPassword = System.getProperty("http.proxyPassword");
|
||||
nonProxyHosts = System.getProperty("http.nonProxyHosts");
|
||||
}
|
||||
|
||||
return executeUrl(httpMethod, url, httpHeaders, content, contentType, timeout, proxyHost, proxyPort, proxyUser, proxyPassword, nonProxyHosts);
|
||||
/** {@link Pattern} which matches the credentials out of an URL */
|
||||
private static final Pattern URL_CREDENTIALS_PATTERN = Pattern.compile("http://(.*?):(.*?)@.*");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param httpHeaders optional HTTP headers which has to be set on request
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param timeout the socket timeout to wait for data
|
||||
* @param proxyHost the hostname of the proxy
|
||||
* @param proxyPort the port of the proxy
|
||||
* @param proxyUser the username to authenticate with the proxy
|
||||
* @param proxyPassword the password to authenticate with the proxy
|
||||
* @param nonProxyHosts the hosts that won't be routed through the proxy
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content, String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser, String proxyPassword, String nonProxyHosts) {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
|
||||
// only configure a proxy if a host is provided
|
||||
if (StringUtils.isNotBlank(proxyHost) && proxyPort != null && shouldUseProxy(url, nonProxyHosts)) {
|
||||
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
|
||||
if (StringUtils.isNotBlank(proxyUser)) {
|
||||
client.getState().setProxyCredentials(AuthScope.ANY,
|
||||
new UsernamePasswordCredentials(proxyUser, proxyPassword));
|
||||
}
|
||||
}
|
||||
|
||||
HttpMethod method = HttpUtil.createHttpMethod(httpMethod, url);
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
|
||||
* Furthermore the <code>http.proxyXXX</code> System variables are read and
|
||||
* set into the {@link HttpClient}.
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param timeout the socket timeout to wait for data
|
||||
*
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, int timeout) {
|
||||
return executeUrl(httpMethod, url, null, null, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
|
||||
* Furthermore the <code>http.proxyXXX</code> System variables are read and
|
||||
* set into the {@link HttpClient}.
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param timeout the socket timeout to wait for data
|
||||
*
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, InputStream content, String contentType,
|
||||
int timeout) {
|
||||
|
||||
return executeUrl(httpMethod, url, null, content, contentType, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
|
||||
* Furthermore the <code>http.proxyXXX</code> System variables are read and
|
||||
* set into the {@link HttpClient}.
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param httpHeaders optional http request headers which has to be sent within request
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param timeout the socket timeout to wait for data
|
||||
*
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
|
||||
String contentType, int timeout) {
|
||||
String proxySet = System.getProperty("http.proxySet");
|
||||
|
||||
String proxyHost = null;
|
||||
int proxyPort = 80;
|
||||
String proxyUser = null;
|
||||
String proxyPassword = null;
|
||||
String nonProxyHosts = null;
|
||||
|
||||
if ("true".equalsIgnoreCase(proxySet)) {
|
||||
proxyHost = System.getProperty("http.proxyHost");
|
||||
String proxyPortString = System.getProperty("http.proxyPort");
|
||||
if (StringUtils.isNotBlank(proxyPortString)) {
|
||||
try {
|
||||
proxyPort = Integer.valueOf(proxyPortString);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.warn("'{}' is not a valid proxy port - using port 80 instead");
|
||||
}
|
||||
}
|
||||
proxyUser = System.getProperty("http.proxyUser");
|
||||
proxyPassword = System.getProperty("http.proxyPassword");
|
||||
nonProxyHosts = System.getProperty("http.nonProxyHosts");
|
||||
}
|
||||
|
||||
return executeUrl(httpMethod, url, httpHeaders, content, contentType, timeout, proxyHost, proxyPort, proxyUser,
|
||||
proxyPassword, nonProxyHosts);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given <code>url</code> with the given <code>httpMethod</code>
|
||||
*
|
||||
* @param httpMethod the HTTP method to use
|
||||
* @param url the url to execute (in milliseconds)
|
||||
* @param httpHeaders optional HTTP headers which has to be set on request
|
||||
* @param content the content to be send to the given <code>url</code> or
|
||||
* <code>null</code> if no content should be send.
|
||||
* @param contentType the content type of the given <code>content</code>
|
||||
* @param timeout the socket timeout to wait for data
|
||||
* @param proxyHost the hostname of the proxy
|
||||
* @param proxyPort the port of the proxy
|
||||
* @param proxyUser the username to authenticate with the proxy
|
||||
* @param proxyPassword the password to authenticate with the proxy
|
||||
* @param nonProxyHosts the hosts that won't be routed through the proxy
|
||||
* @return the response body or <code>NULL</code> when the request went wrong
|
||||
*/
|
||||
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
|
||||
String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser,
|
||||
String proxyPassword, String nonProxyHosts) {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
|
||||
// only configure a proxy if a host is provided
|
||||
if (StringUtils.isNotBlank(proxyHost) && proxyPort != null && shouldUseProxy(url, nonProxyHosts)) {
|
||||
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
|
||||
if (StringUtils.isNotBlank(proxyUser)) {
|
||||
client.getState().setProxyCredentials(AuthScope.ANY,
|
||||
new UsernamePasswordCredentials(proxyUser, proxyPassword));
|
||||
}
|
||||
}
|
||||
|
||||
HttpMethod method = HttpUtil.createHttpMethod(httpMethod, url);
|
||||
method.getParams().setSoTimeout(timeout);
|
||||
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
|
||||
new DefaultHttpMethodRetryHandler(3, false));
|
||||
if(httpHeaders != null){
|
||||
for(String httpHeaderKey: httpHeaders.stringPropertyNames()){
|
||||
method.addRequestHeader(new Header(httpHeaderKey,httpHeaders.getProperty(httpHeaderKey)));
|
||||
}
|
||||
}
|
||||
// add content if a valid method is given ...
|
||||
if (method instanceof EntityEnclosingMethod && content != null ) {
|
||||
EntityEnclosingMethod eeMethod = (EntityEnclosingMethod) method;
|
||||
eeMethod.setRequestEntity(new InputStreamRequestEntity(content, contentType));
|
||||
}
|
||||
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
|
||||
if (httpHeaders != null) {
|
||||
for (String httpHeaderKey : httpHeaders.stringPropertyNames()) {
|
||||
method.addRequestHeader(new Header(httpHeaderKey, httpHeaders.getProperty(httpHeaderKey)));
|
||||
}
|
||||
}
|
||||
// add content if a valid method is given ...
|
||||
if (method instanceof EntityEnclosingMethod && content != null) {
|
||||
EntityEnclosingMethod eeMethod = (EntityEnclosingMethod) method;
|
||||
eeMethod.setRequestEntity(new InputStreamRequestEntity(content, contentType));
|
||||
}
|
||||
|
||||
Credentials credentials = extractCredentials(url);
|
||||
if (credentials != null) {
|
||||
client.getParams().setAuthenticationPreemptive(true);
|
||||
client.getState().setCredentials(AuthScope.ANY, credentials);
|
||||
}
|
||||
Credentials credentials = extractCredentials(url);
|
||||
if (credentials != null) {
|
||||
client.getParams().setAuthenticationPreemptive(true);
|
||||
client.getState().setCredentials(AuthScope.ANY, credentials);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
try {
|
||||
logger.debug("About to execute '" + method.getURI().toString() + "'");
|
||||
} catch (URIException e) {
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
try {
|
||||
logger.debug("About to execute '" + method.getURI().toString() + "'");
|
||||
} catch (URIException e) {
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
int statusCode = client.executeMethod(method);
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
logger.warn("Method failed: " + method.getStatusLine());
|
||||
}
|
||||
try {
|
||||
|
||||
String responseBody = IOUtils.toString(method.getResponseBodyAsStream());
|
||||
if (!responseBody.isEmpty()) {
|
||||
logger.debug(responseBody);
|
||||
}
|
||||
|
||||
return responseBody;
|
||||
}
|
||||
catch (HttpException he) {
|
||||
logger.error("Fatal protocol violation: {}", he.toString());
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
logger.error("Fatal transport error: {}", ioe.toString());
|
||||
}
|
||||
finally {
|
||||
method.releaseConnection();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
int statusCode = client.executeMethod(method);
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
logger.warn("Method failed: " + method.getStatusLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the list of <code>nonProxyHosts</code> contains the
|
||||
* host (which is part of the given <code>urlString</code> or not.
|
||||
*
|
||||
* @param urlString
|
||||
* @param nonProxyHosts
|
||||
*
|
||||
* @return <code>false</code> if the host of the given <code>urlString</code>
|
||||
* is contained in <code>nonProxyHosts</code>-list and <code>true</code>
|
||||
* otherwise
|
||||
*/
|
||||
private static boolean shouldUseProxy(String urlString, String nonProxyHosts) {
|
||||
|
||||
if (StringUtils.isNotBlank(nonProxyHosts)) {
|
||||
String givenHost = urlString;
|
||||
|
||||
try {
|
||||
URL url = new URL(urlString);
|
||||
givenHost = url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
logger.error("the given url {} is malformed", urlString);
|
||||
}
|
||||
|
||||
String[] hosts = nonProxyHosts.split("\\|");
|
||||
for (String host : hosts) {
|
||||
if (host.contains("*")) {
|
||||
// the nonProxyHots-pattern allows wildcards '*' which must
|
||||
// be masked to be used with regular expressions
|
||||
String hostRegexp = host.replaceAll("\\.", "\\\\.");
|
||||
hostRegexp = hostRegexp.replaceAll("\\*", ".*");
|
||||
if (givenHost.matches(hostRegexp)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (givenHost.equals(host)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
String responseBody = IOUtils.toString(method.getResponseBodyAsStream());
|
||||
if (!responseBody.isEmpty()) {
|
||||
logger.debug(responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts username and password from the given <code>url</code>. A valid
|
||||
* url to extract {@link Credentials} from looks like:
|
||||
* <pre>
|
||||
* http://username:password@www.domain.org
|
||||
* </pre>
|
||||
*
|
||||
* @param url the URL to extract {@link Credentials} from
|
||||
*
|
||||
* @return the exracted Credentials or <code>null</code> if the given
|
||||
* <code>url</code> does not contain credentials
|
||||
*/
|
||||
protected static Credentials extractCredentials(String url) {
|
||||
|
||||
Matcher matcher = URL_CREDENTIALS_PATTERN.matcher(url);
|
||||
|
||||
if (matcher.matches()) {
|
||||
|
||||
matcher.reset();
|
||||
return responseBody;
|
||||
} catch (HttpException he) {
|
||||
logger.error("Fatal protocol violation: {}", he.toString());
|
||||
} catch (IOException ioe) {
|
||||
logger.error("Fatal transport error: {}", ioe.toString());
|
||||
} finally {
|
||||
method.releaseConnection();
|
||||
}
|
||||
|
||||
String username = "";
|
||||
String password = "";
|
||||
return null;
|
||||
}
|
||||
|
||||
while (matcher.find()) {
|
||||
username = matcher.group(1);
|
||||
password = matcher.group(2);
|
||||
}
|
||||
|
||||
Credentials credentials =
|
||||
new UsernamePasswordCredentials(username, password);
|
||||
return credentials;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Determines whether the list of <code>nonProxyHosts</code> contains the
|
||||
* host (which is part of the given <code>urlString</code> or not.
|
||||
*
|
||||
* @param urlString
|
||||
* @param nonProxyHosts
|
||||
*
|
||||
* @return <code>false</code> if the host of the given <code>urlString</code>
|
||||
* is contained in <code>nonProxyHosts</code>-list and <code>true</code>
|
||||
* otherwise
|
||||
*/
|
||||
private static boolean shouldUseProxy(String urlString, String nonProxyHosts) {
|
||||
|
||||
/**
|
||||
* Factory method to create a {@link HttpMethod}-object according to the
|
||||
* given String <code>httpMethod</codde>
|
||||
*
|
||||
* @param httpMethodString the name of the {@link HttpMethod} to create
|
||||
* @param url
|
||||
*
|
||||
* @return an object of type {@link GetMethod}, {@link PutMethod},
|
||||
* {@link PostMethod} or {@link DeleteMethod}
|
||||
* @throws IllegalArgumentException if <code>httpMethod</code> is none of
|
||||
* <code>GET</code>, <code>PUT</code>, <code>POST</POST> or <code>DELETE</code>
|
||||
*/
|
||||
public static HttpMethod createHttpMethod(String httpMethodString, String url) {
|
||||
|
||||
if ("GET".equals(httpMethodString)) {
|
||||
return new GetMethod(url);
|
||||
}
|
||||
else if ("PUT".equals(httpMethodString)) {
|
||||
return new PutMethod(url);
|
||||
}
|
||||
else if ("POST".equals(httpMethodString)) {
|
||||
return new PostMethod(url);
|
||||
}
|
||||
else if ("DELETE".equals(httpMethodString)) {
|
||||
return new DeleteMethod(url);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("given httpMethod '" + httpMethodString + "' is unknown");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(nonProxyHosts)) {
|
||||
String givenHost = urlString;
|
||||
|
||||
try {
|
||||
URL url = new URL(urlString);
|
||||
givenHost = url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
logger.error("the given url {} is malformed", urlString);
|
||||
}
|
||||
|
||||
String[] hosts = nonProxyHosts.split("\\|");
|
||||
for (String host : hosts) {
|
||||
if (host.contains("*")) {
|
||||
// the nonProxyHots-pattern allows wildcards '*' which must
|
||||
// be masked to be used with regular expressions
|
||||
String hostRegexp = host.replaceAll("\\.", "\\\\.");
|
||||
hostRegexp = hostRegexp.replaceAll("\\*", ".*");
|
||||
if (givenHost.matches(hostRegexp)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (givenHost.equals(host)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts username and password from the given <code>url</code>. A valid
|
||||
* url to extract {@link Credentials} from looks like:
|
||||
*
|
||||
* <pre>
|
||||
* http://username:password@www.domain.org
|
||||
* </pre>
|
||||
*
|
||||
* @param url the URL to extract {@link Credentials} from
|
||||
*
|
||||
* @return the exracted Credentials or <code>null</code> if the given
|
||||
* <code>url</code> does not contain credentials
|
||||
*/
|
||||
protected static Credentials extractCredentials(String url) {
|
||||
|
||||
Matcher matcher = URL_CREDENTIALS_PATTERN.matcher(url);
|
||||
|
||||
if (matcher.matches()) {
|
||||
|
||||
matcher.reset();
|
||||
|
||||
String username = "";
|
||||
String password = "";
|
||||
|
||||
while (matcher.find()) {
|
||||
username = matcher.group(1);
|
||||
password = matcher.group(2);
|
||||
}
|
||||
|
||||
Credentials credentials = new UsernamePasswordCredentials(username, password);
|
||||
return credentials;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a {@link HttpMethod}-object according to the
|
||||
* given String <code>httpMethod</codde>
|
||||
*
|
||||
* @param httpMethodString the name of the {@link HttpMethod} to create
|
||||
* @param url
|
||||
*
|
||||
* @return an object of type {@link GetMethod}, {@link PutMethod},
|
||||
* {@link PostMethod} or {@link DeleteMethod}
|
||||
* @throws IllegalArgumentException if <code>httpMethod</code> is none of
|
||||
* <code>GET</code>, <code>PUT</code>, <code>POST</POST> or <code>DELETE</code>
|
||||
*/
|
||||
public static HttpMethod createHttpMethod(String httpMethodString, String url) {
|
||||
|
||||
if ("GET".equals(httpMethodString)) {
|
||||
return new GetMethod(url);
|
||||
} else if ("PUT".equals(httpMethodString)) {
|
||||
return new PutMethod(url);
|
||||
} else if ("POST".equals(httpMethodString)) {
|
||||
return new PostMethod(url);
|
||||
} else if ("DELETE".equals(httpMethodString)) {
|
||||
return new DeleteMethod(url);
|
||||
} else {
|
||||
throw new IllegalArgumentException("given httpMethod '" + httpMethodString + "' is unknown");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,41 +16,49 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.osgi.service.http.HttpContext;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of {@link HttpContext} which adds Basic-Authentication
|
||||
* Implementation of {@link HttpContext} which adds Basic-Authentication
|
||||
* functionality to openHAB.
|
||||
*
|
||||
*
|
||||
* @author Thomas.Eichstaedt-Engelen
|
||||
* @since 0.9.0
|
||||
*/
|
||||
public class SecureHttpContext implements HttpContext {
|
||||
|
||||
private HttpContext defaultContext = null;
|
||||
private HttpContext defaultContext = null;
|
||||
|
||||
public SecureHttpContext() {
|
||||
}
|
||||
|
||||
public SecureHttpContext(HttpContext defaultContext, final String realm) {
|
||||
this.defaultContext = defaultContext;
|
||||
}
|
||||
public SecureHttpContext() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>@{inheritDoc}</p>
|
||||
* <p>Delegates to <code>defaultContext.getMimeType()</code>
|
||||
*/
|
||||
public String getMimeType(String name) {
|
||||
return this.defaultContext.getMimeType(name);
|
||||
}
|
||||
public SecureHttpContext(HttpContext defaultContext, final String realm) {
|
||||
this.defaultContext = defaultContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>@{inheritDoc}</p>
|
||||
* <p>Delegates to <code>defaultContext.getResource()</code>
|
||||
*/
|
||||
public URL getResource(String name) {
|
||||
return this.defaultContext.getResource(name);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @{inheritDoc}
|
||||
* </p>
|
||||
* <p>
|
||||
* Delegates to <code>defaultContext.getMimeType()</code>
|
||||
*/
|
||||
@Override
|
||||
public String getMimeType(String name) {
|
||||
return this.defaultContext.getMimeType(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @{inheritDoc}
|
||||
* </p>
|
||||
* <p>
|
||||
* Delegates to <code>defaultContext.getResource()</code>
|
||||
*/
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
return this.defaultContext.getResource(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
|
|
@ -18,25 +18,27 @@ import org.openhab.core.types.UnDefType;
|
|||
import org.openhab.library.tel.types.CallType;
|
||||
|
||||
public class CallItem extends GenericItem {
|
||||
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
|
||||
|
||||
static {
|
||||
acceptedDataTypes.add(CallType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public CallItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
|
||||
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
|
||||
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
static {
|
||||
acceptedDataTypes.add(CallType.class);
|
||||
acceptedDataTypes.add(UnDefType.class);
|
||||
}
|
||||
|
||||
public CallItem(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends State>> getAcceptedDataTypes() {
|
||||
return acceptedDataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
public List<Class<? extends Command>> getAcceptedCommandTypes() {
|
||||
return acceptedCommandTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class CallType implements ComplexType, Command, State {
|
|||
public static final State EMPTY = new CallType(new StringType(""), new StringType(""));
|
||||
|
||||
public CallType() {
|
||||
callDetails = new TreeMap<String, PrimitiveType>();
|
||||
callDetails = new TreeMap<>();
|
||||
}
|
||||
|
||||
public CallType(String value) {
|
||||
|
|
|
@ -42,16 +42,16 @@ public abstract class AbstractGenericBindingProvider implements BindingConfigRea
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractGenericBindingProvider.class);
|
||||
|
||||
private Set<BindingChangeListener> listeners = new CopyOnWriteArraySet<BindingChangeListener>();
|
||||
private Set<BindingChangeListener> listeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
/** caches binding configurations. maps itemNames to {@link BindingConfig}s */
|
||||
protected Map<String, BindingConfig> bindingConfigs = new ConcurrentHashMap<String, BindingConfig>();
|
||||
protected Map<String, BindingConfig> bindingConfigs = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* stores information about the context of items. The map has this content
|
||||
* structure: context -> Set of Items
|
||||
*/
|
||||
protected Map<String, Set<Item>> contextMap = new ConcurrentHashMap<String, Set<Item>>();
|
||||
protected Map<String, Set<Item>> contextMap = new ConcurrentHashMap<>();
|
||||
|
||||
public AbstractGenericBindingProvider() {
|
||||
super();
|
||||
|
@ -85,7 +85,7 @@ public abstract class AbstractGenericBindingProvider implements BindingConfigRea
|
|||
synchronized (contextMap) {
|
||||
Set<Item> items = contextMap.get(context);
|
||||
if (items == null) {
|
||||
items = new HashSet<Item>();
|
||||
items = new HashSet<>();
|
||||
contextMap.put(context, items);
|
||||
}
|
||||
items.add(item);
|
||||
|
@ -149,7 +149,7 @@ public abstract class AbstractGenericBindingProvider implements BindingConfigRea
|
|||
*/
|
||||
@Override
|
||||
public Collection<String> getItemNames() {
|
||||
return new ArrayList<String>(bindingConfigs.keySet());
|
||||
return new ArrayList<>(bindingConfigs.keySet());
|
||||
}
|
||||
|
||||
}
|
|
@ -10,10 +10,10 @@ package org.openhab.model.item.binding;
|
|||
|
||||
public class BindingConfigParseException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1434607160082879845L;
|
||||
private static final long serialVersionUID = 1434607160082879845L;
|
||||
|
||||
public BindingConfigParseException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
public BindingConfigParseException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,51 +11,52 @@ package org.openhab.model.item.binding;
|
|||
import org.openhab.core.items.Item;
|
||||
|
||||
/**
|
||||
* This interface must be implemented by services, which can parse the generic
|
||||
* This interface must be implemented by services, which can parse the generic
|
||||
* binding configuration string used in the {@link GenericItemProvider}.
|
||||
*
|
||||
*
|
||||
* @author Kai Kreuzer
|
||||
* @since 0.3.0
|
||||
*
|
||||
*/
|
||||
public interface BindingConfigReader {
|
||||
|
||||
/**
|
||||
* This defines the type of binding this reader will process, e.g. "knx".
|
||||
*
|
||||
* @return the type of the binding
|
||||
*/
|
||||
public String getBindingType();
|
||||
|
||||
/**
|
||||
* Validates if the type of <code>item</code> is valid for this binding.
|
||||
*
|
||||
* @param item the item whose type is validated
|
||||
* @param bindingConfig the config string which could be used to refine the
|
||||
* validation
|
||||
*
|
||||
* @throws BindingConfigParseException if the type of <code>item</code> is
|
||||
* invalid for this binding
|
||||
*/
|
||||
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException;
|
||||
|
||||
/**
|
||||
* This method is called by the {@link GenericItemProvider} whenever it comes
|
||||
* across a binding configuration string for an item.
|
||||
*
|
||||
* @param context a string of the context from where this item comes from. Usually the file name of the config file
|
||||
* @param item the item for which the binding is defined
|
||||
* @param bindingConfig the configuration string that must be processed
|
||||
*
|
||||
* @throws BindingConfigParseException if the configuration string is not valid
|
||||
*/
|
||||
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException;
|
||||
|
||||
/**
|
||||
* Removes all configuration information for a given context. This is usually called if a config file is reloaded,
|
||||
* so that the old values are removed, before the new ones are processed.
|
||||
*
|
||||
* @param context the context of the configurations that should be removed
|
||||
*/
|
||||
public void removeConfigurations(String context);
|
||||
/**
|
||||
* This defines the type of binding this reader will process, e.g. "knx".
|
||||
*
|
||||
* @return the type of the binding
|
||||
*/
|
||||
public String getBindingType();
|
||||
|
||||
/**
|
||||
* Validates if the type of <code>item</code> is valid for this binding.
|
||||
*
|
||||
* @param item the item whose type is validated
|
||||
* @param bindingConfig the config string which could be used to refine the
|
||||
* validation
|
||||
*
|
||||
* @throws BindingConfigParseException if the type of <code>item</code> is
|
||||
* invalid for this binding
|
||||
*/
|
||||
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException;
|
||||
|
||||
/**
|
||||
* This method is called by the {@link GenericItemProvider} whenever it comes
|
||||
* across a binding configuration string for an item.
|
||||
*
|
||||
* @param context a string of the context from where this item comes from. Usually the file name of the config file
|
||||
* @param item the item for which the binding is defined
|
||||
* @param bindingConfig the configuration string that must be processed
|
||||
*
|
||||
* @throws BindingConfigParseException if the configuration string is not valid
|
||||
*/
|
||||
public void processBindingConfiguration(String context, Item item, String bindingConfig)
|
||||
throws BindingConfigParseException;
|
||||
|
||||
/**
|
||||
* Removes all configuration information for a given context. This is usually called if a config file is reloaded,
|
||||
* so that the old values are removed, before the new ones are processed.
|
||||
*
|
||||
* @param context the context of the configurations that should be removed
|
||||
*/
|
||||
public void removeConfigurations(String context);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Chart</b></em>'.
|
||||
|
@ -19,9 +18,9 @@ package org.openhab.model.sitemap;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Chart#getService <em>Service</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Chart#getRefresh <em>Refresh</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Chart#getPeriod <em>Period</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Chart#getService <em>Service</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Chart#getRefresh <em>Refresh</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Chart#getPeriod <em>Period</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -29,84 +28,89 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Chart extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Service</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Service</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Service</em>' attribute.
|
||||
* @see #setService(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Service()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getService();
|
||||
public interface Chart extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Service</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Service</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Service</em>' attribute.
|
||||
* @see #setService(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Service()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getService();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getService <em>Service</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Service</em>' attribute.
|
||||
* @see #getService()
|
||||
* @generated
|
||||
*/
|
||||
void setService(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getService <em>Service</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Service</em>' attribute.
|
||||
* @see #getService()
|
||||
* @generated
|
||||
*/
|
||||
void setService(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Refresh</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Refresh</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Refresh</em>' attribute.
|
||||
* @see #setRefresh(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Refresh()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getRefresh();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Refresh</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Refresh</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Refresh</em>' attribute.
|
||||
* @see #setRefresh(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Refresh()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getRefresh();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getRefresh <em>Refresh</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Refresh</em>' attribute.
|
||||
* @see #getRefresh()
|
||||
* @generated
|
||||
*/
|
||||
void setRefresh(int value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getRefresh <em>Refresh</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Refresh</em>' attribute.
|
||||
* @see #getRefresh()
|
||||
* @generated
|
||||
*/
|
||||
void setRefresh(int value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Period</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Period</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Period</em>' attribute.
|
||||
* @see #setPeriod(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Period()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getPeriod();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Period</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Period</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Period</em>' attribute.
|
||||
* @see #setPeriod(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Period()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getPeriod();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getPeriod <em>Period</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Period</em>' attribute.
|
||||
* @see #getPeriod()
|
||||
* @generated
|
||||
*/
|
||||
void setPeriod(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getPeriod <em>Period</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Period</em>' attribute.
|
||||
* @see #getPeriod()
|
||||
* @generated
|
||||
*/
|
||||
void setPeriod(String value);
|
||||
|
||||
} // Chart
|
||||
|
|
|
@ -20,11 +20,11 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getItem <em>Item</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getCondition <em>Condition</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getSign <em>Sign</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getState <em>State</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getArg <em>Arg</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getItem <em>Item</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getCondition <em>Condition</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getSign <em>Sign</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getState <em>State</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.ColorArray#getArg <em>Arg</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -32,136 +32,145 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface ColorArray extends EObject
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Item</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Item</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Item</em>' attribute.
|
||||
* @see #setItem(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Item()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getItem();
|
||||
public interface ColorArray extends EObject {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Item</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Item</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Item</em>' attribute.
|
||||
* @see #setItem(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Item()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getItem();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getItem <em>Item</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Item</em>' attribute.
|
||||
* @see #getItem()
|
||||
* @generated
|
||||
*/
|
||||
void setItem(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getItem <em>Item</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Item</em>' attribute.
|
||||
* @see #getItem()
|
||||
* @generated
|
||||
*/
|
||||
void setItem(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Condition</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Condition</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Condition</em>' attribute.
|
||||
* @see #setCondition(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Condition()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getCondition();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Condition</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Condition</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Condition</em>' attribute.
|
||||
* @see #setCondition(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Condition()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getCondition();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getCondition <em>Condition</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Condition</em>' attribute.
|
||||
* @see #getCondition()
|
||||
* @generated
|
||||
*/
|
||||
void setCondition(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getCondition <em>Condition</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Condition</em>' attribute.
|
||||
* @see #getCondition()
|
||||
* @generated
|
||||
*/
|
||||
void setCondition(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Sign</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Sign</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Sign</em>' attribute.
|
||||
* @see #setSign(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Sign()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getSign();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Sign</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Sign</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Sign</em>' attribute.
|
||||
* @see #setSign(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Sign()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getSign();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getSign <em>Sign</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Sign</em>' attribute.
|
||||
* @see #getSign()
|
||||
* @generated
|
||||
*/
|
||||
void setSign(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getSign <em>Sign</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Sign</em>' attribute.
|
||||
* @see #getSign()
|
||||
* @generated
|
||||
*/
|
||||
void setSign(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>State</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>State</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>State</em>' attribute.
|
||||
* @see #setState(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_State()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getState();
|
||||
/**
|
||||
* Returns the value of the '<em><b>State</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>State</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>State</em>' attribute.
|
||||
* @see #setState(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_State()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getState();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getState <em>State</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>State</em>' attribute.
|
||||
* @see #getState()
|
||||
* @generated
|
||||
*/
|
||||
void setState(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getState <em>State</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>State</em>' attribute.
|
||||
* @see #getState()
|
||||
* @generated
|
||||
*/
|
||||
void setState(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Arg</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Arg</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Arg</em>' attribute.
|
||||
* @see #setArg(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Arg()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getArg();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Arg</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Arg</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Arg</em>' attribute.
|
||||
* @see #setArg(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Arg()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getArg();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getArg <em>Arg</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Arg</em>' attribute.
|
||||
* @see #getArg()
|
||||
* @generated
|
||||
*/
|
||||
void setArg(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getArg <em>Arg</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Arg</em>' attribute.
|
||||
* @see #getArg()
|
||||
* @generated
|
||||
*/
|
||||
void setArg(String value);
|
||||
|
||||
} // ColorArray
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Colorpicker</b></em>'.
|
||||
|
@ -19,7 +18,7 @@ package org.openhab.model.sitemap;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Colorpicker#getFrequency <em>Frequency</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Colorpicker#getFrequency <em>Frequency</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -27,32 +26,33 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Colorpicker extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Frequency</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Frequency</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Frequency</em>' attribute.
|
||||
* @see #setFrequency(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorpicker_Frequency()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getFrequency();
|
||||
public interface Colorpicker extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Frequency</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Frequency</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Frequency</em>' attribute.
|
||||
* @see #setFrequency(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getColorpicker_Frequency()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getFrequency();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Colorpicker#getFrequency <em>Frequency</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Frequency</em>' attribute.
|
||||
* @see #getFrequency()
|
||||
* @generated
|
||||
*/
|
||||
void setFrequency(int value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Colorpicker#getFrequency <em>Frequency</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Frequency</em>' attribute.
|
||||
* @see #getFrequency()
|
||||
* @generated
|
||||
*/
|
||||
void setFrequency(int value);
|
||||
|
||||
} // Colorpicker
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Frame</b></em>'.
|
||||
|
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Frame extends LinkableWidget
|
||||
{
|
||||
public interface Frame extends LinkableWidget {
|
||||
} // Frame
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Group</b></em>'.
|
||||
|
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Group extends LinkableWidget
|
||||
{
|
||||
public interface Group extends LinkableWidget {
|
||||
} // Group
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.eclipse.emf.common.util.EList;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Image#getUrl <em>Url</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Image#getRefresh <em>Refresh</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Image#getIconColor <em>Icon Color</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Image#getUrl <em>Url</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Image#getRefresh <em>Refresh</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Image#getIconColor <em>Icon Color</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -30,74 +30,78 @@ import org.eclipse.emf.common.util.EList;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Image extends LinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Url</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Url</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Url</em>' attribute.
|
||||
* @see #setUrl(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getImage_Url()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getUrl();
|
||||
public interface Image extends LinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Url</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Url</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Url</em>' attribute.
|
||||
* @see #setUrl(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getImage_Url()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getUrl();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Image#getUrl <em>Url</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Url</em>' attribute.
|
||||
* @see #getUrl()
|
||||
* @generated
|
||||
*/
|
||||
void setUrl(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Image#getUrl <em>Url</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Url</em>' attribute.
|
||||
* @see #getUrl()
|
||||
* @generated
|
||||
*/
|
||||
void setUrl(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Refresh</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Refresh</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Refresh</em>' attribute.
|
||||
* @see #setRefresh(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getImage_Refresh()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getRefresh();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Refresh</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Refresh</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Refresh</em>' attribute.
|
||||
* @see #setRefresh(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getImage_Refresh()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getRefresh();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Image#getRefresh <em>Refresh</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Refresh</em>' attribute.
|
||||
* @see #getRefresh()
|
||||
* @generated
|
||||
*/
|
||||
void setRefresh(int value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Image#getRefresh <em>Refresh</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Refresh</em>' attribute.
|
||||
* @see #getRefresh()
|
||||
* @generated
|
||||
*/
|
||||
void setRefresh(int value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Icon Color</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.ColorArray}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Icon Color</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Icon Color</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getImage_IconColor()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<ColorArray> getIconColor();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Icon Color</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.ColorArray}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Icon Color</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Icon Color</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getImage_IconColor()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<ColorArray> getIconColor();
|
||||
|
||||
} // Image
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.emf.common.util.EList;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.LinkableWidget#getChildren <em>Children</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.LinkableWidget#getChildren <em>Children</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -28,22 +28,22 @@ import org.eclipse.emf.common.util.EList;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface LinkableWidget extends Widget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Children</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Widget}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Children</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Children</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget_Children()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Widget> getChildren();
|
||||
public interface LinkableWidget extends Widget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Children</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Widget}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Children</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Children</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget_Children()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Widget> getChildren();
|
||||
|
||||
} // LinkableWidget
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>List</b></em>'.
|
||||
|
@ -19,7 +18,7 @@ package org.openhab.model.sitemap;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.List#getSeparator <em>Separator</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.List#getSeparator <em>Separator</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -27,32 +26,33 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface List extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Separator</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Separator</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Separator</em>' attribute.
|
||||
* @see #setSeparator(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getList_Separator()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getSeparator();
|
||||
public interface List extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Separator</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Separator</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Separator</em>' attribute.
|
||||
* @see #setSeparator(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getList_Separator()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getSeparator();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.List#getSeparator <em>Separator</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Separator</em>' attribute.
|
||||
* @see #getSeparator()
|
||||
* @generated
|
||||
*/
|
||||
void setSeparator(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.List#getSeparator <em>Separator</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Separator</em>' attribute.
|
||||
* @see #getSeparator()
|
||||
* @generated
|
||||
*/
|
||||
void setSeparator(String value);
|
||||
|
||||
} // List
|
||||
|
|
|
@ -20,8 +20,8 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Mapping#getCmd <em>Cmd</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Mapping#getLabel <em>Label</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Mapping#getCmd <em>Cmd</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Mapping#getLabel <em>Label</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -29,58 +29,61 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Mapping extends EObject
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Cmd</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Cmd</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Cmd</em>' attribute.
|
||||
* @see #setCmd(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getMapping_Cmd()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getCmd();
|
||||
public interface Mapping extends EObject {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Cmd</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Cmd</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Cmd</em>' attribute.
|
||||
* @see #setCmd(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getMapping_Cmd()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getCmd();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getCmd <em>Cmd</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Cmd</em>' attribute.
|
||||
* @see #getCmd()
|
||||
* @generated
|
||||
*/
|
||||
void setCmd(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getCmd <em>Cmd</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Cmd</em>' attribute.
|
||||
* @see #getCmd()
|
||||
* @generated
|
||||
*/
|
||||
void setCmd(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Label</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Label</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Label</em>' attribute.
|
||||
* @see #setLabel(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getMapping_Label()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getLabel();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Label</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Label</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Label</em>' attribute.
|
||||
* @see #setLabel(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getMapping_Label()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getLabel <em>Label</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Label</em>' attribute.
|
||||
* @see #getLabel()
|
||||
* @generated
|
||||
*/
|
||||
void setLabel(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getLabel <em>Label</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Label</em>' attribute.
|
||||
* @see #getLabel()
|
||||
* @generated
|
||||
*/
|
||||
void setLabel(String value);
|
||||
|
||||
} // Mapping
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Non Linkable Widget</b></em>'.
|
||||
|
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface NonLinkableWidget extends Widget
|
||||
{
|
||||
public interface NonLinkableWidget extends Widget {
|
||||
} // NonLinkableWidget
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.emf.common.util.EList;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Selection#getMappings <em>Mappings</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Selection#getMappings <em>Mappings</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -28,22 +28,22 @@ import org.eclipse.emf.common.util.EList;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Selection extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Mappings</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Mapping}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Mappings</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Mappings</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSelection_Mappings()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Mapping> getMappings();
|
||||
public interface Selection extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Mappings</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Mapping}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Mappings</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Mappings</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSelection_Mappings()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Mapping> getMappings();
|
||||
|
||||
} // Selection
|
||||
|
|
|
@ -20,9 +20,9 @@ import java.math.BigDecimal;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Setpoint#getMinValue <em>Min Value</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Setpoint#getMaxValue <em>Max Value</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Setpoint#getStep <em>Step</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Setpoint#getMinValue <em>Min Value</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Setpoint#getMaxValue <em>Max Value</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Setpoint#getStep <em>Step</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -30,84 +30,89 @@ import java.math.BigDecimal;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Setpoint extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Min Value</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Min Value</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Min Value</em>' attribute.
|
||||
* @see #setMinValue(BigDecimal)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MinValue()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
BigDecimal getMinValue();
|
||||
public interface Setpoint extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Min Value</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Min Value</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Min Value</em>' attribute.
|
||||
* @see #setMinValue(BigDecimal)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MinValue()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
BigDecimal getMinValue();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMinValue <em>Min Value</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Min Value</em>' attribute.
|
||||
* @see #getMinValue()
|
||||
* @generated
|
||||
*/
|
||||
void setMinValue(BigDecimal value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMinValue <em>Min Value</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Min Value</em>' attribute.
|
||||
* @see #getMinValue()
|
||||
* @generated
|
||||
*/
|
||||
void setMinValue(BigDecimal value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Max Value</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Max Value</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Max Value</em>' attribute.
|
||||
* @see #setMaxValue(BigDecimal)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MaxValue()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
BigDecimal getMaxValue();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Max Value</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Max Value</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Max Value</em>' attribute.
|
||||
* @see #setMaxValue(BigDecimal)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MaxValue()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
BigDecimal getMaxValue();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMaxValue <em>Max Value</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Max Value</em>' attribute.
|
||||
* @see #getMaxValue()
|
||||
* @generated
|
||||
*/
|
||||
void setMaxValue(BigDecimal value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMaxValue <em>Max Value</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Max Value</em>' attribute.
|
||||
* @see #getMaxValue()
|
||||
* @generated
|
||||
*/
|
||||
void setMaxValue(BigDecimal value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Step</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Step</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Step</em>' attribute.
|
||||
* @see #setStep(BigDecimal)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_Step()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
BigDecimal getStep();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Step</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Step</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Step</em>' attribute.
|
||||
* @see #setStep(BigDecimal)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_Step()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
BigDecimal getStep();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getStep <em>Step</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Step</em>' attribute.
|
||||
* @see #getStep()
|
||||
* @generated
|
||||
*/
|
||||
void setStep(BigDecimal value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getStep <em>Step</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Step</em>' attribute.
|
||||
* @see #getStep()
|
||||
* @generated
|
||||
*/
|
||||
void setStep(BigDecimal value);
|
||||
|
||||
} // Setpoint
|
||||
|
|
|
@ -20,10 +20,10 @@ import org.eclipse.emf.common.util.EList;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getName <em>Name</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getLabel <em>Label</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getIcon <em>Icon</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getChildren <em>Children</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getName <em>Name</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getLabel <em>Label</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getIcon <em>Icon</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Sitemap#getChildren <em>Children</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -31,100 +31,106 @@ import org.eclipse.emf.common.util.EList;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Sitemap extends SitemapModel
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Name</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Name</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Name</em>' attribute.
|
||||
* @see #setName(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Name()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getName();
|
||||
public interface Sitemap extends SitemapModel {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Name</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Name</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Name</em>' attribute.
|
||||
* @see #setName(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Name()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getName <em>Name</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Name</em>' attribute.
|
||||
* @see #getName()
|
||||
* @generated
|
||||
*/
|
||||
void setName(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getName <em>Name</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Name</em>' attribute.
|
||||
* @see #getName()
|
||||
* @generated
|
||||
*/
|
||||
void setName(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Label</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Label</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Label</em>' attribute.
|
||||
* @see #setLabel(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Label()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getLabel();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Label</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Label</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Label</em>' attribute.
|
||||
* @see #setLabel(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Label()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getLabel <em>Label</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Label</em>' attribute.
|
||||
* @see #getLabel()
|
||||
* @generated
|
||||
*/
|
||||
void setLabel(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getLabel <em>Label</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Label</em>' attribute.
|
||||
* @see #getLabel()
|
||||
* @generated
|
||||
*/
|
||||
void setLabel(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Icon</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Icon</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Icon</em>' attribute.
|
||||
* @see #setIcon(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Icon()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getIcon();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Icon</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Icon</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Icon</em>' attribute.
|
||||
* @see #setIcon(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Icon()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getIcon();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getIcon <em>Icon</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Icon</em>' attribute.
|
||||
* @see #getIcon()
|
||||
* @generated
|
||||
*/
|
||||
void setIcon(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getIcon <em>Icon</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Icon</em>' attribute.
|
||||
* @see #getIcon()
|
||||
* @generated
|
||||
*/
|
||||
void setIcon(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Children</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Widget}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Children</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Children</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Children()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Widget> getChildren();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Children</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Widget}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Children</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Children</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Children()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Widget> getChildren();
|
||||
|
||||
} // Sitemap
|
||||
|
|
|
@ -22,6 +22,5 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface SitemapModel extends EObject
|
||||
{
|
||||
public interface SitemapModel extends EObject {
|
||||
} // SitemapModel
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Slider</b></em>'.
|
||||
|
@ -19,8 +18,8 @@ package org.openhab.model.sitemap;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Slider#getFrequency <em>Frequency</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Slider#isSwitchEnabled <em>Switch Enabled</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Slider#getFrequency <em>Frequency</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Slider#isSwitchEnabled <em>Switch Enabled</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -28,58 +27,62 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Slider extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Frequency</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Frequency</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Frequency</em>' attribute.
|
||||
* @see #setFrequency(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSlider_Frequency()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getFrequency();
|
||||
public interface Slider extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Frequency</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Frequency</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Frequency</em>' attribute.
|
||||
* @see #setFrequency(int)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSlider_Frequency()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
int getFrequency();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#getFrequency <em>Frequency</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Frequency</em>' attribute.
|
||||
* @see #getFrequency()
|
||||
* @generated
|
||||
*/
|
||||
void setFrequency(int value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#getFrequency <em>Frequency</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Frequency</em>' attribute.
|
||||
* @see #getFrequency()
|
||||
* @generated
|
||||
*/
|
||||
void setFrequency(int value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Switch Enabled</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Switch Enabled</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Switch Enabled</em>' attribute.
|
||||
* @see #setSwitchEnabled(boolean)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSlider_SwitchEnabled()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
boolean isSwitchEnabled();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Switch Enabled</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Switch Enabled</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Switch Enabled</em>' attribute.
|
||||
* @see #setSwitchEnabled(boolean)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSlider_SwitchEnabled()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
boolean isSwitchEnabled();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#isSwitchEnabled <em>Switch Enabled</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Switch Enabled</em>' attribute.
|
||||
* @see #isSwitchEnabled()
|
||||
* @generated
|
||||
*/
|
||||
void setSwitchEnabled(boolean value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#isSwitchEnabled <em>Switch Enabled</em>}'
|
||||
* attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Switch Enabled</em>' attribute.
|
||||
* @see #isSwitchEnabled()
|
||||
* @generated
|
||||
*/
|
||||
void setSwitchEnabled(boolean value);
|
||||
|
||||
} // Slider
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.emf.common.util.EList;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Switch#getMappings <em>Mappings</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Switch#getMappings <em>Mappings</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -28,22 +28,22 @@ import org.eclipse.emf.common.util.EList;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Switch extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Mappings</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Mapping}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Mappings</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Mappings</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSwitch_Mappings()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Mapping> getMappings();
|
||||
public interface Switch extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Mappings</b></em>' containment reference list.
|
||||
* The list contents are of type {@link org.openhab.model.sitemap.Mapping}.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Mappings</em>' containment reference list isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Mappings</em>' containment reference list.
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getSwitch_Mappings()
|
||||
* @model containment="true"
|
||||
* @generated
|
||||
*/
|
||||
EList<Mapping> getMappings();
|
||||
|
||||
} // Switch
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Text</b></em>'.
|
||||
|
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Text extends LinkableWidget
|
||||
{
|
||||
public interface Text extends LinkableWidget {
|
||||
} // Text
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
package org.openhab.model.sitemap;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* A representation of the model object '<em><b>Video</b></em>'.
|
||||
|
@ -19,7 +18,7 @@ package org.openhab.model.sitemap;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.Video#getUrl <em>Url</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.Video#getUrl <em>Url</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -27,32 +26,33 @@ package org.openhab.model.sitemap;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface Video extends NonLinkableWidget
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Url</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Url</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Url</em>' attribute.
|
||||
* @see #setUrl(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVideo_Url()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getUrl();
|
||||
public interface Video extends NonLinkableWidget {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Url</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Url</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Url</em>' attribute.
|
||||
* @see #setUrl(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVideo_Url()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getUrl();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Video#getUrl <em>Url</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Url</em>' attribute.
|
||||
* @see #getUrl()
|
||||
* @generated
|
||||
*/
|
||||
void setUrl(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.Video#getUrl <em>Url</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Url</em>' attribute.
|
||||
* @see #getUrl()
|
||||
* @generated
|
||||
*/
|
||||
void setUrl(String value);
|
||||
|
||||
} // Video
|
||||
|
|
|
@ -20,10 +20,10 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* <p>
|
||||
* The following features are supported:
|
||||
* <ul>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getItem <em>Item</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getCondition <em>Condition</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getSign <em>Sign</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getState <em>State</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getItem <em>Item</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getCondition <em>Condition</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getSign <em>Sign</em>}</li>
|
||||
* <li>{@link org.openhab.model.sitemap.VisibilityRule#getState <em>State</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
|
@ -31,110 +31,118 @@ import org.eclipse.emf.ecore.EObject;
|
|||
* @model
|
||||
* @generated
|
||||
*/
|
||||
public interface VisibilityRule extends EObject
|
||||
{
|
||||
/**
|
||||
* Returns the value of the '<em><b>Item</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Item</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Item</em>' attribute.
|
||||
* @see #setItem(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Item()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getItem();
|
||||
public interface VisibilityRule extends EObject {
|
||||
/**
|
||||
* Returns the value of the '<em><b>Item</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Item</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Item</em>' attribute.
|
||||
* @see #setItem(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Item()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getItem();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getItem <em>Item</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Item</em>' attribute.
|
||||
* @see #getItem()
|
||||
* @generated
|
||||
*/
|
||||
void setItem(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getItem <em>Item</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Item</em>' attribute.
|
||||
* @see #getItem()
|
||||
* @generated
|
||||
*/
|
||||
void setItem(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Condition</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Condition</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Condition</em>' attribute.
|
||||
* @see #setCondition(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Condition()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getCondition();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Condition</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Condition</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Condition</em>' attribute.
|
||||
* @see #setCondition(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Condition()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getCondition();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getCondition <em>Condition</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Condition</em>' attribute.
|
||||
* @see #getCondition()
|
||||
* @generated
|
||||
*/
|
||||
void setCondition(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getCondition <em>Condition</em>}'
|
||||
* attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Condition</em>' attribute.
|
||||
* @see #getCondition()
|
||||
* @generated
|
||||
*/
|
||||
void setCondition(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Sign</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Sign</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Sign</em>' attribute.
|
||||
* @see #setSign(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Sign()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getSign();
|
||||
/**
|
||||
* Returns the value of the '<em><b>Sign</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>Sign</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>Sign</em>' attribute.
|
||||
* @see #setSign(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Sign()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getSign();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getSign <em>Sign</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Sign</em>' attribute.
|
||||
* @see #getSign()
|
||||
* @generated
|
||||
*/
|
||||
void setSign(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getSign <em>Sign</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>Sign</em>' attribute.
|
||||
* @see #getSign()
|
||||
* @generated
|
||||
*/
|
||||
void setSign(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>State</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>State</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>State</em>' attribute.
|
||||
* @see #setState(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_State()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getState();
|
||||
/**
|
||||
* Returns the value of the '<em><b>State</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <p>
|
||||
* If the meaning of the '<em>State</em>' attribute isn't clear,
|
||||
* there really should be more of a description here...
|
||||
* </p>
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @return the value of the '<em>State</em>' attribute.
|
||||
* @see #setState(String)
|
||||
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_State()
|
||||
* @model
|
||||
* @generated
|
||||
*/
|
||||
String getState();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getState <em>State</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>State</em>' attribute.
|
||||
* @see #getState()
|
||||
* @generated
|
||||
*/
|
||||
void setState(String value);
|
||||
/**
|
||||
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getState <em>State</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
*
|
||||
* @param value the new value of the '<em>State</em>' attribute.
|
||||
* @see #getState()
|
||||
* @generated
|
||||
*/
|
||||
void setState(String value);
|
||||
|
||||
} // VisibilityRule
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue