Examples of FSParsingException


Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

        try {
            if (pluginsInfoContent != null && pluginsInfoContent.length > 0) {
                plugins = PluginParser.getInstance().parse(pluginsInfoContent);
            }
            if (plugins == null) {
                throw new FSParsingException("Impossible to read attribute pluginsInfo");
            }
        } catch (FSParsingException e1) {
            displayError(e1.getMessage());
            LOGGER.log(Level.SEVERE, e1.getMessage());
        }
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

                if (currentConfig != null && currentConfig.length > 0) {

                    configuration = ConfigParser.getInstance().parse(CURRENT_CONFIG, currentConfig);
                }
                if (configuration == null) {
                    throw new FSParsingException("Impossible to read attribute currentConfig");
                }
            } catch (FSParsingException e1) {
                displayError(e1.getMessage());
                LOGGER.log(Level.SEVERE, e1.getMessage());
            }
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

            try {
                if (pluginsInfoContent != null && pluginsInfoContent.length > 0) {
                    plugins = PluginParser.getInstance().parse(pluginsInfoContent);
                }
                if (plugins == null) {
                    throw new FSParsingException("Impossible to read attribute pluginsInfo");
                }
            } catch (FSParsingException e1) {
                displayError(e1.getMessage());
                LOGGER.log(Level.SEVERE, e1.getMessage());
            }
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

                break;
            case ENUM:
                lEditorComponent = new ComboBox();
                if (param.getValues() == null || param.getValues().length == 0) {
                    throw new FSParsingException("Plugin parameter " + param.getName()
                            + " must have a values property.", lEditorComponent, labelName);
                }
                for (String s : param.getValues()) {
                    ((ComboBox) lEditorComponent).addItem(s);
                    if (s.equalsIgnoreCase(entry.getValue())) {
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

                        currentPlugin.addParameter(currentParameter);
                        currentParameter = null;
                    }
                    plugins.add(currentPlugin);
                } else if (currentParameter != null) {
                    throw new FSParsingException("FSParameter " + currentParameter.getName()
                            + " must exist within a plugin");
                }

                currentPlugin = new Plugin();
                currentPlugin.setName(name);

            } else if (sCurrentLine.endsWith(ParsingUtil.COLON)) {
                String name = sCurrentLine.replace(ParsingUtil.COLON, "").trim();
                if (currentPlugin == null) {
                    throw new FSParsingException("FSParameter " + name + " must exist within a plugin");
                } else if (currentParameter != null) {
                    throw new FSParsingException("No end character found for parameter " + currentParameter.getName());
                } else {
                    currentParameter = new Parameter();
                }

            } else if (sCurrentLine.contains(ParsingUtil.EQUALS)) {

                String[] entryPair = sCurrentLine.split(ParsingUtil.EQUALS);
                String key = entryPair[0].trim();
                String value = entryPair[1].trim();
                if (currentPlugin == null && currentParameter == null) {
                    throw new FSParsingException("Entry " + key + " must exist within a plugin or a parameter");
                } else {
                    // Handle new entry
                    if (currentParameter != null) {
                        if (ParsingUtil.NAME.equals(key)) {
                            currentParameter.setName(value);
                        } else if (ParsingUtil.DESCRIPTION.equals(key)) {
                            currentParameter.setDescription(value);
                        } else if (ParsingUtil.TYPE.equals(key)) {
                            EntryType type = getParameterType(value);
                            currentParameter.setType(type);
                        } else if (ParsingUtil.FORMAT.equals(key)) {
                            ParameterFormat format;
                            if (ParsingUtil.LIST.equals(value)) {
                                format = ParameterFormat.LIST;
                            } else {
                                format = ParameterFormat.SCALAR;
                            }
                            currentParameter.setFormat(format);
                        } else if (ParsingUtil.UNIT.equals(key)) {
                            currentParameter.setUnit(value);
                        } else if (ParsingUtil.MIN_VALUE.equals(key)) {
                            currentParameter.setMinValue(value);
                        } else if (ParsingUtil.MAX_VALUE.equals(key)) {
                            currentParameter.setMaxValue(value);
                        } else if (ParsingUtil.VALUES.equals(key)) {
                            value = value.replace(ParsingUtil.CURLY_BRACE_OPENNING, "")
                                    .replace(ParsingUtil.CURLY_BRACE_CLOSING, "").trim();
                            String[] val = value.split(",");
                            for (String s : val) {
                                s = s.trim();
                            }
                            currentParameter.setValues(val);
                        } else if (ParsingUtil.FROM_CLASS.equals(key)) {
                            value = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                    .replace(ParsingUtil.BRACKET_CLOSING, "").trim();
                            String[] val = value.split(",");
                            for (String s : val) {
                                s = s.trim();
                            }
                            currentParameter.setDevicesClass(val);
                        } else if (ParsingUtil.FROM_DEVICE.equals(key)) {
                            value = value.replace(ParsingUtil.CURLY_BRACE_OPENNING, "")
                                    .replace(ParsingUtil.CURLY_BRACE_CLOSING, "").trim();
                            String[] val = value.split(",");
                            for (String s : val) {
                                s = s.trim();
                            }
                            currentParameter.setAttributeList(val);
                        } else if (ParsingUtil.ATTRIBUTE_SPEC.equals(key)) {
                            currentParameter.setAttributeSpec(value);
                        } else if (ParsingUtil.DEFAULT_VALUE.equals(key)) {
                            currentParameter.setDefaultValue(value);
                        } else if ((key != null) && (key.contains(ParsingUtil.CONSTRAINTS))) {
                            String[] keyParts = key.split("/");
                            if (ParsingUtil.CONSTRAINT.equals(keyParts[1].trim())
                                    || ParsingUtil.CONSTRAINT.equals(keyParts[2].trim())) {
                                Constraint constraint = null;
                                if (value.startsWith(ParsingUtil.IN_LIST_KEYWORD)) {
                                    String[] lStr = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                            .replace(ParsingUtil.BRACKET_CLOSING, "").split(ParsingUtil.COMMA);
                                    List<Double> listDouble = new ArrayList<Double>();
                                    for (String s : lStr) {
                                        try {
                                            Double d = Double.parseDouble(s.trim());
                                            listDouble.add(d);

                                        } catch (NumberFormatException e) {
                                            throw new FSParsingException(e.getMessage(), e);
                                        }
                                    }
                                    constraint = new InConstraint(listDouble);

                                } else if (value.startsWith(ParsingUtil.IN_RANGE_KEYWORD)) {
                                    String[] lStr = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                            .replace(ParsingUtil.BRACKET_CLOSING, "").split(ParsingUtil.COMMA);
                                    if (lStr.length != 2) {
                                        throw new FSParsingException("Can not parse in range constraint value: "
                                                + value);
                                    }
                                    try {
                                        Double min = Double.parseDouble(lStr[0].trim());
                                        Double max = Double.parseDouble(lStr[1].trim());
                                        constraint = new MinMaxConstraint(min, max);
                                    } catch (NumberFormatException e) {
                                        throw new FSParsingException(e.getMessage(), e);
                                    }

                                } else if (ParsingUtil.CONSTANT_KEYWORD.equals(value)) {
                                    constraint = new ConstantConstraint();
                                }
                                if (constraint != null) {
                                    currentParameter.addConstraint(constraint);
                                }

                            }

                        } else if ((key != null) && (key.startsWith(ParsingUtil.IN_LIST_KEYWORD))) {
                            Constraint constraint = null;
                            String[] lStr = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                    .replace(ParsingUtil.BRACKET_CLOSING, "").split(ParsingUtil.COMMA);
                            List<Double> listDouble = new ArrayList<Double>();

                            try {
                                for (String s : lStr) {
                                    Double d = Double.parseDouble(s.trim());
                                    listDouble.add(d);
                                }
                                constraint = new InConstraint(listDouble);

                            } catch (NumberFormatException e) {
                                List<String> listStr = new ArrayList<String>();
                                for (String str : lStr) {
                                    listStr.add(str);
                                }
                                constraint = new InConstraintStr(listStr);
                                // throw new FSParsingException(e.getMessage(), e);
                            }

                            if (constraint != null) {
                                currentParameter.addConstraint(constraint);
                            }

                        } else if ((key != null) && key.startsWith(ParsingUtil.IN_RANGE_KEYWORD)) {
                            Constraint constraint = null;
                            String[] lStr = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                    .replace(ParsingUtil.BRACKET_CLOSING, "").split(ParsingUtil.COMMA);
                            if (lStr.length != 2) {
                                throw new FSParsingException("Can not parse in range constraint value: " + value);
                            }
                            try {
                                Double min = Double.parseDouble(lStr[0].trim());
                                Double max = Double.parseDouble(lStr[1].trim());
                                constraint = new MinMaxConstraint(min, max);
                            } catch (NumberFormatException e) {
                                throw new FSParsingException(e.getMessage(), e);
                            }
                            if (constraint != null) {
                                currentParameter.addConstraint(constraint);
                            }
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

        } else if (("timebase").equals(value)) {
            type = PluginType.TIMEBASE;
        } else if (("continuous-actuator").equals(value)) {
            type = PluginType.CONTINUOUS_ACTUATOR;
        } else {
            throw new FSParsingException("Unknown type of plugin: " + value);
        }
        return type;
    }
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

                            sections = new Section[SECTION_BUFFER_LENGTH];
                            index = 0;
                        }
//                        configuration.addSections(currentSection);
                    } else if (currentObject != null) {
                        throw new FSParsingException("Fly scan object " + currentObject.getName()
                                + " must exist within a section");
                    }

                    // Handle new section
                    if (name.equals(ParsingUtil.ACQUISITION)) {
                        currentSection = new AcquisitionSection();
                    } else if (name.equals(ParsingUtil.ACTORS)) {
                        currentSection = new ActorSection();
                    } else if (name.equals(ParsingUtil.BEHAVIOR)) {
                        currentSection = new BehaviorSection();
                    } else if (name.equals(ParsingUtil.INFO)) {
                        currentSection = new InfoSection();
                    } else if (name.equals(ParsingUtil.RECORDING)) {
                        currentSection = new RecordingSection();
                    } else {
                        currentSection = new Section(name);
                    }

                } else if (sCurrentLine.endsWith(ParsingUtil.COLON)) {
                    String name = sCurrentLine.replace(ParsingUtil.COLON, "").trim();
                    if (currentSection == null) {
                        throw new FSParsingException("Fly scan object " + name + " must exist within a section");
                    } else if (currentObject != null) {
                        // TODO VERIFIER SI TIRET FACULTATIF; SI OUI CLOTURER OBJECT CURRENTOBJECT
                        throw new FSParsingException("No end character has been found for fly scan object "
                                + currentObject.name);
                    } else {
                        // Handle new object
                        if (currentSection instanceof BehaviorSection) {
                            if (name.equals(ParsingUtil.CONTEXT_MONITOR)) {
                                currentObject = new ContextMonitorBehavior(currentSection);
                            } else if (name.equals(ParsingUtil.ACTUATOR)) {
                                currentObject = new ActuatorBehavior(currentSection);
                            } else if (name.equals(ParsingUtil.SENSOR)) {
                                currentObject = new SensorBehavior(currentSection);
                            } else if (name.equals(ParsingUtil.TIMEBASE)) {
                                currentObject = new TimeBaseBehavior(currentSection);
                            } else if (name.equals(ParsingUtil.HOOK)) {
                                currentObject = new HookBehavior(currentSection);
                            } else if (name.equals(ParsingUtil.MONITOR)) {
                                currentObject = new MonitorBehavior(currentSection);
                            }
                        } else if (currentSection instanceof ActorSection) {
                            if (name.equals(ParsingUtil.CONTEXT_MONITOR)) {
                                currentObject = new ContextMonitor(currentSection);
                            } else if (name.equals(ParsingUtil.ACTUATOR)) {
                                currentObject = new StepByStepActuator(currentSection);
                            } else if (name.equals(ParsingUtil.CONTINUOUS_ACTUATOR)) {
                                currentObject = new ContinuousActuator(currentSection);
                            }
//                        else if (name.equals(ParsingUtil.CUSTOM_ACTUATOR)) {
//                            currentObject = new CustomActuator(currentSection);
//                        }
                            else if (name.equals(ParsingUtil.SENSOR)) {
                                currentObject = new Sensor(currentSection);
                            } else if (name.equals(ParsingUtil.TIMEBASE)) {
                                currentObject = new TimeBase(currentSection);
                            } else if (name.equals(ParsingUtil.HOOK)) {
                                currentObject = new Hook(currentSection);
                            } else if (name.equals(ParsingUtil.MONITOR)) {
                                currentObject = new Monitor(currentSection);
                            } else if (name.startsWith(ParsingUtil.CONSTRAINT)) {
                                // Hierarchical constraint case processing
                                currentObject = new HierarchicalConstraint(currentSection);
                                String[] parts = name.split("/");
                                if (parts.length == 3) {
                                    String type = parts[1].trim();
                                    String actorName = parts[2].trim();
                                    ((HierarchicalConstraint) currentObject).setActorName(actorName);
                                    ((HierarchicalConstraint) currentObject).setActorType(ActorType.valueOf(type));

                                }

                            }
                        } else {
                            currentObject = new FSObject(name, currentSection);
                        }
                    }

                } else if (sCurrentLine.contains(ParsingUtil.EQUALS)) {
                    String[] entryPair = sCurrentLine.split(ParsingUtil.EQUALS);
                    String key = entryPair[0].trim();
                    // Method used to prevent bug in case the value of the entry contains '=' character
                    StringBuffer valueSB = new StringBuffer();
                    for (int i = 1; i < entryPair.length; i++) {
                        valueSB.append(entryPair[i]);
                    }
                    String value = valueSB.toString().trim();

                    if ((currentSection == null) && (currentObject == null)) {
                        throw new FSParsingException("Entry " + key + " must exist within a section or an object");
                    } else {
                        // Handle new entry
                        Entry entry = null;
                        if (key.startsWith(ParsingUtil.PARAMETER + ParsingUtil.COLON)) {
                            // Entry entry = null;
                            String[] keyParts = key.split(ParsingUtil.COLON);
                            if (keyParts.length >= 3) {
                                String name = keyParts[2].trim();
                                if (ParsingUtil.LEVEL.equals(keyParts[1].trim())) {
                                    if (currentObject != null) {
                                        entry = getExistingEntry(currentObject, name);
                                    } else if (currentSection != null) {
                                        // TODO Cas limite a tester: un parametre peut il etre specifie a la fois dans
                                        // un
                                        // object et dans son parent section?
                                        entry = getExistingEntry(currentSection, name);
                                    }
                                    if (entry != null) {
                                        entry.setExpert(true);
                                    }

                                } else {
                                    if (currentObject != null) {
                                        entry = getExistingParameterEntry(currentObject, name);
                                    } else if (currentSection != null) {
                                        // TODO Cas limite a tester: un parametre peut il etre specifie a la fois dans
                                        // un
                                        // object et dans son parent section?
                                        entry = getExistingParameterEntry(currentSection, name);
                                    }

                                    if (entry == null) {
                                        entry = new ParameterEntry();
                                    }

                                    entry.setKey(name);
                                    if (ParsingUtil.VALUE.equals(keyParts[1].trim())) {
                                        entry.setValue(value);
                                    } else if (ParsingUtil.CONSTRAINT.equals(keyParts[1].trim())) {
                                        Constraint constraint = null;
                                        if (value.startsWith(ParsingUtil.IN_LIST_KEYWORD)) {
                                            String[] lStr = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                                    .replace(ParsingUtil.BRACKET_CLOSING, "")
                                                    .replace(ParsingUtil.IN_LIST_KEYWORD, "").split(ParsingUtil.COMMA);
                                            List<Double> listDouble = new ArrayList<Double>();
                                            for (String s : lStr) {
                                                try {
                                                    Double d = Double.parseDouble(s.trim());
                                                    listDouble.add(d);

                                                } catch (NumberFormatException e) {

                                                    List<String> listStr = new ArrayList<String>();
                                                    for (String str : lStr) {
                                                        listStr.add(str);
                                                    }
                                                    constraint = new InConstraintStr(listStr);
                                                }
                                            }
                                            constraint = new InConstraint(listDouble);

                                        } else if (value.startsWith(ParsingUtil.IN_RANGE_KEYWORD)) {
                                            String[] lStr = value.replace(ParsingUtil.BRACKET_OPENNING, "")
                                                    .replace(ParsingUtil.BRACKET_CLOSING, "")
                                                    .replace(ParsingUtil.IN_RANGE_KEYWORD, "").split(ParsingUtil.COMMA);
                                            if (lStr.length != 2) {
                                                throw new FSParsingException(
                                                        "Can not parse in range constraint value: " + value);
                                            }
                                            try {
                                                Double min = Double.parseDouble(lStr[0].trim());
                                                Double max = Double.parseDouble(lStr[1].trim());
                                                constraint = new MinMaxConstraint(min, max);
                                            } catch (NumberFormatException e) {
                                                throw new FSParsingException(
                                                        "Failed to parse number value for parameter: " + key
                                                                + " (value=" + value + ")", e);
                                            }

                                        } else if (ParsingUtil.CONSTANT_KEYWORD.equals(value)) {
                                            constraint = new ConstantConstraint();
                                        }
                                        if (constraint != null && (entry instanceof ParameterEntry)) {
                                            ((ParameterEntry) entry).addConstraint(constraint);
                                        }

                                    }

                                    if (entry != null) {
                                        registerEntry(entry, currentObject, currentSection);
                                    }

                                }

                            }

                        } else if ((currentSection instanceof AcquisitionSection) && (currentObject == null)) {

                            if (key.equals(ParsingUtil.CONTINUOUS_RANGES) || key.equals(ParsingUtil.PERIOD)) {
                                entry = new PredefinedEntry(key, value, EntryType.INT);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.INFINITE_MODE) || key.equals(ParsingUtil.MANUAL_MODE)
                                    || key.equals(ParsingUtil.ZIGZAG)) {
                                entry = new PredefinedEntry(key, value, EntryType.BOOL);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.SCAN_DIMENSIONS)) {
                                entry = new PredefinedEntry(key, value, EntryType.MATRIX);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.SCAN_MODE)) {
                                entry = new PredefinedEntry(key, value, EntryType.STRING);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.CONTINUOUS)) {
                                entry = new PredefinedEntry(key, value, EntryType.BOOL);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.DIMENSIONS)) {
                                entry = new PredefinedEntry(key, value, EntryType.MATRIX);
                                registerEntry(entry, currentObject, currentSection);
                            } else {
                                entry = new Entry(key, value, false);
                                registerEntry(entry, currentObject, currentSection);
                            }
                        } else if ((currentSection instanceof BehaviorSection) && (currentObject == null)) {
                            if (ParsingUtil.ERROR_STRATEGY.equals(key)) {
                                entry = new PredefinedEntry(key, value, EntryType.ENUM);
                                registerEntry(entry, currentObject, currentSection);
                            }
                        } else if ((currentSection instanceof InfoSection) && (currentObject == null)) {

                            if (key.equals(ParsingUtil.AUTHORS) || key.equals(ParsingUtil.COMMENT)
                                    || key.equals(ParsingUtil.CONFIG_NAME) || key.equals(ParsingUtil.CONFIG_VERSION)
                                    || key.equals(ParsingUtil.FLYSCAN_VERSION) || key.equals(ParsingUtil.KEYWORDS)
                                    || key.equals(ParsingUtil.REVISION) || key.equals(ParsingUtil.VERSION)) {
                                entry = new PredefinedEntry(key, value, EntryType.STRING);
                                registerEntry(entry, currentObject, currentSection);
                            } else {
                                entry = new Entry(key, value, false);
                                registerEntry(entry, currentObject, currentSection);
                            }
                        } else if ((currentSection instanceof RecordingSection) && (currentObject == null)) {
                            if (key.equals(ParsingUtil.SPLIT) || key.equals(ParsingUtil.MAX_SCAN_LINES_PER_FILE)
                                    || key.equals(ParsingUtil.MAX_STEPS_PER_FILE)) {
                                entry = new PredefinedEntry(key, value, EntryType.NUMBER);
                                registerEntry(entry, currentObject, currentSection);
                            }

                        } else if ((currentObject != null) && ParsingUtil.BUFFER.equals(currentObject.getName())) {
                            if (key.equals(ParsingUtil.NAME)) {
                                entry = new PredefinedEntry(key, value, EntryType.STRING);
                                registerEntry(entry, currentObject, currentSection);
                            }
                        } else if (currentObject instanceof Actor) {
                            if (key.equals(ParsingUtil.IDENTIFIER) || key.equals(ParsingUtil.NAME)) {
                                entry = new PredefinedEntry(key, value, EntryType.STRING);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.DIMENSION)) {
                                entry = new PredefinedEntry(key, value, EntryType.INT);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.ENABLE)) {
                                entry = new PredefinedEntry(key, value, EntryType.BOOL);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (key.equals(ParsingUtil.TYPE)) {
                                entry = new PredefinedEntry(key, value, EntryType.STRING);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (currentObject instanceof Actuator) {
                                if (key.equals(ParsingUtil.TRAJECTORY)) {

                                    TrajectoryType type = null;
                                    if (((Actuator<?>) currentObject).isCustomTrajectory()) {
                                        type = TrajectoryType.CUSTOM;
                                        entry = new PredefinedEntry(key, value, EntryType.STRING);
                                    } else {
                                        entry = new TrajectoryEntry(key, value);
                                        if (currentObject instanceof ContinuousActuator) {
                                            type = TrajectoryType.CONTINUOUS;
                                        } else if (currentObject instanceof StepByStepActuator) {
                                            type = TrajectoryType.STEP_BY_STEP;
                                        }
//                                    else {
//                                        type = TrajectoryType.CUSTOM;
//                                    }
                                        try {
                                            Trajectory trajectory = TrajectoryParser.getInstance().parse(value, type);
                                            ((TrajectoryEntry) entry).setTrajectory(trajectory);
                                        } catch (FSParsingException e) {
                                            // Bufferize FSParsingException in case of custom trajectory and
                                            // 'custom_trajectory' keyword has not been read yet
                                            trajectoryparsingExceptionBuffer.put((Actuator<?>) currentObject, e);
                                        }
                                    }

                                    registerEntry(entry, currentObject, currentSection);
                                } else if (key.equals(ParsingUtil.CUSTOM_TRAJECTORY)) {
                                    entry = new PredefinedEntry(key, value, EntryType.BOOL);
                                    registerEntry(entry, currentObject, currentSection);
                                    boolean isCustomTrajectory = Boolean.parseBoolean(value.trim());
                                    ((Actuator<?>) currentObject).setCustomTrajectory(isCustomTrajectory);

                                    if (isCustomTrajectory) {
                                        // Verify if a trajectory has been specified before and overwrite it
                                        // This is the case where trajectory entry appears prior to
                                        // custom_trajectory=true
                                        // line
                                        for (Entry e : currentObject.getEntries()) {
                                            if (e instanceof TrajectoryEntry) {
                                                String k = e.getKey();
                                                String v = e.getValue();
                                                e = new PredefinedEntry(k, v, EntryType.STRING);
                                            }
                                        }
                                        // Delete map entry related to FSParsingException raised when parsing the custom
                                        // trajectory fails
                                        trajectoryparsingExceptionBuffer.remove(currentObject);
                                    }
                                } else {
                                    entry = new Entry(key, value, false);
                                    registerEntry(entry, currentObject, currentSection);
                                }
                            } else if (currentObject instanceof Hook) {
                                if (key.equals(ParsingUtil.ACTION)) {
                                    entry = new PredefinedEntry(key, value, EntryType.ENUM);
                                    registerEntry(entry, currentObject, currentSection);
                                }
                            } else {
                                entry = new Entry(key, value, false);
                                registerEntry(entry, currentObject, currentSection);
                            }
                        } else if (currentObject != null && currentObject instanceof BehaviorObject) {
                            if (ParsingUtil.DELAY.equals(key) || ParsingUtil.TIMEOUT.equals(key)) {
                                entry = new PredefinedEntry(key, value, EntryType.INT);
                                registerEntry(entry, currentObject, currentSection);
                            } else if (ParsingUtil.ERROR_STRATEGY.equals(key)) {
                                entry = new PredefinedEntry(key, value, EntryType.ENUM);
                                registerEntry(entry, currentObject, currentSection);
                            } else {
                                entry = new Entry(key, value, false);
                                registerEntry(entry, currentObject, currentSection);
                            }
                        } else if (currentObject != null && currentObject instanceof HierarchicalConstraint) {
                            // TODO syntaxe des contraintes hiérarchiques à clarifier
                            if (key.endsWith("enum")) {
                                List<String> possibleValues = Arrays.asList(value.replaceAll(" ", "").split(","));
                                Constraint inConstraint = new InConstraintStr(possibleValues);
                                ((HierarchicalConstraint) currentObject).setConstraint(inConstraint);
                            } else if (key.endsWith(ParsingUtil.VALUE)) {
                                String constant = value.trim();
                                Constraint constantConstraint = new ConstantConstraintStr(constant);
                                ((HierarchicalConstraint) currentObject).setPrerequisite(constantConstraint);
                            } else if (key.endsWith("min")) {
                                Constraint constraint = ((HierarchicalConstraint) currentObject).getConstraint();
                                if (constraint == null) {
                                    constraint = new MinMaxConstraint();
                                }
                                ((MinMaxConstraint) constraint).setMin(Double.parseDouble(value.trim()));
                                ((HierarchicalConstraint) currentObject).setConstraint(constraint);
                            } else if (key.endsWith("max")) {
                                Constraint constraint = ((HierarchicalConstraint) currentObject).getConstraint();
                                if (constraint == null) {
                                    constraint = new MinMaxConstraint();
                                }
                                ((MinMaxConstraint) constraint).setMax(Double.parseDouble(value.trim()));
                                ((HierarchicalConstraint) currentObject).setConstraint(constraint);
                            }
                        } else {

                            /*Entry */entry = new Entry(key, value, false);
                            registerEntry(entry, currentObject, currentSection);

                        }

                        if (entry != null && comment != null) {
                            entry.setComment(comment);
                            comment = null;
                        }

                        if (value.endsWith("\\")) {
                            severalLinesEntry = entry;
                        }

                    }

                } else if (sCurrentLine.trim().equals(ParsingUtil.HYPHEN)) {
                    // Register formerly processed object
                    currentSection.addFSObject(currentObject);
                    if (currentObject instanceof Actuator) {
                        // If a FSParsingException has been catched while trying to parse a trajectory, throw it if
                        // custom_trajectory attribute value is false
                        FSParsingException fsParsingException = trajectoryparsingExceptionBuffer.get(currentObject);
                        if (fsParsingException != null && !((Actuator<?>) currentObject).isCustomTrajectory()) {
                            throw fsParsingException;
                        }
                    }
                    // Release currentObject object
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

                            Double point = Double.parseDouble(pointsStr[i].trim());
                            points.add(point);
                        }
                    } catch (NumberFormatException e) {
                        e.printStackTrace();
                        throw new FSParsingException("Invalid format for trajectory interval" + content);

                    }
                    trajectory = new TabStepByStepTrajectory(points);
                }
            }
View Full Code Here

Examples of fr.soleil.lib.flyscan.model.parsing.exception.FSParsingException

        }
        List<Interval> intervals = new ArrayList<Interval>();
        for (String s : intervalsStr) {
            String[] members = s.split(",");
            if (members.length != 3) {
                throw new FSParsingException("Invalid format for trajectory " + content + " at " + s);
            } else {
                try {
                    double from = Double.parseDouble(members[0]);
                    double to = Double.parseDouble(members[1]);
                    int nbAcqPts = Integer.parseInt(members[2]);
                    if (to < from) {
                        throw new FSParsingException("Invalid format for trajectory interval" + content + " at " + s);
                    } else {
                        Interval interval = new Interval(from, to, nbAcqPts);
                        intervals.add(interval);
                    }
                } catch (NumberFormatException e) {
                    throw new FSParsingException("Invalid format for trajectory interval" + content + " at " + s);
                }
            }
        }
        return intervals;
    }
View Full Code Here
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.