All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.windowsazure.samples.internal.xml.AzureDOMAdapter Maven / Gradle / Ivy

Go to download

jpa4azure, implements a subset of the JPA specification using Azure Storage for pesisting beans. see http://jpa4azure.codeplex.com for more information.

There is a newer version: 0.7
Show newest version
package com.windowsazure.samples.internal.xml;

import com.windowsazure.samples.internal.web.XmlHttpResult;


public abstract class AzureDOMAdapter extends DOMAdapter {
	
	public AzureDOMAdapter(XmlHttpResult xmlHttpResult) {
		super(xmlHttpResult.getXmlString());
		this.xmlHttpResult = xmlHttpResult;
	}
	
	public abstract T build() throws Exception;
	
	protected AzureDOMAdapter(XmlNode node) {
		super(node);
	}
	
	protected String extractTableNameFromEntityId(String idText) {
		int beginIndex = idText.lastIndexOf('/') + 1;
		int endIndex = idText.indexOf('(', beginIndex);
		if (endIndex == -1)
			endIndex = idText.length();
		return idText.substring(beginIndex, endIndex);
	}
	
	protected String extractTableNameFromTableId(String idText) {
		int beginIndex = idText.indexOf('\'') + 1;
		int endIndex = idText.indexOf('\'', beginIndex);
		return idText.substring(beginIndex, endIndex);
	}
	
	protected String getErrorCode()
		throws NodeNotFoundException {
		
		XmlNode errorNode = getRootNode();
		if (errorNode.getLocalName().compareTo("error") != 0)
			return null;
		
		return getInnerText(errorNode, "code");
	}
	
	protected XmlHttpResult xmlHttpResult;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy