本文整理汇总了Java中org.apache.axis2.databinding.utils.ConverterUtil类的典型用法代码示例。如果您正苦于以下问题:Java ConverterUtil类的具体用法?Java ConverterUtil怎么用?Java ConverterUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConverterUtil类属于org.apache.axis2.databinding.utils包,在下文中一共展示了ConverterUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startElement
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (XmlConstants.SERVER_INFO.equals(qName)) {
try {
URI serverUri = new URI(attributes.getValue(XmlConstants.URI_ATTR));
myCurrentServerInfo =
new ServerInfo(serverUri, attributes.getValue(XmlConstants.GUID_ATTR), new TfsBeansHolder(serverUri));
}
catch (URISyntaxException e) {
throw new SAXException(e);
}
}
else if (XmlConstants.WORKSPACE_INFO.equals(qName)) {
String name = attributes.getValue(XmlConstants.NAME_ATTR);
String owner = attributes.getValue(XmlConstants.OWNER_NAME_ATTR);
String computer = attributes.getValue(XmlConstants.COMPUTER_ATTR);
String comment = attributes.getValue(XmlConstants.COMMENT_ATTR);
Calendar timestamp = ConverterUtil.convertToDateTime(attributes.getValue(XmlConstants.TIMESTAMP_ATTR));
myCurrentWorkspaceInfo = new WorkspaceInfo(myCurrentServerInfo, name, owner, computer, comment, timestamp);
}
else if (XmlConstants.MAPPED_PATH.equals(qName)) {
myCurrentWorkspaceInfo
.addWorkingFolderInfo(new WorkingFolderInfo(VcsUtil.getFilePath(attributes.getValue(XmlConstants.PATH_ATTR), true)));
}
}
示例2: toString
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
/**
* Returns the time as it would be in GMT. This is accurate to the seconds. Milliseconds
* probably gets lost.
*
* @return Returns String.
*/
public String toString() {
if (_value == null) {
return "unassigned Time";
}
if (isFromString) {
return originalString;
} else {
StringBuffer timeString = new StringBuffer();
ConverterUtil.appendTime(_value,timeString);
ConverterUtil.appendTimeZone(_value,timeString);
return timeString.toString();
}
}
示例3: writeQName
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
/**
* method to handle Qnames
*/
private void writeQName(javax.xml.namespace.QName qname,
javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
java.lang.String namespaceURI = qname.getNamespaceURI();
if (namespaceURI != null) {
java.lang.String prefix = xmlWriter.getPrefix(namespaceURI);
if (prefix == null) {
prefix = generatePrefix(namespaceURI);
xmlWriter.writeNamespace(prefix, namespaceURI);
xmlWriter.setPrefix(prefix, namespaceURI);
}
if (prefix.trim().length() > 0) {
xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
} else {
// i.e this is the default namespace
xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
}
} else {
xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
}
}
示例4: writeQName
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
private void writeQName(QName qname,
XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
String namespaceURI = qname.getNamespaceURI();
if (namespaceURI != null) {
String prefix = xmlWriter.getPrefix(namespaceURI);
if (prefix == null) {
prefix = generatePrefix(namespaceURI);
xmlWriter.writeNamespace(prefix, namespaceURI);
xmlWriter.setPrefix(prefix, namespaceURI);
}
if (prefix.trim().length() > 0) {
xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname));
} else {
// i.e this is the default namespace
xmlWriter.writeCharacters(ConverterUtil.convertToString(qname));
}
} else {
xmlWriter.writeCharacters(ConverterUtil.convertToString(qname));
}
}
示例5: getDate
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
/**
* Create a Date object from the given date string.
*/
public static Date getDate(String value) throws DataServiceFault {
/* if something goes wrong with converting the value to a date,
* try with dateTime and get the date out it, this is because,
* some service clients send a full date-time string for a date */
try {
java.util.Date date = ConverterUtil.convertToDate(value);
if (null == date) {
throw new DataServiceFault("Empty string or null value was found as date.");
} else {
return new Date(date.getTime());
}
} catch (Exception e) {
java.util.Calendar calendarDate = ConverterUtil.convertToDateTime(value);
if (null == calendarDate) {
throw new DataServiceFault("Empty string or null value was found as date.");
} else {
return new Date(calendarDate.getTimeInMillis());
}
}
}
示例6: transformComment
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
/**
* Transforms the CommentDAO to TComment type.
*
* @param comment : The CommentDAO to be transformed.
* @return : The transformed object.
*/
public static TComment transformComment(CommentDAO comment) {
TComment transformedComment = new TComment();
Calendar addedAt = Calendar.getInstance();
addedAt.setTime(comment.getCommentedDate());
transformedComment.setAddedTime(addedAt);
TUser commentedBy = new TUser();
commentedBy.setTUser(comment.getCommentedBy());
transformedComment.setAddedBy(commentedBy);
transformedComment.setText(comment.getCommentText());
transformedComment.setId(ConverterUtil.convertToURI(comment.getId().toString()));
TUser lastModifiedBy = new TUser();
if (StringUtils.isNotEmpty(comment.getModifiedBy())) {
lastModifiedBy.setTUser(comment.getModifiedBy());
} else {
lastModifiedBy.setTUser(comment.getCommentedBy());
}
transformedComment.setLastModifiedBy(lastModifiedBy);
Calendar modifiedAt = Calendar.getInstance();
if (comment.getModifiedDate() != null) {
modifiedAt.setTime(comment.getModifiedDate());
} else {
modifiedAt.setTime(comment.getCommentedDate());
}
transformedComment.setLastModifiedTime(modifiedAt);
return transformedComment;
}
示例7: transformTaskEvents
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public static TTaskEvents transformTaskEvents(TaskDAO task, String caller) {
TTaskEvents taskEvents = new TTaskEvents();
if (task.getEvents() != null) {
for (EventDAO taskEvent : task.getEvents()) {
TTaskEvent tEvent = new TTaskEvent();
tEvent.setEventDetail(taskEvent.getDetails());
tEvent.setEventId(ConverterUtil.convertToURI(taskEvent.getId().toString()));
TUser user = new TUser();
user.setTUser(taskEvent.getUser());
tEvent.setEventInitiator(user);
//Set the created time
Calendar eventTime = Calendar.getInstance();
eventTime.setTime(taskEvent.getTimeStamp());
tEvent.setEventTime(eventTime);
tEvent.setEventType(taskEvent.getType().toString().toLowerCase());
tEvent.setNewState(transformStatus(taskEvent.getNewState()));
tEvent.setOldState(transformStatus(taskEvent.getOldState()));
taskEvents.addEvent(tEvent);
}
}
return taskEvents;
}
示例8: getSubscription
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
/**
* creates the subscription object from the subscription resource
*
* @param subscriptionResource
* @return
*/
public static Subscription getSubscription(Resource subscriptionResource) {
Subscription subscription = new Subscription();
subscription.setTenantId(CarbonContext.getThreadLocalCarbonContext().getTenantId());
Properties properties = subscriptionResource.getProperties();
if ((properties != null) && (!properties.isEmpty())) {
for (Enumeration enumeration = properties.propertyNames(); enumeration.hasMoreElements();) {
String propertyName = (String) enumeration.nextElement();
if (EventBrokerConstants.EB_RES_SUBSCRIPTION_URL.equals(propertyName)) {
subscription.setEventSinkURL(
subscriptionResource.getProperty(EventBrokerConstants.EB_RES_SUBSCRIPTION_URL));
} else if (EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME.equals(propertyName)) {
subscription.setEventDispatcherName(
subscriptionResource.getProperty(EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME));
} else if (EventBrokerConstants.EB_RES_EXPIRS.equals(propertyName)) {
subscription.setExpires(
ConverterUtil.convertToDateTime(
subscriptionResource.getProperty(EventBrokerConstants.EB_RES_EXPIRS)));
} else if (EventBrokerConstants.EB_RES_OWNER.equals(propertyName)) {
subscription.setOwner(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_OWNER));
} else if (EventBrokerConstants.EB_RES_TOPIC_NAME.equals(propertyName)) {
subscription.setTopicName(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_TOPIC_NAME));
} else if (EventBrokerConstants.EB_RES_CREATED_TIME.equals(propertyName)) {
subscription.setCreatedTime(new Date(Long.parseLong(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_CREATED_TIME))));
} else if (EventBrokerConstants.EB_RES_MODE.equals(propertyName)) {
subscription.setMode(subscriptionResource.getProperty(EventBrokerConstants.EB_RES_MODE));
} else {
subscription.addProperty(propertyName, subscriptionResource.getProperty(propertyName));
}
}
}
return subscription;
}
示例9: getJMSSubscriptions
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Subscription[] getJMSSubscriptions(String topicName) throws EventBrokerException {
try {
Subscription[] subscriptionsArray = new Subscription[0];
UserRegistry userRegistry =
this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
if (!resourcePath.endsWith("/")) {
resourcePath = resourcePath + "/";
}
resourcePath = resourcePath + EventBrokerConstants.EB_CONF_JMS_SUBSCRIPTION_COLLECTION_NAME;
// Get subscriptions
if (userRegistry.resourceExists(resourcePath)) {
Collection subscriptionCollection = (Collection) userRegistry.get(resourcePath);
subscriptionsArray =
new Subscription[subscriptionCollection.getChildCount()];
int index = 0;
for (String subs : subscriptionCollection.getChildren()) {
Collection subscription = (Collection) userRegistry.get(subs);
Subscription subscriptionDetails = new Subscription();
subscriptionDetails.setId(subscription.getProperty("Name"));
subscriptionDetails.setOwner(subscription.getProperty("Owner"));
subscriptionDetails.setCreatedTime(ConverterUtil.convertToDate(subscription.getProperty("createdTime")));
subscriptionsArray[index++] = subscriptionDetails;
}
}
return subscriptionsArray;
} catch (RegistryException e) {
throw new EventBrokerException("Cannot read the registry resources ", e);
}
}
示例10: testCalender
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public void testCalender() throws AxisFault {
RPCServiceClient sender = getRPCClient("EchoXMLService", "echoCalander");
ArrayList args = new ArrayList();
Calendar calendar = Calendar.getInstance();
args.add(ConverterUtil.convertToString(calendar));
OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org", "echoCalander", "req"), args.toArray());
assertEquals(response.getFirstElement().getText(), ConverterUtil.convertToString(calendar));
}
示例11: getElementText
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public String getElementText() throws XMLStreamException {
if (state == START_ELEMENT) {
//move to the end state and return the value
state = END_ELEMENT_STATE;
if (convertedText == null) {
convertedText = ConverterUtil.getStringFromDatahandler(value);
}
return convertedText;
} else {
throw new XMLStreamException();
}
}
示例12: getText
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public String getText() {
if (state == TEXT_STATE) {
if (convertedText == null) {
convertedText =
ConverterUtil.getStringFromDatahandler(value);
}
return convertedText;
} else {
throw new IllegalStateException();
}
}
示例13: getTextCharacters
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public char[] getTextCharacters() {
if (state == TEXT_STATE) {
if (convertedText == null) {
convertedText =
ConverterUtil.getStringFromDatahandler(value);
}
return convertedText.toCharArray();
} else {
throw new IllegalStateException();
}
}
示例14: getTextLength
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public int getTextLength() {
if (state == TEXT_STATE) {
if (convertedText == null) {
convertedText =
ConverterUtil.getStringFromDatahandler(value);
}
return convertedText.length();
} else {
throw new IllegalStateException();
}
}
示例15: getText
import org.apache.axis2.databinding.utils.ConverterUtil; //导入依赖的package包/类
public String getText() {
if (state == DELEGATED_STATE) {
return childReader.getText();
} else if (state == TEXT_STATE) {
Object property = properties[currentPropertyIndex - 1];
if (property instanceof DataHandler){
return ConverterUtil.getStringFromDatahandler((DataHandler)property);
} else {
return (String)properties[currentPropertyIndex - 1];
}
} else {
throw new IllegalStateException();
}
}