304 // PCL DocFlavors 305 private static DocFlavor[] appPCL = { 306 DocFlavor.BYTE_ARRAY.PCL, 307 DocFlavor.INPUT_STREAM.PCL, 308 DocFlavor.URL.PCL 309 }; 310 311 // List of all DocFlavors, used in looping 312 // through all supported mime-types 313 private static Object[] allDocFlavors = { 314 appPDF, appPostScript, appOctetStream, 315 textPlain, imageJPG, imageGIF, imagePNG, 316 textHtml, appPCL, 317 }; 318 319 320 IPPPrintService(String name, URL url) { 321 if ((name == null) || (url == null)){ 322 throw new IllegalArgumentException("null uri or printer name"); 323 } 324 printer = name; 325 supportedDocFlavors = null; 326 supportedCats = null; 327 mediaSizeNames = null; 328 customMediaSizeNames = null; 329 mediaTrays = null; 330 myURL = url; 331 cps = null; 332 isCupsPrinter = false; 333 init = false; 334 defaultMediaIndex = -1; 335 336 String host = myURL.getHost(); 337 if (host!=null && host.equals(CUPSPrinter.getServer())) { 338 isCupsPrinter = true; 339 try { 340 myURI = new URI("ipp://"+host+ 341 "/printers/"+printer); 342 debug_println(debugPrefix+"IPPPrintService myURI : "+myURI); 343 } catch (java.net.URISyntaxException e) { 344 throw new IllegalArgumentException("invalid url"); 345 } 346 } 347 } 348 349 350 IPPPrintService(String name, String uriStr, boolean isCups) { 351 if ((name == null) || (uriStr == null)){ 352 throw new IllegalArgumentException("null uri or printer name"); 353 } 354 printer = name; 355 supportedDocFlavors = null; 356 supportedCats = null; 357 mediaSizeNames = null; 358 customMediaSizeNames = null; 359 mediaTrays = null; 360 cps = null; 361 init = false; 362 defaultMediaIndex = -1; 363 try { 364 myURL = 365 new URL(uriStr.replaceFirst("ipp", "http")); 366 } catch (Exception e) { 367 IPPPrintService.debug_println(debugPrefix+ 368 " IPPPrintService, myURL="+ 369 myURL+" Exception= "+ 370 e); 371 throw new IllegalArgumentException("invalid url"); 372 } 373 374 isCupsPrinter = isCups; 375 try { 376 myURI = new URI(uriStr); 377 debug_println(debugPrefix+"IPPPrintService myURI : "+myURI); 378 } catch (java.net.URISyntaxException e) { 379 throw new IllegalArgumentException("invalid uri"); 380 } 381 } 382 383 | 304 // PCL DocFlavors 305 private static DocFlavor[] appPCL = { 306 DocFlavor.BYTE_ARRAY.PCL, 307 DocFlavor.INPUT_STREAM.PCL, 308 DocFlavor.URL.PCL 309 }; 310 311 // List of all DocFlavors, used in looping 312 // through all supported mime-types 313 private static Object[] allDocFlavors = { 314 appPDF, appPostScript, appOctetStream, 315 textPlain, imageJPG, imageGIF, imagePNG, 316 textHtml, appPCL, 317 }; 318 319 320 IPPPrintService(String name, URL url) { 321 if ((name == null) || (url == null)){ 322 throw new IllegalArgumentException("null uri or printer name"); 323 } 324 try { 325 printer = java.net.URLDecoder.decode(name, "UTF-8"); 326 } catch (java.io.UnsupportedEncodingException e) { 327 System.out.println("Unsupported Encoding Exception"); 328 } 329 supportedDocFlavors = null; 330 supportedCats = null; 331 mediaSizeNames = null; 332 customMediaSizeNames = null; 333 mediaTrays = null; 334 myURL = url; 335 cps = null; 336 isCupsPrinter = false; 337 init = false; 338 defaultMediaIndex = -1; 339 340 String host = myURL.getHost(); 341 if (host!=null && host.equals(CUPSPrinter.getServer())) { 342 isCupsPrinter = true; 343 try { 344 myURI = new URI("ipp://"+host+ 345 "/printers/"+printer); 346 debug_println(debugPrefix+"IPPPrintService myURI : "+myURI); 347 } catch (java.net.URISyntaxException e) { 348 throw new IllegalArgumentException("invalid url"); 349 } 350 } 351 } 352 353 354 IPPPrintService(String name, String uriStr, boolean isCups) { 355 if ((name == null) || (uriStr == null)){ 356 throw new IllegalArgumentException("null uri or printer name"); 357 } 358 try { 359 printer = java.net.URLDecoder.decode(name, "UTF-8"); 360 } catch (java.io.UnsupportedEncodingException e) { 361 System.out.println("Unsupported Encoding Exception"); 362 } 363 supportedDocFlavors = null; 364 supportedCats = null; 365 mediaSizeNames = null; 366 customMediaSizeNames = null; 367 mediaTrays = null; 368 cps = null; 369 init = false; 370 defaultMediaIndex = -1; 371 try { 372 373 myURL = 374 new URL(uriStr.replaceFirst("ipp", "http")); 375 } catch (Exception e) { 376 IPPPrintService.debug_println(debugPrefix+ 377 " IPPPrintService, myURL="+ 378 myURL+" Exception= "+ 379 e); 380 throw new IllegalArgumentException("invalid url"); 381 } 382 383 isCupsPrinter = isCups; 384 try { 385 myURI = new URI(uriStr); 386 debug_println(debugPrefix+"IPPPrintService myURI : "+myURI); 387 } catch (java.net.URISyntaxException e) { 388 throw new IllegalArgumentException("invalid uri"); 389 } 390 } 391 392 |