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


Java ApiException类代码示例

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


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

示例1: getDriveDist

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static long getDriveDist(String addrOne, String addrTwo) throws ApiException, InterruptedException, IOException{
			
	//set up key
   	GeoApiContext distCalcer = new GeoApiContext.Builder()
		    .apiKey(API_KEY)
		    .build();
   	
   	DistanceMatrixApiRequest req = DistanceMatrixApi.newRequest(distCalcer); 
       DistanceMatrix result = req.origins(addrOne)
               .destinations(addrTwo)
               .mode(TravelMode.DRIVING)
               .avoid(RouteRestriction.TOLLS)
               .language("en-US")
               .await();
       
			long distApart = result.rows[0].elements[0].distance.inMeters;
	
	return distApart;
}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:20,代码来源:EarthSearch.java

示例2: distanceMatrix

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static void distanceMatrix(String[] origins, String[] destinations) throws ApiException, InterruptedException, IOException{
	GeoApiContext context = new GeoApiContext.Builder()
		    .apiKey(API_KEY)
		    .build();
		
		DistanceMatrixApiRequest req=DistanceMatrixApi.newRequest(context);
		DistanceMatrix t=req.origins(origins).destinations(destinations).mode(TravelMode.DRIVING).await();
		//long[][] array=new long[origins.length][destinations.length];
		File file=new File("Matrix.txt");
		FileOutputStream out=new FileOutputStream(file);
		DataOutputStream outFile=new DataOutputStream(out);
		for(int i=0;i<origins.length;i++){
			for(int j=0;j<destinations.length;j++){
				//System.out.println(t.rows[i].elements[j].distance.inMeters);
				outFile.writeLong(t.rows[i].elements[j].distance.inMeters);
			}
		}
		outFile.close();
}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:20,代码来源:EarthSearch.java

示例3: School

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public School(String name, int enrollment, boolean boys,boolean girls,boolean HostSect,boolean HostReg,boolean HostSemi, LatLng coords) throws ApiException, InterruptedException, IOException, ClassNotFoundException{
	this.name=name;
	//this.location= lookupAddr();	
	//this.coords=EarthSearch.lookupCoordFromFile(name);
	this.coords=coords;
	this.enrollment=enrollment;
	this.boys=boys;
	this.girls=girls;
	this.HostSect=HostSect;
	this.HostReg=HostReg;
	this.HostSemi=HostSemi;
	this.classification=classify(this.enrollment);
	if(this.isHostSect()==true)
		sectNo++;
	if(this.isHostReg()==true)
		regNo++;
	if(this.isHostSemi()==true)
		semiNo++;
}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:20,代码来源:School.java

示例4: lookupAddr

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static String lookupAddr(String establishment) throws ApiException, InterruptedException, IOException {
	
	//set up key
	GeoApiContext lookupDoodad = new GeoApiContext.Builder()
		    .apiKey(API_KEY)
		    .build();
		GeocodingResult[] results =  GeocodingApi.geocode(lookupDoodad,
		    establishment).await();
		
		//converts results into usable address
		
		String address = (results[0].formattedAddress);
	
	return address;
}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:16,代码来源:EarthSearch.java

示例5: lookupCoord

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static LatLng lookupCoord(String establishment) throws ApiException, InterruptedException, IOException {
		
	//set up key
	GeoApiContext lookupDoodad = new GeoApiContext.Builder()
		    .apiKey(API_KEY)
		    .build();
	GeocodingResult[] results =  GeocodingApi.geocode(lookupDoodad,
	  establishment).await();
			
		//converts results into usable Coordinates
	
		LatLng coords = (results[0].geometry.location);
			//System.out.println(results[0].geometry.location);
	return coords;
}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:16,代码来源:EarthSearch.java

示例6: getError

import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
  if (successful()) {
    return null;
  }
  return ApiException.from(status, errorMessage);
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:8,代码来源:PlaceDetailsRequest.java

示例7: getError

import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
  if (successful()) {
    return null;
  }
  return ApiException.from(reason, message);
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:8,代码来源:GeolocationApi.java

示例8: await

import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public T await() throws ApiException, IOException, InterruptedException {
  try {
    return parseResponse(this, call.get());
  } catch (ExecutionException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    } else {
      // According to
      // https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/urlfetch/URLFetchService
      // all exceptions should be subclass of IOException so this should not happen.
      throw new UnknownErrorException("Unexpected exception from " + e.getMessage());
    }
  }
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:16,代码来源:GaePendingResult.java

示例9: setIfExceptionIsAllowedToRetry

import com.google.maps.errors.ApiException; //导入依赖的package包/类
/**
 * Allows specific API exceptions to be retried or not retried.
 *
 * @param exception The {@code ApiException} to allow or deny being re-tried.
 * @param allowedToRetry Whether to allow or deny re-trying {@code exception}.
 * @return Returns this builder for call chaining.
 */
