本文整理汇总了Java中javax.ws.rs.core.MediaType.TEXT_XML属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.TEXT_XML属性的具体用法?Java MediaType.TEXT_XML怎么用?Java MediaType.TEXT_XML使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.ws.rs.core.MediaType
的用法示例。
在下文中一共展示了MediaType.TEXT_XML属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removefromcart
@GET
@Path("/removefromcart/{itemtype}/{itemmake}/{itemmodel}/{userid}")
@Produces(MediaType.TEXT_XML)
@Consumes(MediaType.TEXT_PLAIN)
public String removefromcart(@PathParam("itemtype") String itemType, @PathParam("itemmake") String itemMake,
@PathParam("itemmodel") String itemModel, @PathParam("userid") String userID) {
int itemafter=0;
String messageToUser="Item removed from cart";
String userResponse="<?xml version='1.0' encoding='UTF-8'?>"+"<result>"+"<messagetouser>";
customerHandle=Singleton.getCustomerhandle(userID); //get customer handle
itemafter=customerHandle.removeItemFromMyCart(itemType,itemMake,itemModel); //remove item customer cart
return userResponse+messageToUser+"</messagetouser><totalitem>"+String.valueOf(itemafter)+"</totalitem></result>";
}
示例2: additemtocart
@GET
@Path("/additemtocart/{itemtype}/{itemmake}/{itemmodel}/{userid}")
@Produces(MediaType.TEXT_XML)
@Consumes(MediaType.TEXT_PLAIN)
public String additemtocart(@PathParam("itemtype") String itemType, @PathParam("itemmake") String itemMake,
@PathParam("itemmodel") String itemModel, @PathParam("userid") String userID) {
int itembefore=0,itemafter=0;
String messageToUser="";
String userResponse="<?xml version='1.0' encoding='UTF-8'?>"+"<result>"+"<messagetouser>";
customerHandle=Singleton.getCustomerhandle(userID); //get customer handle
itemsHandle = Singleton.getItemHandle(itemType, itemMake, itemModel); //get item handle in store
if(itemsHandle.isEmpty()){ //if item not found in store return message
messageToUser="item not found in store while customer trying to add item in cart";
}
else{ //else take count of items beforeadding, add item to cart
itembefore = customerHandle.getshoppingCart().gettotalItem();
itemafter = customerHandle.addItemToMyCart(itemsHandle);
if(itembefore==itemafter){ //if item not added because all items of same type is already in user cart
messageToUser="Already this item is added in cart, there are no more item of same type in store";
}
else{ //else item added sucessfully
messageToUser="One item added to cart";
}
}
return userResponse+messageToUser+"</messagetouser><totalitem>"+String.valueOf(itemafter)+"</totalitem></result>";
}
示例3: smartphonelist
@GET
@Path("/smartphonelist")
@Produces(MediaType.TEXT_XML)
public String smartphonelist() {
return "<?xml version='1.0' encoding='UTF-8'?>"+storeHandle.showItemList("SmartPhone");
}
示例4: hometheaterlist
@GET
@Path("/hometheaterlist")
@Produces(MediaType.TEXT_XML)
public String hometheaterlist() {
return "<?xml version='1.0' encoding='UTF-8'?>"+storeHandle.showItemList("HomeTheater");
}
示例5: laptoplist
@GET
@Path("/laptoplist")
@Produces(MediaType.TEXT_XML)
public String laptoplist() {
return "<?xml version='1.0' encoding='UTF-8'?>"+storeHandle.showItemList("Laptop");
}
示例6: viewcart
@GET
@Path("/viewcart/{userid}")
@Produces(MediaType.TEXT_XML)
public String viewcart(@PathParam("userid") String userID) {
customerHandle=Singleton.getCustomerhandle(userID);
return "<?xml version='1.0' encoding='UTF-8'?>" + "<result>" + customerHandle.viewMyCart() + "</result>";
}
示例7: buyitems
@GET
@Path("/buyitems/{userid}")
@Produces(MediaType.TEXT_XML)
public String buyitems(@PathParam("userid") String userID) {
String userResponse="<?xml version='1.0' encoding='UTF-8'?>" + "<result>";
String messageToUser="";
String sellResponse="";
int totalitems=0;
//get the list of items from customer cart and call sellItem to remove item from store
//if item is already sold to another customer send message accordingly
//call buyItems to remove all items from customer cart
customerHandle=Singleton.getCustomerhandle(userID);
if(!customerHandle.getshoppingCart().getitemsInCart().isEmpty()){ //if cart is not empty take items from customer cart and sell
for(Map.Entry<String, Item> entry : customerHandle.getshoppingCart().getitemsInCart().entrySet()){
sellResponse = storeHandle.sellItem(entry.getValue().getItem_Name(),entry.getValue().getItem_Make(),entry.getValue().getItem_Model());
if(sellResponse.equals("Item not in Store")){
messageToUser="<messagetouser>This item already sold out, no more stock: "+
entry.getValue().getItem_Name()+" "+entry.getValue().getItem_Make()+" "+entry.getValue().getItem_Model()+
"</messagetouser>";
}
else{
messageToUser="<messagetouser>Thanks! Item ready for despatch from store: "+
entry.getValue().getItem_Name()+" "+entry.getValue().getItem_Make()+" "+entry.getValue().getItem_Model()+
"</messagetouser>";
}
userResponse = userResponse + messageToUser;
}
totalitems=customerHandle.buyItems(); //remove all item from customer cart
}
else{ //else send empty cart message
messageToUser="<messagetouser>"+"Cart is empty, please add items in cart"+"</messagetouser>";
userResponse = userResponse + messageToUser;
}
return userResponse + "<totalitem>" + totalitems +"</totalitem>"+ "</result>";
}