當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaType.TEXT_XML屬性代碼示例

本文整理匯總了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>";
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:16,代碼來源:Services.java

示例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>";
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:30,代碼來源:Services.java

示例3: smartphonelist

@GET
@Path("/smartphonelist")
@Produces(MediaType.TEXT_XML)
public String smartphonelist() {
		
    return "<?xml version='1.0' encoding='UTF-8'?>"+storeHandle.showItemList("SmartPhone");
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:7,代碼來源:Services.java

示例4: hometheaterlist

@GET
@Path("/hometheaterlist")
@Produces(MediaType.TEXT_XML)
public String hometheaterlist() {
		
    return "<?xml version='1.0' encoding='UTF-8'?>"+storeHandle.showItemList("HomeTheater");
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:7,代碼來源:Services.java

示例5: laptoplist

@GET
@Path("/laptoplist")
@Produces(MediaType.TEXT_XML)
public String laptoplist() {
	
    return "<?xml version='1.0' encoding='UTF-8'?>"+storeHandle.showItemList("Laptop");
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:7,代碼來源:Services.java

示例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>";

}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:9,代碼來源:Services.java

示例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>";
  }
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:39,代碼來源:Services.java


注:本文中的javax.ws.rs.core.MediaType.TEXT_XML屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。