switch(status) {
                    case DEMAND:
                        state = OpenClosedType.CLOSED;
                        break;
                    case NO_DEMAND:
                        state = OpenClosedType.OPEN;
                        break;
                    default:
                        break;
                }

package org.openhab.binding.rfxcom.internal.messages;

import java.util.Arrays;
import java.util.List;
import javax.xml.bind.DatatypeConverter;
import org.openhab.binding.rfxcom.RFXComValueSelector;
import org.openhab.binding.rfxcom.internal.RFXComException;
import org.openhab.core.library.items.ContactItem;
import org.openhab.core.library.items.NumberItem;
import org.openhab.core.library.items.StringItem;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.types.State;
import org.openhab.core.types.Type;
import org.openhab.core.types.UnDefType;

/**
 * RFXCOM data class for thermostat1 message.
 * Digimax 210 Thermostat RF sensor operational
 *
 * @author Les Ashworth
 * @since 1.4.0
 */
public class RFXComThermostat1Message extends RFXComBaseMessage {

    public enum SubType {

        DIGIMAX_TLX7506(0), DIGIMAX_SHORT_FORMAT(1), UNKNOWN(255);

        private final int subType;

        SubType(int subType) {
            this.subType = subType;
        }

        SubType(byte subType) {
            this.subType = subType;
        }

        public byte toByte() {
            return (byte) subType;
        }

        public static SubType fromByte(int input) {
            for (SubType c : SubType.values()) {
                if (c.subType == input) {
                    return c;
                }
            }
            return SubType.UNKNOWN;
        }
    }

    /* Added item for ContactTypes */
    public enum Status {

        NO_STATUS(0), DEMAND(1), NO_DEMAND(2), INITIALIZING(3), UNKNOWN(255);

        private final int contact;

        Status(int contact) {
            this.contact = contact;
        }

        Status(byte contact) {
            this.contact = contact;
        }

        public byte toByte() {
            return (byte) contact;
        }

        public static Status fromByte(int input) {
            for (Status contact : Status.values()) {
                if (contact.contact == input) {
                    return contact;
                }
            }
            return Status.UNKNOWN;
        }
    }

    /* Operating mode */
    public enum Mode {

        HEATING(0), COOLING(1), UNKNOWN(255);

        private final int mode;

        Mode(int mode) {
            this.mode = mode;
        }

        Mode(byte mode) {
            this.mode = mode;
        }

        public byte toByte() {
            return (byte) mode;
        }

        public static Mode fromByte(int input) {
            for (Mode mode : Mode.values()) {
                if (mode.mode == input) {
                    return mode;
                }
            }
            return Mode.UNKNOWN;
        }
    }

    private final static List<RFXComValueSelector> supportedValueSelectors = Arrays.asList(RFXComValueSelector.RAW_DATA, RFXComValueSelector.SIGNAL_LEVEL, RFXComValueSelector.BATTERY_LEVEL, RFXComValueSelector.TEMPERATURE, RFXComValueSelector.SET_POINT, RFXComValueSelector.CONTACT);

    public SubType subType = SubType.UNKNOWN;

    public int sensorId = 0;

    public byte temperature = 0;

    public byte set = 0;

    public Mode mode = Mode.UNKNOWN;

    public Status status = Status.UNKNOWN;

    public byte signalLevel = 0;

    public RFXComThermostat1Message() {
        packetType = PacketType.THERMOSTAT1;
    }

    public RFXComThermostat1Message(byte[] data) {
        encodeMessage(data);
    }

    @Override
    public String toString() {
        String str = "";
        str += super.toString();
        str += "\n - Sub type = " + subType;
        str += "\n - Id = " + sensorId;
        str += "\n - Temperature = " + temperature;
        str += "\n - Set = " + set;
        str += "\n - Mode = " + mode;
        str += "\n - Status = " + status;
        str += "\n - Signal level = " + signalLevel;
        return str;
    }

