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


Java PhoneNumber類代碼示例

本文整理匯總了Java中com.google.appengine.api.datastore.PhoneNumber的典型用法代碼示例。如果您正苦於以下問題:Java PhoneNumber類的具體用法?Java PhoneNumber怎麽用?Java PhoneNumber使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PhoneNumber類屬於com.google.appengine.api.datastore包,在下文中一共展示了PhoneNumber類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateCustomerAttributes

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的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: setCustomerPhone

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的package包/類
/**
 * Set Customer phone.
 * @param customerPhone
 * 			: customer phone
 * @throws InvalidFieldFormatException 
 */
public void setCustomerPhone(PhoneNumber customerPhone) 
		throws MissingRequiredFieldsException, InvalidFieldFormatException {
	if (customerPhone == null || customerPhone.getNumber().trim().isEmpty()) {
		throw new MissingRequiredFieldsException(this.getClass(), 
	"Customer phone is missing.");
	}
	
	// Check phone number format
	if (!FieldValidator.isValidPhoneNumber(customerPhone.getNumber())) {
		throw new InvalidFieldFormatException(this.getClass(), "Invalid phone number.");
	}
	
	this.customerPhone = customerPhone;
}
 
開發者ID:gfigueroa,項目名稱:internet-radio-gae,代碼行數:21,代碼來源:Customer.java

示例3: createData

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的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.PhoneNumber; //導入依賴的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: testPhoneNumType

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的package包/類
@Test
public void testPhoneNumType() {
    String propertyName = "phoneProp";
    List<Entity> elist = doQuery(kindName, propertyName, PhoneNumber.class, true);
    PhoneNumber phonenum = (PhoneNumber) elist.get(0).getProperty(propertyName);
    PhoneNumber sameDat = (PhoneNumber) elist.get(0).getProperty(propertyName);
    PhoneNumber diffDat = (PhoneNumber) elist.get(1).getProperty(propertyName);
    assertTrue(phonenum.equals(sameDat));
    assertFalse(phonenum.equals(diffDat));
    assertEquals("408-123-4567", phonenum.getNumber());
    assertEquals(0, phonenum.compareTo(sameDat));
    assertTrue(phonenum.compareTo(diffDat) != 0);
    assertEquals(phonenum.hashCode(), phonenum.hashCode());
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-tck,代碼行數:15,代碼來源:StringDataTest.java

示例6: createData

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的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.PhoneNumber; //導入依賴的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: Customer

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的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

示例9: setUp

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的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

示例10: testPhoneNumberProperty

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的package包/類
@Test
public void testPhoneNumberProperty() {
    testEqualityQueries(new PhoneNumber("foo"), new PhoneNumber("bar"));
    testInequalityQueries(new PhoneNumber("111"), new PhoneNumber("222"), new PhoneNumber("333"));
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-tck,代碼行數:6,代碼來源:QueryFilteringByGAEPropertyTypesTest.java

示例11: CustomerSimple

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的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

示例12: getCustomerPhone

import com.google.appengine.api.datastore.PhoneNumber; //導入依賴的package包/類
/**
 * Get Customer phone.
 * @return customer phone
 */
public PhoneNumber getCustomerPhone() {
    return customerPhone;
}
 
開發者ID:gfigueroa,項目名稱:internet-radio-gae,代碼行數:8,代碼來源:Customer.java


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