package jetbrains.mps.lang.smodel.generator.smodelAdapter; /*Generated by MPS */ import org.jetbrains.mps.openapi.model.SNode; import org.jetbrains.mps.openapi.language.SProperty; import org.jetbrains.mps.openapi.model.SNodeAccessUtil; import jetbrains.mps.util.InternUtil; import jetbrains.mps.util.EqualUtil; public class SPropertyOperations { public static void set(SNode node, SProperty property, String propertyValue) { if (node != null) { SNodeAccessUtil.setProperty(node, property, propertyValue); } } public static String getString(SNode node, SProperty property) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); return SPropertyOperations.getString(value); } return null; } public static String getString(String value) { if (value != null) { return InternUtil.intern(value); } else { return null; } } public static int getInteger(SNode node, SProperty property) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); return SPropertyOperations.getInteger(value); } return 0; } public static int getInteger(String value) { try { return (value == null ? 0 : Integer.parseInt(value)); } catch (Exception e) { return 0; } } public static boolean getBoolean(SNode node, SProperty property) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); return SPropertyOperations.getBoolean(value); } return false; } public static boolean getBoolean(String value) { return "true".equals(value); } public static boolean hasValue(SNode node, SProperty property, String propertyValue) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); if (value == null) { return propertyValue == null; } else { return value.equals(propertyValue); } } return false; } public static String getString_def(SNode node, SProperty property, String defaultValue) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); if (value != null) { return InternUtil.intern(value); } } if (defaultValue != null) { return InternUtil.intern(defaultValue); } return null; } public static int getInteger_def(SNode node, SProperty propertyName, String defaultValue) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, propertyName); try { return Integer.parseInt(value); } catch (Exception e) { } } if (defaultValue != null) { try { return Integer.parseInt(defaultValue); } catch (Exception e) { } } return 0; } public static boolean getBoolean_def(SNode node, SProperty property, String defaultValue) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); if (value != null) { if ("true".equals(value)) { return true; } if ("false".equals(value)) { return false; } } } if (defaultValue != null) { try { return Boolean.parseBoolean(defaultValue); } catch (Exception e) { } } return false; } public static boolean hasValue(SNode node, SProperty property, String propertyValue, String defaultValue) { if (node != null) { String value = SNodeAccessUtil.getProperty(node, property); if (value == null) { return EqualUtil.equals(defaultValue, propertyValue); } return value.equals(propertyValue); } return false; } }