    @Override
    public void encodeMessage(byte[] data) {
        super.encodeMessage(data);
        subType = SubType.fromByte(super.subType);
        sensorId = (data[4] & 0xFF) << 8 | (data[5] & 0xFF);
        temperature = data[6];
        set = data[7];
        mode = Mode.fromByte(data[8] >> 7);
        status = Status.fromByte(data[8] & 0x03);
        signalLevel = (byte) ((data[9] & 0xF0) >> 4);
    }

    @Override
    public byte[] decodeMessage() {
        byte[] data = new byte[10];
        data[0] = (byte) (data.length - 1);
        data[1] = RFXComBaseMessage.PacketType.THERMOSTAT1.toByte();
        data[2] = subType.toByte();
        data[3] = seqNbr;
        data[4] = (byte) ((sensorId & 0xFF00) >> 8);
        data[5] = (byte) (sensorId & 0x00FF);
        data[6] = (temperature);
        data[7] = (set);
        data[8] = (byte) ((mode.toByte() << 7) | (status.toByte() & 0xFF));
        data[9] = (byte) (signalLevel << 4);
        return data;
    }

    @Override
    public String generateDeviceId() {
        return String.valueOf(sensorId);
    }

    @Override
    public State convertToState(RFXComValueSelector valueSelector) throws RFXComException {
        org.openhab.core.types.State state = UnDefType.UNDEF;
        if (valueSelector.getItemClass() == NumberItem.class) {
            if (valueSelector == RFXComValueSelector.SIGNAL_LEVEL) {
                state = new DecimalType(signalLevel);
            } else if (valueSelector == RFXComValueSelector.TEMPERATURE) {
                state = new DecimalType(temperature);
            } else if (valueSelector == RFXComValueSelector.SET_POINT) {
                state = new DecimalType(set);
            } else {
                throw new NumberFormatException("Can't convert " + valueSelector + " to NumberItem");
            }
        } else if (valueSelector.getItemClass() == StringItem.class) {
            if (valueSelector == RFXComValueSelector.RAW_DATA) {
                state = new StringType(DatatypeConverter.printHexBinary(rawMessage));
            } else {
                throw new NumberFormatException("Can't convert " + valueSelector + " to StringItem");
            }
        } else if (valueSelector.getItemClass() == ContactItem.class) {
            if (valueSelector == RFXComValueSelector.CONTACT) {

            }
        } else {
            throw new NumberFormatException("Can't convert " + valueSelector + " to " + valueSelector.getItemClass());
        }
        return state;
    }

    @Override
    public void convertFromState(RFXComValueSelector valueSelector, String id, Object subType, Type type, byte seqNumber) throws RFXComException {
        throw new RFXComException("Not supported");
    }

    @Override
    public Object convertSubType(String subType) throws RFXComException {
        for (SubType s : SubType.values()) {
            if (s.toString().equals(subType)) {
                return s;
            }
        }
        throw new RFXComException("Unknown sub type " + subType);
    }

    @Override
    public List<RFXComValueSelector> getSupportedValueSelectors() throws RFXComException {
        return supportedValueSelectors;
    }
}


switch(action.visit(this)) {
                case ASTVisitor.PROCESS_ABORT:
                    return false;
                case ASTVisitor.PROCESS_SKIP:
                    return true;
                default:
                    break;
            }

/**
 * ****************************************************************************
 *
 *  Contributors:
 *     John Camelon (IBM) - Initial API and implementation
 *     Bryan Wilkinson (QNX)
 * *****************************************************************************
 */
package org.eclipse.cdt.internal.core.dom.parser.cpp;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;

public class CPPASTUsingDirective extends ASTNode implements ICPPASTUsingDirective, ICPPASTCompletionContext {

    private IASTName name;

    public CPPASTUsingDirective() {
    }

    public CPPASTUsingDirective(IASTName name) {
        setQualifiedName(name);
    }

    public CPPASTUsingDirective copy() {
        return copy(CopyStyle.withoutLocations);
    }

    public CPPASTUsingDirective copy(CopyStyle style) {
        CPPASTUsingDirective copy = new CPPASTUsingDirective(name == null ? null : name.copy(style));
        copy.setOffsetAndLength(this);
        if (style == CopyStyle.withLocations) {
            copy.setCopyLocation(this);
        }
        return copy;
    }

