repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/mesh/Provisioner1.java
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/mesh/BluezMeshAbortException.java // @SuppressWarnings("serial") // public class BluezMeshAbortException extends DBusException { // // public BluezMeshAbortException(String _message) { // super(_message); // } // // }
import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.mesh.BluezMeshAbortException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.Variant;
package org.bluez.mesh; /** * File generated - 2020-12-28.<br> * Based on bluez Documentation: mesh-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.mesh.Provisioner1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> * <b>Supported properties:</b> <br> * <br> * An array of strings with the following allowed values:<br> * "blink"<br> * "beep"<br> * "vibrate"<br> * "out-numeric"<br> * "out-alpha"<br> * "push"<br> * "twist"<br> * "in-numeric"<br> * "in-alpha"<br> * "static-oob"<br> * "public-oob"<br> * <br> * <br> * Indicates availability of OOB data. An array of strings with the<br> * following allowed values:<br> * "other"<br> * "uri"<br> * "machine-code-2d"<br> * "bar-code"<br> * "nfc"<br> * "number"<br> * "string"<br> * "on-box"<br> * "in-box"<br> * "on-paper",<br> * "in-manual"<br> * "on-device"<br> * <br> * <br> * Uniform Resource Identifier points to out-of-band (OOB)<br> * information (e.g., a public key)<br> * <br> * <br> */ public interface Provisioner1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * The method is called from the bluetooth-meshd daemon when a<br> * unique UUID has been seen during UnprovisionedScan() for<br> * unprovsioned devices.<br> * <br> * The rssi parameter is a signed, normalized measurement of the<br> * signal strength of the recieved unprovisioned beacon.<br> * <br> * The data parameter is a variable length byte array, that may<br> * have 1, 2 or 3 distinct fields contained in it including the 16<br> * byte remote device UUID (always), a 16 bit mask of OOB<br> * authentication flags (optional), and a 32 bit URI hash (if URI<br> * bit set in OOB mask). Whether these fields exist or not is a<br> * decision of the remote device.<br> * <br> * The options parameter is a dictionary that may contain<br> * additional scan result info (currently an empty placeholder for<br> * forward compatibility).<br> * <br> * If a beacon with a UUID that has already been reported is<br> * recieved by the daemon, it will be silently discarded unless it<br> * was recieved at a higher rssi power level. * * @param _rssi rssi * @param _data data * @param _options options */ void ScanResult(int _rssi, byte[] _data, Map<String, Variant<?>> _options); /** * <b>From bluez documentation:</b><br> * <br> * This method is implemented by a Provisioner capable application<br> * and is called when the remote device has been fully<br> * authenticated and confirmed.<br> * <br> * The count parameter is the number of consecutive unicast<br> * addresses the remote device is requesting.<br> * <br> * Return Parameters are from the Mesh Profile Spec:<br> * net_index - Subnet index of the net_key<br> * unicast - Primary Unicast address of the new node * * @param _count count * * @return Tuple of net_index and unicast, maybe null * * @throws BluezMeshAbortException when operation is aborted */
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/mesh/BluezMeshAbortException.java // @SuppressWarnings("serial") // public class BluezMeshAbortException extends DBusException { // // public BluezMeshAbortException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/mesh/Provisioner1.java import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.mesh.BluezMeshAbortException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.Variant; package org.bluez.mesh; /** * File generated - 2020-12-28.<br> * Based on bluez Documentation: mesh-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.mesh.Provisioner1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> * <b>Supported properties:</b> <br> * <br> * An array of strings with the following allowed values:<br> * "blink"<br> * "beep"<br> * "vibrate"<br> * "out-numeric"<br> * "out-alpha"<br> * "push"<br> * "twist"<br> * "in-numeric"<br> * "in-alpha"<br> * "static-oob"<br> * "public-oob"<br> * <br> * <br> * Indicates availability of OOB data. An array of strings with the<br> * following allowed values:<br> * "other"<br> * "uri"<br> * "machine-code-2d"<br> * "bar-code"<br> * "nfc"<br> * "number"<br> * "string"<br> * "on-box"<br> * "in-box"<br> * "on-paper",<br> * "in-manual"<br> * "on-device"<br> * <br> * <br> * Uniform Resource Identifier points to out-of-band (OOB)<br> * information (e.g., a public key)<br> * <br> * <br> */ public interface Provisioner1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * The method is called from the bluetooth-meshd daemon when a<br> * unique UUID has been seen during UnprovisionedScan() for<br> * unprovsioned devices.<br> * <br> * The rssi parameter is a signed, normalized measurement of the<br> * signal strength of the recieved unprovisioned beacon.<br> * <br> * The data parameter is a variable length byte array, that may<br> * have 1, 2 or 3 distinct fields contained in it including the 16<br> * byte remote device UUID (always), a 16 bit mask of OOB<br> * authentication flags (optional), and a 32 bit URI hash (if URI<br> * bit set in OOB mask). Whether these fields exist or not is a<br> * decision of the remote device.<br> * <br> * The options parameter is a dictionary that may contain<br> * additional scan result info (currently an empty placeholder for<br> * forward compatibility).<br> * <br> * If a beacon with a UUID that has already been reported is<br> * recieved by the daemon, it will be silently discarded unless it<br> * was recieved at a higher rssi power level. * * @param _rssi rssi * @param _data data * @param _options options */ void ScanResult(int _rssi, byte[] _data, Map<String, Variant<?>> _options); /** * <b>From bluez documentation:</b><br> * <br> * This method is implemented by a Provisioner capable application<br> * and is called when the remote device has been fully<br> * authenticated and confirmed.<br> * <br> * The count parameter is the number of consecutive unicast<br> * addresses the remote device is requesting.<br> * <br> * Return Parameters are from the Mesh Profile Spec:<br> * net_index - Subnet index of the net_key<br> * unicast - Primary Unicast address of the new node * * @param _count count * * @return Tuple of net_index and unicast, maybe null * * @throws BluezMeshAbortException when operation is aborted */
TwoTuple<UInt16, UInt16> RequestProvData(byte _count) throws BluezMeshAbortException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/AgentManager1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.freedesktop.dbus.DBusPath;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-agent-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.AgentManager1<br> * <br> * <b>Object path:</b><br> * /org/bluez/obex<br> * <br> */ public interface AgentManager1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register an agent to request authorization of<br> * the user to accept/reject objects. Object push<br> * service needs to authorize each received object.<br> * <br> * * @param _agent agent * * @throws BluezAlreadyExistsException when item already exists */ void RegisterAgent(DBusPath _agent) throws BluezAlreadyExistsException; /** * <b>From bluez documentation:</b><br> * <br> * This unregisters the agent that has been previously<br> * registered. The object path parameter must match the<br> * same value that has been used on registration.<br> * <br> * * @param _agent agent * * @throws BluezDoesNotExistException when item does not exist */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/AgentManager1.java import org.freedesktop.dbus.interfaces.DBusInterface; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.freedesktop.dbus.DBusPath; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-agent-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.AgentManager1<br> * <br> * <b>Object path:</b><br> * /org/bluez/obex<br> * <br> */ public interface AgentManager1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register an agent to request authorization of<br> * the user to accept/reject objects. Object push<br> * service needs to authorize each received object.<br> * <br> * * @param _agent agent * * @throws BluezAlreadyExistsException when item already exists */ void RegisterAgent(DBusPath _agent) throws BluezAlreadyExistsException; /** * <b>From bluez documentation:</b><br> * <br> * This unregisters the agent that has been previously<br> * registered. The object path parameter must match the<br> * same value that has been used on registration.<br> * <br> * * @param _agent agent * * @throws BluezDoesNotExistException when item does not exist */
void UnregisterAgent(DBusPath _agent) throws BluezDoesNotExistException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/Agent1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to get the passkey for an authentication.<br> * <br> * The return value should be a string of 1-16 characters<br> * length. The string can be alphanumeric.<br> * <br> * * @param _device device * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/Agent1.java import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to get the passkey for an authentication.<br> * <br> * The return value should be a string of 1-16 characters<br> * length. The string can be alphanumeric.<br> * <br> * * @param _device device * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
String RequestPinCode(DBusPath _device) throws BluezRejectedException, BluezCanceledException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/Agent1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to get the passkey for an authentication.<br> * <br> * The return value should be a string of 1-16 characters<br> * length. The string can be alphanumeric.<br> * <br> * * @param _device device * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/Agent1.java import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to get the passkey for an authentication.<br> * <br> * The return value should be a string of 1-16 characters<br> * length. The string can be alphanumeric.<br> * <br> * * @param _device device * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
String RequestPinCode(DBusPath _device) throws BluezRejectedException, BluezCanceledException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/AgentManager1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: agent-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.AgentManager1<br> * <br> * <b>Object path:</b><br> * /org/bluez<br> * <br> */ public interface AgentManager1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This registers an agent handler.<br> * <br> * The object path defines the path of the agent<br> * that will be called when user input is needed.<br> * <br> * Every application can register its own agent and<br> * for all actions triggered by that application its<br> * agent is used.<br> * <br> * It is not required by an application to register<br> * an agent. If an application does chooses to not<br> * register an agent, the default agent is used. This<br> * is on most cases a good idea. Only application<br> * like a pairing wizard should register their own<br> * agent.<br> * <br> * An application can only register one agent. Multiple<br> * agents per application is not supported.<br> * <br> * The capability parameter can have the values<br> * "DisplayOnly", "DisplayYesNo", "KeyboardOnly",<br> * "NoInputNoOutput" and "KeyboardDisplay" which<br> * reflects the input and output capabilities of the<br> * agent.<br> * <br> * If an empty string is used it will fallback to<br> * "KeyboardDisplay".<br> * <br> * * @param _agent agent * @param _capability capability * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezAlreadyExistsException when item already exists */ void RegisterAgent(DBusPath _agent, String _capability) throws BluezInvalidArgumentsException, BluezAlreadyExistsException; /** * <b>From bluez documentation:</b><br> * <br> * This unregisters the agent that has been previously<br> * registered. The object path parameter must match the<br> * same value that has been used on registration.<br> * <br> * * @param _agent agent * * @throws BluezDoesNotExistException when item does not exist */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/AgentManager1.java import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: agent-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.AgentManager1<br> * <br> * <b>Object path:</b><br> * /org/bluez<br> * <br> */ public interface AgentManager1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This registers an agent handler.<br> * <br> * The object path defines the path of the agent<br> * that will be called when user input is needed.<br> * <br> * Every application can register its own agent and<br> * for all actions triggered by that application its<br> * agent is used.<br> * <br> * It is not required by an application to register<br> * an agent. If an application does chooses to not<br> * register an agent, the default agent is used. This<br> * is on most cases a good idea. Only application<br> * like a pairing wizard should register their own<br> * agent.<br> * <br> * An application can only register one agent. Multiple<br> * agents per application is not supported.<br> * <br> * The capability parameter can have the values<br> * "DisplayOnly", "DisplayYesNo", "KeyboardOnly",<br> * "NoInputNoOutput" and "KeyboardDisplay" which<br> * reflects the input and output capabilities of the<br> * agent.<br> * <br> * If an empty string is used it will fallback to<br> * "KeyboardDisplay".<br> * <br> * * @param _agent agent * @param _capability capability * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezAlreadyExistsException when item already exists */ void RegisterAgent(DBusPath _agent, String _capability) throws BluezInvalidArgumentsException, BluezAlreadyExistsException; /** * <b>From bluez documentation:</b><br> * <br> * This unregisters the agent that has been previously<br> * registered. The object path parameter must match the<br> * same value that has been used on registration.<br> * <br> * * @param _agent agent * * @throws BluezDoesNotExistException when item does not exist */
void UnregisterAgent(DBusPath _agent) throws BluezDoesNotExistException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/HealthDevice1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezHealthErrorException.java // @SuppressWarnings("serial") // public class BluezHealthErrorException extends DBusException { // // public BluezHealthErrorException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java // @SuppressWarnings("serial") // public class BluezNotFoundException extends DBusException { // // public BluezNotFoundException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezOutOfRangeException.java // @SuppressWarnings("serial") // public class BluezOutOfRangeException extends DBusException { // // public BluezOutOfRangeException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezHealthErrorException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotFoundException; import org.bluez.exceptions.BluezOutOfRangeException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthDevice1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br> * <br> * <b>Supported properties:</b> <br> * <br> * object MainChannel [readonly]<br> * <br> * The first reliable channel opened. It is needed by<br> * upper applications in order to send specific protocol<br> * data units. The first reliable can change after a<br> * reconnection.<br> * <br> * <br> * <br> */ public interface HealthDevice1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Sends an echo petition to the remote service. Returns<br> * True if response matches with the buffer sent. If some<br> * error is detected False value is returned.<br> * <br> * * @return boolean - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezOutOfRangeException when value is out of range */ boolean Echo() throws BluezInvalidArgumentsException, BluezOutOfRangeException; /** * <b>From bluez documentation:</b><br> * <br> * Creates a new data channel. The configuration should<br> * indicate the channel quality of service using one of<br> * this values "reliable", "streaming", "any".<br> * <br> * Returns the object path that identifies the data<br> * channel that is already connected.<br> * <br> * * @param _application application * @param _configuration configuration * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezHealthErrorException when operation fails */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezHealthErrorException.java // @SuppressWarnings("serial") // public class BluezHealthErrorException extends DBusException { // // public BluezHealthErrorException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java // @SuppressWarnings("serial") // public class BluezNotFoundException extends DBusException { // // public BluezNotFoundException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezOutOfRangeException.java // @SuppressWarnings("serial") // public class BluezOutOfRangeException extends DBusException { // // public BluezOutOfRangeException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/HealthDevice1.java import org.bluez.exceptions.BluezHealthErrorException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotFoundException; import org.bluez.exceptions.BluezOutOfRangeException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthDevice1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br> * <br> * <b>Supported properties:</b> <br> * <br> * object MainChannel [readonly]<br> * <br> * The first reliable channel opened. It is needed by<br> * upper applications in order to send specific protocol<br> * data units. The first reliable can change after a<br> * reconnection.<br> * <br> * <br> * <br> */ public interface HealthDevice1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Sends an echo petition to the remote service. Returns<br> * True if response matches with the buffer sent. If some<br> * error is detected False value is returned.<br> * <br> * * @return boolean - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezOutOfRangeException when value is out of range */ boolean Echo() throws BluezInvalidArgumentsException, BluezOutOfRangeException; /** * <b>From bluez documentation:</b><br> * <br> * Creates a new data channel. The configuration should<br> * indicate the channel quality of service using one of<br> * this values "reliable", "streaming", "any".<br> * <br> * Returns the object path that identifies the data<br> * channel that is already connected.<br> * <br> * * @param _application application * @param _configuration configuration * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezHealthErrorException when operation fails */
DBusPath CreateChannel(DBusPath _application, String _configuration) throws BluezInvalidArgumentsException, BluezHealthErrorException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/HealthDevice1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezHealthErrorException.java // @SuppressWarnings("serial") // public class BluezHealthErrorException extends DBusException { // // public BluezHealthErrorException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java // @SuppressWarnings("serial") // public class BluezNotFoundException extends DBusException { // // public BluezNotFoundException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezOutOfRangeException.java // @SuppressWarnings("serial") // public class BluezOutOfRangeException extends DBusException { // // public BluezOutOfRangeException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezHealthErrorException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotFoundException; import org.bluez.exceptions.BluezOutOfRangeException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthDevice1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br> * <br> * <b>Supported properties:</b> <br> * <br> * object MainChannel [readonly]<br> * <br> * The first reliable channel opened. It is needed by<br> * upper applications in order to send specific protocol<br> * data units. The first reliable can change after a<br> * reconnection.<br> * <br> * <br> * <br> */ public interface HealthDevice1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Sends an echo petition to the remote service. Returns<br> * True if response matches with the buffer sent. If some<br> * error is detected False value is returned.<br> * <br> * * @return boolean - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezOutOfRangeException when value is out of range */ boolean Echo() throws BluezInvalidArgumentsException, BluezOutOfRangeException; /** * <b>From bluez documentation:</b><br> * <br> * Creates a new data channel. The configuration should<br> * indicate the channel quality of service using one of<br> * this values "reliable", "streaming", "any".<br> * <br> * Returns the object path that identifies the data<br> * channel that is already connected.<br> * <br> * * @param _application application * @param _configuration configuration * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezHealthErrorException when operation fails */ DBusPath CreateChannel(DBusPath _application, String _configuration) throws BluezInvalidArgumentsException, BluezHealthErrorException; /** * <b>From bluez documentation:</b><br> * <br> * Destroys the data channel object. Only the creator of<br> * the channel or the creator of the HealthApplication<br> * that received the data channel will be able to destroy<br> * it.<br> * <br> * * @param _channel channel * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotFoundException when item not found * @throws BluezNotAllowedException when operation not allowed */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezHealthErrorException.java // @SuppressWarnings("serial") // public class BluezHealthErrorException extends DBusException { // // public BluezHealthErrorException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java // @SuppressWarnings("serial") // public class BluezNotFoundException extends DBusException { // // public BluezNotFoundException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezOutOfRangeException.java // @SuppressWarnings("serial") // public class BluezOutOfRangeException extends DBusException { // // public BluezOutOfRangeException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/HealthDevice1.java import org.bluez.exceptions.BluezHealthErrorException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotFoundException; import org.bluez.exceptions.BluezOutOfRangeException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthDevice1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br> * <br> * <b>Supported properties:</b> <br> * <br> * object MainChannel [readonly]<br> * <br> * The first reliable channel opened. It is needed by<br> * upper applications in order to send specific protocol<br> * data units. The first reliable can change after a<br> * reconnection.<br> * <br> * <br> * <br> */ public interface HealthDevice1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Sends an echo petition to the remote service. Returns<br> * True if response matches with the buffer sent. If some<br> * error is detected False value is returned.<br> * <br> * * @return boolean - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezOutOfRangeException when value is out of range */ boolean Echo() throws BluezInvalidArgumentsException, BluezOutOfRangeException; /** * <b>From bluez documentation:</b><br> * <br> * Creates a new data channel. The configuration should<br> * indicate the channel quality of service using one of<br> * this values "reliable", "streaming", "any".<br> * <br> * Returns the object path that identifies the data<br> * channel that is already connected.<br> * <br> * * @param _application application * @param _configuration configuration * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezHealthErrorException when operation fails */ DBusPath CreateChannel(DBusPath _application, String _configuration) throws BluezInvalidArgumentsException, BluezHealthErrorException; /** * <b>From bluez documentation:</b><br> * <br> * Destroys the data channel object. Only the creator of<br> * the channel or the creator of the HealthApplication<br> * that received the data channel will be able to destroy<br> * it.<br> * <br> * * @param _channel channel * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotFoundException when item not found * @throws BluezNotAllowedException when operation not allowed */
void DestroyChannel(DBusPath _channel) throws BluezInvalidArgumentsException, BluezNotFoundException, BluezNotAllowedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/HealthDevice1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezHealthErrorException.java // @SuppressWarnings("serial") // public class BluezHealthErrorException extends DBusException { // // public BluezHealthErrorException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java // @SuppressWarnings("serial") // public class BluezNotFoundException extends DBusException { // // public BluezNotFoundException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezOutOfRangeException.java // @SuppressWarnings("serial") // public class BluezOutOfRangeException extends DBusException { // // public BluezOutOfRangeException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezHealthErrorException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotFoundException; import org.bluez.exceptions.BluezOutOfRangeException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthDevice1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br> * <br> * <b>Supported properties:</b> <br> * <br> * object MainChannel [readonly]<br> * <br> * The first reliable channel opened. It is needed by<br> * upper applications in order to send specific protocol<br> * data units. The first reliable can change after a<br> * reconnection.<br> * <br> * <br> * <br> */ public interface HealthDevice1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Sends an echo petition to the remote service. Returns<br> * True if response matches with the buffer sent. If some<br> * error is detected False value is returned.<br> * <br> * * @return boolean - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezOutOfRangeException when value is out of range */ boolean Echo() throws BluezInvalidArgumentsException, BluezOutOfRangeException; /** * <b>From bluez documentation:</b><br> * <br> * Creates a new data channel. The configuration should<br> * indicate the channel quality of service using one of<br> * this values "reliable", "streaming", "any".<br> * <br> * Returns the object path that identifies the data<br> * channel that is already connected.<br> * <br> * * @param _application application * @param _configuration configuration * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezHealthErrorException when operation fails */ DBusPath CreateChannel(DBusPath _application, String _configuration) throws BluezInvalidArgumentsException, BluezHealthErrorException; /** * <b>From bluez documentation:</b><br> * <br> * Destroys the data channel object. Only the creator of<br> * the channel or the creator of the HealthApplication<br> * that received the data channel will be able to destroy<br> * it.<br> * <br> * * @param _channel channel * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotFoundException when item not found * @throws BluezNotAllowedException when operation not allowed */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezHealthErrorException.java // @SuppressWarnings("serial") // public class BluezHealthErrorException extends DBusException { // // public BluezHealthErrorException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java // @SuppressWarnings("serial") // public class BluezNotFoundException extends DBusException { // // public BluezNotFoundException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezOutOfRangeException.java // @SuppressWarnings("serial") // public class BluezOutOfRangeException extends DBusException { // // public BluezOutOfRangeException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/HealthDevice1.java import org.bluez.exceptions.BluezHealthErrorException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotFoundException; import org.bluez.exceptions.BluezOutOfRangeException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthDevice1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br> * <br> * <b>Supported properties:</b> <br> * <br> * object MainChannel [readonly]<br> * <br> * The first reliable channel opened. It is needed by<br> * upper applications in order to send specific protocol<br> * data units. The first reliable can change after a<br> * reconnection.<br> * <br> * <br> * <br> */ public interface HealthDevice1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Sends an echo petition to the remote service. Returns<br> * True if response matches with the buffer sent. If some<br> * error is detected False value is returned.<br> * <br> * * @return boolean - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezOutOfRangeException when value is out of range */ boolean Echo() throws BluezInvalidArgumentsException, BluezOutOfRangeException; /** * <b>From bluez documentation:</b><br> * <br> * Creates a new data channel. The configuration should<br> * indicate the channel quality of service using one of<br> * this values "reliable", "streaming", "any".<br> * <br> * Returns the object path that identifies the data<br> * channel that is already connected.<br> * <br> * * @param _application application * @param _configuration configuration * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezHealthErrorException when operation fails */ DBusPath CreateChannel(DBusPath _application, String _configuration) throws BluezInvalidArgumentsException, BluezHealthErrorException; /** * <b>From bluez documentation:</b><br> * <br> * Destroys the data channel object. Only the creator of<br> * the channel or the creator of the HealthApplication<br> * that received the data channel will be able to destroy<br> * it.<br> * <br> * * @param _channel channel * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotFoundException when item not found * @throws BluezNotAllowedException when operation not allowed */
void DestroyChannel(DBusPath _channel) throws BluezInvalidArgumentsException, BluezNotFoundException, BluezNotAllowedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/Client1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAuthorizedException.java // @SuppressWarnings("serial") // public class BluezNotAuthorizedException extends DBusException { // // public BluezNotAuthorizedException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAuthorizedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.Client1<br> * <br> * <b>Object path:</b><br> * /org/bluez/obex<br> * <br> */ public interface Client1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Create a new OBEX session for the given remote address.<br> * <br> * The last parameter is a dictionary to hold optional or<br> * type-specific parameters. Typical parameters that can<br> * be set in this dictionary include the following:<br> * <br> * string "Target" : type of session to be created<br> * string "Source" : local address to be used<br> * byte "Channel"<br> * <br> * The currently supported targets are the following:<br> * <br> * "ftp"<br> * "map"<br> * "opp"<br> * "pbap"<br> * "sync"<br> * <br> * * @param _destination destination * @param _args args * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */ DBusPath CreateSession(String _destination, Map<String, Variant<?>> _args) throws BluezInvalidArgumentsException, BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister session and abort pending transfers.<br> * <br> * * @param _session session * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotAuthorizedException when not authorized */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAuthorizedException.java // @SuppressWarnings("serial") // public class BluezNotAuthorizedException extends DBusException { // // public BluezNotAuthorizedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/Client1.java import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotAuthorizedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.Client1<br> * <br> * <b>Object path:</b><br> * /org/bluez/obex<br> * <br> */ public interface Client1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Create a new OBEX session for the given remote address.<br> * <br> * The last parameter is a dictionary to hold optional or<br> * type-specific parameters. Typical parameters that can<br> * be set in this dictionary include the following:<br> * <br> * string "Target" : type of session to be created<br> * string "Source" : local address to be used<br> * byte "Channel"<br> * <br> * The currently supported targets are the following:<br> * <br> * "ftp"<br> * "map"<br> * "opp"<br> * "pbap"<br> * "sync"<br> * <br> * * @param _destination destination * @param _args args * * @return DBusPath - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */ DBusPath CreateSession(String _destination, Map<String, Variant<?>> _args) throws BluezInvalidArgumentsException, BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister session and abort pending transfers.<br> * <br> * * @param _session session * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotAuthorizedException when not authorized */
void RemoveSession(DBusPath _session) throws BluezInvalidArgumentsException, BluezNotAuthorizedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/Synchronization1.java
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.Synchronization1<br> * <br> * <b>Object path:</b><br> * [Session object path]<br> * <br> */ public interface Synchronization1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Set the phonebook object store location for other<br> * operations. Should be called before all the other<br> * operations.<br> * <br> * location: Where the phonebook is stored, possible<br> * values:<br> * "int" ( "internal" which is default )<br> * "sim1"<br> * "sim2"<br> * ......<br> * <br> * * @param _location location * * @throws BluezInvalidArgumentsException when argument is invalid */ void SetLocation(String _location) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Retrieve an entire Phonebook Object store from remote<br> * device, and stores it in a local file.<br> * <br> * If an empty target file is given, a name will be<br> * automatically calculated for the temporary file.<br> * <br> * The returned path represents the newly created transfer,<br> * which should be used to find out if the content has been<br> * successfully transferred or if the operation fails.<br> * <br> * The properties of this transfer are also returned along<br> * with the object path, to avoid a call to GetProperties.<br> * <br> * * @param _targetfile targetfile * * @return TwoTuple&lt;DBusPath, Map&lt;String,Variant&lt;?&gt;&gt;&gt; - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/Synchronization1.java import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.Synchronization1<br> * <br> * <b>Object path:</b><br> * [Session object path]<br> * <br> */ public interface Synchronization1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Set the phonebook object store location for other<br> * operations. Should be called before all the other<br> * operations.<br> * <br> * location: Where the phonebook is stored, possible<br> * values:<br> * "int" ( "internal" which is default )<br> * "sim1"<br> * "sim2"<br> * ......<br> * <br> * * @param _location location * * @throws BluezInvalidArgumentsException when argument is invalid */ void SetLocation(String _location) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Retrieve an entire Phonebook Object store from remote<br> * device, and stores it in a local file.<br> * <br> * If an empty target file is given, a name will be<br> * automatically calculated for the temporary file.<br> * <br> * The returned path represents the newly created transfer,<br> * which should be used to find out if the content has been<br> * successfully transferred or if the operation fails.<br> * <br> * The properties of this transfer are also returned along<br> * with the object path, to avoid a call to GetProperties.<br> * <br> * * @param _targetfile targetfile * * @return TwoTuple&lt;DBusPath, Map&lt;String,Variant&lt;?&gt;&gt;&gt; - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */
TwoTuple<DBusPath, Map<String,Variant<?>>> GetPhonebook(String _targetfile) throws BluezInvalidArgumentsException, BluezFailedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/Synchronization1.java
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.Synchronization1<br> * <br> * <b>Object path:</b><br> * [Session object path]<br> * <br> */ public interface Synchronization1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Set the phonebook object store location for other<br> * operations. Should be called before all the other<br> * operations.<br> * <br> * location: Where the phonebook is stored, possible<br> * values:<br> * "int" ( "internal" which is default )<br> * "sim1"<br> * "sim2"<br> * ......<br> * <br> * * @param _location location * * @throws BluezInvalidArgumentsException when argument is invalid */ void SetLocation(String _location) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Retrieve an entire Phonebook Object store from remote<br> * device, and stores it in a local file.<br> * <br> * If an empty target file is given, a name will be<br> * automatically calculated for the temporary file.<br> * <br> * The returned path represents the newly created transfer,<br> * which should be used to find out if the content has been<br> * successfully transferred or if the operation fails.<br> * <br> * The properties of this transfer are also returned along<br> * with the object path, to avoid a call to GetProperties.<br> * <br> * * @param _targetfile targetfile * * @return TwoTuple&lt;DBusPath, Map&lt;String,Variant&lt;?&gt;&gt;&gt; - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/Synchronization1.java import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.Synchronization1<br> * <br> * <b>Object path:</b><br> * [Session object path]<br> * <br> */ public interface Synchronization1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Set the phonebook object store location for other<br> * operations. Should be called before all the other<br> * operations.<br> * <br> * location: Where the phonebook is stored, possible<br> * values:<br> * "int" ( "internal" which is default )<br> * "sim1"<br> * "sim2"<br> * ......<br> * <br> * * @param _location location * * @throws BluezInvalidArgumentsException when argument is invalid */ void SetLocation(String _location) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Retrieve an entire Phonebook Object store from remote<br> * device, and stores it in a local file.<br> * <br> * If an empty target file is given, a name will be<br> * automatically calculated for the temporary file.<br> * <br> * The returned path represents the newly created transfer,<br> * which should be used to find out if the content has been<br> * successfully transferred or if the operation fails.<br> * <br> * The properties of this transfer are also returned along<br> * with the object path, to avoid a call to GetProperties.<br> * <br> * * @param _targetfile targetfile * * @return TwoTuple&lt;DBusPath, Map&lt;String,Variant&lt;?&gt;&gt;&gt; - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */
TwoTuple<DBusPath, Map<String,Variant<?>>> GetPhonebook(String _targetfile) throws BluezInvalidArgumentsException, BluezFailedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/Agent1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.obex.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to accept/reject a Bluetooth object push request.<br> * <br> * Returns the full path (including the filename) where<br> * the object shall be stored. The tranfer object will<br> * contain a Filename property that contains the default<br> * location and name that can be returned.<br> * <br> * * @param _transfer transfer * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/Agent1.java import org.freedesktop.dbus.interfaces.DBusInterface; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.obex.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to accept/reject a Bluetooth object push request.<br> * <br> * Returns the full path (including the filename) where<br> * the object shall be stored. The tranfer object will<br> * contain a Filename property that contains the default<br> * location and name that can be returned.<br> * <br> * * @param _transfer transfer * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
String AuthorizePush(DBusPath _transfer) throws BluezRejectedException, BluezCanceledException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/Agent1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.obex.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to accept/reject a Bluetooth object push request.<br> * <br> * Returns the full path (including the filename) where<br> * the object shall be stored. The tranfer object will<br> * contain a Filename property that contains the default<br> * location and name that can be returned.<br> * <br> * * @param _transfer transfer * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/Agent1.java import org.freedesktop.dbus.interfaces.DBusInterface; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-agent-api.txt.<br> * <br> * <b>Service:</b> unique name<br> * <b>Interface:</b> org.bluez.obex.Agent1<br> * <br> * <b>Object path:</b><br> * freely definable<br> * <br> */ public interface Agent1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * unregisters the agent. An agent can use it to do<br> * cleanup tasks. There is no need to unregister the<br> * agent, because when this method gets called it has<br> * already been unregistered.<br> * <br> */ void Release(); /** * <b>From bluez documentation:</b><br> * <br> * This method gets called when the service daemon<br> * needs to accept/reject a Bluetooth object push request.<br> * <br> * Returns the full path (including the filename) where<br> * the object shall be stored. The tranfer object will<br> * contain a Filename property that contains the default<br> * location and name that can be returned.<br> * <br> * * @param _transfer transfer * * @return String - maybe null * * @throws BluezRejectedException when operation rejected * @throws BluezCanceledException when operation canceled */
String AuthorizePush(DBusPath _transfer) throws BluezRejectedException, BluezCanceledException;
hypfvieh/bluez-dbus
bluez-dbus/src/test/java/com/github/hypfvieh/helper/BluezInterfaceCreator.java
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/ThreeTuple.java // public class ThreeTuple<A, B, C> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // @Position(2) // private C thirdValue; // // public ThreeTuple(A _firstValue, B _secondValue, C _thirdValue) { // firstValue = _firstValue; // secondValue = _secondValue; // thirdValue = _thirdValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // public C getThirdValue() { // return thirdValue; // } // // public void setThirdValue(C _thirdValue) { // thirdValue = _thirdValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // }
import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; import org.bluez.datatypes.ThreeTuple; import org.bluez.datatypes.TwoTuple; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32; import org.freedesktop.dbus.types.UInt64; import org.freedesktop.dbus.types.Variant; import org.slf4j.LoggerFactory;
String result = sb.toString(); for (String type : types) { if (type.contains("Variant<")) { imports.add(Variant.class.getName()); } if (type.contains("FileDescriptor")) { imports.add(org.freedesktop.dbus.FileDescriptor.class.getName()); } if (type.contains("Map<")) { imports.add(Map.class.getName()); } if (type.contains("Properties")) { imports.add(Properties.class.getName()); } if (type.contains("UInt16")) { imports.add(UInt16.class.getName()); } if (type.contains("UInt32")) { imports.add(UInt32.class.getName()); } if (type.contains("UInt64")) { imports.add(UInt64.class.getName()); } if (type.contains("DBusPath")) { imports.add(DBusPath.class.getName()); }
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/ThreeTuple.java // public class ThreeTuple<A, B, C> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // @Position(2) // private C thirdValue; // // public ThreeTuple(A _firstValue, B _secondValue, C _thirdValue) { // firstValue = _firstValue; // secondValue = _secondValue; // thirdValue = _thirdValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // public C getThirdValue() { // return thirdValue; // } // // public void setThirdValue(C _thirdValue) { // thirdValue = _thirdValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // Path: bluez-dbus/src/test/java/com/github/hypfvieh/helper/BluezInterfaceCreator.java import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; import org.bluez.datatypes.ThreeTuple; import org.bluez.datatypes.TwoTuple; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32; import org.freedesktop.dbus.types.UInt64; import org.freedesktop.dbus.types.Variant; import org.slf4j.LoggerFactory; String result = sb.toString(); for (String type : types) { if (type.contains("Variant<")) { imports.add(Variant.class.getName()); } if (type.contains("FileDescriptor")) { imports.add(org.freedesktop.dbus.FileDescriptor.class.getName()); } if (type.contains("Map<")) { imports.add(Map.class.getName()); } if (type.contains("Properties")) { imports.add(Properties.class.getName()); } if (type.contains("UInt16")) { imports.add(UInt16.class.getName()); } if (type.contains("UInt32")) { imports.add(UInt32.class.getName()); } if (type.contains("UInt64")) { imports.add(UInt64.class.getName()); } if (type.contains("DBusPath")) { imports.add(DBusPath.class.getName()); }
if (type.startsWith("ThreeTuple")) {
hypfvieh/bluez-dbus
bluez-dbus/src/test/java/com/github/hypfvieh/helper/BluezInterfaceCreator.java
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/ThreeTuple.java // public class ThreeTuple<A, B, C> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // @Position(2) // private C thirdValue; // // public ThreeTuple(A _firstValue, B _secondValue, C _thirdValue) { // firstValue = _firstValue; // secondValue = _secondValue; // thirdValue = _thirdValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // public C getThirdValue() { // return thirdValue; // } // // public void setThirdValue(C _thirdValue) { // thirdValue = _thirdValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // }
import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; import org.bluez.datatypes.ThreeTuple; import org.bluez.datatypes.TwoTuple; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32; import org.freedesktop.dbus.types.UInt64; import org.freedesktop.dbus.types.Variant; import org.slf4j.LoggerFactory;
if (type.contains("FileDescriptor")) { imports.add(org.freedesktop.dbus.FileDescriptor.class.getName()); } if (type.contains("Map<")) { imports.add(Map.class.getName()); } if (type.contains("Properties")) { imports.add(Properties.class.getName()); } if (type.contains("UInt16")) { imports.add(UInt16.class.getName()); } if (type.contains("UInt32")) { imports.add(UInt32.class.getName()); } if (type.contains("UInt64")) { imports.add(UInt64.class.getName()); } if (type.contains("DBusPath")) { imports.add(DBusPath.class.getName()); } if (type.startsWith("ThreeTuple")) { imports.add(ThreeTuple.class.getName()); imports.add(Variant.class.getName()); imports.add(Map.class.getName()); imports.add(DBusPath.class.getName());
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/ThreeTuple.java // public class ThreeTuple<A, B, C> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // @Position(2) // private C thirdValue; // // public ThreeTuple(A _firstValue, B _secondValue, C _thirdValue) { // firstValue = _firstValue; // secondValue = _secondValue; // thirdValue = _thirdValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // public C getThirdValue() { // return thirdValue; // } // // public void setThirdValue(C _thirdValue) { // thirdValue = _thirdValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // Path: bluez-dbus/src/test/java/com/github/hypfvieh/helper/BluezInterfaceCreator.java import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; import org.bluez.datatypes.ThreeTuple; import org.bluez.datatypes.TwoTuple; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.messages.DBusSignal; import org.freedesktop.dbus.types.UInt16; import org.freedesktop.dbus.types.UInt32; import org.freedesktop.dbus.types.UInt64; import org.freedesktop.dbus.types.Variant; import org.slf4j.LoggerFactory; if (type.contains("FileDescriptor")) { imports.add(org.freedesktop.dbus.FileDescriptor.class.getName()); } if (type.contains("Map<")) { imports.add(Map.class.getName()); } if (type.contains("Properties")) { imports.add(Properties.class.getName()); } if (type.contains("UInt16")) { imports.add(UInt16.class.getName()); } if (type.contains("UInt32")) { imports.add(UInt32.class.getName()); } if (type.contains("UInt64")) { imports.add(UInt64.class.getName()); } if (type.contains("DBusPath")) { imports.add(DBusPath.class.getName()); } if (type.startsWith("ThreeTuple")) { imports.add(ThreeTuple.class.getName()); imports.add(Variant.class.getName()); imports.add(Map.class.getName()); imports.add(DBusPath.class.getName());
} else if (type.startsWith("TwoTuple")) {
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/Media1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java // @SuppressWarnings("serial") // public class BluezNotSupportedException extends DBusException { // // public BluezNotSupportedException(String _message) { // super(_message); // } // // }
import java.util.Map; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotSupportedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.Variant;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: media-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.Media1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}<br> * <br> */ public interface Media1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register a local end point to sender, the sender can<br> * register as many end points as it likes.<br> * <br> * Note: If the sender disconnects the end points are<br> * automatically unregistered.<br> * <br> * possible properties:<br> * <br> * string UUID:<br> * <br> * UUID of the profile which the endpoint<br> * is for.<br> * <br> * byte Codec:<br> * <br> * Assigned number of codec that the<br> * endpoint implements. The values should<br> * match the profile specification which<br> * is indicated by the UUID.<br> * <br> * array{byte} Capabilities:<br> * <br> * Capabilities blob, it is used as it is<br> * so the size and byte order must match.<br> * <br> * * @param _endpoint endpoint * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid */ void RegisterEndpoint(DBusPath _endpoint, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender end point.<br> * <br> * * @param _endpoint endpoint */ void UnregisterEndpoint(DBusPath _endpoint); /** * <b>From bluez documentation:</b><br> * <br> * Register a media player object to sender, the sender<br> * can register as many objects as it likes.<br> * <br> * Object must implement at least<br> * org.mpris.MediaPlayer2.Player as defined in MPRIS 2.2<br> * spec:<br> * <br> * http://specifications.freedesktop.org/mpris-spec/latest/<br> * <br> * Note: If the sender disconnects its objects are<br> * automatically unregistered.<br> * <br> * * @param _player player * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotSupportedException when operation not supported */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java // @SuppressWarnings("serial") // public class BluezNotSupportedException extends DBusException { // // public BluezNotSupportedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/Media1.java import java.util.Map; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotSupportedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.Variant; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: media-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.Media1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}<br> * <br> */ public interface Media1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register a local end point to sender, the sender can<br> * register as many end points as it likes.<br> * <br> * Note: If the sender disconnects the end points are<br> * automatically unregistered.<br> * <br> * possible properties:<br> * <br> * string UUID:<br> * <br> * UUID of the profile which the endpoint<br> * is for.<br> * <br> * byte Codec:<br> * <br> * Assigned number of codec that the<br> * endpoint implements. The values should<br> * match the profile specification which<br> * is indicated by the UUID.<br> * <br> * array{byte} Capabilities:<br> * <br> * Capabilities blob, it is used as it is<br> * so the size and byte order must match.<br> * <br> * * @param _endpoint endpoint * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid */ void RegisterEndpoint(DBusPath _endpoint, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender end point.<br> * <br> * * @param _endpoint endpoint */ void UnregisterEndpoint(DBusPath _endpoint); /** * <b>From bluez documentation:</b><br> * <br> * Register a media player object to sender, the sender<br> * can register as many objects as it likes.<br> * <br> * Object must implement at least<br> * org.mpris.MediaPlayer2.Player as defined in MPRIS 2.2<br> * spec:<br> * <br> * http://specifications.freedesktop.org/mpris-spec/latest/<br> * <br> * Note: If the sender disconnects its objects are<br> * automatically unregistered.<br> * <br> * * @param _player player * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotSupportedException when operation not supported */
void RegisterPlayer(DBusPath _player, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException, BluezNotSupportedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/Media1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java // @SuppressWarnings("serial") // public class BluezNotSupportedException extends DBusException { // // public BluezNotSupportedException(String _message) { // super(_message); // } // // }
import java.util.Map; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotSupportedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.Variant;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: media-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.Media1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}<br> * <br> */ public interface Media1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register a local end point to sender, the sender can<br> * register as many end points as it likes.<br> * <br> * Note: If the sender disconnects the end points are<br> * automatically unregistered.<br> * <br> * possible properties:<br> * <br> * string UUID:<br> * <br> * UUID of the profile which the endpoint<br> * is for.<br> * <br> * byte Codec:<br> * <br> * Assigned number of codec that the<br> * endpoint implements. The values should<br> * match the profile specification which<br> * is indicated by the UUID.<br> * <br> * array{byte} Capabilities:<br> * <br> * Capabilities blob, it is used as it is<br> * so the size and byte order must match.<br> * <br> * * @param _endpoint endpoint * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid */ void RegisterEndpoint(DBusPath _endpoint, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender end point.<br> * <br> * * @param _endpoint endpoint */ void UnregisterEndpoint(DBusPath _endpoint); /** * <b>From bluez documentation:</b><br> * <br> * Register a media player object to sender, the sender<br> * can register as many objects as it likes.<br> * <br> * Object must implement at least<br> * org.mpris.MediaPlayer2.Player as defined in MPRIS 2.2<br> * spec:<br> * <br> * http://specifications.freedesktop.org/mpris-spec/latest/<br> * <br> * Note: If the sender disconnects its objects are<br> * automatically unregistered.<br> * <br> * * @param _player player * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotSupportedException when operation not supported */ void RegisterPlayer(DBusPath _player, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException, BluezNotSupportedException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender media player.<br> * <br> * * @param _player player */ void UnregisterPlayer(DBusPath _player); /** * <b>From bluez documentation:</b><br> * <br> * Register endpoints an player objects within root<br> * object which must implement ObjectManager.<br> * <br> * The application object path together with the D-Bus<br> * system bus connection ID define the identification of<br> * the application.<br> * <br> * * @param _root root * @param _options options * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezAlreadyExistsException when item already exists */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java // @SuppressWarnings("serial") // public class BluezNotSupportedException extends DBusException { // // public BluezNotSupportedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/Media1.java import java.util.Map; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotSupportedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.Variant; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: media-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.Media1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}<br> * <br> */ public interface Media1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register a local end point to sender, the sender can<br> * register as many end points as it likes.<br> * <br> * Note: If the sender disconnects the end points are<br> * automatically unregistered.<br> * <br> * possible properties:<br> * <br> * string UUID:<br> * <br> * UUID of the profile which the endpoint<br> * is for.<br> * <br> * byte Codec:<br> * <br> * Assigned number of codec that the<br> * endpoint implements. The values should<br> * match the profile specification which<br> * is indicated by the UUID.<br> * <br> * array{byte} Capabilities:<br> * <br> * Capabilities blob, it is used as it is<br> * so the size and byte order must match.<br> * <br> * * @param _endpoint endpoint * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid */ void RegisterEndpoint(DBusPath _endpoint, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender end point.<br> * <br> * * @param _endpoint endpoint */ void UnregisterEndpoint(DBusPath _endpoint); /** * <b>From bluez documentation:</b><br> * <br> * Register a media player object to sender, the sender<br> * can register as many objects as it likes.<br> * <br> * Object must implement at least<br> * org.mpris.MediaPlayer2.Player as defined in MPRIS 2.2<br> * spec:<br> * <br> * http://specifications.freedesktop.org/mpris-spec/latest/<br> * <br> * Note: If the sender disconnects its objects are<br> * automatically unregistered.<br> * <br> * * @param _player player * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotSupportedException when operation not supported */ void RegisterPlayer(DBusPath _player, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException, BluezNotSupportedException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender media player.<br> * <br> * * @param _player player */ void UnregisterPlayer(DBusPath _player); /** * <b>From bluez documentation:</b><br> * <br> * Register endpoints an player objects within root<br> * object which must implement ObjectManager.<br> * <br> * The application object path together with the D-Bus<br> * system bus connection ID define the identification of<br> * the application.<br> * <br> * * @param _root root * @param _options options * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezAlreadyExistsException when item already exists */
void RegisterApplication(DBusPath _root, Map<String, Variant<?>> _options) throws BluezInvalidArgumentsException, BluezAlreadyExistsException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/Media1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java // @SuppressWarnings("serial") // public class BluezNotSupportedException extends DBusException { // // public BluezNotSupportedException(String _message) { // super(_message); // } // // }
import java.util.Map; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotSupportedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.Variant;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: media-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.Media1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}<br> * <br> */ public interface Media1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register a local end point to sender, the sender can<br> * register as many end points as it likes.<br> * <br> * Note: If the sender disconnects the end points are<br> * automatically unregistered.<br> * <br> * possible properties:<br> * <br> * string UUID:<br> * <br> * UUID of the profile which the endpoint<br> * is for.<br> * <br> * byte Codec:<br> * <br> * Assigned number of codec that the<br> * endpoint implements. The values should<br> * match the profile specification which<br> * is indicated by the UUID.<br> * <br> * array{byte} Capabilities:<br> * <br> * Capabilities blob, it is used as it is<br> * so the size and byte order must match.<br> * <br> * * @param _endpoint endpoint * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid */ void RegisterEndpoint(DBusPath _endpoint, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender end point.<br> * <br> * * @param _endpoint endpoint */ void UnregisterEndpoint(DBusPath _endpoint); /** * <b>From bluez documentation:</b><br> * <br> * Register a media player object to sender, the sender<br> * can register as many objects as it likes.<br> * <br> * Object must implement at least<br> * org.mpris.MediaPlayer2.Player as defined in MPRIS 2.2<br> * spec:<br> * <br> * http://specifications.freedesktop.org/mpris-spec/latest/<br> * <br> * Note: If the sender disconnects its objects are<br> * automatically unregistered.<br> * <br> * * @param _player player * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotSupportedException when operation not supported */ void RegisterPlayer(DBusPath _player, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException, BluezNotSupportedException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender media player.<br> * <br> * * @param _player player */ void UnregisterPlayer(DBusPath _player); /** * <b>From bluez documentation:</b><br> * <br> * Register endpoints an player objects within root<br> * object which must implement ObjectManager.<br> * <br> * The application object path together with the D-Bus<br> * system bus connection ID define the identification of<br> * the application.<br> * <br> * * @param _root root * @param _options options * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezAlreadyExistsException when item already exists */ void RegisterApplication(DBusPath _root, Map<String, Variant<?>> _options) throws BluezInvalidArgumentsException, BluezAlreadyExistsException; /** * <b>From bluez documentation:</b><br> * <br> * This unregisters the services that has been<br> * previously registered. The object path parameter<br> * must match the same value that has been used<br> * on registration.<br> * <br> * * @param _application application * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezDoesNotExistException when item does not exist */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java // @SuppressWarnings("serial") // public class BluezAlreadyExistsException extends DBusException { // // public BluezAlreadyExistsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java // @SuppressWarnings("serial") // public class BluezDoesNotExistException extends DBusException { // // public BluezDoesNotExistException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java // @SuppressWarnings("serial") // public class BluezNotSupportedException extends DBusException { // // public BluezNotSupportedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/Media1.java import java.util.Map; import org.bluez.exceptions.BluezAlreadyExistsException; import org.bluez.exceptions.BluezDoesNotExistException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.bluez.exceptions.BluezNotSupportedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.types.Variant; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: media-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.Media1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}<br> * <br> */ public interface Media1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Register a local end point to sender, the sender can<br> * register as many end points as it likes.<br> * <br> * Note: If the sender disconnects the end points are<br> * automatically unregistered.<br> * <br> * possible properties:<br> * <br> * string UUID:<br> * <br> * UUID of the profile which the endpoint<br> * is for.<br> * <br> * byte Codec:<br> * <br> * Assigned number of codec that the<br> * endpoint implements. The values should<br> * match the profile specification which<br> * is indicated by the UUID.<br> * <br> * array{byte} Capabilities:<br> * <br> * Capabilities blob, it is used as it is<br> * so the size and byte order must match.<br> * <br> * * @param _endpoint endpoint * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid */ void RegisterEndpoint(DBusPath _endpoint, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender end point.<br> * <br> * * @param _endpoint endpoint */ void UnregisterEndpoint(DBusPath _endpoint); /** * <b>From bluez documentation:</b><br> * <br> * Register a media player object to sender, the sender<br> * can register as many objects as it likes.<br> * <br> * Object must implement at least<br> * org.mpris.MediaPlayer2.Player as defined in MPRIS 2.2<br> * spec:<br> * <br> * http://specifications.freedesktop.org/mpris-spec/latest/<br> * <br> * Note: If the sender disconnects its objects are<br> * automatically unregistered.<br> * <br> * * @param _player player * @param _properties properties * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezNotSupportedException when operation not supported */ void RegisterPlayer(DBusPath _player, Map<String, Variant<?>> _properties) throws BluezInvalidArgumentsException, BluezNotSupportedException; /** * <b>From bluez documentation:</b><br> * <br> * Unregister sender media player.<br> * <br> * * @param _player player */ void UnregisterPlayer(DBusPath _player); /** * <b>From bluez documentation:</b><br> * <br> * Register endpoints an player objects within root<br> * object which must implement ObjectManager.<br> * <br> * The application object path together with the D-Bus<br> * system bus connection ID define the identification of<br> * the application.<br> * <br> * * @param _root root * @param _options options * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezAlreadyExistsException when item already exists */ void RegisterApplication(DBusPath _root, Map<String, Variant<?>> _options) throws BluezInvalidArgumentsException, BluezAlreadyExistsException; /** * <b>From bluez documentation:</b><br> * <br> * This unregisters the services that has been<br> * previously registered. The object path parameter<br> * must match the same value that has been used<br> * on registration.<br> * <br> * * @param _application application * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezDoesNotExistException when item does not exist */
void UnregisterApplication(DBusPath _application) throws BluezInvalidArgumentsException, BluezDoesNotExistException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/obex/FileTransfer.java
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // }
import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant;
package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.FileTransfer<br> * <br> * <b>Object path:</b><br> * [Session object path]<br> * <br> */ public interface FileTransfer extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Change the current folder of the remote device.<br> * <br> * * @param _folder folder * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */ void ChangeFolder(String _folder) throws BluezInvalidArgumentsException, BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Create a new folder in the remote device.<br> * <br> * * @param _folder folder * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */ void CreateFolder(String _folder) throws BluezInvalidArgumentsException, BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Returns a dictionary containing information about<br> * the current folder content.<br> * <br> * The following keys are defined:<br> * <br> * string Name : Object name in UTF-8 format<br> * string Type : Either "folder" or "file"<br> * uint64 Size : Object size or number of items in<br> * folder<br> * string Permission : Group, owner and other<br> * permission<br> * uint64 Modified : Last change<br> * uint64 Accessed : Last access<br> * uint64 Created : Creation date<br> * <br> * * @return Map&lt;String, Variant&lt;?&gt;&gt;[] - maybe null * * @throws BluezFailedException on failure */ Map<String, Variant<?>>[] ListFolder() throws BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Copy the source file (from remote device) to the<br> * target file (on local filesystem).<br> * <br> * If an empty target file is given, a name will be<br> * automatically calculated for the temporary file.<br> * <br> * The returned path represents the newly created transfer,<br> * which should be used to find out if the content has been<br> * successfully transferred or if the operation fails.<br> * <br> * The properties of this transfer are also returned along<br> * with the object path, to avoid a call to GetProperties.<br> * <br> * * @param _targetfile targetfile * @param _sourcefile sourcefile * * @return TwoTuple&lt;DBusPath, Map&lt;String,Variant&lt;?&gt;&gt;&gt; - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */
// Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java // public class TwoTuple<A, B> extends Tuple { // // @Position(0) // private A firstValue; // @Position(1) // private B secondValue; // // public TwoTuple(A _firstValue, B _secondValue) { // firstValue = _firstValue; // secondValue = _secondValue; // } // // public A getFirstValue() { // return firstValue; // } // // public void setFirstValue(A _firstValue) { // firstValue = _firstValue; // } // // public B getSecondValue() { // return secondValue; // } // // public void setSecondValue(B _secondValue) { // secondValue = _secondValue; // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java // @SuppressWarnings("serial") // public class BluezFailedException extends DBusException { // // public BluezFailedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java // @SuppressWarnings("serial") // public class BluezInvalidArgumentsException extends DBusException { // // public BluezInvalidArgumentsException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/obex/FileTransfer.java import org.freedesktop.dbus.interfaces.DBusInterface; import java.util.Map; import org.bluez.datatypes.TwoTuple; import org.bluez.exceptions.BluezFailedException; import org.bluez.exceptions.BluezInvalidArgumentsException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.types.Variant; package org.bluez.obex; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: obex-api.txt.<br> * <br> * <b>Service:</b> org.bluez.obex<br> * <b>Interface:</b> org.bluez.obex.FileTransfer<br> * <br> * <b>Object path:</b><br> * [Session object path]<br> * <br> */ public interface FileTransfer extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Change the current folder of the remote device.<br> * <br> * * @param _folder folder * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */ void ChangeFolder(String _folder) throws BluezInvalidArgumentsException, BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Create a new folder in the remote device.<br> * <br> * * @param _folder folder * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */ void CreateFolder(String _folder) throws BluezInvalidArgumentsException, BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Returns a dictionary containing information about<br> * the current folder content.<br> * <br> * The following keys are defined:<br> * <br> * string Name : Object name in UTF-8 format<br> * string Type : Either "folder" or "file"<br> * uint64 Size : Object size or number of items in<br> * folder<br> * string Permission : Group, owner and other<br> * permission<br> * uint64 Modified : Last change<br> * uint64 Accessed : Last access<br> * uint64 Created : Creation date<br> * <br> * * @return Map&lt;String, Variant&lt;?&gt;&gt;[] - maybe null * * @throws BluezFailedException on failure */ Map<String, Variant<?>>[] ListFolder() throws BluezFailedException; /** * <b>From bluez documentation:</b><br> * <br> * Copy the source file (from remote device) to the<br> * target file (on local filesystem).<br> * <br> * If an empty target file is given, a name will be<br> * automatically calculated for the temporary file.<br> * <br> * The returned path represents the newly created transfer,<br> * which should be used to find out if the content has been<br> * successfully transferred or if the operation fails.<br> * <br> * The properties of this transfer are also returned along<br> * with the object path, to avoid a call to GetProperties.<br> * <br> * * @param _targetfile targetfile * @param _sourcefile sourcefile * * @return TwoTuple&lt;DBusPath, Map&lt;String,Variant&lt;?&gt;&gt;&gt; - maybe null * * @throws BluezInvalidArgumentsException when argument is invalid * @throws BluezFailedException on failure */
TwoTuple<DBusPath, Map<String,Variant<?>>> GetFile(String _targetfile, String _sourcefile) throws BluezInvalidArgumentsException, BluezFailedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/org/bluez/HealthChannel1.java
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAcquiredException.java // @SuppressWarnings("serial") // public class BluezNotAcquiredException extends DBusException { // // public BluezNotAcquiredException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotConnectedException.java // @SuppressWarnings("serial") // public class BluezNotConnectedException extends DBusException { // // public BluezNotConnectedException(String _message) { // super(_message); // } // // }
import org.bluez.exceptions.BluezNotAcquiredException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotConnectedException; import org.freedesktop.dbus.FileDescriptor; import org.freedesktop.dbus.interfaces.DBusInterface;
package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthChannel1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/chanZZZ<br> * <br> * <b>Supported properties:</b> <br> * <br> * string Type [readonly]<br> * <br> * The quality of service of the data channel. ("reliable"<br> * or "streaming")<br> * <br> * object Device [readonly]<br> * <br> * Identifies the Remote Device that is connected with.<br> * Maps with a HealthDevice object.<br> * <br> * object Application [readonly]<br> * <br> * Identifies the HealthApplication to which this channel<br> * is related to (which indirectly defines its role and<br> * data type).<br> * <br> */ public interface HealthChannel1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Returns the file descriptor for this data channel. If<br> * the data channel is not connected it will also<br> * reconnect.<br> * <br> * * @return FileDescriptor - maybe null * * @throws BluezNotConnectedException when bluez not connected * @throws BluezNotAllowedException when operation not allowed */ FileDescriptor Acquire() throws BluezNotConnectedException, BluezNotAllowedException; /** * <b>From bluez documentation:</b><br> * <br> * Releases the fd. Application should also need to<br> * close() it.<br> * <br> * * @throws BluezNotAcquiredException when item is not acquired * @throws BluezNotAllowedException when operation not allowed */
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAcquiredException.java // @SuppressWarnings("serial") // public class BluezNotAcquiredException extends DBusException { // // public BluezNotAcquiredException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java // @SuppressWarnings("serial") // public class BluezNotAllowedException extends DBusException { // // public BluezNotAllowedException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotConnectedException.java // @SuppressWarnings("serial") // public class BluezNotConnectedException extends DBusException { // // public BluezNotConnectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/org/bluez/HealthChannel1.java import org.bluez.exceptions.BluezNotAcquiredException; import org.bluez.exceptions.BluezNotAllowedException; import org.bluez.exceptions.BluezNotConnectedException; import org.freedesktop.dbus.FileDescriptor; import org.freedesktop.dbus.interfaces.DBusInterface; package org.bluez; /** * File generated - 2020-06-18.<br> * Based on bluez Documentation: health-api.txt.<br> * <br> * <b>Service:</b> org.bluez<br> * <b>Interface:</b> org.bluez.HealthChannel1<br> * <br> * <b>Object path:</b><br> * [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/chanZZZ<br> * <br> * <b>Supported properties:</b> <br> * <br> * string Type [readonly]<br> * <br> * The quality of service of the data channel. ("reliable"<br> * or "streaming")<br> * <br> * object Device [readonly]<br> * <br> * Identifies the Remote Device that is connected with.<br> * Maps with a HealthDevice object.<br> * <br> * object Application [readonly]<br> * <br> * Identifies the HealthApplication to which this channel<br> * is related to (which indirectly defines its role and<br> * data type).<br> * <br> */ public interface HealthChannel1 extends DBusInterface { /** * <b>From bluez documentation:</b><br> * <br> * Returns the file descriptor for this data channel. If<br> * the data channel is not connected it will also<br> * reconnect.<br> * <br> * * @return FileDescriptor - maybe null * * @throws BluezNotConnectedException when bluez not connected * @throws BluezNotAllowedException when operation not allowed */ FileDescriptor Acquire() throws BluezNotConnectedException, BluezNotAllowedException; /** * <b>From bluez documentation:</b><br> * <br> * Releases the fd. Application should also need to<br> * close() it.<br> * <br> * * @throws BluezNotAcquiredException when item is not acquired * @throws BluezNotAllowedException when operation not allowed */
void Release() throws BluezNotAcquiredException, BluezNotAllowedException;
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/com/github/hypfvieh/bluetooth/wrapper/ProfileHandler.java
// Path: bluez-dbus/src/main/java/org/bluez/Profile1.java // public interface Profile1 extends DBusInterface { // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when the service daemon<br> // * unregisters the profile. A profile can use it to do<br> // * cleanup tasks. There is no need to unregister the<br> // * profile, because when this method gets called it has<br> // * already been unregistered.<br> // * <br> // */ // void Release(); // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a new service level<br> // * connection has been made and authorized.<br> // * <br> // * Common fd_properties:<br> // * <br> // * uint16 Version Profile version (optional)<br> // * uint16 Features Profile features (optional)<br> // * <br> // * // * @param _device device // * @param fd fd // * @param _fd_properties fd_properties // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void NewConnection(DBusPath _device, FileDescriptor fd, Map<String, Variant<?>> _fd_properties) throws BluezRejectedException, BluezCanceledException; // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a profile gets<br> // * disconnected.<br> // * <br> // * The file descriptor is no longer owned by the service<br> // * daemon and the profile implementation needs to take<br> // * care of cleaning up all connections.<br> // * <br> // * If multiple file descriptors are indicated via<br> // * NewConnection, it is expected that all of them<br> // * are disconnected before returning from this<br> // * method call.<br> // * <br> // * // * @param _device device // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void RequestDisconnection(DBusPath _device) throws BluezRejectedException, BluezCanceledException; // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // }
import java.util.Map; import org.bluez.Profile1; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.FileDescriptor; import org.freedesktop.dbus.types.Variant;
package com.github.hypfvieh.bluetooth.wrapper; public final class ProfileHandler implements Profile1 { private final String objectPath; private final ProfileChangeListener profileChangeListener; public ProfileHandler(String _objectPath, ProfileChangeListener _profileChangeListener) { this.objectPath = _objectPath; this.profileChangeListener = _profileChangeListener; } @Override
// Path: bluez-dbus/src/main/java/org/bluez/Profile1.java // public interface Profile1 extends DBusInterface { // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when the service daemon<br> // * unregisters the profile. A profile can use it to do<br> // * cleanup tasks. There is no need to unregister the<br> // * profile, because when this method gets called it has<br> // * already been unregistered.<br> // * <br> // */ // void Release(); // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a new service level<br> // * connection has been made and authorized.<br> // * <br> // * Common fd_properties:<br> // * <br> // * uint16 Version Profile version (optional)<br> // * uint16 Features Profile features (optional)<br> // * <br> // * // * @param _device device // * @param fd fd // * @param _fd_properties fd_properties // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void NewConnection(DBusPath _device, FileDescriptor fd, Map<String, Variant<?>> _fd_properties) throws BluezRejectedException, BluezCanceledException; // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a profile gets<br> // * disconnected.<br> // * <br> // * The file descriptor is no longer owned by the service<br> // * daemon and the profile implementation needs to take<br> // * care of cleaning up all connections.<br> // * <br> // * If multiple file descriptors are indicated via<br> // * NewConnection, it is expected that all of them<br> // * are disconnected before returning from this<br> // * method call.<br> // * <br> // * // * @param _device device // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void RequestDisconnection(DBusPath _device) throws BluezRejectedException, BluezCanceledException; // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/com/github/hypfvieh/bluetooth/wrapper/ProfileHandler.java import java.util.Map; import org.bluez.Profile1; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.FileDescriptor; import org.freedesktop.dbus.types.Variant; package com.github.hypfvieh.bluetooth.wrapper; public final class ProfileHandler implements Profile1 { private final String objectPath; private final ProfileChangeListener profileChangeListener; public ProfileHandler(String _objectPath, ProfileChangeListener _profileChangeListener) { this.objectPath = _objectPath; this.profileChangeListener = _profileChangeListener; } @Override
public void NewConnection(DBusPath _device, FileDescriptor _fd, Map<String, Variant<?>> _fdProperties) throws BluezRejectedException, BluezCanceledException {
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/com/github/hypfvieh/bluetooth/wrapper/ProfileHandler.java
// Path: bluez-dbus/src/main/java/org/bluez/Profile1.java // public interface Profile1 extends DBusInterface { // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when the service daemon<br> // * unregisters the profile. A profile can use it to do<br> // * cleanup tasks. There is no need to unregister the<br> // * profile, because when this method gets called it has<br> // * already been unregistered.<br> // * <br> // */ // void Release(); // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a new service level<br> // * connection has been made and authorized.<br> // * <br> // * Common fd_properties:<br> // * <br> // * uint16 Version Profile version (optional)<br> // * uint16 Features Profile features (optional)<br> // * <br> // * // * @param _device device // * @param fd fd // * @param _fd_properties fd_properties // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void NewConnection(DBusPath _device, FileDescriptor fd, Map<String, Variant<?>> _fd_properties) throws BluezRejectedException, BluezCanceledException; // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a profile gets<br> // * disconnected.<br> // * <br> // * The file descriptor is no longer owned by the service<br> // * daemon and the profile implementation needs to take<br> // * care of cleaning up all connections.<br> // * <br> // * If multiple file descriptors are indicated via<br> // * NewConnection, it is expected that all of them<br> // * are disconnected before returning from this<br> // * method call.<br> // * <br> // * // * @param _device device // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void RequestDisconnection(DBusPath _device) throws BluezRejectedException, BluezCanceledException; // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // }
import java.util.Map; import org.bluez.Profile1; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.FileDescriptor; import org.freedesktop.dbus.types.Variant;
package com.github.hypfvieh.bluetooth.wrapper; public final class ProfileHandler implements Profile1 { private final String objectPath; private final ProfileChangeListener profileChangeListener; public ProfileHandler(String _objectPath, ProfileChangeListener _profileChangeListener) { this.objectPath = _objectPath; this.profileChangeListener = _profileChangeListener; } @Override
// Path: bluez-dbus/src/main/java/org/bluez/Profile1.java // public interface Profile1 extends DBusInterface { // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when the service daemon<br> // * unregisters the profile. A profile can use it to do<br> // * cleanup tasks. There is no need to unregister the<br> // * profile, because when this method gets called it has<br> // * already been unregistered.<br> // * <br> // */ // void Release(); // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a new service level<br> // * connection has been made and authorized.<br> // * <br> // * Common fd_properties:<br> // * <br> // * uint16 Version Profile version (optional)<br> // * uint16 Features Profile features (optional)<br> // * <br> // * // * @param _device device // * @param fd fd // * @param _fd_properties fd_properties // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void NewConnection(DBusPath _device, FileDescriptor fd, Map<String, Variant<?>> _fd_properties) throws BluezRejectedException, BluezCanceledException; // // /** // * <b>From bluez documentation:</b><br> // * <br> // * This method gets called when a profile gets<br> // * disconnected.<br> // * <br> // * The file descriptor is no longer owned by the service<br> // * daemon and the profile implementation needs to take<br> // * care of cleaning up all connections.<br> // * <br> // * If multiple file descriptors are indicated via<br> // * NewConnection, it is expected that all of them<br> // * are disconnected before returning from this<br> // * method call.<br> // * <br> // * // * @param _device device // * // * @throws BluezRejectedException when operation rejected // * @throws BluezCanceledException when operation canceled // */ // void RequestDisconnection(DBusPath _device) throws BluezRejectedException, BluezCanceledException; // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java // @SuppressWarnings("serial") // public class BluezCanceledException extends DBusException { // // public BluezCanceledException(String _message) { // super(_message); // } // // } // // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java // @SuppressWarnings("serial") // public class BluezRejectedException extends DBusException { // // public BluezRejectedException(String _message) { // super(_message); // } // // } // Path: bluez-dbus/src/main/java/com/github/hypfvieh/bluetooth/wrapper/ProfileHandler.java import java.util.Map; import org.bluez.Profile1; import org.bluez.exceptions.BluezCanceledException; import org.bluez.exceptions.BluezRejectedException; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.FileDescriptor; import org.freedesktop.dbus.types.Variant; package com.github.hypfvieh.bluetooth.wrapper; public final class ProfileHandler implements Profile1 { private final String objectPath; private final ProfileChangeListener profileChangeListener; public ProfileHandler(String _objectPath, ProfileChangeListener _profileChangeListener) { this.objectPath = _objectPath; this.profileChangeListener = _profileChangeListener; } @Override
public void NewConnection(DBusPath _device, FileDescriptor _fd, Map<String, Variant<?>> _fdProperties) throws BluezRejectedException, BluezCanceledException {
hypfvieh/bluez-dbus
bluez-dbus/src/main/java/com/github/hypfvieh/bluetooth/wrapper/AbstractBluetoothObject.java
// Path: bluez-dbus/src/main/java/com/github/hypfvieh/DbusHelper.java // public final class DbusHelper { // // private static final Logger LOGGER = LoggerFactory.getLogger(DbusHelper.class); // // private DbusHelper() { // // } // // /** // * Find all &lt;node&gt;-Elements in DBUS Introspection XML and extracts the value of the 'name' attribute. // * @param _connection the dbus connection // * @param _path dbus-path-to-introspect // * @return Set of String, maybe empty but never null // */ // public static Set<String> findNodes(DBusConnection _connection, String _path) { // Set<String> foundNodes = new LinkedHashSet<>(); // if (_connection == null || _path == null || _path.trim().isEmpty()) { // return foundNodes; // } // try { // Introspectable remoteObject = _connection.getRemoteObject("org.bluez", _path, Introspectable.class); // String introspect = remoteObject.Introspect(); // Document doc = XmlHelper.parseXmlString(introspect); // NodeList nodes = XmlHelper.applyXpathExpressionToDocument("/node/node", doc); // for (int i = 0; i < nodes.getLength(); i++) { // if (nodes.item(i) instanceof Element) { // Element elem = (Element) nodes.item(i); // foundNodes.add(elem.getAttribute("name")); // } // } // return foundNodes; // } catch (DBusException _ex) { // LOGGER.info("Exception while search DBus.", _ex); // } catch (IOException _ex) { // LOGGER.error("Exception while applying Xpath to introspection result", _ex); // } catch (Exception _ex) { // LOGGER.error("Critical error while reading DBUS response (maybe no bluetoothd daemon running?)", _ex); // } // return foundNodes; // } // // /** // * Creates an java object from a bluez dbus response. // * @param _connection Dbus connection to use // * @param _path dbus request path // * @param _objClass interface class to use // * @param <T> some class/interface implementing/extending {@link DBusInterface} // * @return the created object or null on error // */ // public static <T extends DBusInterface> T getRemoteObject(DBusConnection _connection, String _path, Class<T> _objClass) { // try { // return _connection.getRemoteObject("org.bluez", _path, _objClass); // } catch (DBusException _ex) { // LOGGER.warn("Error while converting dbus response to object.", _ex); // } // return null; // } // // }
import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import org.freedesktop.dbus.connections.impl.DBusConnection; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.exceptions.DBusExecutionException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.interfaces.Properties; import org.freedesktop.dbus.types.Variant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.github.hypfvieh.DbusHelper;
package com.github.hypfvieh.bluetooth.wrapper; /** * Base class of all bluetooth wrapper object classes. * * @author hypfvieh * */ public abstract class AbstractBluetoothObject { private final Logger logger = LoggerFactory.getLogger(getClass()); private final BluetoothDeviceType bluetoothType; private DBusConnection dbusConnection; private final String dbusPath; public AbstractBluetoothObject(BluetoothDeviceType _bluetoothType, DBusConnection _dbusConnection, String _dbusPath) { bluetoothType = _bluetoothType; dbusConnection = _dbusConnection; dbusPath = _dbusPath; } /** * DBus-Interface class used in this wrapper object. * @return class which implements the interface */ protected abstract Class<? extends DBusInterface> getInterfaceClass(); public BluetoothDeviceType getBluetoothType() { return bluetoothType; } public String getDbusPath() { return dbusPath; } public DBusConnection getDbusConnection() { return dbusConnection; } /** * Helper to get remote objects from DBus. * @param _objectNames Set of object names to retrieve [e.g service0000, service0001] * @param _parentPath DBus parent path (objectName will be appended) [e.g. /org/bluez/hci0] * @param _type Expected DBusInterface type [e.g. Device1] * @param <T> class/interface extending {@link DBusInterface} * @return Map of string key and the given interface */ protected <T extends DBusInterface> Map<String, T> getRemoteObjects(Set<String> _objectNames, String _parentPath, Class<T> _type) { Map<String, T> map = new LinkedHashMap<>(); String path = _parentPath; // append slash to parent path if missing if (!_parentPath.endsWith("/")) { path += "/"; } // iterate all object names for (String string : _objectNames) {
// Path: bluez-dbus/src/main/java/com/github/hypfvieh/DbusHelper.java // public final class DbusHelper { // // private static final Logger LOGGER = LoggerFactory.getLogger(DbusHelper.class); // // private DbusHelper() { // // } // // /** // * Find all &lt;node&gt;-Elements in DBUS Introspection XML and extracts the value of the 'name' attribute. // * @param _connection the dbus connection // * @param _path dbus-path-to-introspect // * @return Set of String, maybe empty but never null // */ // public static Set<String> findNodes(DBusConnection _connection, String _path) { // Set<String> foundNodes = new LinkedHashSet<>(); // if (_connection == null || _path == null || _path.trim().isEmpty()) { // return foundNodes; // } // try { // Introspectable remoteObject = _connection.getRemoteObject("org.bluez", _path, Introspectable.class); // String introspect = remoteObject.Introspect(); // Document doc = XmlHelper.parseXmlString(introspect); // NodeList nodes = XmlHelper.applyXpathExpressionToDocument("/node/node", doc); // for (int i = 0; i < nodes.getLength(); i++) { // if (nodes.item(i) instanceof Element) { // Element elem = (Element) nodes.item(i); // foundNodes.add(elem.getAttribute("name")); // } // } // return foundNodes; // } catch (DBusException _ex) { // LOGGER.info("Exception while search DBus.", _ex); // } catch (IOException _ex) { // LOGGER.error("Exception while applying Xpath to introspection result", _ex); // } catch (Exception _ex) { // LOGGER.error("Critical error while reading DBUS response (maybe no bluetoothd daemon running?)", _ex); // } // return foundNodes; // } // // /** // * Creates an java object from a bluez dbus response. // * @param _connection Dbus connection to use // * @param _path dbus request path // * @param _objClass interface class to use // * @param <T> some class/interface implementing/extending {@link DBusInterface} // * @return the created object or null on error // */ // public static <T extends DBusInterface> T getRemoteObject(DBusConnection _connection, String _path, Class<T> _objClass) { // try { // return _connection.getRemoteObject("org.bluez", _path, _objClass); // } catch (DBusException _ex) { // LOGGER.warn("Error while converting dbus response to object.", _ex); // } // return null; // } // // } // Path: bluez-dbus/src/main/java/com/github/hypfvieh/bluetooth/wrapper/AbstractBluetoothObject.java import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import org.freedesktop.dbus.connections.impl.DBusConnection; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.exceptions.DBusExecutionException; import org.freedesktop.dbus.interfaces.DBusInterface; import org.freedesktop.dbus.interfaces.Properties; import org.freedesktop.dbus.types.Variant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.github.hypfvieh.DbusHelper; package com.github.hypfvieh.bluetooth.wrapper; /** * Base class of all bluetooth wrapper object classes. * * @author hypfvieh * */ public abstract class AbstractBluetoothObject { private final Logger logger = LoggerFactory.getLogger(getClass()); private final BluetoothDeviceType bluetoothType; private DBusConnection dbusConnection; private final String dbusPath; public AbstractBluetoothObject(BluetoothDeviceType _bluetoothType, DBusConnection _dbusConnection, String _dbusPath) { bluetoothType = _bluetoothType; dbusConnection = _dbusConnection; dbusPath = _dbusPath; } /** * DBus-Interface class used in this wrapper object. * @return class which implements the interface */ protected abstract Class<? extends DBusInterface> getInterfaceClass(); public BluetoothDeviceType getBluetoothType() { return bluetoothType; } public String getDbusPath() { return dbusPath; } public DBusConnection getDbusConnection() { return dbusConnection; } /** * Helper to get remote objects from DBus. * @param _objectNames Set of object names to retrieve [e.g service0000, service0001] * @param _parentPath DBus parent path (objectName will be appended) [e.g. /org/bluez/hci0] * @param _type Expected DBusInterface type [e.g. Device1] * @param <T> class/interface extending {@link DBusInterface} * @return Map of string key and the given interface */ protected <T extends DBusInterface> Map<String, T> getRemoteObjects(Set<String> _objectNames, String _parentPath, Class<T> _type) { Map<String, T> map = new LinkedHashMap<>(); String path = _parentPath; // append slash to parent path if missing if (!_parentPath.endsWith("/")) { path += "/"; } // iterate all object names for (String string : _objectNames) {
T remoteObject = DbusHelper.getRemoteObject(getDbusConnection(), path + string, _type);
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/editor/PersonEditor.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.e4.ui.di.Persist; import org.eclipse.e4.ui.model.application.ui.MDirtyable; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender;
package org.fipro.eclipse.migration.e4.ui.editor; public class PersonEditor { public static final String ID = "org.fipro.eclipse.migration.ui.editor.personeditor"; public static final String CONTRIBUTION_URI = "bundleclass://org.fipro.eclipse.migration.e4.ui/org.fipro.eclipse.migration.e4.ui.editor.PersonEditor"; public static final String PERSON_INPUT_DATA = "personInputData"; @Inject private MDirtyable dirtyable;
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/editor/PersonEditor.java import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.e4.ui.di.Persist; import org.eclipse.e4.ui.model.application.ui.MDirtyable; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender; package org.fipro.eclipse.migration.e4.ui.editor; public class PersonEditor { public static final String ID = "org.fipro.eclipse.migration.ui.editor.personeditor"; public static final String CONTRIBUTION_URI = "bundleclass://org.fipro.eclipse.migration.e4.ui/org.fipro.eclipse.migration.e4.ui.editor.PersonEditor"; public static final String PERSON_INPUT_DATA = "personInputData"; @Inject private MDirtyable dirtyable;
private Person person;
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/editor/PersonEditor.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.e4.ui.di.Persist; import org.eclipse.e4.ui.model.application.ui.MDirtyable; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender;
GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); Text firstNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); Label lastNameLabel = new Label(parent, SWT.NONE); lastNameLabel.setText("Lastname:"); GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); Text lastNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); Label marriedLabel = new Label(parent, SWT.NONE); marriedLabel.setText("Married:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); Button marriedButton = new Button(parent, SWT.CHECK); Label genderLabel = new Label(parent, SWT.NONE); genderLabel.setText("Gender:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); ComboViewer genderCombo = new ComboViewer(parent); genderCombo.setContentProvider(ArrayContentProvider.getInstance()); genderCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return super.getText(element); } });
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/editor/PersonEditor.java import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.e4.ui.di.Persist; import org.eclipse.e4.ui.model.application.ui.MDirtyable; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender; GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); Text firstNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); Label lastNameLabel = new Label(parent, SWT.NONE); lastNameLabel.setText("Lastname:"); GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); Text lastNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); Label marriedLabel = new Label(parent, SWT.NONE); marriedLabel.setText("Married:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); Button marriedButton = new Button(parent, SWT.CHECK); Label genderLabel = new Label(parent, SWT.NONE); genderLabel.setText("Gender:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); ComboViewer genderCombo = new ComboViewer(parent); genderCombo.setContentProvider(ArrayContentProvider.getInstance()); genderCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return super.getText(element); } });
genderCombo.setInput(Gender.values());
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderLabelProvider.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.ui.view.overview; public class GenderLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderLabelProvider.java import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.ui.view.overview; public class GenderLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
Person element= (Person) cell.getElement();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/FirstNameEditingSupport.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class FirstNameEditingSupport extends EditingSupport { public FirstNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/FirstNameEditingSupport.java import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; package org.fipro.eclipse.migration.e4.ui.view.overview; public class FirstNameEditingSupport extends EditingSupport { public FirstNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).getFirstName();
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/preferences/DescriptionPreferencePage.java
// Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/Activator.java // public class Activator extends AbstractUIPlugin { // // // The plug-in ID // public static final String PLUGIN_ID = "org.fipro.eclipse.migration.ui"; //$NON-NLS-1$ // // // The shared instance // private static Activator plugin; // // /** // * The constructor // */ // public Activator() { // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) // */ // @Override // public void start(BundleContext context) throws Exception { // super.start(context); // plugin = this; // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) // */ // @Override // public void stop(BundleContext context) throws Exception { // plugin = null; // super.stop(context); // } // // /** // * Returns the shared instance // * // * @return the shared instance // */ // public static Activator getDefault() { // return plugin; // } // // /** // * Returns an image descriptor for the image file at the given // * plug-in relative path // * // * @param path the path // * @return the image descriptor // */ // public static ImageDescriptor getImageDescriptor(String path) { // return imageDescriptorFromPlugin(PLUGIN_ID, path); // } // }
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.fipro.eclipse.migration.ui.Activator;
// Reset the fields to the defaults checkBoxBlack.setSelection(isBlack); checkBoxBlue.setSelection(!isBlack); } /** * Called when user clicks Apply or OK * * @return boolean */ @Override public boolean performOk() { // Get the preference store IPreferenceStore preferenceStore = getPreferenceStore(); // Set the values from the fields if (checkBoxBlack != null && checkBoxBlack.getSelection()) { preferenceStore.setValue(DESCRIPTION_COLOR, "black"); } else if (checkBoxBlue != null && checkBoxBlue.getSelection()) { preferenceStore.setValue(DESCRIPTION_COLOR, "blue"); } // Return true to allow dialog to close return true; } @Override public void init(IWorkbench workbench) {
// Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/Activator.java // public class Activator extends AbstractUIPlugin { // // // The plug-in ID // public static final String PLUGIN_ID = "org.fipro.eclipse.migration.ui"; //$NON-NLS-1$ // // // The shared instance // private static Activator plugin; // // /** // * The constructor // */ // public Activator() { // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) // */ // @Override // public void start(BundleContext context) throws Exception { // super.start(context); // plugin = this; // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) // */ // @Override // public void stop(BundleContext context) throws Exception { // plugin = null; // super.stop(context); // } // // /** // * Returns the shared instance // * // * @return the shared instance // */ // public static Activator getDefault() { // return plugin; // } // // /** // * Returns an image descriptor for the image file at the given // * plug-in relative path // * // * @param path the path // * @return the image descriptor // */ // public static ImageDescriptor getImageDescriptor(String path) { // return imageDescriptorFromPlugin(PLUGIN_ID, path); // } // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/preferences/DescriptionPreferencePage.java import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.fipro.eclipse.migration.ui.Activator; // Reset the fields to the defaults checkBoxBlack.setSelection(isBlack); checkBoxBlue.setSelection(!isBlack); } /** * Called when user clicks Apply or OK * * @return boolean */ @Override public boolean performOk() { // Get the preference store IPreferenceStore preferenceStore = getPreferenceStore(); // Set the values from the fields if (checkBoxBlack != null && checkBoxBlack.getSelection()) { preferenceStore.setValue(DESCRIPTION_COLOR, "black"); } else if (checkBoxBlue != null && checkBoxBlue.getSelection()) { preferenceStore.setValue(DESCRIPTION_COLOR, "blue"); } // Return true to allow dialog to close return true; } @Override public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/MarriedEditingSupport.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckboxCellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.ui.view.overview; public class MarriedEditingSupport extends EditingSupport { public MarriedEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new CheckboxCellEditor((Composite) getViewer().getControl(), SWT.CHECK); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/MarriedEditingSupport.java import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckboxCellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.ui.view.overview; public class MarriedEditingSupport extends EditingSupport { public MarriedEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new CheckboxCellEditor((Composite) getViewer().getControl(), SWT.CHECK); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).isMarried();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/DescriptionView.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // }
import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender;
package org.fipro.eclipse.migration.e4.ui.view; @SuppressWarnings("restriction") public class DescriptionView { Text description; @PostConstruct public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); description = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); } @Inject
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/DescriptionView.java import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender; package org.fipro.eclipse.migration.e4.ui.view; @SuppressWarnings("restriction") public class DescriptionView { Text description; @PostConstruct public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); description = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); } @Inject
void updateDescription(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Person person) {
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/DescriptionView.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // }
import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender;
package org.fipro.eclipse.migration.e4.ui.view; @SuppressWarnings("restriction") public class DescriptionView { Text description; @PostConstruct public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); description = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); } @Inject void updateDescription(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Person person) { if (description != null && !description.isDisposed()) { if (person != null) { description.setText(person.getFirstName() + " " + person.getLastName() + " is a " + (person.isMarried() ? "married " : "single ")
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/DescriptionView.java import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender; package org.fipro.eclipse.migration.e4.ui.view; @SuppressWarnings("restriction") public class DescriptionView { Text description; @PostConstruct public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); description = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); } @Inject void updateDescription(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Person person) { if (description != null && !description.isDisposed()) { if (person != null) { description.setText(person.getFirstName() + " " + person.getLastName() + " is a " + (person.isMarried() ? "married " : "single ")
+ (Gender.MALE.equals(person.getGender()) ? "man" : "woman"));
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/MarriedLabelProvider.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.swt.graphics.Image; import org.fipro.eclipse.migration.e4.model.Person; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class MarriedLabelProvider extends StyledCellLabelProvider { private final Image uncheckedImg; private final Image checkedImg; public MarriedLabelProvider() { LocalResourceManager resourceMgr = new LocalResourceManager(JFaceResources.getResources()); Bundle bundle = FrameworkUtil.getBundle(getClass()); URL checked = FileLocator.find(bundle, new Path("icons/checked.gif"), null); URL unchecked = FileLocator.find(bundle, new Path("icons/unchecked.gif"), null); this.checkedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(checked)); this.uncheckedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(unchecked)); } @Override public void update(ViewerCell cell) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/MarriedLabelProvider.java import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.swt.graphics.Image; import org.fipro.eclipse.migration.e4.model.Person; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; package org.fipro.eclipse.migration.e4.ui.view.overview; public class MarriedLabelProvider extends StyledCellLabelProvider { private final Image uncheckedImg; private final Image checkedImg; public MarriedLabelProvider() { LocalResourceManager resourceMgr = new LocalResourceManager(JFaceResources.getResources()); Bundle bundle = FrameworkUtil.getBundle(getClass()); URL checked = FileLocator.find(bundle, new Path("icons/checked.gif"), null); URL unchecked = FileLocator.find(bundle, new Path("icons/unchecked.gif"), null); this.checkedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(checked)); this.uncheckedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(unchecked)); } @Override public void update(ViewerCell cell) {
if (((Person)cell.getElement()).isMarried()) {
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderLabelProvider.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.e4.model.Person;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class GenderLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderLabelProvider.java import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.e4.model.Person; package org.fipro.eclipse.migration.e4.ui.view.overview; public class GenderLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
Person element= (Person) cell.getElement();
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderEditingSupport.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender;
package org.fipro.eclipse.migration.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider());
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderEditingSupport.java import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender; package org.fipro.eclipse.migration.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider());
cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE));
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderEditingSupport.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender;
package org.fipro.eclipse.migration.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider()); cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE)); } @Override protected CellEditor getCellEditor(Object element) { return cellEditor; } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderEditingSupport.java import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender; package org.fipro.eclipse.migration.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider()); cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE)); } @Override protected CellEditor getCellEditor(Object element) { return cellEditor; } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).getGender();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/LastNameLabelProvider.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.e4.model.Person;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class LastNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/LastNameLabelProvider.java import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.e4.model.Person; package org.fipro.eclipse.migration.e4.ui.view.overview; public class LastNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
Person element= (Person) cell.getElement();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/PreferenceManagerSupplier.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java // public class ContributedPreferenceNode extends PreferenceNode { // // private final String path; // private final String nodeQualifier; // private final Class<? extends IPreferencePage> pageClass; // // public ContributedPreferenceNode( // String id, String label, // ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass, // String path, String nodeQualifier) { // // super(id, label, imageDescriptor, pageClass.getName()); // this.path = path; // this.pageClass = pageClass; // // this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); // } // // @Override // public void createPage() { // try { // setPage(this.pageClass.newInstance()); // } catch (InstantiationException|IllegalAccessException e) { // e.printStackTrace(); // } // // if (getLabelImage() != null) { // getPage().setImageDescriptor(getImageDescriptor()); // } // getPage().setTitle(getLabelText()); // // ((PreferencePage)getPage()).setPreferenceStore( // new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); // } // // public String getPath() { // return path; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java // public class PreferenceNodeContribution { // // private final List<ContributedPreferenceNode> nodes = new ArrayList<>(); // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass) { // this(id, label, null, pageClass, null, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // this(id, label, null, pageClass, path, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // this(id, label, null, pageClass, path, nodeQualifier); // } // // public PreferenceNodeContribution( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // // public List<ContributedPreferenceNode> getPreferenceNodes() { // return this.nodes; // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass) { // addPreferenceNode(id, label, null, pageClass, null, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // addPreferenceNode(id, label, null, pageClass, path, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // addPreferenceNode(id, label, null, pageClass, path, nodeQualifier); // } // // public void addPreferenceNode( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // }
import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; import org.eclipse.e4.core.di.suppliers.IRequestor; import org.eclipse.jface.preference.PreferenceManager; import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy;
package org.fipro.eclipse.migration.e4.service.preferences.impl; @SuppressWarnings("restriction") @Component( service=ExtendedObjectSupplier.class, property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr" ) public class PreferenceManagerSupplier extends ExtendedObjectSupplier { PreferenceManager mgr; @Override public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { return getManager(); } protected PreferenceManager getManager() { if (this.mgr == null) { this.mgr = new PreferenceManager(); } return mgr; } @Reference( cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC )
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java // public class ContributedPreferenceNode extends PreferenceNode { // // private final String path; // private final String nodeQualifier; // private final Class<? extends IPreferencePage> pageClass; // // public ContributedPreferenceNode( // String id, String label, // ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass, // String path, String nodeQualifier) { // // super(id, label, imageDescriptor, pageClass.getName()); // this.path = path; // this.pageClass = pageClass; // // this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); // } // // @Override // public void createPage() { // try { // setPage(this.pageClass.newInstance()); // } catch (InstantiationException|IllegalAccessException e) { // e.printStackTrace(); // } // // if (getLabelImage() != null) { // getPage().setImageDescriptor(getImageDescriptor()); // } // getPage().setTitle(getLabelText()); // // ((PreferencePage)getPage()).setPreferenceStore( // new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); // } // // public String getPath() { // return path; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java // public class PreferenceNodeContribution { // // private final List<ContributedPreferenceNode> nodes = new ArrayList<>(); // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass) { // this(id, label, null, pageClass, null, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // this(id, label, null, pageClass, path, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // this(id, label, null, pageClass, path, nodeQualifier); // } // // public PreferenceNodeContribution( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // // public List<ContributedPreferenceNode> getPreferenceNodes() { // return this.nodes; // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass) { // addPreferenceNode(id, label, null, pageClass, null, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // addPreferenceNode(id, label, null, pageClass, path, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // addPreferenceNode(id, label, null, pageClass, path, nodeQualifier); // } // // public void addPreferenceNode( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/PreferenceManagerSupplier.java import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; import org.eclipse.e4.core.di.suppliers.IRequestor; import org.eclipse.jface.preference.PreferenceManager; import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; package org.fipro.eclipse.migration.e4.service.preferences.impl; @SuppressWarnings("restriction") @Component( service=ExtendedObjectSupplier.class, property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr" ) public class PreferenceManagerSupplier extends ExtendedObjectSupplier { PreferenceManager mgr; @Override public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { return getManager(); } protected PreferenceManager getManager() { if (this.mgr == null) { this.mgr = new PreferenceManager(); } return mgr; } @Reference( cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC )
synchronized void addPreferenceNode(PreferenceNodeContribution node) {
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/PreferenceManagerSupplier.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java // public class ContributedPreferenceNode extends PreferenceNode { // // private final String path; // private final String nodeQualifier; // private final Class<? extends IPreferencePage> pageClass; // // public ContributedPreferenceNode( // String id, String label, // ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass, // String path, String nodeQualifier) { // // super(id, label, imageDescriptor, pageClass.getName()); // this.path = path; // this.pageClass = pageClass; // // this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); // } // // @Override // public void createPage() { // try { // setPage(this.pageClass.newInstance()); // } catch (InstantiationException|IllegalAccessException e) { // e.printStackTrace(); // } // // if (getLabelImage() != null) { // getPage().setImageDescriptor(getImageDescriptor()); // } // getPage().setTitle(getLabelText()); // // ((PreferencePage)getPage()).setPreferenceStore( // new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); // } // // public String getPath() { // return path; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java // public class PreferenceNodeContribution { // // private final List<ContributedPreferenceNode> nodes = new ArrayList<>(); // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass) { // this(id, label, null, pageClass, null, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // this(id, label, null, pageClass, path, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // this(id, label, null, pageClass, path, nodeQualifier); // } // // public PreferenceNodeContribution( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // // public List<ContributedPreferenceNode> getPreferenceNodes() { // return this.nodes; // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass) { // addPreferenceNode(id, label, null, pageClass, null, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // addPreferenceNode(id, label, null, pageClass, path, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // addPreferenceNode(id, label, null, pageClass, path, nodeQualifier); // } // // public void addPreferenceNode( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // }
import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; import org.eclipse.e4.core.di.suppliers.IRequestor; import org.eclipse.jface.preference.PreferenceManager; import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy;
package org.fipro.eclipse.migration.e4.service.preferences.impl; @SuppressWarnings("restriction") @Component( service=ExtendedObjectSupplier.class, property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr" ) public class PreferenceManagerSupplier extends ExtendedObjectSupplier { PreferenceManager mgr; @Override public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { return getManager(); } protected PreferenceManager getManager() { if (this.mgr == null) { this.mgr = new PreferenceManager(); } return mgr; } @Reference( cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC ) synchronized void addPreferenceNode(PreferenceNodeContribution node) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java // public class ContributedPreferenceNode extends PreferenceNode { // // private final String path; // private final String nodeQualifier; // private final Class<? extends IPreferencePage> pageClass; // // public ContributedPreferenceNode( // String id, String label, // ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass, // String path, String nodeQualifier) { // // super(id, label, imageDescriptor, pageClass.getName()); // this.path = path; // this.pageClass = pageClass; // // this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); // } // // @Override // public void createPage() { // try { // setPage(this.pageClass.newInstance()); // } catch (InstantiationException|IllegalAccessException e) { // e.printStackTrace(); // } // // if (getLabelImage() != null) { // getPage().setImageDescriptor(getImageDescriptor()); // } // getPage().setTitle(getLabelText()); // // ((PreferencePage)getPage()).setPreferenceStore( // new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); // } // // public String getPath() { // return path; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java // public class PreferenceNodeContribution { // // private final List<ContributedPreferenceNode> nodes = new ArrayList<>(); // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass) { // this(id, label, null, pageClass, null, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // this(id, label, null, pageClass, path, null); // } // // public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // this(id, label, null, pageClass, path, nodeQualifier); // } // // public PreferenceNodeContribution( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // // public List<ContributedPreferenceNode> getPreferenceNodes() { // return this.nodes; // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass) { // addPreferenceNode(id, label, null, pageClass, null, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path) { // addPreferenceNode(id, label, null, pageClass, path, null); // } // // public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) { // addPreferenceNode(id, label, null, pageClass, path, nodeQualifier); // } // // public void addPreferenceNode( // String id, // String label, // ImageDescriptor imageDescriptor, // Class<? extends IPreferencePage> pageClass, // String path, // String nodeQualifier) { // // this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); // } // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/PreferenceManagerSupplier.java import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; import org.eclipse.e4.core.di.suppliers.IRequestor; import org.eclipse.jface.preference.PreferenceManager; import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; package org.fipro.eclipse.migration.e4.service.preferences.impl; @SuppressWarnings("restriction") @Component( service=ExtendedObjectSupplier.class, property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr" ) public class PreferenceManagerSupplier extends ExtendedObjectSupplier { PreferenceManager mgr; @Override public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { return getManager(); } protected PreferenceManager getManager() { if (this.mgr == null) { this.mgr = new PreferenceManager(); } return mgr; } @Reference( cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC ) synchronized void addPreferenceNode(PreferenceNodeContribution node) {
for (ContributedPreferenceNode contribNode : node.getPreferenceNodes()) {
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/editor/PersonEditor.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.EditorPart; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender;
package org.fipro.eclipse.migration.ui.editor; public class PersonEditor extends EditorPart { public static final String ID = "org.fipro.eclipse.migration.ui.editor.personeditor";
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/editor/PersonEditor.java import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.EditorPart; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender; package org.fipro.eclipse.migration.ui.editor; public class PersonEditor extends EditorPart { public static final String ID = "org.fipro.eclipse.migration.ui.editor.personeditor";
Person person;
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/editor/PersonEditor.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.EditorPart; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender;
GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); Text firstNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); Label lastNameLabel = new Label(parent, SWT.NONE); lastNameLabel.setText("Lastname:"); GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); Text lastNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); Label marriedLabel = new Label(parent, SWT.NONE); marriedLabel.setText("Married:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); Button marriedButton = new Button(parent, SWT.CHECK); Label genderLabel = new Label(parent, SWT.NONE); genderLabel.setText("Gender:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); ComboViewer genderCombo = new ComboViewer(parent); genderCombo.setContentProvider(ArrayContentProvider.getInstance()); genderCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return super.getText(element); } });
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/editor/PersonEditor.java import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.EditorPart; import org.fipro.eclipse.migration.model.Person; import org.fipro.eclipse.migration.model.Person.Gender; GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); Text firstNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); Label lastNameLabel = new Label(parent, SWT.NONE); lastNameLabel.setText("Lastname:"); GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); Text lastNameField = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); Label marriedLabel = new Label(parent, SWT.NONE); marriedLabel.setText("Married:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); Button marriedButton = new Button(parent, SWT.CHECK); Label genderLabel = new Label(parent, SWT.NONE); genderLabel.setText("Gender:"); GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); ComboViewer genderCombo = new ComboViewer(parent); genderCombo.setContentProvider(ArrayContentProvider.getInstance()); genderCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return super.getText(element); } });
genderCombo.setInput(Gender.values());
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/LastNameLabelProvider.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.ui.view.overview; public class LastNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/LastNameLabelProvider.java import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.ui.view.overview; public class LastNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
Person element= (Person) cell.getElement();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/handler/PreferencesHandler.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java // public class ContributedPreferenceNode extends PreferenceNode { // // private final String path; // private final String nodeQualifier; // private final Class<? extends IPreferencePage> pageClass; // // public ContributedPreferenceNode( // String id, String label, // ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass, // String path, String nodeQualifier) { // // super(id, label, imageDescriptor, pageClass.getName()); // this.path = path; // this.pageClass = pageClass; // // this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); // } // // @Override // public void createPage() { // try { // setPage(this.pageClass.newInstance()); // } catch (InstantiationException|IllegalAccessException e) { // e.printStackTrace(); // } // // if (getLabelImage() != null) { // getPage().setImageDescriptor(getImageDescriptor()); // } // getPage().setTitle(getLabelText()); // // ((PreferencePage)getPage()).setPreferenceStore( // new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); // } // // public String getPath() { // return path; // } // // }
import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.PreferenceManager; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; import org.fipro.eclipse.migration.e4.service.preferences.PrefMgr;
package org.fipro.eclipse.migration.e4.ui.handler; public class PreferencesHandler { @Execute public void execute(Shell shell, @PrefMgr PreferenceManager manager) { PreferenceDialog dialog = new PreferenceDialog(shell, manager) { @Override protected TreeViewer createTreeViewer(Composite parent) { TreeViewer viewer = super.createTreeViewer(parent); viewer.setComparator(new ViewerComparator() { @Override public int category(Object element) { // this ensures that the General preferences page is always on top // while the other pages are ordered alphabetical
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java // public class ContributedPreferenceNode extends PreferenceNode { // // private final String path; // private final String nodeQualifier; // private final Class<? extends IPreferencePage> pageClass; // // public ContributedPreferenceNode( // String id, String label, // ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass, // String path, String nodeQualifier) { // // super(id, label, imageDescriptor, pageClass.getName()); // this.path = path; // this.pageClass = pageClass; // // this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); // } // // @Override // public void createPage() { // try { // setPage(this.pageClass.newInstance()); // } catch (InstantiationException|IllegalAccessException e) { // e.printStackTrace(); // } // // if (getLabelImage() != null) { // getPage().setImageDescriptor(getImageDescriptor()); // } // getPage().setTitle(getLabelText()); // // ((PreferencePage)getPage()).setPreferenceStore( // new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); // } // // public String getPath() { // return path; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/handler/PreferencesHandler.java import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.PreferenceManager; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; import org.fipro.eclipse.migration.e4.service.preferences.PrefMgr; package org.fipro.eclipse.migration.e4.ui.handler; public class PreferencesHandler { @Execute public void execute(Shell shell, @PrefMgr PreferenceManager manager) { PreferenceDialog dialog = new PreferenceDialog(shell, manager) { @Override protected TreeViewer createTreeViewer(Composite parent) { TreeViewer viewer = super.createTreeViewer(parent); viewer.setComparator(new ViewerComparator() { @Override public int category(Object element) { // this ensures that the General preferences page is always on top // while the other pages are ordered alphabetical
if (element instanceof ContributedPreferenceNode
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/FirstNameLabelProvider.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.e4.model.Person;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class FirstNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/FirstNameLabelProvider.java import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.e4.model.Person; package org.fipro.eclipse.migration.e4.ui.view.overview; public class FirstNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
Person element= (Person) cell.getElement();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/MarriedEditingSupport.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckboxCellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class MarriedEditingSupport extends EditingSupport { public MarriedEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new CheckboxCellEditor((Composite) getViewer().getControl(), SWT.CHECK); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/MarriedEditingSupport.java import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckboxCellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; package org.fipro.eclipse.migration.e4.ui.view.overview; public class MarriedEditingSupport extends EditingSupport { public MarriedEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new CheckboxCellEditor((Composite) getViewer().getControl(), SWT.CHECK); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).isMarried();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderEditingSupport.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider());
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderEditingSupport.java import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender; package org.fipro.eclipse.migration.e4.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider());
cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE));
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderEditingSupport.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // }
import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider()); cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE)); } @Override protected CellEditor getCellEditor(Object element) { return cellEditor; } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public enum Gender { // MALE, FEMALE // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderEditingSupport.java import java.util.Arrays; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.model.Person.Gender; package org.fipro.eclipse.migration.e4.ui.view.overview; public class GenderEditingSupport extends EditingSupport { private ComboBoxViewerCellEditor cellEditor; public GenderEditingSupport(ColumnViewer viewer) { super(viewer); cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); cellEditor.setLabelProvider(new LabelProvider()); cellEditor.setContentProvider(new ArrayContentProvider()); cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE)); } @Override protected CellEditor getCellEditor(Object element) { return cellEditor; } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).getGender();
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/MarriedLabelProvider.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.swt.graphics.Image; import org.fipro.eclipse.migration.model.Person; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil;
package org.fipro.eclipse.migration.ui.view.overview; public class MarriedLabelProvider extends StyledCellLabelProvider { private final Image uncheckedImg; private final Image checkedImg; public MarriedLabelProvider() { LocalResourceManager resourceMgr = new LocalResourceManager(JFaceResources.getResources()); Bundle bundle = FrameworkUtil.getBundle(getClass()); URL checked = FileLocator.find(bundle, new Path("icons/checked.gif"), null); URL unchecked = FileLocator.find(bundle, new Path("icons/unchecked.gif"), null); this.checkedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(checked)); this.uncheckedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(unchecked)); } @Override public void update(ViewerCell cell) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/MarriedLabelProvider.java import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.swt.graphics.Image; import org.fipro.eclipse.migration.model.Person; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; package org.fipro.eclipse.migration.ui.view.overview; public class MarriedLabelProvider extends StyledCellLabelProvider { private final Image uncheckedImg; private final Image checkedImg; public MarriedLabelProvider() { LocalResourceManager resourceMgr = new LocalResourceManager(JFaceResources.getResources()); Bundle bundle = FrameworkUtil.getBundle(getClass()); URL checked = FileLocator.find(bundle, new Path("icons/checked.gif"), null); URL unchecked = FileLocator.find(bundle, new Path("icons/unchecked.gif"), null); this.checkedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(checked)); this.uncheckedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(unchecked)); } @Override public void update(ViewerCell cell) {
if (((Person)cell.getElement()).isMarried()) {
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/LastNameEditingSupport.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.ui.view.overview; public class LastNameEditingSupport extends EditingSupport { public LastNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/LastNameEditingSupport.java import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.ui.view.overview; public class LastNameEditingSupport extends EditingSupport { public LastNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).getLastName();
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.service/src/org/fipro/eclipse/migration/service/PersonServiceImpl.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.service; /** * Class that acts as service for accessing numerous {@link Person}s. * The values are randomly put together out of names and places from "The Simpsons" */ public class PersonServiceImpl { public static String[] maleNames = { "Bart", "Homer", "Lenny", "Carl", "Waylon", "Ned", "Timothy"}; public static String[] femaleNames = { "Marge", "Lisa", "Maggie", "Edna", "Helen", "Jessica"}; public static String[] lastNames = { "Simpson", "Leonard", "Carlson", "Smithers", "Flanders", "Krabappel", "Lovejoy"}; /** * Creates a list of {@link Person}s. * @param numberOfPersons The number of {@link Person}s that should be generated. * @return */
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.service/src/org/fipro/eclipse/migration/service/PersonServiceImpl.java import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.service; /** * Class that acts as service for accessing numerous {@link Person}s. * The values are randomly put together out of names and places from "The Simpsons" */ public class PersonServiceImpl { public static String[] maleNames = { "Bart", "Homer", "Lenny", "Carl", "Waylon", "Ned", "Timothy"}; public static String[] femaleNames = { "Marge", "Lisa", "Maggie", "Edna", "Helen", "Jessica"}; public static String[] lastNames = { "Simpson", "Leonard", "Carlson", "Smithers", "Flanders", "Krabappel", "Lovejoy"}; /** * Creates a list of {@link Person}s. * @param numberOfPersons The number of {@link Person}s that should be generated. * @return */
public static List<Person> getPersons(int numberOfPersons) {
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.service/src/org/fipro/eclipse/migration/e4/service/internal/PersonServiceImpl.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.service/src/org/fipro/eclipse/migration/e4/service/PersonService.java // public interface PersonService { // // /** // * Creates a list of {@link Person}s. // * @param numberOfPersons The number of {@link Person}s that should be generated. // * @return // */ // List<Person> getPersons(int numberOfPersons); // // /** // * Creates a random person out of names which are taken from "The Simpsons" // * and enrich them with random generated married state and birthday date. // * @return // */ // Person createPerson(int id); // }
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.service.PersonService; import org.osgi.service.component.annotations.Component;
package org.fipro.eclipse.migration.e4.service.internal; /** * Class that acts as service for accessing numerous {@link Person}s. * The values are randomly put together out of names and places from "The Simpsons" */ @Component public final class PersonServiceImpl implements PersonService { public String[] maleNames = { "Bart", "Homer", "Lenny", "Carl", "Waylon", "Ned", "Timothy"}; public String[] femaleNames = { "Marge", "Lisa", "Maggie", "Edna", "Helen", "Jessica"}; public String[] lastNames = { "Simpson", "Leonard", "Carlson", "Smithers", "Flanders", "Krabappel", "Lovejoy"}; @Override
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // // Path: e4-based-application/org.fipro.eclipse.migration.e4.service/src/org/fipro/eclipse/migration/e4/service/PersonService.java // public interface PersonService { // // /** // * Creates a list of {@link Person}s. // * @param numberOfPersons The number of {@link Person}s that should be generated. // * @return // */ // List<Person> getPersons(int numberOfPersons); // // /** // * Creates a random person out of names which are taken from "The Simpsons" // * and enrich them with random generated married state and birthday date. // * @return // */ // Person createPerson(int id); // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.service/src/org/fipro/eclipse/migration/e4/service/internal/PersonServiceImpl.java import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; import org.fipro.eclipse.migration.e4.model.Person; import org.fipro.eclipse.migration.e4.service.PersonService; import org.osgi.service.component.annotations.Component; package org.fipro.eclipse.migration.e4.service.internal; /** * Class that acts as service for accessing numerous {@link Person}s. * The values are randomly put together out of names and places from "The Simpsons" */ @Component public final class PersonServiceImpl implements PersonService { public String[] maleNames = { "Bart", "Homer", "Lenny", "Carl", "Waylon", "Ned", "Timothy"}; public String[] femaleNames = { "Marge", "Lisa", "Maggie", "Edna", "Helen", "Jessica"}; public String[] lastNames = { "Simpson", "Leonard", "Carlson", "Smithers", "Flanders", "Krabappel", "Lovejoy"}; @Override
public List<Person> getPersons(int numberOfPersons) {
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/FirstNameEditingSupport.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.ui.view.overview; public class FirstNameEditingSupport extends EditingSupport { public FirstNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/FirstNameEditingSupport.java import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.ui.view.overview; public class FirstNameEditingSupport extends EditingSupport { public FirstNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).getFirstName();
fipro78/e4-cookbook-migration-guide
e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/LastNameEditingSupport.java
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person;
package org.fipro.eclipse.migration.e4.ui.view.overview; public class LastNameEditingSupport extends EditingSupport { public LastNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
// Path: e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/LastNameEditingSupport.java import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.widgets.Composite; import org.fipro.eclipse.migration.e4.model.Person; package org.fipro.eclipse.migration.e4.ui.view.overview; public class LastNameEditingSupport extends EditingSupport { public LastNameEditingSupport(ColumnViewer viewer) { super(viewer); } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor((Composite) getViewer().getControl()); } @Override protected boolean canEdit(Object element) { return true; } @Override protected Object getValue(Object element) {
return ((Person) element).getLastName();
fipro78/e4-cookbook-migration-guide
e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/FirstNameLabelProvider.java
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // }
import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.model.Person;
package org.fipro.eclipse.migration.ui.view.overview; public class FirstNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
// Path: e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java // public class Person extends ModelObject { // // public enum Gender { // MALE, FEMALE // } // // private final int id; // private String firstName; // private String lastName; // private Gender gender; // private boolean married; // private Date birthday; // // public Person(int id) { // this.id = id; // } // // public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { // this.id = id; // this.firstName = firstName; // this.lastName = lastName; // this.gender = gender; // this.married = married; // this.birthday = birthday; // } // // public Person(Person base) { // this.id = base.id; // this.firstName = base.firstName; // this.lastName = base.lastName; // this.gender = base.gender; // this.married = base.married; // this.birthday = base.birthday; // } // // public int getId() { // return id; // } // // public String getFirstName() { // return firstName; // } // // public void setFirstName(String firstName) { // firePropertyChange("firstName", this.firstName, this.firstName = firstName); // } // // public String getLastName() { // return lastName; // } // // public void setLastName(String lastName) { // firePropertyChange("lastName", this.lastName, this.lastName = lastName); // } // // public Gender getGender() { // return gender; // } // // public void setGender(Gender gender) { // firePropertyChange("gender", this.gender, this.gender = gender); // } // // public boolean isMarried() { // return married; // } // // public void setMarried(boolean married) { // firePropertyChange("married", this.married, this.married = married); // } // // public Date getBirthday() { // return birthday; // } // // public void setBirthday(Date birthday) { // this.birthday = birthday; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + id; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Person other = (Person) obj; // if (id != other.id) // return false; // return true; // } // // } // Path: e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/FirstNameLabelProvider.java import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.ViewerCell; import org.fipro.eclipse.migration.model.Person; package org.fipro.eclipse.migration.ui.view.overview; public class FirstNameLabelProvider extends StyledCellLabelProvider { @Override public void update(ViewerCell cell) {
Person element= (Person) cell.getElement();
RestComm/sctp
sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpClientHandler.java
// Path: sctp-api/src/main/java/org/mobicents/protocols/api/IpChannelType.java // public enum IpChannelType { // SCTP(0, "SCTP"), TCP(1, "TCP"); // // int code; // String type; // // private IpChannelType(int code, String type) { // this.code = code; // this.type = type; // // } // // public int getCode() { // return this.code; // } // // public String getType() { // return type; // } // // public static IpChannelType getInstance(int code) { // switch (code) { // case 0: // return IpChannelType.SCTP; // case 1: // return IpChannelType.TCP; // } // // return null; // } // // public static IpChannelType getInstance(String type) { // if (type.equalsIgnoreCase("SCTP")) { // return SCTP; // } else if (type.equalsIgnoreCase("TCP")) { // return TCP; // } // // return null; // } // }
import java.net.InetSocketAddress; import org.apache.log4j.Logger; import org.mobicents.protocols.api.IpChannelType; import io.netty.channel.ChannelHandlerContext;
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { if (logger.isDebugEnabled()) { logger.debug(String.format("channelRegistered event: association=%s", this.association)); } } @Override public void channelActive(ChannelHandlerContext ctx) { if (logger.isDebugEnabled()) { logger.debug(String.format("channelActive event: association=%s", this.association)); } this.ctx = ctx; this.channel = ctx.channel(); this.association.setChannelHandler(this); String host = null; int port = 0; InetSocketAddress sockAdd = ((InetSocketAddress) channel.remoteAddress()); if (sockAdd != null) { host = sockAdd.getAddress().getHostAddress(); port = sockAdd.getPort(); } if (logger.isInfoEnabled()) { logger.info(String.format("Association=%s connected to host=%s port=%d", association.getName(), host, port)); }
// Path: sctp-api/src/main/java/org/mobicents/protocols/api/IpChannelType.java // public enum IpChannelType { // SCTP(0, "SCTP"), TCP(1, "TCP"); // // int code; // String type; // // private IpChannelType(int code, String type) { // this.code = code; // this.type = type; // // } // // public int getCode() { // return this.code; // } // // public String getType() { // return type; // } // // public static IpChannelType getInstance(int code) { // switch (code) { // case 0: // return IpChannelType.SCTP; // case 1: // return IpChannelType.TCP; // } // // return null; // } // // public static IpChannelType getInstance(String type) { // if (type.equalsIgnoreCase("SCTP")) { // return SCTP; // } else if (type.equalsIgnoreCase("TCP")) { // return TCP; // } // // return null; // } // } // Path: sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpClientHandler.java import java.net.InetSocketAddress; import org.apache.log4j.Logger; import org.mobicents.protocols.api.IpChannelType; import io.netty.channel.ChannelHandlerContext; @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { if (logger.isDebugEnabled()) { logger.debug(String.format("channelRegistered event: association=%s", this.association)); } } @Override public void channelActive(ChannelHandlerContext ctx) { if (logger.isDebugEnabled()) { logger.debug(String.format("channelActive event: association=%s", this.association)); } this.ctx = ctx; this.channel = ctx.channel(); this.association.setChannelHandler(this); String host = null; int port = 0; InetSocketAddress sockAdd = ((InetSocketAddress) channel.remoteAddress()); if (sockAdd != null) { host = sockAdd.getAddress().getHostAddress(); port = sockAdd.getPort(); } if (logger.isInfoEnabled()) { logger.info(String.format("Association=%s connected to host=%s port=%d", association.getName(), host, port)); }
if (association.getIpChannelType() == IpChannelType.TCP) {
NovaCrypto/Base58
src/test/java/io/github/novacrypto/base58/EncodeTargetCapacitySetTests.java
// Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // // Path: src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java // static byte[] getBytesWithMaxValue(final int byteLength) { // final byte[] bytes = new byte[byteLength]; // for (int i = 0; i < byteLength; i++) { // bytes[i] = (byte) 255; // } // return bytes; // }
import org.junit.Test; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static io.github.novacrypto.base58.CapacityCalculatorTests.getBytesWithMaxValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class EncodeTargetCapacitySetTests { static class CapacityTargetSpy implements EncodeTargetCapacity, EncodeTarget { private boolean beforeAppend = true; int capacityOnFirstAppend; @Override public void setCapacity(final int characters) { assertTrue(beforeAppend); this.capacityOnFirstAppend = characters; } @Override public void append(final char c) { beforeAppend = false; } } static class CapacityTargetSpyFromCapacity implements EncodeTargetFromCapacity { int capacitySet; final StringBuilder sb = new StringBuilder(); @Override public EncodeTarget withCapacity(final int characters) { capacitySet = characters; return sb::append; } } @Test public void sets_capacity_3bytes() { final CapacityTargetSpy spy = new CapacityTargetSpy();
// Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // // Path: src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java // static byte[] getBytesWithMaxValue(final int byteLength) { // final byte[] bytes = new byte[byteLength]; // for (int i = 0; i < byteLength; i++) { // bytes[i] = (byte) 255; // } // return bytes; // } // Path: src/test/java/io/github/novacrypto/base58/EncodeTargetCapacitySetTests.java import org.junit.Test; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static io.github.novacrypto.base58.CapacityCalculatorTests.getBytesWithMaxValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class EncodeTargetCapacitySetTests { static class CapacityTargetSpy implements EncodeTargetCapacity, EncodeTarget { private boolean beforeAppend = true; int capacityOnFirstAppend; @Override public void setCapacity(final int characters) { assertTrue(beforeAppend); this.capacityOnFirstAppend = characters; } @Override public void append(final char c) { beforeAppend = false; } } static class CapacityTargetSpyFromCapacity implements EncodeTargetFromCapacity { int capacitySet; final StringBuilder sb = new StringBuilder(); @Override public EncodeTarget withCapacity(final int characters) { capacitySet = characters; return sb::append; } } @Test public void sets_capacity_3bytes() { final CapacityTargetSpy spy = new CapacityTargetSpy();
Base58.newSecureInstance().encode(getBytesWithMaxValue(3), spy, spy);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/base58/EncodeTargetCapacitySetTests.java
// Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // // Path: src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java // static byte[] getBytesWithMaxValue(final int byteLength) { // final byte[] bytes = new byte[byteLength]; // for (int i = 0; i < byteLength; i++) { // bytes[i] = (byte) 255; // } // return bytes; // }
import org.junit.Test; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static io.github.novacrypto.base58.CapacityCalculatorTests.getBytesWithMaxValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class EncodeTargetCapacitySetTests { static class CapacityTargetSpy implements EncodeTargetCapacity, EncodeTarget { private boolean beforeAppend = true; int capacityOnFirstAppend; @Override public void setCapacity(final int characters) { assertTrue(beforeAppend); this.capacityOnFirstAppend = characters; } @Override public void append(final char c) { beforeAppend = false; } } static class CapacityTargetSpyFromCapacity implements EncodeTargetFromCapacity { int capacitySet; final StringBuilder sb = new StringBuilder(); @Override public EncodeTarget withCapacity(final int characters) { capacitySet = characters; return sb::append; } } @Test public void sets_capacity_3bytes() { final CapacityTargetSpy spy = new CapacityTargetSpy(); Base58.newSecureInstance().encode(getBytesWithMaxValue(3), spy, spy);
// Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // // Path: src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java // static byte[] getBytesWithMaxValue(final int byteLength) { // final byte[] bytes = new byte[byteLength]; // for (int i = 0; i < byteLength; i++) { // bytes[i] = (byte) 255; // } // return bytes; // } // Path: src/test/java/io/github/novacrypto/base58/EncodeTargetCapacitySetTests.java import org.junit.Test; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static io.github.novacrypto.base58.CapacityCalculatorTests.getBytesWithMaxValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class EncodeTargetCapacitySetTests { static class CapacityTargetSpy implements EncodeTargetCapacity, EncodeTarget { private boolean beforeAppend = true; int capacityOnFirstAppend; @Override public void setCapacity(final int characters) { assertTrue(beforeAppend); this.capacityOnFirstAppend = characters; } @Override public void append(final char c) { beforeAppend = false; } } static class CapacityTargetSpyFromCapacity implements EncodeTargetFromCapacity { int capacitySet; final StringBuilder sb = new StringBuilder(); @Override public EncodeTarget withCapacity(final int characters) { capacitySet = characters; return sb::append; } } @Test public void sets_capacity_3bytes() { final CapacityTargetSpy spy = new CapacityTargetSpy(); Base58.newSecureInstance().encode(getBytesWithMaxValue(3), spy, spy);
assertEquals(maximumBase58StringLength(3), spy.capacityOnFirstAppend);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/BufferClearTests.java
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // }
import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; public final class BufferClearTests { @Test public void clearsBufferAfterEncode() { final SpyWorkingBuffer spy = givenSpyBuffer();
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // } // Path: src/test/java/io/github/novacrypto/BufferClearTests.java import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; public final class BufferClearTests { @Test public void clearsBufferAfterEncode() { final SpyWorkingBuffer spy = givenSpyBuffer();
final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(spy);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/BufferClearTests.java
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // }
import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; public final class BufferClearTests { @Test public void clearsBufferAfterEncode() { final SpyWorkingBuffer spy = givenSpyBuffer();
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // } // Path: src/test/java/io/github/novacrypto/BufferClearTests.java import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; public final class BufferClearTests { @Test public void clearsBufferAfterEncode() { final SpyWorkingBuffer spy = givenSpyBuffer();
final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(spy);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/BufferClearTests.java
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // }
import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals;
final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingPut(spy)); assertThatThrownBy(() -> encoder.encode(new byte[]{(byte) 1})) .hasMessage("Can't put"); spy.assertClearedLast(); } @Test public void clearsBufferOnGetExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingGet(spy)); assertThatThrownBy(() -> encoder.decode("a")) .hasMessage("Can't get"); spy.assertClearedLast(); } @Test public void clearsBufferOnPutExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingPut(spy)); assertThatThrownBy(() -> encoder.decode("a")) .hasMessage("Can't put"); spy.assertClearedLast(); } @Test public void clearsBufferOnBadCharExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingGet(spy)); assertThatThrownBy(() -> encoder.decode("0"))
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // } // Path: src/test/java/io/github/novacrypto/BufferClearTests.java import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingPut(spy)); assertThatThrownBy(() -> encoder.encode(new byte[]{(byte) 1})) .hasMessage("Can't put"); spy.assertClearedLast(); } @Test public void clearsBufferOnGetExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingGet(spy)); assertThatThrownBy(() -> encoder.decode("a")) .hasMessage("Can't get"); spy.assertClearedLast(); } @Test public void clearsBufferOnPutExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingPut(spy)); assertThatThrownBy(() -> encoder.decode("a")) .hasMessage("Can't put"); spy.assertClearedLast(); } @Test public void clearsBufferOnBadCharExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(throwingGet(spy)); assertThatThrownBy(() -> encoder.decode("0"))
.isInstanceOf(BadCharacterException.class);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/BufferClearTests.java
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // }
import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals;
@Test public void clearsBufferOnCharSequenceExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(spy); assertThatThrownBy(() -> encoder.decode(throwingCharSequence())) .hasMessage("Bad CharSequence"); spy.assertClearedLast(); } private CharSequence throwingCharSequence() { return new CharSequence() { @Override public int length() { return 10; } @Override public char charAt(final int index) { if (index < 5) return 'a'; throw new RuntimeException("Bad CharSequence"); } @Override public CharSequence subSequence(final int start, final int end) { return null; } }; }
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // } // Path: src/test/java/io/github/novacrypto/BufferClearTests.java import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; @Test public void clearsBufferOnCharSequenceExceptionDuringDecode() { final SpyWorkingBuffer spy = givenSpyBuffer(); final GeneralEncoderDecoder encoder = Base58.newInstanceWithBuffer(spy); assertThatThrownBy(() -> encoder.decode(throwingCharSequence())) .hasMessage("Bad CharSequence"); spy.assertClearedLast(); } private CharSequence throwingCharSequence() { return new CharSequence() { @Override public int length() { return 10; } @Override public char charAt(final int index) { if (index < 5) return 'a'; throw new RuntimeException("Bad CharSequence"); } @Override public CharSequence subSequence(final int start, final int end) { return null; } }; }
private WorkingBuffer throwingGet(final WorkingBuffer buffer) {
NovaCrypto/Base58
src/test/java/io/github/novacrypto/BufferClearTests.java
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // }
import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals;
private CharSequence throwingCharSequence() { return new CharSequence() { @Override public int length() { return 10; } @Override public char charAt(final int index) { if (index < 5) return 'a'; throw new RuntimeException("Bad CharSequence"); } @Override public CharSequence subSequence(final int start, final int end) { return null; } }; } private WorkingBuffer throwingGet(final WorkingBuffer buffer) { return new ThrowingGet(buffer); } private WorkingBuffer throwingPut(final WorkingBuffer buffer) { return new ThrowingPut(buffer); } private SpyWorkingBuffer givenSpyBuffer() {
// Path: src/main/java/io/github/novacrypto/base58/BadCharacterException.java // public final class BadCharacterException extends RuntimeException { // // public BadCharacterException(final char charAtI) { // super("Bad character in base58 string, '" + charAtI + "'"); // } // } // // Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/ByteArrayWorkingBuffer.java // public final class ByteArrayWorkingBuffer implements WorkingBuffer { // // private static final byte[] EMPTY = new byte[0]; // // private byte[] bytes = EMPTY; // // @Override // public void setCapacity(final int atLeast) { // bytes = ensureCapacity(bytes, atLeast); // clear(bytes); // } // // @Override // public byte get(final int index) { // return bytes[index]; // } // // @Override // public void put(final int index, final byte value) { // bytes[index] = value; // } // // @Override // public void clear() { // clear(bytes); // } // // private static byte[] ensureCapacity(final byte[] bytes, final int atLeast) { // if (bytes.length >= atLeast) { // return bytes; // } // clear(bytes); // return new byte[atLeast]; // } // // private static void clear(final byte[] bytes) { // Arrays.fill(bytes, (byte) 255); // } // } // // Path: src/main/java/io/github/novacrypto/base58/GeneralEncoderDecoder.java // public interface GeneralEncoderDecoder extends EncoderDecoder, SecureEncoderDecoder { // } // // Path: src/main/java/io/github/novacrypto/base58/WorkingBuffer.java // public interface WorkingBuffer { // void setCapacity(int atLeast); // // byte get(int index); // // void put(int index, byte value); // // void clear(); // } // Path: src/test/java/io/github/novacrypto/BufferClearTests.java import io.github.novacrypto.base58.BadCharacterException; import io.github.novacrypto.base58.Base58; import io.github.novacrypto.base58.ByteArrayWorkingBuffer; import io.github.novacrypto.base58.GeneralEncoderDecoder; import io.github.novacrypto.base58.WorkingBuffer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; private CharSequence throwingCharSequence() { return new CharSequence() { @Override public int length() { return 10; } @Override public char charAt(final int index) { if (index < 5) return 'a'; throw new RuntimeException("Bad CharSequence"); } @Override public CharSequence subSequence(final int start, final int end) { return null; } }; } private WorkingBuffer throwingGet(final WorkingBuffer buffer) { return new ThrowingGet(buffer); } private WorkingBuffer throwingPut(final WorkingBuffer buffer) { return new ThrowingPut(buffer); } private SpyWorkingBuffer givenSpyBuffer() {
final WorkingBuffer buffer = new ByteArrayWorkingBuffer();
NovaCrypto/Base58
src/test/java/io/github/novacrypto/Base58ResourceTestVectors.java
// Path: src/test/java/io/github/novacrypto/base58/json/TestVector.java // public final class TestVector { // // @SerializedName("dataHex") // public String dataHex; // // @SerializedName("dataBase58") // public String dataBase58; // } // // Path: src/test/java/io/github/novacrypto/base58/json/TestVectorCollection.java // public final class TestVectorCollection { // public List<TestVector> vectors; // }
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.json.TestVector; import io.github.novacrypto.base58.json.TestVectorCollection; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.Arrays; import java.util.Collection;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; @RunWith(Parameterized.class) public final class Base58ResourceTestVectors { @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][]{ {"LargeCase.json"}, {"OneByte.json"}, {"Random82Length.json"}, {"RandomDecreasingLength.json"}, {"RandomIncreasingLength.json"} }); }
// Path: src/test/java/io/github/novacrypto/base58/json/TestVector.java // public final class TestVector { // // @SerializedName("dataHex") // public String dataHex; // // @SerializedName("dataBase58") // public String dataBase58; // } // // Path: src/test/java/io/github/novacrypto/base58/json/TestVectorCollection.java // public final class TestVectorCollection { // public List<TestVector> vectors; // } // Path: src/test/java/io/github/novacrypto/Base58ResourceTestVectors.java import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.json.TestVector; import io.github.novacrypto.base58.json.TestVectorCollection; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.Arrays; import java.util.Collection; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; @RunWith(Parameterized.class) public final class Base58ResourceTestVectors { @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][]{ {"LargeCase.json"}, {"OneByte.json"}, {"Random82Length.json"}, {"RandomDecreasingLength.json"}, {"RandomIncreasingLength.json"} }); }
private final TestVectorCollection collection;
NovaCrypto/Base58
src/test/java/io/github/novacrypto/Base58ResourceTestVectors.java
// Path: src/test/java/io/github/novacrypto/base58/json/TestVector.java // public final class TestVector { // // @SerializedName("dataHex") // public String dataHex; // // @SerializedName("dataBase58") // public String dataBase58; // } // // Path: src/test/java/io/github/novacrypto/base58/json/TestVectorCollection.java // public final class TestVectorCollection { // public List<TestVector> vectors; // }
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.json.TestVector; import io.github.novacrypto.base58.json.TestVectorCollection; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.Arrays; import java.util.Collection;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; @RunWith(Parameterized.class) public final class Base58ResourceTestVectors { @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][]{ {"LargeCase.json"}, {"OneByte.json"}, {"Random82Length.json"}, {"RandomDecreasingLength.json"}, {"RandomIncreasingLength.json"} }); } private final TestVectorCollection collection; public Base58ResourceTestVectors(final String resourceName) { collection = Resources.loadJsonResource(resourceName, TestVectorCollection.class); } @Test public void encodeStatic() {
// Path: src/test/java/io/github/novacrypto/base58/json/TestVector.java // public final class TestVector { // // @SerializedName("dataHex") // public String dataHex; // // @SerializedName("dataBase58") // public String dataBase58; // } // // Path: src/test/java/io/github/novacrypto/base58/json/TestVectorCollection.java // public final class TestVectorCollection { // public List<TestVector> vectors; // } // Path: src/test/java/io/github/novacrypto/Base58ResourceTestVectors.java import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.json.TestVector; import io.github.novacrypto.base58.json.TestVectorCollection; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.Arrays; import java.util.Collection; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; @RunWith(Parameterized.class) public final class Base58ResourceTestVectors { @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][]{ {"LargeCase.json"}, {"OneByte.json"}, {"Random82Length.json"}, {"RandomDecreasingLength.json"}, {"RandomIncreasingLength.json"} }); } private final TestVectorCollection collection; public Base58ResourceTestVectors(final String resourceName) { collection = Resources.loadJsonResource(resourceName, TestVectorCollection.class); } @Test public void encodeStatic() {
for (final TestVector vector : collection.vectors) {
NovaCrypto/Base58
src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // }
import static io.github.novacrypto.base58.Base58.base58Encode; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static org.junit.Assert.assertEquals; import org.junit.Test;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class CapacityCalculatorTests { @Test public void capacity_of_low_byte_lengths() { for (int byteLength = 0; byteLength < 1000; byteLength++) {
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // Path: src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java import static io.github.novacrypto.base58.Base58.base58Encode; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static org.junit.Assert.assertEquals; import org.junit.Test; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class CapacityCalculatorTests { @Test public void capacity_of_low_byte_lengths() { for (int byteLength = 0; byteLength < 1000; byteLength++) {
assertEquals(actualMaxLengthOfBytes(byteLength), maximumBase58StringLength(byteLength));
NovaCrypto/Base58
src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // }
import static io.github.novacrypto.base58.Base58.base58Encode; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static org.junit.Assert.assertEquals; import org.junit.Test;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class CapacityCalculatorTests { @Test public void capacity_of_low_byte_lengths() { for (int byteLength = 0; byteLength < 1000; byteLength++) { assertEquals(actualMaxLengthOfBytes(byteLength), maximumBase58StringLength(byteLength)); } } @Test public void capacity_of_higher_byte_lengths() { for (int byteLength = 2000; byteLength < 2050; byteLength++) { assertEquals(actualMaxLengthOfBytes(byteLength), maximumBase58StringLength(byteLength)); } } private static int actualMaxLengthOfBytes(final int byteLength) {
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // Path: src/test/java/io/github/novacrypto/base58/CapacityCalculatorTests.java import static io.github.novacrypto.base58.Base58.base58Encode; import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import static org.junit.Assert.assertEquals; import org.junit.Test; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; public final class CapacityCalculatorTests { @Test public void capacity_of_low_byte_lengths() { for (int byteLength = 0; byteLength < 1000; byteLength++) { assertEquals(actualMaxLengthOfBytes(byteLength), maximumBase58StringLength(byteLength)); } } @Test public void capacity_of_higher_byte_lengths() { for (int byteLength = 2000; byteLength < 2050; byteLength++) { assertEquals(actualMaxLengthOfBytes(byteLength), maximumBase58StringLength(byteLength)); } } private static int actualMaxLengthOfBytes(final int byteLength) {
return base58Encode(getBytesWithMaxValue(byteLength)).length();
NovaCrypto/Base58
src/main/java/io/github/novacrypto/base58/Base58EncoderDecoder.java
// Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // }
import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import java.util.Arrays;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; final class Base58EncoderDecoder implements GeneralEncoderDecoder { private static final char[] DIGITS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray(); private static final int[] VALUES = initValues(DIGITS); private final WorkingBuffer workingBuffer; private final StringBuilderEncodeTarget target = new StringBuilderEncodeTarget(); Base58EncoderDecoder(final WorkingBuffer workingBuffer) { this.workingBuffer = workingBuffer; } @Override public String encode(final byte[] bytes) { target.clear(); encode(bytes, target, target); return target.toString(); } @Override public void encode(final byte[] bytes, final EncodeTargetFromCapacity target) {
// Path: src/main/java/io/github/novacrypto/base58/CapacityCalculator.java // static int maximumBase58StringLength(final int byteLength) { // return (int) Math.ceil(byteLength * storageRatio); // } // Path: src/main/java/io/github/novacrypto/base58/Base58EncoderDecoder.java import static io.github.novacrypto.base58.CapacityCalculator.maximumBase58StringLength; import java.util.Arrays; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto.base58; final class Base58EncoderDecoder implements GeneralEncoderDecoder { private static final char[] DIGITS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray(); private static final int[] VALUES = initValues(DIGITS); private final WorkingBuffer workingBuffer; private final StringBuilderEncodeTarget target = new StringBuilderEncodeTarget(); Base58EncoderDecoder(final WorkingBuffer workingBuffer) { this.workingBuffer = workingBuffer; } @Override public String encode(final byte[] bytes) { target.clear(); encode(bytes, target, target); return target.toString(); } @Override public void encode(final byte[] bytes, final EncodeTargetFromCapacity target) {
final int characters = maximumBase58StringLength(bytes.length);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/Base58EncodeTests.java
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/EncodeTarget.java // public interface EncodeTarget { // void append(char c); // }
import io.github.novacrypto.base58.EncodeTarget; import org.junit.Test; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.Base58;
@Test public void twoFiveFiveByteArrayLength1() { assertBase58("5Q", new byte[]{(byte) 255}); } @Test public void twoFiveFiveByteArrayLength2() { assertBase58("LUv", new byte[]{(byte) 255, (byte) 255}); } @Test public void allByteValues() { final byte[] bytes = new byte[256]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) i; } assertBase58( "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY", bytes); } private void assertBase58(final String expected, final byte[] bytes) { assertEquals(expected, base58InstanceEncode(bytes)); assertEquals(expected, base58StaticEncode(bytes)); assertEquals(expected, base58SecureInstanceEncode(bytes)); assertEquals(expected, base58SecureInstanceEncodeSetCapacity(bytes)); assertEquals(expected, base58SecureInstanceEncodeFluentCapacity(bytes)); } static String base58InstanceEncode(final byte[] bytes) {
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/EncodeTarget.java // public interface EncodeTarget { // void append(char c); // } // Path: src/test/java/io/github/novacrypto/Base58EncodeTests.java import io.github.novacrypto.base58.EncodeTarget; import org.junit.Test; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.Base58; @Test public void twoFiveFiveByteArrayLength1() { assertBase58("5Q", new byte[]{(byte) 255}); } @Test public void twoFiveFiveByteArrayLength2() { assertBase58("LUv", new byte[]{(byte) 255, (byte) 255}); } @Test public void allByteValues() { final byte[] bytes = new byte[256]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) i; } assertBase58( "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY", bytes); } private void assertBase58(final String expected, final byte[] bytes) { assertEquals(expected, base58InstanceEncode(bytes)); assertEquals(expected, base58StaticEncode(bytes)); assertEquals(expected, base58SecureInstanceEncode(bytes)); assertEquals(expected, base58SecureInstanceEncodeSetCapacity(bytes)); assertEquals(expected, base58SecureInstanceEncodeFluentCapacity(bytes)); } static String base58InstanceEncode(final byte[] bytes) {
return Base58.newInstance().encode(bytes);
NovaCrypto/Base58
src/test/java/io/github/novacrypto/Base58EncodeTests.java
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/EncodeTarget.java // public interface EncodeTarget { // void append(char c); // }
import io.github.novacrypto.base58.EncodeTarget; import org.junit.Test; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.Base58;
@Test public void twoFiveFiveByteArrayLength2() { assertBase58("LUv", new byte[]{(byte) 255, (byte) 255}); } @Test public void allByteValues() { final byte[] bytes = new byte[256]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) i; } assertBase58( "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY", bytes); } private void assertBase58(final String expected, final byte[] bytes) { assertEquals(expected, base58InstanceEncode(bytes)); assertEquals(expected, base58StaticEncode(bytes)); assertEquals(expected, base58SecureInstanceEncode(bytes)); assertEquals(expected, base58SecureInstanceEncodeSetCapacity(bytes)); assertEquals(expected, base58SecureInstanceEncodeFluentCapacity(bytes)); } static String base58InstanceEncode(final byte[] bytes) { return Base58.newInstance().encode(bytes); } static String base58SecureInstanceEncode(final byte[] bytes) {
// Path: src/main/java/io/github/novacrypto/base58/Base58.java // public final class Base58 { // // Base58() { // } // // public static GeneralEncoderDecoder newInstanceWithBuffer(final WorkingBuffer workingBuffer) { // return new Base58EncoderDecoder(workingBuffer); // } // // public static EncoderDecoder newInstance() { // return newInstanceWithBuffer(new ByteArrayWorkingBuffer()); // } // // public static SecureEncoderDecoder newSecureInstance() { // return newInstanceWithBuffer(new SecureWorkingBuffer()); // } // // private static final ThreadLocal<EncoderDecoder> working = new ThreadLocal<>(); // // /** // * Encodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param bytes bytes to encode // * @return base58 string representation // */ // public static String base58Encode(final byte[] bytes) { // return getThreadSharedBase58().encode(bytes); // } // // /** // * Decodes given bytes as a number in base58. // * Threadsafe, uses an instance per thread. // * // * @param base58 string to decode // * @return number as bytes // */ // public static byte[] base58Decode(final CharSequence base58) { // return getThreadSharedBase58().decode(base58); // } // // private static EncoderDecoder getThreadSharedBase58() { // EncoderDecoder base58 = working.get(); // if (base58 == null) { // base58 = newInstance(); // working.set(base58); // } // return base58; // } // } // // Path: src/main/java/io/github/novacrypto/base58/EncodeTarget.java // public interface EncodeTarget { // void append(char c); // } // Path: src/test/java/io/github/novacrypto/Base58EncodeTests.java import io.github.novacrypto.base58.EncodeTarget; import org.junit.Test; import static org.junit.Assert.assertEquals; import io.github.novacrypto.base58.Base58; @Test public void twoFiveFiveByteArrayLength2() { assertBase58("LUv", new byte[]{(byte) 255, (byte) 255}); } @Test public void allByteValues() { final byte[] bytes = new byte[256]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) i; } assertBase58( "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY", bytes); } private void assertBase58(final String expected, final byte[] bytes) { assertEquals(expected, base58InstanceEncode(bytes)); assertEquals(expected, base58StaticEncode(bytes)); assertEquals(expected, base58SecureInstanceEncode(bytes)); assertEquals(expected, base58SecureInstanceEncodeSetCapacity(bytes)); assertEquals(expected, base58SecureInstanceEncodeFluentCapacity(bytes)); } static String base58InstanceEncode(final byte[] bytes) { return Base58.newInstance().encode(bytes); } static String base58SecureInstanceEncode(final byte[] bytes) {
final EncodeTarget target = new InsecureStringBufferEncodeTarget();
NovaCrypto/Base58
src/test/java/io/github/novacrypto/InsecureByteArrayTarget.java
// Path: src/main/java/io/github/novacrypto/base58/DecodeTarget.java // public interface DecodeTarget { // DecodeWriter getWriterForLength(int len); // } // // Path: src/main/java/io/github/novacrypto/base58/DecodeWriter.java // public interface DecodeWriter { // void append(byte b); // }
import io.github.novacrypto.base58.DecodeWriter; import io.github.novacrypto.base58.DecodeTarget;
/* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; final class InsecureByteArrayTarget implements DecodeTarget { private int idx = 0; private byte[] bytes; @Override
// Path: src/main/java/io/github/novacrypto/base58/DecodeTarget.java // public interface DecodeTarget { // DecodeWriter getWriterForLength(int len); // } // // Path: src/main/java/io/github/novacrypto/base58/DecodeWriter.java // public interface DecodeWriter { // void append(byte b); // } // Path: src/test/java/io/github/novacrypto/InsecureByteArrayTarget.java import io.github.novacrypto.base58.DecodeWriter; import io.github.novacrypto.base58.DecodeTarget; /* * Base58 library, a Java implementation of Base58 encode/decode * Copyright (C) 2017-2019 Alan Evans, NovaCrypto * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * Original source: https://github.com/NovaCrypto/Base58 * You can contact the authors via github issues. */ package io.github.novacrypto; final class InsecureByteArrayTarget implements DecodeTarget { private int idx = 0; private byte[] bytes; @Override
public DecodeWriter getWriterForLength(final int len) {
confabulation/symbolic
java_sentence_completion/src/sparse/int_/CSR2Dint.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSR2Dfloat.java // package sparse.int_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dint extends Matrix2Dint { protected int[] A; protected int[] IA; protected int[] JA; public CSR2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/int_/CSR2Dint.java import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSR2Dfloat.java // package sparse.int_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dint extends Matrix2Dint { protected int[] A; protected int[] IA; protected int[] JA; public CSR2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line
TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();
confabulation/symbolic
java_sentence_completion/src/sparse/int_/CSR2Dint.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSR2Dfloat.java // package sparse.int_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dint extends Matrix2Dint { protected int[] A; protected int[] IA; protected int[] JA; public CSR2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/int_/CSR2Dint.java import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSR2Dfloat.java // package sparse.int_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dint extends Matrix2Dint { protected int[] A; protected int[] IA; protected int[] JA; public CSR2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();
for (Entry<Pair<Integer, Integer>, Integer> e : m.nz_elements()) {
confabulation/symbolic
java_sentence_completion/src/utils/test/ArrayTools2DTest.java
// Path: java_sentence_completion/src/utils/ArrayTools2D.java // public class ArrayTools2D { // /** // * Returns a copy of the elements array[i][j], with i in [a1, b1[ and j in // * [a2, b2[ // * <p> // * TODO improve algorithm so to tolerate out of range indexes (see the // * advanced test) // * </p> // * // * @param array // * 2D array. External array cannot contain null values and must // * be at least contain a single sub-array. // * @param a1 // * <= b1 // * @param a2 // * <= b2 // * @param b1 // * all lines from a1 included to b1 excluded are copied // * @param b2 // * in those lines, only the indexes from a2 included to b2 // * excluded are copied // * @return the copied rectangle // */ // public static <T> T[][] copyOfRectangle(T[][] array, int a1, int a2, // int b1, int b2) { // if (b1 - a1 < 0) { // throw new IllegalArgumentException("b1 (" + b1 + ") - a1 (" + a1 // + ") < 0"); // } // if (b2 - a2 < 0) { // throw new IllegalArgumentException("b2 (" + b2 + ") - a2 (" + a2 // + ") < 0"); // } // T[][] ret = Arrays.copyOf(array, b1 - a1); // for (int i = 0; i < ret.length; i++) { // if (0 <= a1 + i && a1 + i < array.length) { // ret[i] = Arrays.copyOfRange(array[a1 + i], a2, b2); // } else { // ret[i] = Arrays.copyOfRange(array[0], a2, b2); // Arrays.fill(ret[i], null); // } // } // return ret; // } // }
import utils.ArrayTools2D; import static org.junit.Assert.*; import org.junit.Ignore; import org.junit.Test;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package utils.test; public class ArrayTools2DTest { @Test public void copyOfRectangle() { Integer[][] value; Integer[][] array = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; Integer[][] expected1 = {{ 8, 9}};
// Path: java_sentence_completion/src/utils/ArrayTools2D.java // public class ArrayTools2D { // /** // * Returns a copy of the elements array[i][j], with i in [a1, b1[ and j in // * [a2, b2[ // * <p> // * TODO improve algorithm so to tolerate out of range indexes (see the // * advanced test) // * </p> // * // * @param array // * 2D array. External array cannot contain null values and must // * be at least contain a single sub-array. // * @param a1 // * <= b1 // * @param a2 // * <= b2 // * @param b1 // * all lines from a1 included to b1 excluded are copied // * @param b2 // * in those lines, only the indexes from a2 included to b2 // * excluded are copied // * @return the copied rectangle // */ // public static <T> T[][] copyOfRectangle(T[][] array, int a1, int a2, // int b1, int b2) { // if (b1 - a1 < 0) { // throw new IllegalArgumentException("b1 (" + b1 + ") - a1 (" + a1 // + ") < 0"); // } // if (b2 - a2 < 0) { // throw new IllegalArgumentException("b2 (" + b2 + ") - a2 (" + a2 // + ") < 0"); // } // T[][] ret = Arrays.copyOf(array, b1 - a1); // for (int i = 0; i < ret.length; i++) { // if (0 <= a1 + i && a1 + i < array.length) { // ret[i] = Arrays.copyOfRange(array[a1 + i], a2, b2); // } else { // ret[i] = Arrays.copyOfRange(array[0], a2, b2); // Arrays.fill(ret[i], null); // } // } // return ret; // } // } // Path: java_sentence_completion/src/utils/test/ArrayTools2DTest.java import utils.ArrayTools2D; import static org.junit.Assert.*; import org.junit.Ignore; import org.junit.Test; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package utils.test; public class ArrayTools2DTest { @Test public void copyOfRectangle() { Integer[][] value; Integer[][] array = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; Integer[][] expected1 = {{ 8, 9}};
value = ArrayTools2D.copyOfRectangle(array, 2, 1, 3, 3);
confabulation/symbolic
java_sentence_completion/src/sparse/int_/Matrix2Dint.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // }
import sparse.Pair; import java.util.Map.Entry; import java.util.Set;
* column number * @throws IndexOutOfBoundsException * if l or c is not in the matrix bounds */ protected void check_bounds(int l, int c) throws IndexOutOfBoundsException { // bounds if (l >= nlines || c >= ncols) { throw new IndexOutOfBoundsException(l + " >= " + nlines + " or " + c + " >= " + ncols); } if (l < 0 || c < 0) { throw new IndexOutOfBoundsException("l (" + l + ") < 0 or c (" + c + ") <0"); } } /** * Multiplies the matrix by the given vector * * @param vec * non-null * @return the result in a new vector */ public abstract DOK1Dint multiply(DOK1Dint vec); /** * returns a set of the non-zero elements * * @return the non-zero elements */
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // Path: java_sentence_completion/src/sparse/int_/Matrix2Dint.java import sparse.Pair; import java.util.Map.Entry; import java.util.Set; * column number * @throws IndexOutOfBoundsException * if l or c is not in the matrix bounds */ protected void check_bounds(int l, int c) throws IndexOutOfBoundsException { // bounds if (l >= nlines || c >= ncols) { throw new IndexOutOfBoundsException(l + " >= " + nlines + " or " + c + " >= " + ncols); } if (l < 0 || c < 0) { throw new IndexOutOfBoundsException("l (" + l + ") < 0 or c (" + c + ") <0"); } } /** * Multiplies the matrix by the given vector * * @param vec * non-null * @return the result in a new vector */ public abstract DOK1Dint multiply(DOK1Dint vec); /** * returns a set of the non-zero elements * * @return the non-zero elements */
public abstract Set<Entry<Pair<Integer, Integer>, Integer>> nz_elements();
confabulation/symbolic
java_sentence_completion/src/sparse/int_/CSC2Dint.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSC2Dfloat.java // package sparse.int_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dint extends Matrix2Dint { protected final int[] A; protected final int[] IA; protected final int[] JA; public CSC2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/int_/CSC2Dint.java import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSC2Dfloat.java // package sparse.int_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dint extends Matrix2Dint { protected final int[] A; protected final int[] IA; protected final int[] JA; public CSC2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column
TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();
confabulation/symbolic
java_sentence_completion/src/sparse/int_/CSC2Dint.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSC2Dfloat.java // package sparse.int_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dint extends Matrix2Dint { protected final int[] A; protected final int[] IA; protected final int[] JA; public CSC2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/int_/CSC2Dint.java import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ // // Auto-generated file from float_/CSC2Dfloat.java // package sparse.int_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dint extends Matrix2Dint { protected final int[] A; protected final int[] IA; protected final int[] JA; public CSC2Dint(Matrix2Dint m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new int[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();
for (Entry<Pair<Integer, Integer>, Integer> e : m.nz_elements()) {
confabulation/symbolic
java_sentence_completion/src/parser/GenericSymbolParser.java
// Path: java_sentence_completion/src/utils/RuntimeIOException.java // public class RuntimeIOException extends RuntimeException { // // private static final long serialVersionUID = -1399650097256466789L; // // public RuntimeIOException() { // super(); // } // // public RuntimeIOException(String message) { // super(message); // } // // public RuntimeIOException(Throwable cause) { // super(cause); // } // // public RuntimeIOException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: java_sentence_completion/src/utils/ArrayTools.java // public static boolean in(boolean elem, boolean... list) { // if (list == null) { // return false; // } // for (boolean e : list) { // if (elem == e) { // return true; // } // } // return false; // }
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import utils.RuntimeIOException; import static utils.ArrayTools.in;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package parser; /** * A parametric parser. * <p> * The essential parameter is the {@link Tokenizer} which controls the parsing * process. * </p> * * @author bernard and Cédric * */ public class GenericSymbolParser { protected FileInputStream fis; // private BufferedInputStream bis; // private DataInputStream stream; protected BufferedReader stream; String file; protected Tokenizer tok; /** * whether the parser is at the beginning of the file */ protected boolean head_of_file; /** * Open the file for reading. Parses the line word by word * * @param file * non-null, a readable file */ public GenericSymbolParser(String file) throws IOException { this(file, new WordTokenizer()); } /** * Open the file for reading * * @param file * non-null, a readable file * @param tok * non-null the tokenizer * @throws IOException */ public GenericSymbolParser(String file, Tokenizer tok) throws IOException {
// Path: java_sentence_completion/src/utils/RuntimeIOException.java // public class RuntimeIOException extends RuntimeException { // // private static final long serialVersionUID = -1399650097256466789L; // // public RuntimeIOException() { // super(); // } // // public RuntimeIOException(String message) { // super(message); // } // // public RuntimeIOException(Throwable cause) { // super(cause); // } // // public RuntimeIOException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: java_sentence_completion/src/utils/ArrayTools.java // public static boolean in(boolean elem, boolean... list) { // if (list == null) { // return false; // } // for (boolean e : list) { // if (elem == e) { // return true; // } // } // return false; // } // Path: java_sentence_completion/src/parser/GenericSymbolParser.java import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import utils.RuntimeIOException; import static utils.ArrayTools.in; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package parser; /** * A parametric parser. * <p> * The essential parameter is the {@link Tokenizer} which controls the parsing * process. * </p> * * @author bernard and Cédric * */ public class GenericSymbolParser { protected FileInputStream fis; // private BufferedInputStream bis; // private DataInputStream stream; protected BufferedReader stream; String file; protected Tokenizer tok; /** * whether the parser is at the beginning of the file */ protected boolean head_of_file; /** * Open the file for reading. Parses the line word by word * * @param file * non-null, a readable file */ public GenericSymbolParser(String file) throws IOException { this(file, new WordTokenizer()); } /** * Open the file for reading * * @param file * non-null, a readable file * @param tok * non-null the tokenizer * @throws IOException */ public GenericSymbolParser(String file, Tokenizer tok) throws IOException {
if (in(null, file, tok)) {
confabulation/symbolic
java_sentence_completion/src/parser/GenericSymbolParser.java
// Path: java_sentence_completion/src/utils/RuntimeIOException.java // public class RuntimeIOException extends RuntimeException { // // private static final long serialVersionUID = -1399650097256466789L; // // public RuntimeIOException() { // super(); // } // // public RuntimeIOException(String message) { // super(message); // } // // public RuntimeIOException(Throwable cause) { // super(cause); // } // // public RuntimeIOException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: java_sentence_completion/src/utils/ArrayTools.java // public static boolean in(boolean elem, boolean... list) { // if (list == null) { // return false; // } // for (boolean e : list) { // if (elem == e) { // return true; // } // } // return false; // }
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import utils.RuntimeIOException; import static utils.ArrayTools.in;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package parser; /** * A parametric parser. * <p> * The essential parameter is the {@link Tokenizer} which controls the parsing * process. * </p> * * @author bernard and Cédric * */ public class GenericSymbolParser { protected FileInputStream fis; // private BufferedInputStream bis; // private DataInputStream stream; protected BufferedReader stream; String file; protected Tokenizer tok; /** * whether the parser is at the beginning of the file */ protected boolean head_of_file; /** * Open the file for reading. Parses the line word by word * * @param file * non-null, a readable file */ public GenericSymbolParser(String file) throws IOException { this(file, new WordTokenizer()); } /** * Open the file for reading * * @param file * non-null, a readable file * @param tok * non-null the tokenizer * @throws IOException */ public GenericSymbolParser(String file, Tokenizer tok) throws IOException { if (in(null, file, tok)) { throw new NullPointerException("file (" + file + "), or mtok (" + tok + ") is null"); } this.file = file; if (!new File(file).canRead()) { throw new FileNotFoundException(file + " doesn't exists"); } this.tok = tok; fis = null; stream = null; head_of_file = true; try { fis = new FileInputStream(file); // Here BufferedInputStream is added for fast reading. // bis = new BufferedInputStream(fis); // stream = new DataInputStream(bis); stream = new BufferedReader(new InputStreamReader(fis, "UTF-8")); } catch (IOException e) { e.printStackTrace(); } } /** * Closes and reopens file, without relinquishing all the file descriptors * * @throws RuntimeIOException * when an {@link IOException} occurs */
// Path: java_sentence_completion/src/utils/RuntimeIOException.java // public class RuntimeIOException extends RuntimeException { // // private static final long serialVersionUID = -1399650097256466789L; // // public RuntimeIOException() { // super(); // } // // public RuntimeIOException(String message) { // super(message); // } // // public RuntimeIOException(Throwable cause) { // super(cause); // } // // public RuntimeIOException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: java_sentence_completion/src/utils/ArrayTools.java // public static boolean in(boolean elem, boolean... list) { // if (list == null) { // return false; // } // for (boolean e : list) { // if (elem == e) { // return true; // } // } // return false; // } // Path: java_sentence_completion/src/parser/GenericSymbolParser.java import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import utils.RuntimeIOException; import static utils.ArrayTools.in; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package parser; /** * A parametric parser. * <p> * The essential parameter is the {@link Tokenizer} which controls the parsing * process. * </p> * * @author bernard and Cédric * */ public class GenericSymbolParser { protected FileInputStream fis; // private BufferedInputStream bis; // private DataInputStream stream; protected BufferedReader stream; String file; protected Tokenizer tok; /** * whether the parser is at the beginning of the file */ protected boolean head_of_file; /** * Open the file for reading. Parses the line word by word * * @param file * non-null, a readable file */ public GenericSymbolParser(String file) throws IOException { this(file, new WordTokenizer()); } /** * Open the file for reading * * @param file * non-null, a readable file * @param tok * non-null the tokenizer * @throws IOException */ public GenericSymbolParser(String file, Tokenizer tok) throws IOException { if (in(null, file, tok)) { throw new NullPointerException("file (" + file + "), or mtok (" + tok + ") is null"); } this.file = file; if (!new File(file).canRead()) { throw new FileNotFoundException(file + " doesn't exists"); } this.tok = tok; fis = null; stream = null; head_of_file = true; try { fis = new FileInputStream(file); // Here BufferedInputStream is added for fast reading. // bis = new BufferedInputStream(fis); // stream = new DataInputStream(bis); stream = new BufferedReader(new InputStreamReader(fis, "UTF-8")); } catch (IOException e) { e.printStackTrace(); } } /** * Closes and reopens file, without relinquishing all the file descriptors * * @throws RuntimeIOException * when an {@link IOException} occurs */
public void restart() throws RuntimeIOException {
confabulation/symbolic
java_sentence_completion/src/sparse/float_/CSC2Dfloat.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dfloat extends Matrix2Dfloat { protected final float[] A; protected final int[] IA; protected final int[] JA; public CSC2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/float_/CSC2Dfloat.java import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dfloat extends Matrix2Dfloat { protected final float[] A; protected final int[] IA; protected final int[] JA; public CSC2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column
TreeMap<PairOfInts, Float> ordered_m = new TreeMap<PairOfInts, Float>();
confabulation/symbolic
java_sentence_completion/src/sparse/float_/CSC2Dfloat.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dfloat extends Matrix2Dfloat { protected final float[] A; protected final int[] IA; protected final int[] JA; public CSC2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column TreeMap<PairOfInts, Float> ordered_m = new TreeMap<PairOfInts, Float>();
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/float_/CSC2Dfloat.java import java.util.Arrays; import java.util.HashSet; import java.util.TreeMap; import java.util.Map.Entry; import java.util.Set; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse column matrix * * @author bernard and cedric * */ public class CSC2Dfloat extends Matrix2Dfloat { protected final float[] A; protected final int[] IA; protected final int[] JA; public CSC2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[ncols + 1]; JA = new int[nnz]; // get the nz elements ordered by column TreeMap<PairOfInts, Float> ordered_m = new TreeMap<PairOfInts, Float>();
for (Entry<Pair<Integer, Integer>, Float> e : m.nz_elements()) {
confabulation/symbolic
java_sentence_completion/src/utils/test/StringToolsTest.java
// Path: java_sentence_completion/src/utils/StringTools.java // public class StringTools { // // /** // * Fold the line up to <em>max_chars</em> characters + the line feed, // * splitting on spaces when possible // * // * @param max_chars // * > 0 // * @param s // * non null // * @return the folded line // */ // public static String fold(int max_chars, String s) { // String ret = ""; // int last_split = 0; // int last_space = -1; // // for (int i = 0; i < s.length(); i++) { // // if (s.charAt(i) == ' ' || s.charAt(i) == '\n') { // last_space = i; // } // // if (i - last_split == max_chars) { // if (last_space < last_split) { // no space in the line. // // Split the long word // ret += s.substring(last_split, i) + '\n'; // last_split = i; // } else { // ret += s.substring(last_split, last_space) + '\n'; // i = last_space; // go back just after the space // last_split = i + 1; // } // } // } // if (last_split != s.length()) { // ret += s.substring(last_split); // } // return ret; // } // }
import static org.junit.Assert.*; import java.util.Arrays; import java.util.Iterator; import java.util.Random; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import utils.StringTools;
package utils.test; public class StringToolsTest { @BeforeClass public static void setUpBeforeClass() throws Exception { } @AfterClass public static void tearDownAfterClass() throws Exception { } @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void fold_test_ntimes() { for (int i = 0; i < 100; i++) { fold(); } } public void fold() { String data, ret; int max_chars = 4; // * if splitting on space always succeeds and no '\n' is present // ` then s.equals(re.replaceAll("\n", " ")) // Whitespace test int n = 22; data = new String(new char[n]).replaceAll("\0", " "); // repeat str
// Path: java_sentence_completion/src/utils/StringTools.java // public class StringTools { // // /** // * Fold the line up to <em>max_chars</em> characters + the line feed, // * splitting on spaces when possible // * // * @param max_chars // * > 0 // * @param s // * non null // * @return the folded line // */ // public static String fold(int max_chars, String s) { // String ret = ""; // int last_split = 0; // int last_space = -1; // // for (int i = 0; i < s.length(); i++) { // // if (s.charAt(i) == ' ' || s.charAt(i) == '\n') { // last_space = i; // } // // if (i - last_split == max_chars) { // if (last_space < last_split) { // no space in the line. // // Split the long word // ret += s.substring(last_split, i) + '\n'; // last_split = i; // } else { // ret += s.substring(last_split, last_space) + '\n'; // i = last_space; // go back just after the space // last_split = i + 1; // } // } // } // if (last_split != s.length()) { // ret += s.substring(last_split); // } // return ret; // } // } // Path: java_sentence_completion/src/utils/test/StringToolsTest.java import static org.junit.Assert.*; import java.util.Arrays; import java.util.Iterator; import java.util.Random; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import utils.StringTools; package utils.test; public class StringToolsTest { @BeforeClass public static void setUpBeforeClass() throws Exception { } @AfterClass public static void tearDownAfterClass() throws Exception { } @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void fold_test_ntimes() { for (int i = 0; i < 100; i++) { fold(); } } public void fold() { String data, ret; int max_chars = 4; // * if splitting on space always succeeds and no '\n' is present // ` then s.equals(re.replaceAll("\n", " ")) // Whitespace test int n = 22; data = new String(new char[n]).replaceAll("\0", " "); // repeat str
ret = StringTools.fold(max_chars, data);
confabulation/symbolic
java_sentence_completion/src/confabulation/Multiconfabulation1.java
// Path: java_sentence_completion/src/parser/Tokenizer.java // public abstract class Tokenizer { // /** // * convert a sentence presented as words into symbols // * // * @param words // * can contain empty strings, or be null // * @return one symbol per word, in the same order. null means no symbol for // * the word (can be used to deal with multi-word symbols) // * <p> // * <strong>Condition:</strong> // * </p> // * <p> // * words == return == null || return.length == words.length // * </p> // */ // public abstract String[] words2symbols(String[] words); // // /** // * parse <em>line</em> into symbols, using <em>separator_regex</em> to // * separate the words. Empty words "" are ignored // * // * @param line // * can be null // * @param separator_regex // * non-null, well-formed regex for the separator // * @return one symbol per word, in the same order, null if line is null // * @see #words2symbols(String[]) // */ // public String[] parse(String line, String separator_regex) { // return parse(line, Pattern.compile(separator_regex)); // } // // /** // * Core of {@link #parse(String, String)}, for optimisation // * // * @see #parse(String, String) // * @see #words2symbols(String[]) // */ // public String[] parse(String line, Pattern separator_pattern) { // if (line == null) { // return null; // } // String[] temp = ArrayTools.removeEvery("", // separator_pattern.split(line)); // // return words2symbols(temp); // } // } // // Path: java_sentence_completion/src/parser/WordTokenizer.java // public class WordTokenizer extends Tokenizer { // // /* // * (non-Javadoc) // * // * @see parser.Tokenizer#words2symbols(java.lang.String[]) // */ // @Override // public String[] words2symbols(String[] words) { // return words; // } // // }
import java.io.IOException; import parser.Tokenizer; import parser.WordTokenizer;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package confabulation; /** * @author bernard and cedric * */ public class Multiconfabulation1 extends FullMeshConfabulation { protected int n_multiconf; public Multiconfabulation1(int n_modules, String filename) throws IOException {
// Path: java_sentence_completion/src/parser/Tokenizer.java // public abstract class Tokenizer { // /** // * convert a sentence presented as words into symbols // * // * @param words // * can contain empty strings, or be null // * @return one symbol per word, in the same order. null means no symbol for // * the word (can be used to deal with multi-word symbols) // * <p> // * <strong>Condition:</strong> // * </p> // * <p> // * words == return == null || return.length == words.length // * </p> // */ // public abstract String[] words2symbols(String[] words); // // /** // * parse <em>line</em> into symbols, using <em>separator_regex</em> to // * separate the words. Empty words "" are ignored // * // * @param line // * can be null // * @param separator_regex // * non-null, well-formed regex for the separator // * @return one symbol per word, in the same order, null if line is null // * @see #words2symbols(String[]) // */ // public String[] parse(String line, String separator_regex) { // return parse(line, Pattern.compile(separator_regex)); // } // // /** // * Core of {@link #parse(String, String)}, for optimisation // * // * @see #parse(String, String) // * @see #words2symbols(String[]) // */ // public String[] parse(String line, Pattern separator_pattern) { // if (line == null) { // return null; // } // String[] temp = ArrayTools.removeEvery("", // separator_pattern.split(line)); // // return words2symbols(temp); // } // } // // Path: java_sentence_completion/src/parser/WordTokenizer.java // public class WordTokenizer extends Tokenizer { // // /* // * (non-Javadoc) // * // * @see parser.Tokenizer#words2symbols(java.lang.String[]) // */ // @Override // public String[] words2symbols(String[] words) { // return words; // } // // } // Path: java_sentence_completion/src/confabulation/Multiconfabulation1.java import java.io.IOException; import parser.Tokenizer; import parser.WordTokenizer; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package confabulation; /** * @author bernard and cedric * */ public class Multiconfabulation1 extends FullMeshConfabulation { protected int n_multiconf; public Multiconfabulation1(int n_modules, String filename) throws IOException {
this(n_modules, filename, new WordTokenizer());
confabulation/symbolic
java_sentence_completion/src/confabulation/Multiconfabulation1.java
// Path: java_sentence_completion/src/parser/Tokenizer.java // public abstract class Tokenizer { // /** // * convert a sentence presented as words into symbols // * // * @param words // * can contain empty strings, or be null // * @return one symbol per word, in the same order. null means no symbol for // * the word (can be used to deal with multi-word symbols) // * <p> // * <strong>Condition:</strong> // * </p> // * <p> // * words == return == null || return.length == words.length // * </p> // */ // public abstract String[] words2symbols(String[] words); // // /** // * parse <em>line</em> into symbols, using <em>separator_regex</em> to // * separate the words. Empty words "" are ignored // * // * @param line // * can be null // * @param separator_regex // * non-null, well-formed regex for the separator // * @return one symbol per word, in the same order, null if line is null // * @see #words2symbols(String[]) // */ // public String[] parse(String line, String separator_regex) { // return parse(line, Pattern.compile(separator_regex)); // } // // /** // * Core of {@link #parse(String, String)}, for optimisation // * // * @see #parse(String, String) // * @see #words2symbols(String[]) // */ // public String[] parse(String line, Pattern separator_pattern) { // if (line == null) { // return null; // } // String[] temp = ArrayTools.removeEvery("", // separator_pattern.split(line)); // // return words2symbols(temp); // } // } // // Path: java_sentence_completion/src/parser/WordTokenizer.java // public class WordTokenizer extends Tokenizer { // // /* // * (non-Javadoc) // * // * @see parser.Tokenizer#words2symbols(java.lang.String[]) // */ // @Override // public String[] words2symbols(String[] words) { // return words; // } // // }
import java.io.IOException; import parser.Tokenizer; import parser.WordTokenizer;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package confabulation; /** * @author bernard and cedric * */ public class Multiconfabulation1 extends FullMeshConfabulation { protected int n_multiconf; public Multiconfabulation1(int n_modules, String filename) throws IOException { this(n_modules, filename, new WordTokenizer()); }
// Path: java_sentence_completion/src/parser/Tokenizer.java // public abstract class Tokenizer { // /** // * convert a sentence presented as words into symbols // * // * @param words // * can contain empty strings, or be null // * @return one symbol per word, in the same order. null means no symbol for // * the word (can be used to deal with multi-word symbols) // * <p> // * <strong>Condition:</strong> // * </p> // * <p> // * words == return == null || return.length == words.length // * </p> // */ // public abstract String[] words2symbols(String[] words); // // /** // * parse <em>line</em> into symbols, using <em>separator_regex</em> to // * separate the words. Empty words "" are ignored // * // * @param line // * can be null // * @param separator_regex // * non-null, well-formed regex for the separator // * @return one symbol per word, in the same order, null if line is null // * @see #words2symbols(String[]) // */ // public String[] parse(String line, String separator_regex) { // return parse(line, Pattern.compile(separator_regex)); // } // // /** // * Core of {@link #parse(String, String)}, for optimisation // * // * @see #parse(String, String) // * @see #words2symbols(String[]) // */ // public String[] parse(String line, Pattern separator_pattern) { // if (line == null) { // return null; // } // String[] temp = ArrayTools.removeEvery("", // separator_pattern.split(line)); // // return words2symbols(temp); // } // } // // Path: java_sentence_completion/src/parser/WordTokenizer.java // public class WordTokenizer extends Tokenizer { // // /* // * (non-Javadoc) // * // * @see parser.Tokenizer#words2symbols(java.lang.String[]) // */ // @Override // public String[] words2symbols(String[] words) { // return words; // } // // } // Path: java_sentence_completion/src/confabulation/Multiconfabulation1.java import java.io.IOException; import parser.Tokenizer; import parser.WordTokenizer; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package confabulation; /** * @author bernard and cedric * */ public class Multiconfabulation1 extends FullMeshConfabulation { protected int n_multiconf; public Multiconfabulation1(int n_modules, String filename) throws IOException { this(n_modules, filename, new WordTokenizer()); }
public Multiconfabulation1(int n_modules, String filename, Tokenizer tok)
confabulation/symbolic
java_sentence_completion/src/utils/test/MathToolsTest.java
// Path: java_sentence_completion/src/utils/MathTools.java // public class MathTools { // // /** // * Ramp function // * // * <a href="https://en.wikipedia.org/wiki/Ramp_function">wikipedia<a> // * // * @param x // * @return x if x > 0; 0 otherwise // */ // public static int ramp_fun(int x) { // return x > 0 ? x : 0; // } // // /** // * Ramp function // * // * <a href="https://en.wikipedia.org/wiki/Ramp_function">wikipedia<a> // * // * @param x // * @return x if x > 0; 0 otherwise // */ // public static float ramp_fun(float x) { // return x > 0 ? x : 0; // } // // /** // * sum over the arguments // * // * @param ints // * non-null // * @return the sum of each element of ints // */ // public static int sum(int... ints) { // int sum = 0; // for (int i : ints) { // sum += i; // } // return sum; // } // // /** // * minimum // * @param is non-null, length > 0 // * @return the minimal element // */ // public static int min(int... is) { // int min = is[0]; // for (int i : is) { // if (i < min){ // min = i; // } // } // return min ; // } // // /** // * maximum // * @param is non-null, length > 0 // * @return the maximal element // */ // public static int max(int... is) { // int max = is[0]; // for (int i : is) { // if (i > max){ // max = i; // } // } // return max ; // } // }
import static org.junit.Assert.*; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import utils.MathTools;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ /** * */ package utils.test; /** * @author bernard and cedric * */ public class MathToolsTest { /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { } /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception { } /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception { } /** * Test method for {@link utils.MathTools#ramp_fun(int)}. */ @Test public void ramp() {
// Path: java_sentence_completion/src/utils/MathTools.java // public class MathTools { // // /** // * Ramp function // * // * <a href="https://en.wikipedia.org/wiki/Ramp_function">wikipedia<a> // * // * @param x // * @return x if x > 0; 0 otherwise // */ // public static int ramp_fun(int x) { // return x > 0 ? x : 0; // } // // /** // * Ramp function // * // * <a href="https://en.wikipedia.org/wiki/Ramp_function">wikipedia<a> // * // * @param x // * @return x if x > 0; 0 otherwise // */ // public static float ramp_fun(float x) { // return x > 0 ? x : 0; // } // // /** // * sum over the arguments // * // * @param ints // * non-null // * @return the sum of each element of ints // */ // public static int sum(int... ints) { // int sum = 0; // for (int i : ints) { // sum += i; // } // return sum; // } // // /** // * minimum // * @param is non-null, length > 0 // * @return the minimal element // */ // public static int min(int... is) { // int min = is[0]; // for (int i : is) { // if (i < min){ // min = i; // } // } // return min ; // } // // /** // * maximum // * @param is non-null, length > 0 // * @return the maximal element // */ // public static int max(int... is) { // int max = is[0]; // for (int i : is) { // if (i > max){ // max = i; // } // } // return max ; // } // } // Path: java_sentence_completion/src/utils/test/MathToolsTest.java import static org.junit.Assert.*; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import utils.MathTools; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ /** * */ package utils.test; /** * @author bernard and cedric * */ public class MathToolsTest { /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { } /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception { } /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception { } /** * Test method for {@link utils.MathTools#ramp_fun(int)}. */ @Test public void ramp() {
assertEquals(0, MathTools.ramp_fun(0));
confabulation/symbolic
java_sentence_completion/src/sparse/float_/Matrix2Dfloat.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // }
import java.util.Map.Entry; import java.util.Set; import sparse.Pair;
* column number * @throws IndexOutOfBoundsException * if l or c is not in the matrix bounds */ protected void check_bounds(int l, int c) throws IndexOutOfBoundsException { // bounds if (l >= nlines || c >= ncols) { throw new IndexOutOfBoundsException(l + " >= " + nlines + " or " + c + " >= " + ncols); } if (l < 0 || c < 0) { throw new IndexOutOfBoundsException("l (" + l + ") < 0 or c (" + c + ") <0"); } } /** * Multiplies the matrix by the given vector * * @param vec * non-null * @return the result in a new vector */ public abstract DOK1Dfloat multiply(DOK1Dfloat vec); /** * returns a set of the non-zero elements * * @return the non-zero elements */
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // Path: java_sentence_completion/src/sparse/float_/Matrix2Dfloat.java import java.util.Map.Entry; import java.util.Set; import sparse.Pair; * column number * @throws IndexOutOfBoundsException * if l or c is not in the matrix bounds */ protected void check_bounds(int l, int c) throws IndexOutOfBoundsException { // bounds if (l >= nlines || c >= ncols) { throw new IndexOutOfBoundsException(l + " >= " + nlines + " or " + c + " >= " + ncols); } if (l < 0 || c < 0) { throw new IndexOutOfBoundsException("l (" + l + ") < 0 or c (" + c + ") <0"); } } /** * Multiplies the matrix by the given vector * * @param vec * non-null * @return the result in a new vector */ public abstract DOK1Dfloat multiply(DOK1Dfloat vec); /** * returns a set of the non-zero elements * * @return the non-zero elements */
public abstract Set<Entry<Pair<Integer, Integer>, Float>> nz_elements();
confabulation/symbolic
java_sentence_completion/src/colt/SparseFloatMatrix2DSaverTest.java
// Path: java_sentence_completion/src/colt/SparseFloatMatrix2DSaver.java // public static class FormatErrorException extends Exception { // // /** stupid constructor */ // public FormatErrorException(String string) { // super(string); // } // // /** // * eclipse wants this... // */ // private static final long serialVersionUID = -1089861148505190177L; // }
import cern.colt.matrix.tfloat.impl.SparseFloatMatrix2D; import colt.SparseFloatMatrix2DSaver.FormatErrorException; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Random; import org.junit.Test;
assertEquals("SparseFloatMatrix2D (" + nrows + "," + ncolumns +")", in.readLine()); assertEquals("0,0,1.0", in.readLine()); assertEquals("1,1,1.0", in.readLine()); assertEquals("SparseFloatMatrix2D END", in.readLine()); in.close(); } catch (FileNotFoundException e) { e.printStackTrace(); throw new AssertionError("This shouldn't happen"); } catch (IOException e) { e.printStackTrace(); throw new AssertionError("This shouldn't happen"); } finally { f.delete(); } } @Test public void test_read(){ int nrows = 10; int ncolumns = 5; SparseFloatMatrix2D m = new SparseFloatMatrix2D(nrows, ncolumns); m.set(0, 0, 1); m.set(1, 1, 1); File f = new File("test_read"+ new Random().nextLong() + ".txt"); SparseFloatMatrix2DSaver.write(m, f.getPath()); try { assertEquals(m, SparseFloatMatrix2DSaver.read(f.getPath())); } catch (FileNotFoundException e) { e.printStackTrace(); throw new AssertionError(f.getPath() + " not found");
// Path: java_sentence_completion/src/colt/SparseFloatMatrix2DSaver.java // public static class FormatErrorException extends Exception { // // /** stupid constructor */ // public FormatErrorException(String string) { // super(string); // } // // /** // * eclipse wants this... // */ // private static final long serialVersionUID = -1089861148505190177L; // } // Path: java_sentence_completion/src/colt/SparseFloatMatrix2DSaverTest.java import cern.colt.matrix.tfloat.impl.SparseFloatMatrix2D; import colt.SparseFloatMatrix2DSaver.FormatErrorException; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Random; import org.junit.Test; assertEquals("SparseFloatMatrix2D (" + nrows + "," + ncolumns +")", in.readLine()); assertEquals("0,0,1.0", in.readLine()); assertEquals("1,1,1.0", in.readLine()); assertEquals("SparseFloatMatrix2D END", in.readLine()); in.close(); } catch (FileNotFoundException e) { e.printStackTrace(); throw new AssertionError("This shouldn't happen"); } catch (IOException e) { e.printStackTrace(); throw new AssertionError("This shouldn't happen"); } finally { f.delete(); } } @Test public void test_read(){ int nrows = 10; int ncolumns = 5; SparseFloatMatrix2D m = new SparseFloatMatrix2D(nrows, ncolumns); m.set(0, 0, 1); m.set(1, 1, 1); File f = new File("test_read"+ new Random().nextLong() + ".txt"); SparseFloatMatrix2DSaver.write(m, f.getPath()); try { assertEquals(m, SparseFloatMatrix2DSaver.read(f.getPath())); } catch (FileNotFoundException e) { e.printStackTrace(); throw new AssertionError(f.getPath() + " not found");
} catch (FormatErrorException e) {
confabulation/symbolic
java_sentence_completion/src/sparse/float_/CSR2Dfloat.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dfloat extends Matrix2Dfloat { protected float[] A; protected int[] IA; protected int[] JA; public CSR2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/float_/CSR2Dfloat.java import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dfloat extends Matrix2Dfloat { protected float[] A; protected int[] IA; protected int[] JA; public CSR2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line
TreeMap<PairOfInts, Float> ordered_m = new TreeMap<PairOfInts, Float>();
confabulation/symbolic
java_sentence_completion/src/sparse/float_/CSR2Dfloat.java
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dfloat extends Matrix2Dfloat { protected float[] A; protected int[] IA; protected int[] JA; public CSR2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line TreeMap<PairOfInts, Float> ordered_m = new TreeMap<PairOfInts, Float>();
// Path: java_sentence_completion/src/sparse/Pair.java // public class Pair<A, B> implements Entry<A, B> { // public final A first; // public final B second; // // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // // public int hashCode() { // int hashFirst = first != null ? first.hashCode() : 0; // int hashSecond = second != null ? second.hashCode() : 0; // // return (hashFirst + hashSecond) * hashSecond + hashFirst; // } // // public boolean equals(Object other) { // if (other instanceof Pair<?, ?>) { // Pair<?, ?> otherPair = (Pair<?, ?>) other; // return ((this.first == otherPair.first || (this.first != null // && otherPair.first != null && this.first // .equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null // && otherPair.second != null && this.second // .equals(otherPair.second)))); // } // // return false; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public A getKey() { // return first; // } // // @Override // public B getValue() { // return second; // } // // /** // * Immutable // * // * @throws UnsupportedOperationException // * always // */ // @Override // public B setValue(B value) throws UnsupportedOperationException { // throw new UnsupportedOperationException("Immutable"); // } // // } // // Path: java_sentence_completion/src/sparse/PairOfInts.java // public class PairOfInts implements Comparable<PairOfInts> { // public final int first; // public final int second; // // public PairOfInts(int first, int second) { // this.first = first; // this.second = second; // } // // public PairOfInts(Entry<Integer, Integer> entry){ // first = entry.getKey(); // second = entry.getValue(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + first; // result = prime * result + second; // return result; // } // // public String toString() { // return "(" + first + ", " + second + ")"; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // // PairOfInts other = (PairOfInts) obj; // return first == other.first && second == other.second; // } // // @Override // public int compareTo(PairOfInts o) { // int first_diff = first - o.first; // if (first_diff != 0) { // return first_diff; // } // return second - o.second; // } // // /** // * put the second number in first position, and the first in second // * <p> // * Matthew 20:16 : "So the last will be first, and the first will be last." // * </p> // * // * @return a new object with the inverted fields // */ // public PairOfInts reverse() { // return new PairOfInts(second, first); // } // } // Path: java_sentence_completion/src/sparse/float_/CSR2Dfloat.java import java.util.Arrays; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import sparse.Pair; import sparse.PairOfInts; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package sparse.float_; /** * Compressed sparse row matrix * * @author bernard and cedric * */ public class CSR2Dfloat extends Matrix2Dfloat { protected float[] A; protected int[] IA; protected int[] JA; public CSR2Dfloat(Matrix2Dfloat m) { super(m.nlines, m.ncols); int nnz = m.nnz(); A = new float[nnz]; IA = new int[nlines + 1]; JA = new int[nnz]; // get the nz elements ordered by line TreeMap<PairOfInts, Float> ordered_m = new TreeMap<PairOfInts, Float>();
for (Entry<Pair<Integer, Integer>, Float> e : m.nz_elements()) {
confabulation/symbolic
java_sentence_completion/src/utils/test/StopwatchTest.java
// Path: java_sentence_completion/src/utils/Stopwatch.java // public class Stopwatch { // // private List<String> sections; // // private LinkedList<Long> times; // private long last_start = 0; // // /** // * Creates the stopwatch. Must be {@link #start()}ed // */ // public Stopwatch() { // sections = new LinkedList<String>(); // times = new LinkedList<Long>(); // } // // /** // * Start the stopwatch // * // * @see #start(String) // * @see #stop() // */ // public void start() { // start(""); // } // // /** // * start the stopwatch, registering the result with a custom section name // * // * @param section // * the section name. If null or empty string, a default name // * which includes a section number is used // * @see #start() // * @see #stop() // */ // public void start(String section) { // if (is_started()) { // stop(); // } // if (section == null || section == "") { // sections.add("section no." + (sections.size() + 1)); // } else { // sections.add(section); // } // // last_start = System.currentTimeMillis(); // } // // /** // * stop the stopwatch (no effect if it is already stopped) // * // * @see #start() // * @see Stopwatch#start(String) // */ // public void stop() { // if (is_started()) { // times.add(System.currentTimeMillis() - last_start); // } // } // // /** // * whether stopwatch is currently running or stopped // */ // public boolean is_started() { // return times.size() == sections.size() - 1; // } // // /** // * Full {@link #stats(boolean)} // */ // public String stats(){ // return stats(true); // } // // /** // * some stats about the stopwatch. The currently running section is ignored. // * // * @param section_detail // * include times for each section // */ // public String stats(boolean section_detail) { // String ret = ""; // if (is_started()) { // ret += "Stopwatch running. Running section ignored\n"; // } // // // sections and times // if (section_detail) { // ret += times_by_section(sections, times); // } // // // min and max // if (times.size() > 0) { // String min_section = sections.get(0); // long min = times.get(0); // String max_section = min_section; // long max = min; // Iterator<String> sec_it = sections.iterator(); // for (long t : times) { // String cur_sec = sec_it.next(); // if (t < min) { // min = t; // min_section = cur_sec; // } else if (t > max) { // max = t; // max_section = cur_sec; // } // } // ret += "Shortest section: " + min + "ms\t" + min_section + "\n"; // ret += "Longuest section: " + max + "ms\t" + max_section + "\n"; // } // // long total_time = get_total_time(); // ret += "Total time: " + total_time + "ms\n"; // if (times.size() > 0) { // ret += "Average time: " + ((double) total_time / times.size()) // + "ms\n"; // } // return ret; // } // // // /** // * the total execution time // */ // public long get_total_time() { // long total = 0; // for (long t : times) { // total += t; // } // return total; // } // // // /** // * TODO spec // * @param sections // * @param times // * @return // */ // public static String times_by_section(List<String> sections, List<Long> times){ // String ret = ""; // Iterator<String> sec_it = sections.iterator(); // for (long t : times) { // ret += sec_it.next() + "\t" + t + "ms\n"; // } // return ret; // } // // // /** // * @return the sections // */ // public List<String> getSections() { // return sections; // } // // /** // * @return the times // */ // public LinkedList<Long> getTimes() { // return times; // } // }
import org.junit.Test; import utils.Stopwatch;
/** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package utils.test; public class StopwatchTest { /** * A stupid test function that never fails */ @Test public void test() {
// Path: java_sentence_completion/src/utils/Stopwatch.java // public class Stopwatch { // // private List<String> sections; // // private LinkedList<Long> times; // private long last_start = 0; // // /** // * Creates the stopwatch. Must be {@link #start()}ed // */ // public Stopwatch() { // sections = new LinkedList<String>(); // times = new LinkedList<Long>(); // } // // /** // * Start the stopwatch // * // * @see #start(String) // * @see #stop() // */ // public void start() { // start(""); // } // // /** // * start the stopwatch, registering the result with a custom section name // * // * @param section // * the section name. If null or empty string, a default name // * which includes a section number is used // * @see #start() // * @see #stop() // */ // public void start(String section) { // if (is_started()) { // stop(); // } // if (section == null || section == "") { // sections.add("section no." + (sections.size() + 1)); // } else { // sections.add(section); // } // // last_start = System.currentTimeMillis(); // } // // /** // * stop the stopwatch (no effect if it is already stopped) // * // * @see #start() // * @see Stopwatch#start(String) // */ // public void stop() { // if (is_started()) { // times.add(System.currentTimeMillis() - last_start); // } // } // // /** // * whether stopwatch is currently running or stopped // */ // public boolean is_started() { // return times.size() == sections.size() - 1; // } // // /** // * Full {@link #stats(boolean)} // */ // public String stats(){ // return stats(true); // } // // /** // * some stats about the stopwatch. The currently running section is ignored. // * // * @param section_detail // * include times for each section // */ // public String stats(boolean section_detail) { // String ret = ""; // if (is_started()) { // ret += "Stopwatch running. Running section ignored\n"; // } // // // sections and times // if (section_detail) { // ret += times_by_section(sections, times); // } // // // min and max // if (times.size() > 0) { // String min_section = sections.get(0); // long min = times.get(0); // String max_section = min_section; // long max = min; // Iterator<String> sec_it = sections.iterator(); // for (long t : times) { // String cur_sec = sec_it.next(); // if (t < min) { // min = t; // min_section = cur_sec; // } else if (t > max) { // max = t; // max_section = cur_sec; // } // } // ret += "Shortest section: " + min + "ms\t" + min_section + "\n"; // ret += "Longuest section: " + max + "ms\t" + max_section + "\n"; // } // // long total_time = get_total_time(); // ret += "Total time: " + total_time + "ms\n"; // if (times.size() > 0) { // ret += "Average time: " + ((double) total_time / times.size()) // + "ms\n"; // } // return ret; // } // // // /** // * the total execution time // */ // public long get_total_time() { // long total = 0; // for (long t : times) { // total += t; // } // return total; // } // // // /** // * TODO spec // * @param sections // * @param times // * @return // */ // public static String times_by_section(List<String> sections, List<Long> times){ // String ret = ""; // Iterator<String> sec_it = sections.iterator(); // for (long t : times) { // ret += sec_it.next() + "\t" + t + "ms\n"; // } // return ret; // } // // // /** // * @return the sections // */ // public List<String> getSections() { // return sections; // } // // /** // * @return the times // */ // public LinkedList<Long> getTimes() { // return times; // } // } // Path: java_sentence_completion/src/utils/test/StopwatchTest.java import org.junit.Test; import utils.Stopwatch; /** * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert * * Confabulation_Symbolic is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Confabulation_Symbolic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Confabulation_Symbolic. If not, see <http://www.gnu.org/licenses/>. */ package utils.test; public class StopwatchTest { /** * A stupid test function that never fails */ @Test public void test() {
Stopwatch sw = new Stopwatch();
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min;
avg += entries.get(j).getY() / (2 * windowSize + 1); } smoothEntries.add(new Entry(time, avg)); } return smoothEntries; } static double[] findShifts(List<Entry> phoneEntries, List<Entry> waltEntries) { double[] phoneTimes = new double[phoneEntries.size()]; double[] phoneValues = new double[phoneEntries.size()]; double[] waltTimes = new double[waltEntries.size()]; double[] waltValues = new double[waltEntries.size()]; for (int i = 0; i < phoneTimes.length; i++) { phoneTimes[i] = phoneEntries.get(i).getX(); phoneValues[i] = phoneEntries.get(i).getY(); } for (int i = 0; i < waltTimes.length; i++) { waltTimes[i] = waltEntries.get(i).getX(); waltValues[i] = waltEntries.get(i).getY(); } double[] shiftCorrelations = new double[401]; for (int i = 0; i < shiftCorrelations.length; i++) { double shift = i / 10.; final double[] shiftedPhoneTimes = new double[phoneTimes.length]; for (int j = 0; j < phoneTimes.length; j++) { shiftedPhoneTimes[j] = phoneTimes[j] - shift; }
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min; avg += entries.get(j).getY() / (2 * windowSize + 1); } smoothEntries.add(new Entry(time, avg)); } return smoothEntries; } static double[] findShifts(List<Entry> phoneEntries, List<Entry> waltEntries) { double[] phoneTimes = new double[phoneEntries.size()]; double[] phoneValues = new double[phoneEntries.size()]; double[] waltTimes = new double[waltEntries.size()]; double[] waltValues = new double[waltEntries.size()]; for (int i = 0; i < phoneTimes.length; i++) { phoneTimes[i] = phoneEntries.get(i).getX(); phoneValues[i] = phoneEntries.get(i).getY(); } for (int i = 0; i < waltTimes.length; i++) { waltTimes[i] = waltEntries.get(i).getX(); waltValues[i] = waltEntries.get(i).getY(); } double[] shiftCorrelations = new double[401]; for (int i = 0; i < shiftCorrelations.length; i++) { double shift = i / 10.; final double[] shiftedPhoneTimes = new double[phoneTimes.length]; for (int j = 0; j < phoneTimes.length; j++) { shiftedPhoneTimes[j] = phoneTimes[j] - shift; }
final double[] interpolatedValues = interp(shiftedPhoneTimes, waltTimes, waltValues);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min;
startMeasurement(); return; } if (v.getId() == R.id.button_close_chart) { latencyChartLayout.setVisibility(View.GONE); } } private void calculateAndDrawLatencyChart(final String latencyString) { List<Entry> phoneEntries = new ArrayList<>(); List<Entry> waltEntries = getEntriesFromString(latencyString); List<Entry> waltSmoothEntries = smoothEntries(waltEntries, 4); for (AccelerometerEvent e : phoneAccelerometerData) { phoneEntries.add(new Entry(e.callbackTimeMs, e.value)); } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min; startMeasurement(); return; } if (v.getId() == R.id.button_close_chart) { latencyChartLayout.setVisibility(View.GONE); } } private void calculateAndDrawLatencyChart(final String latencyString) { List<Entry> phoneEntries = new ArrayList<>(); List<Entry> waltEntries = getEntriesFromString(latencyString); List<Entry> waltSmoothEntries = smoothEntries(waltEntries, 4); for (AccelerometerEvent e : phoneAccelerometerData) { phoneEntries.add(new Entry(e.callbackTimeMs, e.value)); } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries
float phoneMean = mean(phoneEntries);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min;
return; } if (v.getId() == R.id.button_close_chart) { latencyChartLayout.setVisibility(View.GONE); } } private void calculateAndDrawLatencyChart(final String latencyString) { List<Entry> phoneEntries = new ArrayList<>(); List<Entry> waltEntries = getEntriesFromString(latencyString); List<Entry> waltSmoothEntries = smoothEntries(waltEntries, 4); for (AccelerometerEvent e : phoneAccelerometerData) { phoneEntries.add(new Entry(e.callbackTimeMs, e.value)); } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries float phoneMean = mean(phoneEntries);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min; return; } if (v.getId() == R.id.button_close_chart) { latencyChartLayout.setVisibility(View.GONE); } } private void calculateAndDrawLatencyChart(final String latencyString) { List<Entry> phoneEntries = new ArrayList<>(); List<Entry> waltEntries = getEntriesFromString(latencyString); List<Entry> waltSmoothEntries = smoothEntries(waltEntries, 4); for (AccelerometerEvent e : phoneAccelerometerData) { phoneEntries.add(new Entry(e.callbackTimeMs, e.value)); } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries float phoneMean = mean(phoneEntries);
float phoneMax = max(phoneEntries);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min;
} if (v.getId() == R.id.button_close_chart) { latencyChartLayout.setVisibility(View.GONE); } } private void calculateAndDrawLatencyChart(final String latencyString) { List<Entry> phoneEntries = new ArrayList<>(); List<Entry> waltEntries = getEntriesFromString(latencyString); List<Entry> waltSmoothEntries = smoothEntries(waltEntries, 4); for (AccelerometerEvent e : phoneAccelerometerData) { phoneEntries.add(new Entry(e.callbackTimeMs, e.value)); } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries float phoneMean = mean(phoneEntries); float phoneMax = max(phoneEntries);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min; } if (v.getId() == R.id.button_close_chart) { latencyChartLayout.setVisibility(View.GONE); } } private void calculateAndDrawLatencyChart(final String latencyString) { List<Entry> phoneEntries = new ArrayList<>(); List<Entry> waltEntries = getEntriesFromString(latencyString); List<Entry> waltSmoothEntries = smoothEntries(waltEntries, 4); for (AccelerometerEvent e : phoneAccelerometerData) { phoneEntries.add(new Entry(e.callbackTimeMs, e.value)); } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries float phoneMean = mean(phoneEntries); float phoneMax = max(phoneEntries);
float phoneMin = min(phoneEntries);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min;
} while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries float phoneMean = mean(phoneEntries); float phoneMax = max(phoneEntries); float phoneMin = min(phoneEntries); float waltMin = min(waltSmoothEntries); float phoneRange = phoneMax - phoneMin; float waltRange = max(waltSmoothEntries) - waltMin; for (Entry e : waltSmoothEntries) { e.setY((e.getY() - waltMin) * (phoneRange / waltRange) + phoneMin - phoneMean); } // Adjust phoneEntries so mean=0 for (Entry e : phoneEntries) { e.setY(e.getY() - phoneMean); } double[] shifts = findShifts(phoneEntries, waltSmoothEntries);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static int argmax(double[] a) { // int imax = 0; // for (int i=1; i<a.length; i++) if (a[i] > a[imax]) imax = i; // return imax; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double[] interp(double[] x, double[] xp, double[] yp) { // // assuming that x and xp are already sorted. // // go over x and xp as if we are merging them // double[] y = new double[x.length]; // int i = 0; // int ip = 0; // // // skip x points that are outside the data // while (i < x.length && x[i] < xp[0]) i++; // // while (ip < xp.length && i < x.length) { // // skip until we see an xp >= current x // while (ip < xp.length && xp[ip] < x[i]) ip++; // if (ip >= xp.length) break; // if (xp[ip] == x[i]) { // y[i] = yp[ip]; // } else { // double dy = yp[ip] - yp[ip-1]; // double dx = xp[ip] - xp[ip-1]; // y[i] = yp[ip-1] + dy/dx * (x[i] - xp[ip-1]); // } // i++; // } // return y; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float max(List<Entry> entries) { // float max = Float.MIN_VALUE; // for (Entry e : entries) { // max = Math.max(max, e.getY()); // } // return max; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // public static double mean(double[] x) { // double s = 0; // for (double v: x) s += v; // return s / x.length; // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static float min(List<Entry> entries) { // float min = Float.MAX_VALUE; // for (Entry e : entries) { // min = Math.min(min, e.getY()); // } // return min; // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AccelerometerFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.github.mikephil.charting.charts.ScatterChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.ScatterData; import com.github.mikephil.charting.data.ScatterDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.chromium.latency.walt.Utils.argmax; import static org.chromium.latency.walt.Utils.interp; import static org.chromium.latency.walt.Utils.max; import static org.chromium.latency.walt.Utils.mean; import static org.chromium.latency.walt.Utils.min; } while (phoneEntries.get(0).getX() < waltSmoothEntries.get(0).getX()) { // This event is earlier than any walt event, so discard it phoneEntries.remove(0); } while (phoneEntries.get(phoneEntries.size() - 1).getX() > waltSmoothEntries.get(waltSmoothEntries.size() - 1).getX()) { // This event is later than any walt event, so discard it phoneEntries.remove(phoneEntries.size() - 1); } // Adjust waltEntries so min and max is the same as phoneEntries float phoneMean = mean(phoneEntries); float phoneMax = max(phoneEntries); float phoneMin = min(phoneEntries); float waltMin = min(waltSmoothEntries); float phoneRange = phoneMax - phoneMin; float waltRange = max(waltSmoothEntries) - waltMin; for (Entry e : waltSmoothEntries) { e.setY((e.getY() - waltMin) * (phoneRange / waltRange) + phoneMin - phoneMean); } // Adjust phoneEntries so mean=0 for (Entry e : phoneEntries) { e.setY(e.getY() - phoneMean); } double[] shifts = findShifts(phoneEntries, waltSmoothEntries);
double bestShift = argmax(shifts) / 10d;
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/BaseTest.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // }
import android.content.Context; import static org.chromium.latency.walt.Utils.getBooleanPreference;
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.chromium.latency.walt; abstract class BaseTest { interface TestStateListener { void onTestStopped(); void onTestStoppedWithError(); void onTestPartialResult(double value); } Context context; SimpleLogger logger; TraceLogger traceLogger = null; WaltDevice waltDevice; TestStateListener testStateListener = null; AutoRunFragment.ResultHandler resultHandler = null; BaseTest(Context context) { this.context = context; waltDevice = WaltDevice.getInstance(context); logger = SimpleLogger.getInstance(context);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/BaseTest.java import android.content.Context; import static org.chromium.latency.walt.Utils.getBooleanPreference; /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.chromium.latency.walt; abstract class BaseTest { interface TestStateListener { void onTestStopped(); void onTestStoppedWithError(); void onTestPartialResult(double value); } Context context; SimpleLogger logger; TraceLogger traceLogger = null; WaltDevice waltDevice; TestStateListener testStateListener = null; AutoRunFragment.ResultHandler resultHandler = null; BaseTest(Context context) { this.context = context; waltDevice = WaltDevice.getInstance(context); logger = SimpleLogger.getInstance(context);
if (getBooleanPreference(context, R.string.preference_systrace, true)) {
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AudioTest.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // }
import android.content.Context; import android.media.AudioManager; import android.os.Handler; import java.io.IOException; import java.util.ArrayList; import java.util.Locale; import static org.chromium.latency.walt.Utils.getIntPreference;
// Audio out private int requestedBeeps; private int recordingRepetitions; private static int recorderSyncAfterRepetitions = 10; private final int threshold; ArrayList<Double> deltas_mic = new ArrayList<>(); private ArrayList<Double> deltas_play2queue = new ArrayList<>(); ArrayList<Double> deltas_queue2wire = new ArrayList<>(); private ArrayList<Double> deltasJ2N = new ArrayList<>(); long lastBeepTime; public static native long playTone(); public static native void startWarmTest(); public static native void stopTests(); public static native void createEngine(); public static native void destroyEngine(); public static native void createBufferQueueAudioPlayer(int frameRate, int framesPerBuffer); public static native void startRecording(); public static native void createAudioRecorder(int frameRate, int framesToRecord); public static native short[] getRecordedWave(); public static native long getTeRec(); public static native long getTcRec(); public static native long getTePlay(); AudioTest(Context context) { super(context);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AudioTest.java import android.content.Context; import android.media.AudioManager; import android.os.Handler; import java.io.IOException; import java.util.ArrayList; import java.util.Locale; import static org.chromium.latency.walt.Utils.getIntPreference; // Audio out private int requestedBeeps; private int recordingRepetitions; private static int recorderSyncAfterRepetitions = 10; private final int threshold; ArrayList<Double> deltas_mic = new ArrayList<>(); private ArrayList<Double> deltas_play2queue = new ArrayList<>(); ArrayList<Double> deltas_queue2wire = new ArrayList<>(); private ArrayList<Double> deltasJ2N = new ArrayList<>(); long lastBeepTime; public static native long playTone(); public static native void startWarmTest(); public static native void stopTests(); public static native void createEngine(); public static native void destroyEngine(); public static native void createBufferQueueAudioPlayer(int frameRate, int framesPerBuffer); public static native void startRecording(); public static native void createAudioRecorder(int frameRate, int framesToRecord); public static native short[] getRecordedWave(); public static native long getTeRec(); public static native long getTcRec(); public static native long getTePlay(); AudioTest(Context context) { super(context);
playbackRepetitions = getIntPreference(context, R.string.preference_audio_out_reps, 10);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/MidiTest.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // }
import static org.chromium.latency.walt.Utils.getIntPreference; import android.annotation.TargetApi; import android.content.Context; import android.media.midi.MidiDevice; import android.media.midi.MidiDeviceInfo; import android.media.midi.MidiInputPort; import android.media.midi.MidiManager; import android.media.midi.MidiOutputPort; import android.media.midi.MidiReceiver; import android.os.Handler; import java.io.IOException; import java.util.ArrayList; import java.util.Locale;
/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.chromium.latency.walt; @TargetApi(23) class MidiTest extends BaseTest { private Handler handler = new Handler(); private static final String TEENSY_MIDI_NAME = "Teensyduino Teensy MIDI"; private static final byte[] noteMsg = {(byte) 0x90, (byte) 99, (byte) 0}; private MidiManager midiManager; private MidiDevice midiDevice; // Output and Input here are with respect to the MIDI device, not the Android device. private MidiOutputPort midiOutputPort; private MidiInputPort midiInputPort; private boolean isConnecting = false; private long last_tWalt = 0; private long last_tSys = 0; private long last_tJava = 0; private int inputSyncAfterRepetitions = 100; private int outputSyncAfterRepetitions = 20; // TODO: implement periodic clock sync for output private int inputRepetitions; private int outputRepetitions; private int repetitionsDone; private ArrayList<Double> deltasToSys = new ArrayList<>(); ArrayList<Double> deltasInputTotal = new ArrayList<>(); ArrayList<Double> deltasOutputTotal = new ArrayList<>(); private static final int noteDelay = 300; private static final int timeout = 1000; MidiTest(Context context) { super(context);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/MidiTest.java import static org.chromium.latency.walt.Utils.getIntPreference; import android.annotation.TargetApi; import android.content.Context; import android.media.midi.MidiDevice; import android.media.midi.MidiDeviceInfo; import android.media.midi.MidiInputPort; import android.media.midi.MidiManager; import android.media.midi.MidiOutputPort; import android.media.midi.MidiReceiver; import android.os.Handler; import java.io.IOException; import java.util.ArrayList; import java.util.Locale; /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.chromium.latency.walt; @TargetApi(23) class MidiTest extends BaseTest { private Handler handler = new Handler(); private static final String TEENSY_MIDI_NAME = "Teensyduino Teensy MIDI"; private static final byte[] noteMsg = {(byte) 0x90, (byte) 99, (byte) 0}; private MidiManager midiManager; private MidiDevice midiDevice; // Output and Input here are with respect to the MIDI device, not the Android device. private MidiOutputPort midiOutputPort; private MidiInputPort midiInputPort; private boolean isConnecting = false; private long last_tWalt = 0; private long last_tSys = 0; private long last_tJava = 0; private int inputSyncAfterRepetitions = 100; private int outputSyncAfterRepetitions = 20; // TODO: implement periodic clock sync for output private int inputRepetitions; private int outputRepetitions; private int repetitionsDone; private ArrayList<Double> deltasToSys = new ArrayList<>(); ArrayList<Double> deltasInputTotal = new ArrayList<>(); ArrayList<Double> deltasOutputTotal = new ArrayList<>(); private static final int noteDelay = 300; private static final int timeout = 1000; MidiTest(Context context) { super(context);
inputRepetitions = getIntPreference(context, R.string.preference_midi_in_reps, 100);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/AudioFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // }
import android.Manifest; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.media.AudioManager; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.components.LimitLine; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static org.chromium.latency.walt.Utils.getIntPreference;
public void onDestroy() { super.onDestroy(); audioTest.teardown(); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.button_start_audio: chartLayout.setVisibility(View.GONE); disableButtons(); AudioTestType testType = getSelectedTestType(); switch (testType) { case CONTINUOUS_PLAYBACK: case CONTINUOUS_RECORDING: case DISPLAY_WAVEFORM: audioTest.setAudioMode(AudioTest.AudioMode.CONTINUOUS); audioTest.setPeriod(AudioTest.CONTINUOUS_TEST_PERIOD); break; case COLD_PLAYBACK: case COLD_RECORDING: audioTest.setAudioMode(AudioTest.AudioMode.CONTINUOUS); audioTest.setPeriod(AudioTest.COLD_TEST_PERIOD); break; } if (testType == AudioTestType.DISPLAY_WAVEFORM) { // Only need to record 1 beep to display wave audioTest.setRecordingRepetitions(1); } else { audioTest.setRecordingRepetitions(
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/AudioFragment.java import android.Manifest; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.media.AudioManager; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.components.LimitLine; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static org.chromium.latency.walt.Utils.getIntPreference; public void onDestroy() { super.onDestroy(); audioTest.teardown(); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.button_start_audio: chartLayout.setVisibility(View.GONE); disableButtons(); AudioTestType testType = getSelectedTestType(); switch (testType) { case CONTINUOUS_PLAYBACK: case CONTINUOUS_RECORDING: case DISPLAY_WAVEFORM: audioTest.setAudioMode(AudioTest.AudioMode.CONTINUOUS); audioTest.setPeriod(AudioTest.CONTINUOUS_TEST_PERIOD); break; case COLD_PLAYBACK: case COLD_RECORDING: audioTest.setAudioMode(AudioTest.AudioMode.CONTINUOUS); audioTest.setPeriod(AudioTest.COLD_TEST_PERIOD); break; } if (testType == AudioTestType.DISPLAY_WAVEFORM) { // Only need to record 1 beep to display wave audioTest.setRecordingRepetitions(1); } else { audioTest.setRecordingRepetitions(
getIntPreference(getContext(), R.string.preference_audio_in_reps, 5));
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/ScreenResponseFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.Choreographer; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static org.chromium.latency.walt.Utils.getBooleanPreference; import static org.chromium.latency.walt.Utils.getIntPreference;
private boolean isFastPathGraphics = false; int initiatedBlinks = 0; int detectedBlinks = 0; boolean isBoxWhite = false; long lastFrameStartTime; long lastFrameCallbackTime; long lastSetBackgroundTime; ArrayList<Double> deltas_w2b = new ArrayList<>(); ArrayList<Double> deltas_b2w = new ArrayList<>(); ArrayList<Double> deltas = new ArrayList<>(); private static final int color_gray = Color.argb(0xFF, 0xBB, 0xBB, 0xBB); private StringBuilder brightnessCurveData; private BroadcastReceiver logReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!isTestRunning) { String msg = intent.getStringExtra("message"); blackBox.append(msg + "\n"); } } }; public ScreenResponseFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/ScreenResponseFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.Choreographer; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static org.chromium.latency.walt.Utils.getBooleanPreference; import static org.chromium.latency.walt.Utils.getIntPreference; private boolean isFastPathGraphics = false; int initiatedBlinks = 0; int detectedBlinks = 0; boolean isBoxWhite = false; long lastFrameStartTime; long lastFrameCallbackTime; long lastSetBackgroundTime; ArrayList<Double> deltas_w2b = new ArrayList<>(); ArrayList<Double> deltas_b2w = new ArrayList<>(); ArrayList<Double> deltas = new ArrayList<>(); private static final int color_gray = Color.argb(0xFF, 0xBB, 0xBB, 0xBB); private StringBuilder brightnessCurveData; private BroadcastReceiver logReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!isTestRunning) { String msg = intent.getStringExtra("message"); blackBox.append(msg + "\n"); } } }; public ScreenResponseFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/ScreenResponseFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.Choreographer; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static org.chromium.latency.walt.Utils.getBooleanPreference; import static org.chromium.latency.walt.Utils.getIntPreference;
int initiatedBlinks = 0; int detectedBlinks = 0; boolean isBoxWhite = false; long lastFrameStartTime; long lastFrameCallbackTime; long lastSetBackgroundTime; ArrayList<Double> deltas_w2b = new ArrayList<>(); ArrayList<Double> deltas_b2w = new ArrayList<>(); ArrayList<Double> deltas = new ArrayList<>(); private static final int color_gray = Color.argb(0xFF, 0xBB, 0xBB, 0xBB); private StringBuilder brightnessCurveData; private BroadcastReceiver logReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!isTestRunning) { String msg = intent.getStringExtra("message"); blackBox.append(msg + "\n"); } } }; public ScreenResponseFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // } // // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getInt(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/ScreenResponseFragment.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.Choreographer; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static org.chromium.latency.walt.Utils.getBooleanPreference; import static org.chromium.latency.walt.Utils.getIntPreference; int initiatedBlinks = 0; int detectedBlinks = 0; boolean isBoxWhite = false; long lastFrameStartTime; long lastFrameCallbackTime; long lastSetBackgroundTime; ArrayList<Double> deltas_w2b = new ArrayList<>(); ArrayList<Double> deltas_b2w = new ArrayList<>(); ArrayList<Double> deltas = new ArrayList<>(); private static final int color_gray = Color.argb(0xFF, 0xBB, 0xBB, 0xBB); private StringBuilder brightnessCurveData; private BroadcastReceiver logReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!isTestRunning) { String msg = intent.getStringExtra("message"); blackBox.append(msg + "\n"); } } }; public ScreenResponseFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
shouldShowLatencyChart = getBooleanPreference(getContext(), R.string.preference_show_blink_histogram, true);
google/walt
android/WALT/app/src/main/java/org/chromium/latency/walt/TapLatencyFragment.java
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // }
import java.util.ArrayList; import java.util.Locale; import static org.chromium.latency.walt.Utils.getBooleanPreference; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.TextView; import java.io.IOException;
physicalToKernelTime, kernelToCallbackTime)); } } traceLogEvent(tapEvent); updateCountsDisplay(); return true; } }; private void traceLogEvent(UsMotionEvent tapEvent) { if (!tapEvent.isOk) return; if (traceLogger == null) return; if (tapEvent.action != MotionEvent.ACTION_DOWN && tapEvent.action != MotionEvent.ACTION_UP) return; final String title = tapEvent.action == MotionEvent.ACTION_UP ? "Tap-Up" : "Tap-Down"; traceLogger.log(tapEvent.physicalTime + waltDevice.clock.baseTime, tapEvent.kernelTime + waltDevice.clock.baseTime, title + " Physical", "Bar starts at accelerometer shock and ends at kernel time of tap event"); traceLogger.log(tapEvent.kernelTime + waltDevice.clock.baseTime, tapEvent.createTime + waltDevice.clock.baseTime, title + " App Callback", "Bar starts at kernel time of tap event and ends at app callback time"); } public TapLatencyFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java // static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) { // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); // return preferences.getBoolean(context.getString(keyId), defaultValue); // } // Path: android/WALT/app/src/main/java/org/chromium/latency/walt/TapLatencyFragment.java import java.util.ArrayList; import java.util.Locale; import static org.chromium.latency.walt.Utils.getBooleanPreference; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.TextView; import java.io.IOException; physicalToKernelTime, kernelToCallbackTime)); } } traceLogEvent(tapEvent); updateCountsDisplay(); return true; } }; private void traceLogEvent(UsMotionEvent tapEvent) { if (!tapEvent.isOk) return; if (traceLogger == null) return; if (tapEvent.action != MotionEvent.ACTION_DOWN && tapEvent.action != MotionEvent.ACTION_UP) return; final String title = tapEvent.action == MotionEvent.ACTION_UP ? "Tap-Up" : "Tap-Down"; traceLogger.log(tapEvent.physicalTime + waltDevice.clock.baseTime, tapEvent.kernelTime + waltDevice.clock.baseTime, title + " Physical", "Bar starts at accelerometer shock and ends at kernel time of tap event"); traceLogger.log(tapEvent.kernelTime + waltDevice.clock.baseTime, tapEvent.createTime + waltDevice.clock.baseTime, title + " App Callback", "Bar starts at kernel time of tap event and ends at app callback time"); } public TapLatencyFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
shouldShowLatencyChart = getBooleanPreference(getContext(), R.string.preference_show_tap_histogram, true);