Package eu.planets_project.pp.plato.xml.freemind

Source Code of eu.planets_project.pp.plato.xml.freemind.PolicyNode

/*******************************************************************************
* Copyright (c) 2006-2010 Vienna University of Technology,
* Department of Software Technology and Interactive Systems
*
* All rights reserved. This program and the accompanying
* materials are made available under the terms of the
* Apache License, Version 2.0 which accompanies
* this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*******************************************************************************/
package eu.planets_project.pp.plato.xml.freemind;

import eu.planets_project.pp.plato.model.scales.BooleanScale;
import eu.planets_project.pp.plato.model.scales.IntRangeScale;
import eu.planets_project.pp.plato.model.scales.OrdinalScale;
import eu.planets_project.pp.plato.model.scales.PositiveFloatScale;
import eu.planets_project.pp.plato.model.scales.RestrictedScale;
import eu.planets_project.pp.plato.model.scales.Scale;
import eu.planets_project.pp.plato.util.PlatoLogger;


public class PolicyNode extends Node {

    public Scale createScale() {
        try {
            if ("Y".equals(getTEXT())) {
                return new BooleanScale();
            }

            if ("N".equals(getTEXT())) {
                return new BooleanScale();
            }

            if ("?".equals(getTEXT())) {
                return null;
            }

            if (getTEXT().indexOf(Scale.SEPARATOR) != -1 ) {
                RestrictedScale v = null;
                v = new IntRangeScale();
                if (! ((IntRangeScale)v).validateAndSetRestriction(getTEXT())) {
                    v= new OrdinalScale();
                    v.setRestriction(getTEXT());
                }
                return v;
            }
        } catch (Exception e) {
            PlatoLogger.getLogger(this.getClass()).warn("invalid scale format, ignoring: "+getTEXT(),e);
        }

        //default behaviour: float scale and the TEXT as unit
        PositiveFloatScale v = new PositiveFloatScale();
        v.setUnit(getTEXT());
        return v;
    }
}
TOP

Related Classes of eu.planets_project.pp.plato.xml.freemind.PolicyNode

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.