    public IASTName getQualifiedName() {
        return name;
    }

    public void setQualifiedName(IASTName qualifiedName) {
        assertNotFrozen();
        this.name = qualifiedName;
        if (qualifiedName != null) {
            qualifiedName.setParent(this);
            qualifiedName.setPropertyInParent(QUALIFIED_NAME);
        }
    }

    @Override
    public boolean accept(ASTVisitor action) {
        if (action.shouldVisitDeclarations) {

        }
        if (name != null)
            if (!name.accept(action))
                return false;
        if (action.shouldVisitDeclarations) {
            switch(action.leave(this)) {
                case ASTVisitor.PROCESS_ABORT:
                    return false;
                case ASTVisitor.PROCESS_SKIP:
                    return true;
                default:
                    break;
            }
        }
        return true;
    }

    public int getRoleForName(IASTName n) {
        if (n == name)
            return r_reference;
        return r_unclear;
    }

    public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) {
        IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
        List<IBinding> filtered = new ArrayList<IBinding>();
        for (IBinding binding : bindings) {
            if (binding instanceof ICPPNamespace) {
                filtered.add(binding);
            }
        }
        return filtered.toArray(new IBinding[filtered.size()]);
    }

    public IBinding[] findBindings(IASTName n, boolean isPrefix) {
        return findBindings(n, isPrefix, null);
    }
}


switch(m_interpolation) {
            default:
            case INTERP_LINEAR:
                return coeff_linear(v0, v1);
            case INTERP_IF:
                return coeff_IF(v0, v1);
            case INTERP_THRESHOLD:
                return coeff_threshold(v0, v1);
        }

/**
 * **************************************************************************
 *
 *  purpose. Use it at your own risk. If there's a problem you get to fix it.
 *
 * **************************************************************************
 */
package abfab3d.grid.op;

import abfab3d.core.GridDataDesc;
import abfab3d.core.GridDataChannel;
import abfab3d.core.Grid2D;
import abfab3d.grid.Grid2DInt;
import abfab3d.grid.Grid2DShort;
import abfab3d.grid.Grid2DByte;
import abfab3d.grid.Operation2D;
import abfab3d.grid.util.GridUtil;
import abfab3d.core.MathUtil;
import abfab3d.core.Bounds;
import abfab3d.param.BaseParameterizable;
import abfab3d.param.Parameter;
import abfab3d.param.DoubleParameter;
import abfab3d.param.IntParameter;
import abfab3d.util.PointMap;
import static abfab3d.core.Output.printf;
import static abfab3d.core.Output.time;
import static abfab3d.core.Units.MM;
import static java.lang.Math.max;
import static java.lang.Math.sqrt;
import static java.lang.Math.round;
import static abfab3d.core.MathUtil.iround;

/**
 * calculates signed distance data of 2D shape represented on the Grid2D
 *
 * the shape is given via implicit equation AttributeChannel.getValue(grid.getAttribute(x,y)) = threshold
 *
 * distance inside shape is negative
 * distance outside shape is positive
 *
 * interior pixels not reached by maxInDistance are initialized to -maxInDstance
 * exterior pixels not reached by maxOutDistance are initialized to maxOutDstance
 *
 * @author Vladimir Bulatov
 */
public class DistanceTransform2DOp extends BaseParameterizable implements Operation2D {

    public static boolean DEBUG = false;

    public static boolean DEBUG_TIMING = true;

    static int debugCount = 100;

    static final double TOL = 1.e-2;

    // half voxel offset to the center of voxel
    static final double HALF = 0.5;

    DoubleParameter mp_maxOutDist = new DoubleParameter("maxOutDist", "maximal outer distance to make transform", 10 * MM);

    DoubleParameter mp_maxInDist = new DoubleParameter("maxInDist", "maximal inner distance to make transform", 10 * MM);

    DoubleParameter mp_surfaceValue = new DoubleParameter("surface", "surface of the shape value", 0.5);

    IntParameter mp_interiorSign = new IntParameter("interiorSign", "sign of shape interior values", 1);

