当前位置: 首页>>代码示例>>Java>>正文


Java PostalAddress类代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.PostalAddress的典型用法代码示例。如果您正苦于以下问题:Java PostalAddress类的具体用法?Java PostalAddress怎么用?Java PostalAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PostalAddress类属于com.google.appengine.api.datastore包,在下文中一共展示了PostalAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCustomerAttributes

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
   * Update Customer attributes.
   * Update's the given customer's attributes in the datastore.
   * @param email
   * 			: the email of the customer whose attributes will be updated
   * @param customerName
   * 			: the new name to give to the customer
   * @param customerPhone
   * 			: the new phone to give to the customer
   * @param customerGender
   * 			: the new gender to give to the customer
   * @param customerAddress
   * 			: the new address to give to the customer
   * @param customerComments
   * 			: the new comments to give to the customer
* @throws MissingRequiredFieldsException 
* @throws InvalidFieldFormatException 
   */
public static void updateCustomerAttributes(Email email, String customerName, 
		PhoneNumber customerPhone, Customer.Gender customerGender, PostalAddress customerAddress,
		String customerComments) throws MissingRequiredFieldsException, InvalidFieldFormatException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Key key = KeyFactory.createKey(Customer.class.getSimpleName(), email.getEmail());
		Customer customer = pm.getObjectById(Customer.class, key);
		tx.begin();
		customer.setCustomerName(customerName);
		customer.setCustomerPhone(customerPhone);
		customer.setCustomerGender(customerGender);
		customer.setCustomerAddress(customerAddress);
		customer.setCustomerComments(customerComments);
		tx.commit();
		log.info("Customer \"" + email.getEmail() + "\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:45,代码来源:CustomerManager.java

示例2: setCustomerAddress

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
 * Set Customer address line 1.
 * @param customerAddressLine1
 * 			: customer address line 1
 * @throws MissingRequiredFieldsException 
 */
public void setCustomerAddress(PostalAddress customerAddress)
		throws MissingRequiredFieldsException {
	if (customerAddress == null || customerAddress.getAddress().trim().isEmpty()) {
		throw new MissingRequiredFieldsException(this.getClass(), 
	"Customer address is missing.");
	}
	this.customerAddress = customerAddress;
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:15,代码来源:Customer.java

示例3: createData

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Before
public void createData() throws InterruptedException {
    Entity newRec;
    String[] stringDat = {"abc", "xyz", "mno"};
    PhoneNumber[] phoneDat = {new PhoneNumber("408-123-4567"), new PhoneNumber("650-321-7654"),
        new PhoneNumber("408-987-6543")};
    PostalAddress[] addressDat = {new PostalAddress("123 Google Rd. CA 12345"),
        new PostalAddress("19451 Via Monte Rd. CA95070"), new PostalAddress("9 1st St. CA 95000")};
    Email[] emailDat = {new Email("[email protected]"), new Email("[email protected]"),
        new Email("[email protected]")};
    Link[] linkDat = {new Link("http://www.hotmail.com"), new Link("http://www.google.com.com"),
        new Link("http://www.gmail.com")};
    Category[] categoryDat = {new Category("developer"), new Category("test"),
        new Category("manager")};
    Text[] textDat = {new Text("english"), new Text("chinese"), new Text("japanese")};
    ShortBlob[] byteString = {new ShortBlob("shortblob".getBytes()),
        new ShortBlob("shortText".getBytes()), new ShortBlob("shortImage".getBytes())};
    Blob[] blobDat = {new Blob("blobImage".getBytes()), new Blob("blobText".getBytes()),
        new Blob("blobData".getBytes())};

    clearData(kindName);
    List<Entity> elist = new ArrayList<Entity>();
    for (int i = 0; i < 3; i++) {
        newRec = new Entity(kindName, rootKey);
        newRec.setProperty("stringProp", stringDat[i]);
        newRec.setProperty("phoneProp", phoneDat[i]);
        newRec.setProperty("addressProp", addressDat[i]);
        newRec.setProperty("emailProp", emailDat[i]);
        newRec.setProperty("linkProp", linkDat[i]);
        newRec.setProperty("categoryProp", categoryDat[i]);
        newRec.setProperty("textProp", textDat[i]);
        newRec.setProperty("byteStrProp", byteString[i]);
        newRec.setProperty("blobProp", blobDat[i]);
        elist.add(newRec);
    }
    service.put(elist);
    sync(waitTime);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:39,代码来源:StringDataTest.java

示例4: testFilter

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Test
public void testFilter() {
    doAllFilters(kindName, "stringProp", "mno");
    doEqOnlyFilter(kindName, "phoneProp", new PhoneNumber("650-321-7654"));
    doEqOnlyFilter(kindName, "addressProp", new PostalAddress("19451 Via Monte Rd. CA95070"));
    doEqOnlyFilter(kindName, "emailProp", new Email("[email protected]"));
    doEqOnlyFilter(kindName, "linkProp", new Link("http://www.google.com.com"));
    doEqOnlyFilter(kindName, "categoryProp", new Category("test"));
    doEqOnlyFilter(kindName, "byteStrProp", new ShortBlob("shortText".getBytes()));
    String[] inDat = {"abc", "xyz"};
    doInFilter(kindName, "stringProp", inDat);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:13,代码来源:StringDataTest.java

示例5: testPostalAddrType

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Test
public void testPostalAddrType() {
    String propertyName = "addressProp";
    List<Entity> elist = doQuery(kindName, propertyName, PostalAddress.class, true);
    PostalAddress postaladdr = (PostalAddress) elist.get(0).getProperty(propertyName);
    PostalAddress sameDat = (PostalAddress) elist.get(0).getProperty(propertyName);
    PostalAddress diffDat = (PostalAddress) elist.get(1).getProperty(propertyName);
    assertTrue(postaladdr.equals(sameDat));
    assertFalse(postaladdr.equals(diffDat));
    assertEquals("123 Google Rd. CA 12345", postaladdr.getAddress());
    assertEquals(0, postaladdr.compareTo(sameDat));
    assertTrue(postaladdr.compareTo(diffDat) != 0);
    assertEquals(postaladdr.hashCode(), postaladdr.hashCode());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:15,代码来源:StringDataTest.java

示例6: createData

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Before
public void createData() throws InterruptedException {
    clearData(kindName);

    List<Entity> elist = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        Entity newRec = new Entity(kindName, rootKey);
        newRec.setProperty("stringData", "string data" + i);
        newRec.setProperty("timestamp", new Date());
        newRec.setProperty("shortBlobData", new ShortBlob(("shortBlobData" + i).getBytes()));
        newRec.setProperty("intData", 20 * i);
        newRec.setProperty("textData", new Text("textData" + i));
        newRec.setProperty("floatData", 1234 + 0.1 * i);
        newRec.setProperty("booleanData", true);
        newRec.setProperty("urlData", new Link("http://www.google.com"));
        newRec.setProperty("emailData", new Email("somebody123" + i + "@google.com"));
        newRec.setProperty("phoneData", new PhoneNumber("408-123-000" + i));
        newRec.setProperty("adressData", new PostalAddress("123 st. CA 12345" + i));
        newRec.setProperty("ratingData", new Rating(10 * i));
        newRec.setProperty("geoptData", new GeoPt((float) (i + 0.12), (float) (i + 0.98)));
        newRec.setProperty("categoryData", new Category("category" + i));
        newRec.setProperty("intList", Arrays.asList(i, 50 + i, 90 + i));
        elist.add(newRec);
    }
    service.put(elist);

    sync(1000);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:29,代码来源:QueryTest.java

示例7: createData

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Before
public void createData() throws InterruptedException {
    List<Entity> eList = new ArrayList<Entity>();
    for (int i = 0; i < namespaceDat.length; i++) {
        NamespaceManager.set(namespaceDat[i]);
        for (int k = 0; k < kindDat.length; k++) {
            Query q = new Query(kindDat[k]);
            if (service.prepare(q).countEntities(fo) == 0) {
                for (int c = 0; c < count; c++) {
                    Entity newRec = new Entity(kindDat[k]);
                    newRec.setProperty("name", kindDat[k] + c);
                    newRec.setProperty("timestamp", new Date());
                    newRec.setProperty("shortBlobData", new ShortBlob("shortBlobData".getBytes()));
                    newRec.setProperty("intData", 12345);
                    newRec.setProperty("textData", new Text("textData"));
                    newRec.setProperty("floatData", new Double(12345.12345));
                    newRec.setProperty("booleanData", true);
                    newRec.setProperty("urlData", new Link("http://www.google.com"));
                    newRec.setProperty("emailData", new Email("[email protected]"));
                    newRec.setProperty("phoneData", new PhoneNumber("408-123-4567"));
                    newRec.setProperty("adressData", new PostalAddress("123 st. CA 12345"));
                    newRec.setProperty("ratingData", new Rating(55));
                    newRec.setProperty("geoptData", new GeoPt((float) 12.12, (float) 98.98));
                    newRec.setProperty("categoryData", new Category("abc"));
                    eList.add(newRec);
                }
            }
        }
    }
    if (eList.size() > 0) {
        service.put(eList);
        sync(waitTime);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:35,代码来源:SchemaTest.java

示例8: updateStationAttributes

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
   * Update Station attributes.
   * Update's the given Station's attributes in the datastore.
   * @param email
   * 			: the email of the Station whose attributes will be updated
   * @param stationType
   * 			: the new station type's key to give to the Station
   * @param stationPrivilegeLevel
   * 			: the new privilege level of the station
   * @param stationName
   * 			: the new name to give to the Station
   * @param stationNumber
   * 			: the new number to give to the Station
   * @param stationDescription
   * 			: the new description to give to the Station
   * @param region
   * 			: the new region of the Station
   * @param stationAddress
   * 			: the new address of the Station
   * @param stationWebsite
   * 			: Station website
   * @param stationLogo
   * 			: Station logo blob key
   * @param stationComments
   * 			: the new comments to give to the Station
* @throws MissingRequiredFieldsException 
   */
public static void updateStationAttributes(
		Email email,
		Long stationType,
		Integer stationPrivilegeLevel,
           String stationName,
           String stationNumber,
           String stationDescription,
           Long region,
           PostalAddress stationAddress,
           Link stationWebsite, 
           BlobKey stationLogo, 
           String stationComments) 
           		throws MissingRequiredFieldsException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Key key = KeyFactory.createKey(Station.class.getSimpleName(), 
				email.getEmail());
		Station station = pm.getObjectById(Station.class, key);
		
		BlobKey oldStationLogo = station.getStationLogo();
		
		tx.begin();
		station.setStationType(stationType);
		station.setPrivilegeLevel(stationPrivilegeLevel);
		station.setStationName(stationName);
		station.setStationNumber(stationNumber);
		station.setStationDescription(stationDescription);
		station.setRegion(region);
		station.setStationAddress(stationAddress);
		station.setStationWebsite(stationWebsite);
		station.setStationLogo(stationLogo);
		station.setStationComments(stationComments);
		tx.commit();
		
		if (!oldStationLogo.equals(stationLogo) &&
				oldStationLogo != null) {
			blobstoreService.delete(oldStationLogo);
		}
		
		log.info("Station \"" + email.getEmail() + 
				"\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:80,代码来源:StationManager.java

示例9: Station

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
 * Station constructor.
 * @param user
 * 			: the user for this station
 * @param stationType
 * 			: station type key
 * @param stationPrivilegeLevel
 * 			: station privilege level
 * @param stationName
 * 			: station name
 * @param stationNumber
 * 			: station number
 * @param stationDescription
 * 			: station description
 * @param region
 * 			: station region
 * @param stationAddress
 * 			: station address
 * @param stationWebsite
 * 			: station website
 * @param stationLogo
 * 			: station logo blob key
 * @param stationComments
 * 			: station comments
 * @throws MissingRequiredFieldsException
 * @throws InvalidFieldFormatException 
 */
public Station(User user, 
		Long stationType, 
		Integer stationPrivilegeLevel, 
		String stationName, 
		String stationNumber, 
		String stationDescription, 
		Long region, 
		PostalAddress stationAddress,
		Link stationWebsite, 
		BlobKey stationLogo, 
		String stationComments) 
		throws MissingRequiredFieldsException {
    
	// Check "required field" constraints
	if (user == null || stationType == null || stationPrivilegeLevel == null ||
			stationName == null || stationNumber == null ||
			stationDescription == null) {
		throw new MissingRequiredFieldsException(
				this, "One or more required fields are missing.");
	}
	if (stationName.trim().isEmpty() || stationNumber.trim().isEmpty() ||
			stationDescription.trim().isEmpty()) {
		throw new MissingRequiredFieldsException(
				this, "One or more required fields are missing.");
	}
	
	this.user = user;
	
	// Create key with user email
	this.key = KeyFactory.createKey(Station.class.getSimpleName(), user.getUserEmail().getEmail());
	
	this.stationType = stationType;
	this.stationPrivilegeLevel = stationPrivilegeLevel;
	this.stationName = stationName;
	this.stationNumber = stationNumber;
	this.stationDescription = stationDescription;
	this.region = region;
	this.stationAddress = stationAddress;
    this.stationWebsite = stationWebsite;
    this.stationLogo = stationLogo;
    this.stationComments = stationComments;
    
	// Create empty lists
	this.channels = new ArrayList<Channel>();
	this.playlists = new ArrayList<Playlist>();
	this.stationImages = new ArrayList<StationImage>();
	this.stationAudios = new ArrayList<StationAudio>();
	
	// Initialize the versions in 0
	this.playlistVersion = 0;
	this.stationImageVersion = 0;
	this.stationAudioVersion = 0;
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:81,代码来源:Station.java

示例10: Customer

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
 * Customer constructor.
 * @param user
 * 			: user for this customer
 * @param customerName
 * 			: customer name
 * @param customerPhone
 * 			: customer phone
 * @param customerGender
 * 			: customer gender
 * @param customerAddress
 * 			: customer address
 * @param customerComments
 * 			: customer comments
 * @throws MissingRequiredFieldsException
 * @throws InvalidFieldFormatException
 */
public Customer(User user, String customerName, 
                PhoneNumber customerPhone, Gender customerGender,
		        PostalAddress customerAddress, String customerComments) 
		throws MissingRequiredFieldsException, InvalidFieldFormatException {
    
	// Check "required field" constraints
	if (user == null || customerName == null || customerPhone == null || customerGender == null ||
			customerAddress == null) {
		throw new MissingRequiredFieldsException(this.getClass(), "One or more required fields are missing.");
	}
	if (customerName.trim().isEmpty() || customerPhone.getNumber().trim().isEmpty() || 
			customerAddress.getAddress().trim().isEmpty()) {
		throw new MissingRequiredFieldsException(this.getClass(), "One or more required fields are missing.");
	}
	
	// Check phone number format
	if (!FieldValidator.isValidPhoneNumber(customerPhone.getNumber())) {
		throw new InvalidFieldFormatException(this.getClass(), "Invalid phone number.");
	}
	
	this.user = user;
	
	// Create key with user email
	this.key = KeyFactory.createKey(Customer.class.getSimpleName(), user.getUserEmail().getEmail());
	
	this.customerName = customerName;
    this.customerPhone = customerPhone;
    
    this.gender = customerGender;
    switch(customerGender) {
    	case MALE:
    		this.customerGender = "male";
    		break;
    	case FEMALE:
    		this.customerGender = "female";
    		break;
    }

    this.customerAddress = customerAddress;
    this.status = Status.UNCONFIRMED;
    this.customerStatus = "unconfirmed";
    this.customerComments = customerComments;
    
    this.ownedUserGroups = new ArrayList<UserGroup>();
    this.followedUserGroups = new ArrayList<Key>();
    this.userRecommendations = new ArrayList<UserRecommendation>();
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:65,代码来源:Customer.java

示例11: setUp

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Before
public void setUp() {
    super.setUp();

    values = asList(
        asSet((Object) null),
        asSet((short) -10, -10, -10L),
        asSet((short) 10, 10, 10L, new Rating(10)),
        asSet((short) 20, 20, 20L, new Rating(20)),
        asSet(createDate(2013, 1, 1)),
        asSet(createDate(2013, 5, 5)),
        asSet(1381363199999999L),   // 1 microsecond before 2013-10-10
        asSet(new Date(1381363200000L), 1381363200000000L), // 2013-10-10
        asSet(1381363200000001L),   // 1 microsecond after 2013-10-10
        asSet(false),
        asSet(true),
        asSet(
            "sip sip",
            new ShortBlob("sip sip".getBytes()),
            new PostalAddress("sip sip"),
            new PhoneNumber("sip sip"),
            new Email("sip sip"),
            new IMHandle(IMHandle.Scheme.sip, "sip"),   // this is stored as "sip sip"
            new Link("sip sip"),
            new Category("sip sip"),
            new BlobKey("sip sip")
        ),
        asSet(
            "xmpp xmpp",
            new ShortBlob("xmpp xmpp".getBytes()),
            new PostalAddress("xmpp xmpp"),
            new PhoneNumber("xmpp xmpp"),
            new Email("xmpp xmpp"),
            new IMHandle(IMHandle.Scheme.xmpp, "xmpp"), // this is stored as "xmpp xmpp"
            new Link("xmpp xmpp"),
            new Category("xmpp xmpp"),
            new BlobKey("xmpp xmpp")
        ),
        asSet(-10f, -10d),
        asSet(10f, 10d),
        asSet(20f, 20d),
        asSet(new GeoPt(10f, 10f)),
        asSet(new GeoPt(20f, 20f)),
        asSet(new User("aaa", "aaa"), new User("aaa", "otherAuthDomain")),  // ordering must depend only on the email
        asSet(new User("bbb", "bbb")),
        asSet(KeyFactory.createKey("kind", "aaa")),
        asSet(KeyFactory.createKey("kind", "bbb"))
    );

    entities = new ArrayList<Set<Entity>>();
    for (Set<?> values2 : values) {
        Set<Entity> entities2 = new HashSet<Entity>();
        entities.add(entities2);
        for (Object value : values2) {
            entities2.add(storeTestEntityWithSingleProperty(value));
        }
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:59,代码来源:OrderingTest.java

示例12: testPostalAddressProperty

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Test
public void testPostalAddressProperty() {
    testEqualityQueries(new PostalAddress("foo"), new PostalAddress("bar"));
    testInequalityQueries(new PostalAddress("aaa"), new PostalAddress("bbb"), new PostalAddress("ccc"));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:6,代码来源:QueryFilteringByGAEPropertyTypesTest.java

示例13: testEmailProperty

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
@Test
public void testEmailProperty() {
    testEqualityQueries(new PostalAddress("[email protected]"), new PostalAddress("[email protected]"));
    testInequalityQueries(new PostalAddress("[email protected]"), new PostalAddress("[email protected]"), new PostalAddress("[email protected]"));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:6,代码来源:QueryFilteringByGAEPropertyTypesTest.java

示例14: CustomerSimple

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
 * CustomerSimple constructor.
 * @param key
 * 			: restaurant key
 * @param customerName
 * 			: customer name
 * @param customerPhone
 * 			: customer phone
 * @param customerGender
 * 			: customer gender
 * @param customerAddress
 * 			: customer address
 */
public CustomerSimple(String key, String customerName, 
		PhoneNumber customerPhone, String customerGender,
		PostalAddress customerAddress) {

	this.key = key;
	this.customerName = customerName;
	this.customerPhone = customerPhone;
	this.customerGender = customerGender;
	this.customerAddress = customerAddress;
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:24,代码来源:CustomerSimple.java

示例15: getStationAddress

import com.google.appengine.api.datastore.PostalAddress; //导入依赖的package包/类
/**
 * Get Station address.
 * @return station address
 */
public PostalAddress getStationAddress() {
	return stationAddress;
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:8,代码来源:Station.java


注:本文中的com.google.appengine.api.datastore.PostalAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。