当前位置: 首页>>代码示例>>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;未经允许,请勿转载。