    IntParameter mp_interpolation = new IntParameter("interpolation", "type of interpolation", INTERP_LINEAR);

    DoubleParameter mp_surfaceLayerThickness = new DoubleParameter("surfaceLayerThickness", "thickness of initila surface layer", 2);

    Parameter[] m_param = new Parameter[] { mp_maxOutDist, mp_maxInDist, mp_surfaceValue, mp_interiorSign, mp_surfaceLayerThickness };

    public static final int INTERP_THRESHOLD = 0, INTERP_LINEAR = 1, INTERP_IF = 2;

    /**
     *     @param inDistance maximal distance to calculate transform inside of the shape. Measured in meters
     *     @param outDistance maximal distance to calculate transform outside of the shape. Measured in meters
     *     @param surfaceValue value at surface of the shape
     */
    public DistanceTransform2DOp(double maxInDistance, double maxOutDistance, double surfaceValue) {
        this(maxInDistance, maxOutDistance, surfaceValue, 1);
    }

    /**
     *     @param inDistance maximal distance to calculate transform inside of the shape. Measured in meters
     *     @param outDistance maximal distance to calculate transform outside of the shape. Measured in meters
     *     @param surfaceValue value at surface of the shape
     *     @param interiorSign sign of shape interior
     */
    public DistanceTransform2DOp(double maxInDistance, double maxOutDistance, double surfaceValue, int interiorSign) {
        addParams(m_param);
        mp_maxInDist.setValue(maxInDistance);
        mp_maxOutDist.setValue(maxOutDistance);
        mp_surfaceValue.setValue(surfaceValue);
    }

    /**
     *       set sign to be used for interior of the input shape
     */
    public void setInteriorSign(int interiorSign) {
        mp_interiorSign.setValue(interiorSign);
    }

    public void setInterpolation(int interpolation) {
        mp_interpolation.setValue(interpolation);
    }

    // local class variable
    private double m_maxInDistance;

    private double m_maxOutDistance;

    private double m_voxelSize;

    private int m_nx;

    private int m_ny;

    private int[] m_neighbors;

    private int m_subvoxelResolution = 100;

    private double m_surfaceValue;

    // sign of input data inside of shape
    private int m_interiorSign;

    int m_interpolation = INTERP_LINEAR;

    private GridDataChannel m_dataChannel;

    private PointMap m_points;

    private Grid2D m_indexGrid;

    private Grid2D m_distanceGrid;

    /**
     * Execute an operation on a grid.  If the operation changes the grid
     * dimensions then a new one will be returned from the call.
     *
     * @param grid The grid to use for grid A.
     * @return new grid with distance transform data
     */
    public Grid2D execute(Grid2D grid) {
        long t0 = time();
        double surfaceLayerThickness = mp_surfaceLayerThickness.getValue();
        m_interpolation = mp_interpolation.getValue();
        m_maxInDistance = mp_maxInDist.getValue();
        m_maxOutDistance = mp_maxOutDist.getValue();
        m_surfaceValue = mp_surfaceValue.getValue();
        m_interiorSign = mp_interiorSign.getValue();
        if (DEBUG)
            printf("DistanceTransform2D.execute(%s)\n", grid.getClass().getName());
        if (DEBUG)
            printf("  m_inDistance: %7.3f mm  m_outDistance: %7.3f mm \n", m_maxInDistance / MM, m_maxOutDistance / MM);
        m_voxelSize = grid.getVoxelSize();
        m_nx = grid.getWidth();
        m_ny = grid.getHeight();
        m_dataChannel = grid.getDataDesc().getChannel(0);
        m_neighbors = Neighborhood.makeDisk(surfaceLayerThickness + 1);
        Bounds bounds = grid.getGridBounds();
        m_indexGrid = new Grid2DInt(bounds, m_voxelSize);
        m_distanceGrid = new Grid2DShort(m_nx, m_ny, m_voxelSize);
        GridDataChannel distChannel = new GridDataChannel(GridDataChannel.DISTANCE, "dist", 16, 0, -m_maxInDistance, m_maxOutDistance);
        m_distanceGrid.setDataDesc(new GridDataDesc(distChannel));
        // init dist grid with value outside of syrface layer
        GridUtil.fill(m_distanceGrid, distChannel.makeAtt(surfaceLayerThickness));
        // subvoxel precision ofd point hash map
        m_points = new PointMap(0.01);
        m_points.add(0, 0, 0);
        // find surface points
        // initialize distanceas in thin layer around surface
        initializeSurfaceLayer(grid, surfaceLayerThickness);
        int pcnt = m_points.getPointCount();
        double[] px = new double[pcnt];
        double[] py = new double[pcnt];
        m_points.getPoints(px, py);
        if (false) {
            printf("points count: %d\n", pcnt);
            for (int i = 1; i < pcnt; i++) {
                printf("(%5.2f %5.2f)\n", px[i], py[i]);
            }
        }
        // distribute distances to the whole grid
        ClosestPointIndexer.PI2(pcnt, px, py, m_indexGrid);
        ClosestPointIndexer.getPointsInWorldUnits(m_indexGrid, px, py);
        Grid2D interiorGrid = makeInteriorGrid(grid, m_dataChannel, m_surfaceValue, m_interiorSign);
        ClosestPointIndexer.makeDistanceGrid2D(m_indexGrid, px, py, interiorGrid, m_maxInDistance, m_maxOutDistance, m_distanceGrid);
        if (DEBUG)
            printf("DistanceTransformIndexed2D.execute() time: %d ms\n", (time() - t0));
        return m_distanceGrid;
    }

