org.eclipse.emf.common.util.Enumerator Java Examples

The following examples show how to use org.eclipse.emf.common.util.Enumerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: n4js   Author: eclipse   File: PackageJsonUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private static <T extends Enumerator> T parseEnumLiteral(EEnum emfEnumType, Class<T> javaEnumType,
		String enumLiteralStr) {
	EEnumLiteral emfLit = enumLiteralStr != null ? emfEnumType.getELiterals().stream()
			.filter(lit -> lit.getName().equalsIgnoreCase(enumLiteralStr))
			.findFirst().orElse(null) : null;
	if (emfLit == null) {
		return null;
	}
	final Enumerator javaLit = emfLit.getInstance();
	@SuppressWarnings("unchecked")
	T javaLitCasted = javaEnumType.isInstance(javaLit) ? (T) javaLit : null;
	return javaLitCasted;
}
 
Example #2
Source Project: eip-designer   Author: lbroudoux   File: ResequencerPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.ResequencerPropertiesEditionPart#initPart(Object input, Enumerator current)
 */
public void initPart(Object input, Enumerator current) {
	part.setInput(input);
	part.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Resequencer.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Resequencer_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #3
Source Project: eip-designer   Author: lbroudoux   File: RoutePropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RoutePropertiesEditionPart#setExchangeType(Enumerator newValue)
 * 
 */
public void setExchangeType(Enumerator newValue) {
	exchangeType.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Route.Properties.exchangeType);
	if (eefElementEditorReadOnlyState && exchangeType.isEnabled()) {
		exchangeType.setEnabled(false);
		exchangeType.setToolTipText(EipMessages.Route_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !exchangeType.isEnabled()) {
		exchangeType.setEnabled(true);
	}	
	
}
 
Example #4
Source Project: statecharts   Author: Yakindu   File: UnaryExpressionImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Enumerator getOperator() {
	// TODO: implement this method
	// Ensure that you remove @generated or mark it @generated NOT
	throw new UnsupportedOperationException();
}
 
Example #5
Source Project: statecharts   Author: Yakindu   File: LogicalAndExpressionImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public Enumerator getOperator() {
	return LogicalOperator.AND;
}
 
Example #6
Source Project: eip-designer   Author: lbroudoux   File: RoutePropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RoutePropertiesEditionPart#initExchangeType(Object input, Enumerator current)
 */
public void initExchangeType(Object input, Enumerator current) {
	exchangeType.setInput(input);
	exchangeType.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Route.Properties.exchangeType);
	if (eefElementEditorReadOnlyState && exchangeType.isEnabled()) {
		exchangeType.setEnabled(false);
		exchangeType.setToolTipText(EipMessages.Route_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !exchangeType.isEnabled()) {
		exchangeType.setEnabled(true);
	}	
	
}
 
Example #7
Source Project: eip-designer   Author: lbroudoux   File: RoutePropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RoutePropertiesEditionPart#setExchangeType(Enumerator newValue)
 * 
 */
public void setExchangeType(Enumerator newValue) {
	exchangeType.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Route.Properties.exchangeType);
	if (eefElementEditorReadOnlyState && exchangeType.isEnabled()) {
		exchangeType.setEnabled(false);
		exchangeType.setToolTipText(EipMessages.Route_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !exchangeType.isEnabled()) {
		exchangeType.setEnabled(true);
	}	
	
}
 
Example #8
Source Project: eip-designer   Author: lbroudoux   File: RecipientListRouterPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RecipientListRouterPropertiesEditionPart#initType(Object input, Enumerator current)
 */
public void initType(Object input, Enumerator current) {
	type.setInput(input);
	type.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.RecipientListRouter.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.RecipientListRouter_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #9
Source Project: eip-designer   Author: lbroudoux   File: RecipientListRouterPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RecipientListRouterPropertiesEditionPart#setType(Enumerator newValue)
 * 
 */
public void setType(Enumerator newValue) {
	type.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.RecipientListRouter.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.RecipientListRouter_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #10
Source Project: eip-designer   Author: lbroudoux   File: EnricherPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.EnricherPropertiesEditionPart#initPart(Object input, Enumerator current)
 */
public void initPart(Object input, Enumerator current) {
	part.setInput(input);
	part.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Enricher.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Enricher_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #11
Source Project: eip-designer   Author: lbroudoux   File: EnricherPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.EnricherPropertiesEditionPart#setPart(Enumerator newValue)
 * 
 */
public void setPart(Enumerator newValue) {
	part.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Enricher.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Enricher_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #12
Source Project: eip-designer   Author: lbroudoux   File: RouterPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RouterPropertiesEditionPart#initType(Object input, Enumerator current)
 */
public void initType(Object input, Enumerator current) {
	type.setInput(input);
	type.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Router.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.Router_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #13
Source Project: eip-designer   Author: lbroudoux   File: RouterPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RouterPropertiesEditionPart#setType(Enumerator newValue)
 * 
 */
public void setType(Enumerator newValue) {
	type.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Router.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.Router_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #14
Source Project: eip-designer   Author: lbroudoux   File: ResequencerPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.ResequencerPropertiesEditionPart#initPart(Object input, Enumerator current)
 */
public void initPart(Object input, Enumerator current) {
	part.setInput(input);
	part.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Resequencer.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Resequencer_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #15
Source Project: eip-designer   Author: lbroudoux   File: ResequencerPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.ResequencerPropertiesEditionPart#setPart(Enumerator newValue)
 * 
 */
public void setPart(Enumerator newValue) {
	part.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Resequencer.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Resequencer_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #16
Source Project: eip-designer   Author: lbroudoux   File: AggregatorPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.AggregatorPropertiesEditionPart#initPart(Object input, Enumerator current)
 */
public void initPart(Object input, Enumerator current) {
	part.setInput(input);
	part.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Aggregator.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Aggregator_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #17
Source Project: eip-designer   Author: lbroudoux   File: AggregatorPropertiesEditionPartForm.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.AggregatorPropertiesEditionPart#setPart(Enumerator newValue)
 * 
 */
public void setPart(Enumerator newValue) {
	part.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Aggregator.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Aggregator_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #18
Source Project: eip-designer   Author: lbroudoux   File: ResequencerPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.ResequencerPropertiesEditionPart#setPart(Enumerator newValue)
 * 
 */
public void setPart(Enumerator newValue) {
	part.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Resequencer.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Resequencer_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #19
Source Project: eip-designer   Author: lbroudoux   File: EnricherPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.EnricherPropertiesEditionPart#initPart(Object input, Enumerator current)
 */
public void initPart(Object input, Enumerator current) {
	part.setInput(input);
	part.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Enricher.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Enricher_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #20
Source Project: eip-designer   Author: lbroudoux   File: EnricherPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.EnricherPropertiesEditionPart#setPart(Enumerator newValue)
 * 
 */
public void setPart(Enumerator newValue) {
	part.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Enricher.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Enricher_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #21
Source Project: eip-designer   Author: lbroudoux   File: RecipientListRouterPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RecipientListRouterPropertiesEditionPart#initType(Object input, Enumerator current)
 */
public void initType(Object input, Enumerator current) {
	type.setInput(input);
	type.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.RecipientListRouter.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.RecipientListRouter_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #22
Source Project: eip-designer   Author: lbroudoux   File: RecipientListRouterPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RecipientListRouterPropertiesEditionPart#setType(Enumerator newValue)
 * 
 */
public void setType(Enumerator newValue) {
	type.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.RecipientListRouter.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.RecipientListRouter_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #23
Source Project: eip-designer   Author: lbroudoux   File: AggregatorPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.AggregatorPropertiesEditionPart#initPart(Object input, Enumerator current)
 */
public void initPart(Object input, Enumerator current) {
	part.setInput(input);
	part.modelUpdating(new StructuredSelection(current));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Aggregator.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Aggregator_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #24
Source Project: eip-designer   Author: lbroudoux   File: AggregatorPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.AggregatorPropertiesEditionPart#setPart(Enumerator newValue)
 * 
 */
public void setPart(Enumerator newValue) {
	part.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Aggregator.Properties.part);
	if (eefElementEditorReadOnlyState && part.isEnabled()) {
		part.setEnabled(false);
		part.setToolTipText(EipMessages.Aggregator_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !part.isEnabled()) {
		part.setEnabled(true);
	}	
	
}
 
Example #25
Source Project: eip-designer   Author: lbroudoux   File: RouterPropertiesEditionPartImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see com.github.lbroudoux.dsl.eip.parts.RouterPropertiesEditionPart#setType(Enumerator newValue)
 * 
 */
public void setType(Enumerator newValue) {
	type.modelUpdating(new StructuredSelection(newValue));
	boolean eefElementEditorReadOnlyState = isReadOnly(EipViewsRepository.Router.Properties.type);
	if (eefElementEditorReadOnlyState && type.isEnabled()) {
		type.setEnabled(false);
		type.setToolTipText(EipMessages.Router_ReadOnly);
	} else if (!eefElementEditorReadOnlyState && !type.isEnabled()) {
		type.setEnabled(true);
	}	
	
}
 
Example #26
Source Project: IfcPlugins   Author: opensourceBIM   File: IfcParserWriterUtils.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
public static void writePrimitive(Object val, PrintWriter printWriter) throws SerializerException, IOException {
	if (val.getClass().getSimpleName().equals("Tristate")) {
		if (val.toString().equals("TRUE")) {
			printWriter.write(".T.");
		} else if (val.toString().equals("FALSE")) {
			printWriter.write(".F.");
		} else if (val.toString().equals("UNDEFINED")) {
			printWriter.write(".U.");
		}
	} else if (val instanceof Double) {
		if (((Double)val).isInfinite() || (((Double)val).isNaN())) {
			LOGGER.info("Serializing infinite or NaN double as 0.0");
			printWriter.write("0.0");
		} else {
			String string = val.toString();
			if (string.endsWith(".0")) {
				printWriter.write((string.substring(0, string.length() - 1)));
			} else {
				printWriter.write(string);
			}
		}
	} else if (val instanceof Boolean) {
		Boolean bool = (Boolean)val;
		if (bool) {
			printWriter.write(".T.");
		} else {
			printWriter.write(".F.");
		}
	} else if (val instanceof String) {
		printWriter.write('\'');
		String stringVal = (String)val;
		for (int i=0; i<stringVal.length(); i++) {
			char c = stringVal.charAt(i);
			if (c == '\'') {
				printWriter.write(new char[]{'\'', '\''});
			} else if (c == '\\') {
				printWriter.write(new char[]{'\\', '\\'});
			} else if (c >= 32 && c <= 126) {
				// ISO 8859-1
				printWriter.write(new char[]{c});
			} else if (c < 255) {
				//  ISO 10646 and ISO 8859-1 are the same < 255 , using ISO_8859_1
				printWriter.write("\\X\\");
				printWriter.write(Hex.encodeHex(Charsets.ISO_8859_1.encode(CharBuffer.wrap(new char[]{(char) c})).array(), false));
			} else {
				if (USE_ISO_8859_1) {
					// ISO 8859-1 with -128 offset
					printWriter.write("\\S\\");
					printWriter.write((char)Charsets.ISO_8859_1.encode(new String(new char[]{(char) (c - 128)})).get());
				} else {
					// The following code has not been tested (2012-04-25)
					// Use UCS-2 or UCS-4
					
					// TODO when multiple sequential characters should be encoded in UCS-2 or UCS-4, we don't really need to add all those \X0\ \X2\ and \X4\ chars
					if (Character.isLowSurrogate(c)) {
						throw new SerializerException("Unexpected low surrogate range char");
					} else if (Character.isHighSurrogate(c)) {
						// We need UCS-4, this is probably never happening
						if (i + 1 < stringVal.length()) {
							char low = stringVal.charAt(i + 1);
							if (!Character.isLowSurrogate(low)) {
								throw new SerializerException("High surrogate char should be followed by char in low surrogate range");
							}
							try {
								printWriter.write("\\X4\\");
								printWriter.write(Hex.encodeHex(Charset.forName("UTF-32").encode(new String(new char[]{c, low})).array(), false));
								printWriter.write("\\X0\\");
							} catch (UnsupportedCharsetException e) {
								throw new SerializerException(e);
							}
							i++;
						} else {
							throw new SerializerException("High surrogate char should be followed by char in low surrogate range, but end of string reached");
						}
					} else {
						// UCS-2 will do
						printWriter.write(("\\X2\\"));
						printWriter.write(Hex.encodeHex(Charsets.UTF_16BE.encode(CharBuffer.wrap(new char[]{c})).array(), false));
						printWriter.write("\\X0\\");
					}
				}
			}
		}
		printWriter.write('\'');
	} else if (val instanceof Enumerator) {
		printWriter.write(".");
		printWriter.write(val.toString());
		printWriter.write(".");
	} else if (val instanceof byte[]) {
		// TODO printing default leading 0, must be wrong
		printWriter.write("\"0");
		printWriter.write(Hex.encodeHexString((byte[])val));
		printWriter.write("\"");
	} else {
		printWriter.write((val == null ? "$" : val.toString()));
	}
}
 
Example #27
Source Project: xtext-extras   Author: eclipse   File: InternalEnumRulesTestLanguageParser.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public final Enumerator ruleGeneratedEnum() throws RecognitionException {
    Enumerator current = null;

    Token enumLiteral_0=null;
    Token enumLiteral_1=null;


    	enterRule();

    try {
        // InternalEnumRulesTestLanguage.g:201:2: ( ( (enumLiteral_0= 'SameName' ) | (enumLiteral_1= 'DifferentLiteral' ) ) )
        // InternalEnumRulesTestLanguage.g:202:2: ( (enumLiteral_0= 'SameName' ) | (enumLiteral_1= 'DifferentLiteral' ) )
        {
        // InternalEnumRulesTestLanguage.g:202:2: ( (enumLiteral_0= 'SameName' ) | (enumLiteral_1= 'DifferentLiteral' ) )
        int alt4=2;
        int LA4_0 = input.LA(1);

        if ( (LA4_0==13) ) {
            alt4=1;
        }
        else if ( (LA4_0==15) ) {
            alt4=2;
        }
        else {
            NoViableAltException nvae =
                new NoViableAltException("", 4, 0, input);

            throw nvae;
        }
        switch (alt4) {
            case 1 :
                // InternalEnumRulesTestLanguage.g:203:3: (enumLiteral_0= 'SameName' )
                {
                // InternalEnumRulesTestLanguage.g:203:3: (enumLiteral_0= 'SameName' )
                // InternalEnumRulesTestLanguage.g:204:4: enumLiteral_0= 'SameName'
                {
                enumLiteral_0=(Token)match(input,13,FollowSets000.FOLLOW_2); 

                				current = grammarAccess.getGeneratedEnumAccess().getSameNameEnumLiteralDeclaration_0().getEnumLiteral().getInstance();
                				newLeafNode(enumLiteral_0, grammarAccess.getGeneratedEnumAccess().getSameNameEnumLiteralDeclaration_0());
                			

                }


                }
                break;
            case 2 :
                // InternalEnumRulesTestLanguage.g:211:3: (enumLiteral_1= 'DifferentLiteral' )
                {
                // InternalEnumRulesTestLanguage.g:211:3: (enumLiteral_1= 'DifferentLiteral' )
                // InternalEnumRulesTestLanguage.g:212:4: enumLiteral_1= 'DifferentLiteral'
                {
                enumLiteral_1=(Token)match(input,15,FollowSets000.FOLLOW_2); 

                				current = grammarAccess.getGeneratedEnumAccess().getDifferentNameEnumLiteralDeclaration_1().getEnumLiteral().getInstance();
                				newLeafNode(enumLiteral_1, grammarAccess.getGeneratedEnumAccess().getDifferentNameEnumLiteralDeclaration_1());
                			

                }


                }
                break;

        }


        }


        	leaveRule();

    }

        catch (RecognitionException re) {
            recover(input,re);
            appendSkippedTokens();
        }
    finally {
    }
    return current;
}
 
Example #28
public final Enumerator ruleKindOfKeyword() throws RecognitionException {
    Enumerator current = null;

    Token enumLiteral_0=null;
    Token enumLiteral_1=null;


    	enterRule();

    try {
        // InternalEnumAndReferenceTestLanguage.g:144:2: ( ( (enumLiteral_0= 'kindOfKeyword' ) | (enumLiteral_1= 'anotherEnumLiteral' ) ) )
        // InternalEnumAndReferenceTestLanguage.g:145:2: ( (enumLiteral_0= 'kindOfKeyword' ) | (enumLiteral_1= 'anotherEnumLiteral' ) )
        {
        // InternalEnumAndReferenceTestLanguage.g:145:2: ( (enumLiteral_0= 'kindOfKeyword' ) | (enumLiteral_1= 'anotherEnumLiteral' ) )
        int alt1=2;
        int LA1_0 = input.LA(1);

        if ( (LA1_0==12) ) {
            alt1=1;
        }
        else if ( (LA1_0==13) ) {
            alt1=2;
        }
        else {
            NoViableAltException nvae =
                new NoViableAltException("", 1, 0, input);

            throw nvae;
        }
        switch (alt1) {
            case 1 :
                // InternalEnumAndReferenceTestLanguage.g:146:3: (enumLiteral_0= 'kindOfKeyword' )
                {
                // InternalEnumAndReferenceTestLanguage.g:146:3: (enumLiteral_0= 'kindOfKeyword' )
                // InternalEnumAndReferenceTestLanguage.g:147:4: enumLiteral_0= 'kindOfKeyword'
                {
                enumLiteral_0=(Token)match(input,12,FollowSets000.FOLLOW_2); 

                				current = grammarAccess.getKindOfKeywordAccess().getKindOfKeywordEnumLiteralDeclaration_0().getEnumLiteral().getInstance();
                				newLeafNode(enumLiteral_0, grammarAccess.getKindOfKeywordAccess().getKindOfKeywordEnumLiteralDeclaration_0());
                			

                }


                }
                break;
            case 2 :
                // InternalEnumAndReferenceTestLanguage.g:154:3: (enumLiteral_1= 'anotherEnumLiteral' )
                {
                // InternalEnumAndReferenceTestLanguage.g:154:3: (enumLiteral_1= 'anotherEnumLiteral' )
                // InternalEnumAndReferenceTestLanguage.g:155:4: enumLiteral_1= 'anotherEnumLiteral'
                {
                enumLiteral_1=(Token)match(input,13,FollowSets000.FOLLOW_2); 

                				current = grammarAccess.getKindOfKeywordAccess().getAnotherEnumLiteralEnumLiteralDeclaration_1().getEnumLiteral().getInstance();
                				newLeafNode(enumLiteral_1, grammarAccess.getKindOfKeywordAccess().getAnotherEnumLiteralEnumLiteralDeclaration_1());
                			

                }


                }
                break;

        }


        }


        	leaveRule();

    }

        catch (RecognitionException re) {
            recover(input,re);
            appendSkippedTokens();
        }
    finally {
    }
    return current;
}
 
Example #29
Source Project: xtext-eclipse   Author: eclipse   File: InternalEnumRulesUiTestLanguageParser.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public final Enumerator ruleGeneratedEnum() throws RecognitionException {
    Enumerator current = null;

    Token enumLiteral_0=null;
    Token enumLiteral_1=null;


    	enterRule();

    try {
        // InternalEnumRulesUiTestLanguage.g:201:2: ( ( (enumLiteral_0= 'SameName' ) | (enumLiteral_1= 'DifferentLiteral' ) ) )
        // InternalEnumRulesUiTestLanguage.g:202:2: ( (enumLiteral_0= 'SameName' ) | (enumLiteral_1= 'DifferentLiteral' ) )
        {
        // InternalEnumRulesUiTestLanguage.g:202:2: ( (enumLiteral_0= 'SameName' ) | (enumLiteral_1= 'DifferentLiteral' ) )
        int alt4=2;
        int LA4_0 = input.LA(1);

        if ( (LA4_0==13) ) {
            alt4=1;
        }
        else if ( (LA4_0==15) ) {
            alt4=2;
        }
        else {
            NoViableAltException nvae =
                new NoViableAltException("", 4, 0, input);

            throw nvae;
        }
        switch (alt4) {
            case 1 :
                // InternalEnumRulesUiTestLanguage.g:203:3: (enumLiteral_0= 'SameName' )
                {
                // InternalEnumRulesUiTestLanguage.g:203:3: (enumLiteral_0= 'SameName' )
                // InternalEnumRulesUiTestLanguage.g:204:4: enumLiteral_0= 'SameName'
                {
                enumLiteral_0=(Token)match(input,13,FollowSets000.FOLLOW_2); 

                				current = grammarAccess.getGeneratedEnumAccess().getSameNameEnumLiteralDeclaration_0().getEnumLiteral().getInstance();
                				newLeafNode(enumLiteral_0, grammarAccess.getGeneratedEnumAccess().getSameNameEnumLiteralDeclaration_0());
                			

                }


                }
                break;
            case 2 :
                // InternalEnumRulesUiTestLanguage.g:211:3: (enumLiteral_1= 'DifferentLiteral' )
                {
                // InternalEnumRulesUiTestLanguage.g:211:3: (enumLiteral_1= 'DifferentLiteral' )
                // InternalEnumRulesUiTestLanguage.g:212:4: enumLiteral_1= 'DifferentLiteral'
                {
                enumLiteral_1=(Token)match(input,15,FollowSets000.FOLLOW_2); 

                				current = grammarAccess.getGeneratedEnumAccess().getDifferentNameEnumLiteralDeclaration_1().getEnumLiteral().getInstance();
                				newLeafNode(enumLiteral_1, grammarAccess.getGeneratedEnumAccess().getDifferentNameEnumLiteralDeclaration_1());
                			

                }


                }
                break;

        }


        }


        	leaveRule();

    }

        catch (RecognitionException re) {
            recover(input,re);
            appendSkippedTokens();
        }
    finally {
    }
    return current;
}
 
Example #30
public final EObject rulePolygonBasedShape() throws RecognitionException {
    EObject current = null;

    Enumerator lv_shape_0_0 = null;



    	enterRule();

    try {
        // InternalContentAssistNoTerminalExtensionTestLanguage.g:78:2: ( ( (lv_shape_0_0= rulePolygonBasedNodeShape ) )+ )
        // InternalContentAssistNoTerminalExtensionTestLanguage.g:79:2: ( (lv_shape_0_0= rulePolygonBasedNodeShape ) )+
        {
        // InternalContentAssistNoTerminalExtensionTestLanguage.g:79:2: ( (lv_shape_0_0= rulePolygonBasedNodeShape ) )+
        int cnt1=0;
        loop1:
        do {
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( ((LA1_0>=5 && LA1_0<=24)) ) {
                alt1=1;
            }


            switch (alt1) {
        	case 1 :
        	    // InternalContentAssistNoTerminalExtensionTestLanguage.g:80:3: (lv_shape_0_0= rulePolygonBasedNodeShape )
        	    {
        	    // InternalContentAssistNoTerminalExtensionTestLanguage.g:80:3: (lv_shape_0_0= rulePolygonBasedNodeShape )
        	    // InternalContentAssistNoTerminalExtensionTestLanguage.g:81:4: lv_shape_0_0= rulePolygonBasedNodeShape
        	    {

        	    				newCompositeNode(grammarAccess.getPolygonBasedShapeAccess().getShapePolygonBasedNodeShapeEnumRuleCall_0());
        	    			
        	    pushFollow(FollowSets000.FOLLOW_3);
        	    lv_shape_0_0=rulePolygonBasedNodeShape();

        	    state._fsp--;


        	    				if (current==null) {
        	    					current = createModelElementForParent(grammarAccess.getPolygonBasedShapeRule());
        	    				}
        	    				add(
        	    					current,
        	    					"shape",
        	    					lv_shape_0_0,
        	    					"org.eclipse.xtext.ui.tests.editor.contentassist.ContentAssistNoTerminalExtensionTestLanguage.PolygonBasedNodeShape");
        	    				afterParserOrEnumRuleCall();
        	    			

        	    }


        	    }
        	    break;

        	default :
        	    if ( cnt1 >= 1 ) break loop1;
                    EarlyExitException eee =
                        new EarlyExitException(1, input);
                    throw eee;
            }
            cnt1++;
        } while (true);


        }


        	leaveRule();

    }

        catch (RecognitionException re) {
            recover(input,re);
            appendSkippedTokens();
        }
    finally {
    }
    return current;
}