Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 Red Hat, Inc. Distributed under license by Red Hat, Inc. All rights reserved. This program is made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at Contributors: Red Hat, Inc. - initial API and implementation /

André Dietisheim
public abstract class AbstractOpenShiftJsonResponseUnmarshaller<OPENSHIFTOBJECT> {
	private String response;
	public OpenShiftResponse<OPENSHIFTOBJECT> unmarshall(String responsethrows OpenShiftException {
		try {
			ModelNode node = ModelNode.fromJSONString(response);
			OPENSHIFTOBJECT openshiftObject = createOpenShiftObject(node);
			return new OpenShiftResponse<OPENSHIFTOBJECT>(debugmessagesresultopenshiftObjectexitCode);
catch (IllegalArgumentException e) {
			throw new OpenShiftException(e"Could not parse response \"{0}\""response);
catch (Exception e) {
			throw new OpenShiftException(e"Could not unmarshall response \"{0}\""response);
	protected abstract OPENSHIFTOBJECT createOpenShiftObject(ModelNode responseNodethrows Exception;
	protected String getResponse() {
		return ;
	protected String getString(String propertyModelNode node) {
		ModelNode propertyNode = node.get(property);
		if (!isSet(propertyNode)) {
			// replace "undefined" by null
			return null;
		return propertyNode.asString();
	protected boolean isSet(ModelNode node) {
		return node != null
				&& node.getType() != .;
	protected Date getDate(String propertyModelNode nodethrows DatatypeConfigurationException {
		ModelNode propertyNode = node.get(property);
		return RFC822DateUtils.getDate(propertyNode.asString());
	protected long getLong(String propertyModelNode node) {
		ModelNode propertyNode = node.get(property);
		return propertyNode.asLong(-1);
New to GrepCode? Check out our FAQ X