    public Grid2D getIndexGrid() {
        return m_indexGrid;
    }

    public Grid2D getDistanceGrid() {
        return m_distanceGrid;
    }

    void initializeSurfaceLayer(Grid2D dataGrid, double surfaceThickness) {
        int nx = dataGrid.getWidth();
        int ny = dataGrid.getHeight();
        GridDataChannel dataConverter = m_dataChannel;
        int nx1 = nx - 1;
        int ny1 = ny - 1;
        double vs = dataGrid.getVoxelSize();
        Bounds bounds = dataGrid.getGridBounds();
        double xmin = bounds.xmin;
        double ymin = bounds.ymin;
        double th = m_surfaceValue;
        for (int iy = 0; iy < ny1; iy++) {
            double y = iy + HALF;
            for (int ix = 0; ix < nx1; ix++) {
                double x = ix + HALF;
                double v0 = dataConverter.getValue(dataGrid.getAttribute(ix, iy)) - th;
                double vx = dataConverter.getValue(dataGrid.getAttribute(ix + 1, iy)) - th;
                double vy = dataConverter.getValue(dataGrid.getAttribute(ix, iy + 1)) - th;
                if ((v0 <= 0. && vx > 0) || (v0 >= 0. && vx < 0)) {
                    // add point on x segment
                    addPoint(x + coeff(v0, vx), y, surfaceThickness);
                }
                if ((v0 <= 0. && vy > 0) || (v0 >= 0. && vy < 0)) {
                    // add point on y segment
                    addPoint(x, y + coeff(v0, vy), surfaceThickness);
                }
            }
        }
    }

    final double coeff(double v0, double v1) {

    }

    final double coeff_threshold(double v0, double v1) {
        return (v0 / (v0 - v1) < 0.5) ? 0 : 1;
    }

    /**
     *       root of linear map (0,1) -> (v0, v1)
     *       v0 + x*(v1-v0) = 0
     */
    final double coeff_linear(double v0, double v1) {
        return v0 / (v0 - v1);
    }

    final double coeff_IF(double v0, double v1) {
        return MathUtil.coeffIF((v0 + m_surfaceValue), (v1 + m_surfaceValue));
    }