public Builder setIfExceptionIsAllowedToRetry(
    Class<? extends ApiException> exception, boolean allowedToRetry) {
  if (allowedToRetry) {
    exceptionsAllowedToRetry.add(exception);
  } else {
    exceptionsAllowedToRetry.remove(exception);
  }
  return this;
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:17,代码来源:GeoApiContext.java

示例10: main

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static void main(String[] args) throws ApiException, InterruptedException, IOException, ClassNotFoundException {
	// TODO Auto-generated method stub
	File file=new File("All Schools Lists.txt");
	Scanner scan =new Scanner(file).useDelimiter("\\*|\\n");
	
	FileOutputStream fileOut=new FileOutputStream("Coords.dat");
	ObjectOutputStream objOut=new ObjectOutputStream(fileOut);
	ObjectInputStream objIn=new ObjectInputStream(new FileInputStream("Coords.dat"));
	int c=0;
	ArrayList<String>names=new ArrayList<String>();
	while(scan.hasNext()){
		String name=scan.next();
		int enrollment=scan.nextInt();
		boolean boys=assignBoolean(scan.next());
		boolean girls=assignBoolean(scan.next());
		boolean HostSect=assignBoolean(scan.next());
		boolean HostReg=assignBoolean(scan.next());
		boolean HostSemi=assignBoolean(scan.next());
		names.add(name);
	}
	
	Coord []x=new Coord[names.size()];
	System.out.println(x.length);
	int j=0;
	for( j=0;j<x.length;j++){
		String tN=names.get(j);
		LatLng tL=EarthSearch.lookupCoord(tN+",IN");
		x[j]=new Coord(tN,tL);
		objOut.writeObject(x[j]);
	}
	System.out.println(j);
	//Coord []temp=new Coord[391-383];
	//System.out.println(EarthSearch.lookupCoord("Evansville Reitz Memorial High School"));
	/*
	for(int k=383;k<391;k++){
		System.out.println(names.get(k));
		LatLng l=EarthSearch.lookupCoord(names.get(k)+",IN");
		System.out.println(l.lat);
	}*/
	objOut.close();
	fileOut.close();
	System.out.println("Done writing");
	int flag=1;
	System.out.println("Read");
	/*Coord temp[]=new Coord[names.size()];
	for(int i=0;i<names.size();i++){
		temp[i]=(Coord)objIn.readObject();
		//System.out.println(temp.getNameSchool()+"\t"+temp.getCoords().lat);
	}*/
	try{
		while((Coord)objIn.readObject()!=null){
			Coord tempO=(Coord)objIn.readObject();
			if(tempO==null)
				break;
			System.out.println("Name: "+tempO.getNameSchool()+"\t"+tempO.lat);
			
		}
	}
	catch(EOFException e){
		System.out.println("Reached EOF");
	}
	/*while((Coord)objIn.readObject()!=null){
		Coord tempO=(Coord)objIn.readObject();
		if(tempO==null)
			break;
		System.out.println("Name: "+tempO.getNameSchool()+"\t"+tempO.lat);
		
	}*/
	objIn.close();
}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:71,代码来源:Coord.java

示例11: main

import com.google.maps.errors.ApiException; //导入依赖的package包/类
public static void main(String[] args) throws ApiException, InterruptedException, IOException {
		
		//String establishment = "Snider High School, Indiana";
		//EarthSearch.lookupAddress(establishment);

	//	System.out.println(EarthSearch.computeDriveDistance("5901 Heywood Cove, Fort Wayne, IN 46815",
	//			"4600 Fairlawn Pass, Fort Wayne, IN 46815"));
		
	//	String establishment = "Snider High School, Indiana";
	//	System.out.println(EarthSearch.lookupAddr(establishment));
	
		
///////		
		//CREATES GUI!! I did it!
		
		//Test URL string for window
//		String url = "https://maps.googleapis.com/maps/api/staticmap?center=Indianapolis,IN&zoom=7&size=500x500&markers=color:green%7CHuntington+North+High+School";
//		
//
//		Display display = new Display();
//		
//        Shell shell = new Shell(display);
//        shell.setSize(552, 575);
//        
//        new MapGUI(shell, SWT.NONE, url);
//
////         the layout manager handle the layout
////         of the widgets in the container
//        shell.setLayout(new FillLayout());
//
//        //add some widgets to the Shell
//        shell.open();
//        while (!shell.isDisposed()) {
//            if (!display.readAndDispatch()) {
//                display.sleep();
//            }
//        }
//        display.dispose();
//       
		
		//new ViewGUI();

		new InitGUI();
	}
 
开发者ID:Celethor,项目名称:CS360proj1,代码行数:45,代码来源:BensTestingClass.java

示例12: getError

import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
  return null;
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:5,代码来源:PhotoRequest.java

示例13: getError

import com.google.maps.errors.ApiException; //导入依赖的package包/类
@Override
public ApiException getError() {
  return ApiException.from(error.status, error.message);
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:5,代码来源:RoadsApi.java

示例14: retry

import com.google.maps.errors.ApiException; //导入依赖的package包/类
private T retry() throws IOException, ApiException, InterruptedException {
  retryCounter++;
  LOG.info("Retrying request. Retry #{}", retryCounter);
  this.call = client.fetchAsync(request);
  return this.await();
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:7,代码来源:GaePendingResult.java

示例15: shouldRetry

import com.google.maps.errors.ApiException; //导入依赖的package包/类
private boolean shouldRetry(ApiException exception) {
  return exceptionsAllowedToRetry.contains(exception.getClass())
      && cumulativeSleepTime < errorTimeOut
      && (maxRetries == null || retryCounter < maxRetries);
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:6,代码来源:GaePendingResult.java


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