    // add point to the neigborhood in indexGrid
    // and update layerDistanceGrid
    final void addPoint(double px, double py, double surfaceThickness) {
        int x0 = iround(px);
        int y0 = iround(py);
        int index = 0;
        int ncount = m_neighbors.length;
        for (int i = 0; i < ncount; i += 3) {
            int vx = x0 + m_neighbors[i], vy = y0 + m_neighbors[i + 1];
            if (vx >= 0 && vy >= 0 && vx < m_nx && vy < m_ny) {
                double dx = vx + HALF - px, dy = vy + HALF - py;
                double dist = sqrt(dx * dx + dy * dy);
                if (dist <= surfaceThickness - TOL) {
                    int newdist = (int) (dist * m_subvoxelResolution + 0.5);
                    int olddist = (int) m_distanceGrid.getAttribute(vx, vy);
                    if (newdist < olddist) {
                        // better point found
                        m_distanceGrid.setAttribute(vx, vy, newdist);
                        if (index == 0) {
                            // point is being added first time
                            index = m_points.add(px, py, 0.);
                            if (false)
                                printf("adding new point (%7.4f, %7.4f) index: %d \n", px, py, index);
                        }
                        m_indexGrid.setAttribute(vx, vy, index);
                    }
                }
            }
        }
    }

    Grid2D makeInteriorGrid(Grid2D grid, GridDataChannel dataConverter, double threshold, int interiorSign) {
        int nx = grid.getWidth();
        int ny = grid.getHeight();
        Grid2D interiorGrid = new Grid2DByte(grid.getGridBounds(), grid.getVoxelSize());
        for (int y = 0; y < ny; y++) {
            for (int x = 0; x < nx; x++) {
                double d = interiorSign * (dataConverter.getValue(grid.getAttribute(x, y)) - threshold);
                if (d <= 0.) {
                    // exterior
                    interiorGrid.setAttribute(x, y, 0);
                } else {
                    interiorGrid.setAttribute(x, y, 1);
                }
            }
        }
        return interiorGrid;
    }
}


switch(style) {
            case Font.PLAIN:
                return resourceBundle.getString("Font.plain");
            case Font.BOLD:
                return resourceBundle.getString("Font.bold");
            case Font.ITALIC:
                return resourceBundle.getString("Font.italic");
            case Font.BOLD | Font.ITALIC:
                return resourceBundle.getString("Font.boldItalic");
            default:
                return "";
        }

package com.jidesoft.converter;

import java.awt.*;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Converter which converts Font to String and converts it back.
 */
public class FontConverter implements ObjectConverter {

    public String toString(Object object, ConverterContext context) {
        if (object instanceof Font) {
            Font font = (Font) object;
            return font.getName() + ", " + getResourceString(font.getStyle()) + ", " + font.getSize();
        } else {
            return null;
        }
    }

    protected String getResourceString(int style) {
        final ResourceBundle resourceBundle = Resource.getResourceBundle(Locale.getDefault());

    }

    protected int getStyleValue(String style) {
        final ResourceBundle resourceBundle = Resource.getResourceBundle(Locale.getDefault());
        if (resourceBundle.getString("Font.italic").equalsIgnoreCase(style)) {
            return Font.ITALIC;
        } else if (resourceBundle.getString("Font.bold").equalsIgnoreCase(style)) {
            return Font.BOLD;
        } else if (resourceBundle.getString("Font.boldItalic").equalsIgnoreCase(style)) {
            return Font.BOLD | Font.ITALIC;
        } else {
            return Font.PLAIN;
        }
    }

    public boolean supportToString(Object object, ConverterContext context) {
        return true;
    }

    public Object fromString(String string, ConverterContext context) {
        if (string == null || string.length() == 0) {
            return null;
        } else {
            String fontFace = null;
            int style = Font.PLAIN;
            int size = 10;
            String[] strings = string.split(",");
            if (strings.length > 0) {
                fontFace = strings[0].trim();
            }
            if (strings.length > 1) {
                style = getStyleValue(strings[1].trim());
            }
            if (strings.length > 2) {
                try {
                    double s = Double.parseDouble(strings[2].trim());
                    size = (int) s;
                } catch (NumberFormatException e) {
                    // ignore
                }
            }
            if (fontFace != null) {
                return new Font(fontFace, style, size);
            } else {
                return null;
            }
        }
    }

    public boolean supportFromString(String string, ConverterContext context) {
        return true;
    }
}