Java 类javax.print.attribute.standard.RequestingUserName 实例源码
项目:javify
文件:IppRequest.java
/**
* Writes an attribute in TextSyntax into the stream.
* <p>
* By default attributes are qritten as TEXT_WITHOUT_LANGUAGE value-tag.
* As some attributes in the JPS are TextSyntax attributes but actually
* of NAME value-tag in IPP this method checks for these attributes and
* writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream.
* </p>
*
* @param attribute the attribute
* @param out the stream to write to
* @throws IOException if thrown by the stream
*/
private void write(TextSyntax attribute) throws IOException
{
// We only use *WithoutLanguage, correct according to spec.
String name = ((Attribute) attribute).getName();
if (attribute instanceof RequestingUserName
|| attribute instanceof JobName
|| attribute instanceof DocumentName
|| attribute instanceof JobOriginatingUserName)
out.writeByte(IppValueTag.NAME_WITHOUT_LANGUAGE);
else if (attribute instanceof DocumentFormat)
out.writeByte(IppValueTag.MIME_MEDIA_TYPE);
else
out.writeByte(IppValueTag.TEXT_WITHOUT_LANGUAGE);
out.writeShort(name.length());
out.write(name.getBytes());
out.writeShort(attribute.getValue().length());
out.write(attribute.getValue().getBytes());
}
项目:jvm-stm
文件:IppRequest.java
/**
* Writes an attribute in TextSyntax into the stream.
* <p>
* By default attributes are qritten as TEXT_WITHOUT_LANGUAGE value-tag.
* As some attributes in the JPS are TextSyntax attributes but actually
* of NAME value-tag in IPP this method checks for these attributes and
* writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream.
* </p>
*
* @param attribute the attribute
* @param out the stream to write to
* @throws IOException if thrown by the stream
*/
private void write(TextSyntax attribute) throws IOException
{
// We only use *WithoutLanguage, correct according to spec.
String name = ((Attribute) attribute).getName();
if (attribute instanceof RequestingUserName
|| attribute instanceof JobName
|| attribute instanceof DocumentName
|| attribute instanceof JobOriginatingUserName)
out.writeByte(IppValueTag.NAME_WITHOUT_LANGUAGE);
else if (attribute instanceof DocumentFormat)
out.writeByte(IppValueTag.MIME_MEDIA_TYPE);
else
out.writeByte(IppValueTag.TEXT_WITHOUT_LANGUAGE);
out.writeShort(name.length());
out.write(name.getBytes());
out.writeShort(attribute.getValue().length());
out.write(attribute.getValue().getBytes());
}
项目:cn1
文件:GDIClient.java
public Object getDefaultAttributeValue(Class category) {
if (category.equals(JobName.class)) {
return new JobName("Java GDI client print job", Locale.US);
} else if (category.equals(RequestingUserName.class)) {
return new RequestingUserName(System.getProperty("user.name"),
Locale.US);
} else if (category.equals(Destination.class)) {
File file = new File(System.getProperty("user.dir") +
File.separator + "output.prn");
return new Destination(file.toURI());
} else if (category.equals(SheetCollate.class)) {
return SheetCollate.COLLATED;
} else if (category.equals(Copies.class)) {
return new Copies(1);
}
return null;
}
项目:cn1
文件:ServiceUIDialog.java
void fillUserNameField() {
boolean flg =
myService.isAttributeCategorySupported(RequestingUserName.class);
userNameTxt.setEnabled(flg);
userNameLabel.setEnabled(flg);
if (firstUse && attrs.containsKey(RequestingUserName.class)) {
userNameTxt.setText(((TextSyntax)
attrs.get(RequestingUserName.class)).getValue());
}
if (flg && (userNameTxt.getText().length() <= 0)) {
RequestingUserName defaul = (RequestingUserName) (myService
.getDefaultAttributeValue(RequestingUserName.class));
userNameTxt.setText(defaul==null ? "" : (String) (defaul.getValue()));
}
}
项目:cn1
文件:CUPSClient.java
private Object[] getDefaultAttributeValueEx(Class category) {
if (Destination.class.isAssignableFrom(category)) {
return new Object[0];
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName(
(String) AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty("user.name");
}
}), Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Java print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Java print document",
Locale.US) };
}
return null;
}
项目:cn1
文件:CUPSClient.java
private Object[] getSupportedAttributeValuesEx(Class category,
DocFlavor flavor) {
if (Destination.class.isAssignableFrom(category)) {
String ms = flavor.getMediaSubtype();
if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
|| ms.equalsIgnoreCase("png")
|| ms.equalsIgnoreCase("postscript")
|| flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
try {
return new Object[] { new Destination(new URI(
"file:///foo/bar")) };
} catch (URISyntaxException e) {
// return empty array - values are not supported
return new Object[0];
}
}
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName("I.A.Muser", Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Foo print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Foo document", Locale.US) };
}
return null;
}
项目:JamVM-PH
文件:IppRequest.java
/**
* Writes an attribute in TextSyntax into the stream.
* <p>
* By default attributes are qritten as TEXT_WITHOUT_LANGUAGE value-tag.
* As some attributes in the JPS are TextSyntax attributes but actually
* of NAME value-tag in IPP this method checks for these attributes and
* writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream.
* </p>
*
* @param attribute the attribute
* @param out the stream to write to
* @throws IOException if thrown by the stream
*/
private void write(TextSyntax attribute) throws IOException
{
// We only use *WithoutLanguage, correct according to spec.
String name = ((Attribute) attribute).getName();
if (attribute instanceof RequestingUserName
|| attribute instanceof JobName
|| attribute instanceof DocumentName
|| attribute instanceof JobOriginatingUserName)
out.writeByte(IppValueTag.NAME_WITHOUT_LANGUAGE);
else if (attribute instanceof DocumentFormat)
out.writeByte(IppValueTag.MIME_MEDIA_TYPE);
else
out.writeByte(IppValueTag.TEXT_WITHOUT_LANGUAGE);
out.writeShort(name.length());
out.write(name.getBytes());
out.writeShort(attribute.getValue().length());
out.write(attribute.getValue().getBytes());
}
项目:classpath
文件:IppRequest.java
/**
* Writes an attribute in TextSyntax into the stream.
* <p>
* By default attributes are qritten as TEXT_WITHOUT_LANGUAGE value-tag.
* As some attributes in the JPS are TextSyntax attributes but actually
* of NAME value-tag in IPP this method checks for these attributes and
* writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream.
* </p>
*
* @param attribute the attribute
* @param out the stream to write to
* @throws IOException if thrown by the stream
*/
private void write(TextSyntax attribute) throws IOException
{
// We only use *WithoutLanguage, correct according to spec.
String name = ((Attribute) attribute).getName();
if (attribute instanceof RequestingUserName
|| attribute instanceof JobName
|| attribute instanceof DocumentName
|| attribute instanceof JobOriginatingUserName)
out.writeByte(IppValueTag.NAME_WITHOUT_LANGUAGE);
else if (attribute instanceof DocumentFormat)
out.writeByte(IppValueTag.MIME_MEDIA_TYPE);
else
out.writeByte(IppValueTag.TEXT_WITHOUT_LANGUAGE);
out.writeShort(name.length());
out.write(name.getBytes());
out.writeShort(attribute.getValue().length());
out.write(attribute.getValue().getBytes());
}
项目:freeVM
文件:GDIClient.java
public Object getDefaultAttributeValue(Class category) {
if (category.equals(JobName.class)) {
return new JobName("Java GDI client print job", Locale.US);
} else if (category.equals(RequestingUserName.class)) {
return new RequestingUserName(System.getProperty("user.name"),
Locale.US);
} else if (category.equals(Destination.class)) {
File file = new File(System.getProperty("user.dir") +
File.separator + "output.prn");
return new Destination(file.toURI());
} else if (category.equals(SheetCollate.class)) {
return SheetCollate.COLLATED;
} else if (category.equals(Copies.class)) {
return new Copies(1);
}
return null;
}
项目:freeVM
文件:ServiceUIDialog.java
void fillUserNameField() {
boolean flg =
myService.isAttributeCategorySupported(RequestingUserName.class);
userNameTxt.setEnabled(flg);
userNameLabel.setEnabled(flg);
if (firstUse && attrs.containsKey(RequestingUserName.class)) {
userNameTxt.setText(((TextSyntax)
attrs.get(RequestingUserName.class)).getValue());
}
if (flg && (userNameTxt.getText().length() <= 0)) {
RequestingUserName defaul = (RequestingUserName) (myService
.getDefaultAttributeValue(RequestingUserName.class));
userNameTxt.setText(defaul==null ? "" : (String) (defaul.getValue()));
}
}
项目:freeVM
文件:CUPSClient.java
private Object[] getDefaultAttributeValueEx(Class category) {
if (Destination.class.isAssignableFrom(category)) {
return new Object[0];
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName(
(String) AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty("user.name");
}
}), Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Java print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Java print document",
Locale.US) };
}
return null;
}
项目:freeVM
文件:CUPSClient.java
private Object[] getSupportedAttributeValuesEx(Class category,
DocFlavor flavor) {
if (Destination.class.isAssignableFrom(category)) {
String ms = flavor.getMediaSubtype();
if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
|| ms.equalsIgnoreCase("png")
|| ms.equalsIgnoreCase("postscript")
|| flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
try {
return new Object[] { new Destination(new URI(
"file:///foo/bar")) };
} catch (URISyntaxException e) {
// return empty array - values are not supported
return new Object[0];
}
}
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName("I.A.Muser", Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Foo print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Foo document", Locale.US) };
}
return null;
}
项目:freeVM
文件:GDIClient.java
public Object getDefaultAttributeValue(Class category) {
if (category.equals(JobName.class)) {
return new JobName("Java GDI client print job", Locale.US);
} else if (category.equals(RequestingUserName.class)) {
return new RequestingUserName(System.getProperty("user.name"),
Locale.US);
} else if (category.equals(Destination.class)) {
File file = new File(System.getProperty("user.dir") +
File.separator + "output.prn");
return new Destination(file.toURI());
} else if (category.equals(SheetCollate.class)) {
return SheetCollate.COLLATED;
} else if (category.equals(Copies.class)) {
return new Copies(1);
}
return null;
}
项目:freeVM
文件:ServiceUIDialog.java
void fillUserNameField() {
boolean flg =
myService.isAttributeCategorySupported(RequestingUserName.class);
userNameTxt.setEnabled(flg);
userNameLabel.setEnabled(flg);
if (firstUse && attrs.containsKey(RequestingUserName.class)) {
userNameTxt.setText(((TextSyntax)
attrs.get(RequestingUserName.class)).getValue());
}
if (flg && (userNameTxt.getText().length() <= 0)) {
RequestingUserName defaul = (RequestingUserName) (myService
.getDefaultAttributeValue(RequestingUserName.class));
userNameTxt.setText(defaul==null ? "" : (String) (defaul.getValue()));
}
}
项目:freeVM
文件:CUPSClient.java
private Object[] getDefaultAttributeValueEx(Class category) {
if (Destination.class.isAssignableFrom(category)) {
return new Object[0];
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName(
(String) AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty("user.name");
}
}), Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Java print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Java print document",
Locale.US) };
}
return null;
}
项目:freeVM
文件:CUPSClient.java
private Object[] getSupportedAttributeValuesEx(Class category,
DocFlavor flavor) {
if (Destination.class.isAssignableFrom(category)) {
String ms = flavor.getMediaSubtype();
if (ms.equalsIgnoreCase("gif") || ms.equalsIgnoreCase("jpeg")
|| ms.equalsIgnoreCase("png")
|| ms.equalsIgnoreCase("postscript")
|| flavor.getClass() == DocFlavor.SERVICE_FORMATTED.class) {
try {
return new Object[] { new Destination(new URI(
"file:///foo/bar")) };
} catch (URISyntaxException e) {
// return empty array - values are not supported
return new Object[0];
}
}
} else if (RequestingUserName.class.isAssignableFrom(category)) {
return new Object[] { new RequestingUserName("I.A.Muser", Locale.US) };
} else if (JobName.class.isAssignableFrom(category)) {
return new Object[] { new JobName("Foo print job", Locale.US) };
} else if (DocumentName.class.isAssignableFrom(category)) {
return new Object[] { new DocumentName("Foo document", Locale.US) };
}
return null;
}
项目:JuggleMasterPro
文件:PrintJobAttributesSubJPanel.java
final public void focusLost(FocusEvent objPfocusEvent) {
final Object objLsourceObject = objPfocusEvent.getSource();
if (objLsourceObject == this.objGjobNameJTextField) {
this.objGprintJDialog.getAttributes().add(new JobName(this.objGjobNameJTextField.getText(), Locale.getDefault()));
} else if (objLsourceObject == this.objGuserNameJTextField) {
this.objGprintJDialog.getAttributes().add(new RequestingUserName(this.objGuserNameJTextField.getText(), Locale.getDefault()));
}
}
项目:javify
文件:PrinterDialog.java
private void updateTextfields(FocusEvent event)
{
if (event.getSource() == jobname_tf)
atts.add(new JobName(jobname_tf.getText(), null));
else
atts.add(new RequestingUserName(username_tf.getText(), null));
}
项目:jvm-stm
文件:PrinterDialog.java
private void updateTextfields(FocusEvent event)
{
if (event.getSource() == jobname_tf)
atts.add(new JobName(jobname_tf.getText(), null));
else
atts.add(new RequestingUserName(username_tf.getText(), null));
}
项目:cn1
文件:WinPrintService.java
public Object getDefaultAttributeValue(
final Class<? extends Attribute> category) {
checkArgs(category, null);
final DevmodeStructWrapper dm = getDefaultPrinterProps();
if (JobName.class.equals(category)) {
return DEFAULT_JOB_NAME;
} else if (RequestingUserName.class.equals(category)) {
return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
null);
} else if (Destination.class.equals(category)) {
File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
+ File.separator + "output.prn"); //$NON-NLS-1$
return new Destination(file.toURI());
} else if (OrientationRequested.class.equals(category)) {
return dm.getOrientation();
} else if (Paper.class.equals(category)) {
return getDefaultPaper();
} else if (Media.class.equals(category)) {
return getDefaultPaper().getSize().getMediaSizeName();
} else if (MediaSize.class.equals(category)) {
return getDefaultPaper().getSize();
} else if (PrintQuality.class.equals(category)) {
return dm.getPrintQuality();
} else if (Sides.class.equals(category)) {
return dm.getSides();
} else if (Copies.class.equals(category)) {
return dm.getCopies();
} else if (SheetCollate.class.equals(category)) {
return dm.getCollate();
} else if (PrinterResolution.class.equals(category)) {
return dm.getPrinterResolution();
} else if (Chromaticity.class.equals(category)) {
return dm.getChromaticity();
}
return null;
}
项目:cn1
文件:GDIClient.java
public Class[] getSupportedAttributeCategories() {
ArrayList supportedCategories = new ArrayList();
if (getCopiesSupported(serviceName) >= 1) {
supportedCategories.add(Copies.class);
}
if (getSidesSupported(serviceName)) {
supportedCategories.add(Sides.class);
}
if (getSupportedMediaSizeNames() != null) {
supportedCategories.add(Media.class);
}
if (getResolutionsSupported(serviceName) != null) {
supportedCategories.add(PrinterResolution.class);
}
if (getOrientationSupported(serviceName)) {
supportedCategories.add(OrientationRequested.class);
}
if (getCollateSupported(serviceName)) {
supportedCategories.add(SheetCollate.class);
}
supportedCategories.add(Chromaticity.class);
supportedCategories.add(JobName.class);
supportedCategories.add(RequestingUserName.class);
supportedCategories.add(Destination.class);
Class[] categories = new Class[supportedCategories.size()];
supportedCategories.toArray(categories);
return categories;
}
项目:cn1
文件:ServiceUIDialog.java
private void updateUserName() {
if (userNameTxt.isEnabled()) {
String name = userNameTxt.getText();
if (name.length() == 0) {
removeAttribute(RequestingUserName.class);
} else {
newAttrs.add(new RequestingUserName(name, Locale.getDefault()));
}
} else {
removeAttribute(RequestingUserName.class);
}
}
项目:cn1
文件:CUPSClient.java
private void getSupportedAttributeCategoriesEx(ArrayList clazz) {
if (!clazz.contains(Destination.class)) {
clazz.add(Destination.class);
}
if (!clazz.contains(RequestingUserName.class)) {
clazz.add(RequestingUserName.class);
}
if (!clazz.contains(JobName.class)) {
clazz.add(JobName.class);
}
if (!clazz.contains(DocumentName.class)) {
clazz.add(DocumentName.class);
}
}
项目:JamVM-PH
文件:PrinterDialog.java
private void updateTextfields(FocusEvent event)
{
if (event.getSource() == jobname_tf)
atts.add(new JobName(jobname_tf.getText(), null));
else
atts.add(new RequestingUserName(username_tf.getText(), null));
}
项目:classpath
文件:PrinterDialog.java
private void updateTextfields(FocusEvent event)
{
if (event.getSource() == jobname_tf)
atts.add(new JobName(jobname_tf.getText(), null));
else
atts.add(new RequestingUserName(username_tf.getText(), null));
}
项目:freeVM
文件:GDIClient.java
public Class[] getSupportedAttributeCategories() {
ArrayList supportedCategories = new ArrayList();
if (getCopiesSupported(serviceName) >= 1) {
supportedCategories.add(Copies.class);
}
if (getSidesSupported(serviceName)) {
supportedCategories.add(Sides.class);
}
if (getSupportedMediaSizeNames() != null) {
supportedCategories.add(Media.class);
}
if (getResolutionsSupported(serviceName) != null) {
supportedCategories.add(PrinterResolution.class);
}
if (getOrientationSupported(serviceName)) {
supportedCategories.add(OrientationRequested.class);
}
if (getCollateSupported(serviceName)) {
supportedCategories.add(SheetCollate.class);
}
supportedCategories.add(Chromaticity.class);
supportedCategories.add(JobName.class);
supportedCategories.add(RequestingUserName.class);
supportedCategories.add(Destination.class);
Class[] categories = new Class[supportedCategories.size()];
supportedCategories.toArray(categories);
return categories;
}
项目:freeVM
文件:ServiceUIDialog.java
private void updateUserName() {
if (userNameTxt.isEnabled()) {
String name = userNameTxt.getText();
if (name.length() == 0) {
removeAttribute(RequestingUserName.class);
} else {
newAttrs.add(new RequestingUserName(name, Locale.getDefault()));
}
} else {
removeAttribute(RequestingUserName.class);
}
}
项目:freeVM
文件:CUPSClient.java
private void getSupportedAttributeCategoriesEx(ArrayList clazz) {
if (!clazz.contains(Destination.class)) {
clazz.add(Destination.class);
}
if (!clazz.contains(RequestingUserName.class)) {
clazz.add(RequestingUserName.class);
}
if (!clazz.contains(JobName.class)) {
clazz.add(JobName.class);
}
if (!clazz.contains(DocumentName.class)) {
clazz.add(DocumentName.class);
}
}
项目:freeVM
文件:WinPrintService.java
public Object getDefaultAttributeValue(
final Class<? extends Attribute> category) {
checkArgs(category, null);
final DevmodeStructWrapper dm = getDefaultPrinterProps();
if (JobName.class.equals(category)) {
return DEFAULT_JOB_NAME;
} else if (RequestingUserName.class.equals(category)) {
return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
null);
} else if (Destination.class.equals(category)) {
File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
+ File.separator + "output.prn"); //$NON-NLS-1$
return new Destination(file.toURI());
} else if (OrientationRequested.class.equals(category)) {
return dm.getOrientation();
} else if (Paper.class.equals(category)) {
return getDefaultPaper();
} else if (Media.class.equals(category)) {
return getDefaultPaper().getSize().getMediaSizeName();
} else if (MediaSize.class.equals(category)) {
return getDefaultPaper().getSize();
} else if (PrintQuality.class.equals(category)) {
return dm.getPrintQuality();
} else if (Sides.class.equals(category)) {
return dm.getSides();
} else if (Copies.class.equals(category)) {
return dm.getCopies();
} else if (SheetCollate.class.equals(category)) {
return dm.getCollate();
} else if (PrinterResolution.class.equals(category)) {
return dm.getPrinterResolution();
} else if (Chromaticity.class.equals(category)) {
return dm.getChromaticity();
}
return null;
}
项目:freeVM
文件:GDIClient.java
public Class[] getSupportedAttributeCategories() {
ArrayList supportedCategories = new ArrayList();
if (getCopiesSupported(serviceName) >= 1) {
supportedCategories.add(Copies.class);
}
if (getSidesSupported(serviceName)) {
supportedCategories.add(Sides.class);
}
if (getSupportedMediaSizeNames() != null) {
supportedCategories.add(Media.class);
}
if (getResolutionsSupported(serviceName) != null) {
supportedCategories.add(PrinterResolution.class);
}
if (getOrientationSupported(serviceName)) {
supportedCategories.add(OrientationRequested.class);
}
if (getCollateSupported(serviceName)) {
supportedCategories.add(SheetCollate.class);
}
supportedCategories.add(Chromaticity.class);
supportedCategories.add(JobName.class);
supportedCategories.add(RequestingUserName.class);
supportedCategories.add(Destination.class);
Class[] categories = new Class[supportedCategories.size()];
supportedCategories.toArray(categories);
return categories;
}
项目:freeVM
文件:ServiceUIDialog.java
private void updateUserName() {
if (userNameTxt.isEnabled()) {
String name = userNameTxt.getText();
if (name.length() == 0) {
removeAttribute(RequestingUserName.class);
} else {
newAttrs.add(new RequestingUserName(name, Locale.getDefault()));
}
} else {
removeAttribute(RequestingUserName.class);
}
}
项目:freeVM
文件:CUPSClient.java
private void getSupportedAttributeCategoriesEx(ArrayList clazz) {
if (!clazz.contains(Destination.class)) {
clazz.add(Destination.class);
}
if (!clazz.contains(RequestingUserName.class)) {
clazz.add(RequestingUserName.class);
}
if (!clazz.contains(JobName.class)) {
clazz.add(JobName.class);
}
if (!clazz.contains(DocumentName.class)) {
clazz.add(DocumentName.class);
}
}
项目:javify
文件:IppPrintService.java
/**
* @see javax.print.PrintService#getDefaultAttributeValue(java.lang.Class)
*/
public Object getDefaultAttributeValue(Class<? extends Attribute> category)
{
// required attributes
if (category.equals(Fidelity.class))
return Fidelity.FIDELITY_FALSE;
if (category.equals(JobName.class))
return JOB_NAME;
if (category.equals(RequestingUserName.class))
return REQUESTING_USER_NAME;
// optional attributes
if (category.equals(JobPriority.class)
&& printerAttr.containsKey(JobPriorityDefault.class))
return getPrinterDefaultAttribute(JobPriorityDefault.class);
if (category.equals(JobHoldUntil.class)
&& printerAttr.containsKey(JobHoldUntilDefault.class))
return getPrinterDefaultAttribute(JobHoldUntilDefault.class);
if (category.equals(JobSheets.class)
&& printerAttr.containsKey(JobSheetsDefault.class))
return getPrinterDefaultAttribute(JobSheetsDefault .class);
if (category.equals(MultipleDocumentHandling.class)
&& printerAttr.containsKey(MultipleDocumentHandlingDefault.class))
return getPrinterDefaultAttribute(MultipleDocumentHandlingDefault.class);
if (category.equals(Copies.class)
&& printerAttr.containsKey(CopiesDefault.class))
return getPrinterDefaultAttribute(CopiesDefault.class);
if (category.equals(Finishings.class)
&& printerAttr.containsKey(FinishingsDefault.class))
return getPrinterDefaultAttribute(FinishingsDefault.class);
if (category.equals(Sides.class)
&& printerAttr.containsKey(SidesDefault.class))
return getPrinterDefaultAttribute(SidesDefault.class);
if (category.equals(NumberUp.class)
&& printerAttr.containsKey(NumberUpDefault.class))
return getPrinterDefaultAttribute(NumberUpDefault.class);
if (category.equals(OrientationRequested.class)
&& printerAttr.containsKey(OrientationRequestedDefault.class))
return getPrinterDefaultAttribute(OrientationRequestedDefault.class);
if (category.equals(Media.class)
&& printerAttr.containsKey(MediaDefault.class))
return getPrinterDefaultAttribute(MediaDefault.class);
if (category.equals(PrinterResolution.class)
&& printerAttr.containsKey(PrinterResolutionDefault.class))
return getPrinterDefaultAttribute(PrinterResolutionDefault.class);
if (category.equals(PrintQuality.class)
&& printerAttr.containsKey(PrintQualityDefault.class))
return getPrinterDefaultAttribute(PrintQualityDefault.class);
if (category.equals(Compression.class)
&& printerAttr.containsKey(CompressionSupported.class))
return Compression.NONE;
if (category.equals(PageRanges.class))
return new PageRanges(1, Integer.MAX_VALUE);
return null;
}
项目:javify
文件:IppPrintService.java
/**
* @see javax.print.PrintService#getSupportedAttributeCategories()
*/
public Class<?>[] getSupportedAttributeCategories()
{
Set<Class<? extends Attribute>> categories =
new HashSet<Class<? extends Attribute>>();
// Should only be job template attributes as of section 4.2
if (printerAttr.containsKey(JobPrioritySupported.class))
categories.add(JobPriority.class);
if (printerAttr.containsKey(JobHoldUntilSupported.class))
categories.add(JobHoldUntil.class);
if (printerAttr.containsKey(JobSheetsSupported.class))
categories.add(JobSheets.class);
if (printerAttr.containsKey(MultipleDocumentHandlingSupported.class))
categories.add(MultipleDocumentHandling.class);
if (printerAttr.containsKey(CopiesSupported.class))
categories.add(Copies.class);
if (printerAttr.containsKey(FinishingsSupported.class))
{
// if only none finishing is supported - it does not count as supported
Set<FinishingsSupported> set = getPrinterAttributeSet(FinishingsSupported.class);
if (! (set.size() == 1 && set.contains(FinishingsSupported.NONE)))
categories.add(Finishings.class);
}
if (printerAttr.containsKey(PageRangesSupported.class))
categories.add(PageRanges.class);
if (printerAttr.containsKey(SidesSupported.class))
categories.add(Sides.class);
if (printerAttr.containsKey(NumberUpSupported.class))
categories.add(NumberUp.class);
if (printerAttr.containsKey(OrientationRequestedSupported.class))
categories.add(OrientationRequested.class);
if (printerAttr.containsKey(MediaSupported.class))
categories.add(Media.class);
if (printerAttr.containsKey(PrinterResolutionSupported.class))
categories.add(PrinterResolution.class);
if (printerAttr.containsKey(PrintQualitySupported.class))
categories.add(PrintQuality.class);
// Chromaticity, Destination, MediaPrintableArea,
// SheetCollate, PresentationDirection - not IPP attributes
// attributes outside section 4.2
if (printerAttr.containsKey(CompressionSupported.class))
categories.add(Compression.class);
if (printerAttr.containsKey(JobImpressionsSupported.class))
categories.add(JobImpressions.class);
if (printerAttr.containsKey(JobKOctetsSupported.class))
categories.add(JobKOctets.class);
if (printerAttr.containsKey(JobMediaSheetsSupported.class))
categories.add(JobMediaSheets.class);
// always supported as required by IPP specification
categories.add(Fidelity.class);
categories.add(JobName.class);
categories.add(RequestingUserName.class);
return categories.toArray(new Class[categories.size()]);
}
项目:jvm-stm
文件:IppPrintService.java
/**
* @see javax.print.PrintService#getDefaultAttributeValue(java.lang.Class)
*/
public Object getDefaultAttributeValue(Class category)
{
// required attributes
if (category.equals(Fidelity.class))
return Fidelity.FIDELITY_FALSE;
if (category.equals(JobName.class))
return JOB_NAME;
if (category.equals(RequestingUserName.class))
return REQUESTING_USER_NAME;
// optional attributes
if (category.equals(JobPriority.class)
&& printerAttr.containsKey(JobPriorityDefault.class))
return getPrinterDefaultAttribute(JobPriorityDefault.class);
if (category.equals(JobHoldUntil.class)
&& printerAttr.containsKey(JobHoldUntilDefault.class))
return getPrinterDefaultAttribute(JobHoldUntilDefault.class);
if (category.equals(JobSheets.class)
&& printerAttr.containsKey(JobSheetsDefault.class))
return getPrinterDefaultAttribute(JobSheetsDefault .class);
if (category.equals(MultipleDocumentHandling.class)
&& printerAttr.containsKey(MultipleDocumentHandlingDefault.class))
return getPrinterDefaultAttribute(MultipleDocumentHandlingDefault.class);
if (category.equals(Copies.class)
&& printerAttr.containsKey(CopiesDefault.class))
return getPrinterDefaultAttribute(CopiesDefault.class);
if (category.equals(Finishings.class)
&& printerAttr.containsKey(FinishingsDefault.class))
return getPrinterDefaultAttribute(FinishingsDefault.class);
if (category.equals(Sides.class)
&& printerAttr.containsKey(SidesDefault.class))
return getPrinterDefaultAttribute(SidesDefault.class);
if (category.equals(NumberUp.class)
&& printerAttr.containsKey(NumberUpDefault.class))
return getPrinterDefaultAttribute(NumberUpDefault.class);
if (category.equals(OrientationRequested.class)
&& printerAttr.containsKey(OrientationRequestedDefault.class))
return getPrinterDefaultAttribute(OrientationRequestedDefault.class);
if (category.equals(Media.class)
&& printerAttr.containsKey(MediaDefault.class))
return getPrinterDefaultAttribute(MediaDefault.class);
if (category.equals(PrinterResolution.class)
&& printerAttr.containsKey(PrinterResolutionDefault.class))
return getPrinterDefaultAttribute(PrinterResolutionDefault.class);
if (category.equals(PrintQuality.class)
&& printerAttr.containsKey(PrintQualityDefault.class))
return getPrinterDefaultAttribute(PrintQualityDefault.class);
if (category.equals(Compression.class)
&& printerAttr.containsKey(CompressionSupported.class))
return Compression.NONE;
if (category.equals(PageRanges.class))
return new PageRanges(1, Integer.MAX_VALUE);
return null;
}
项目:jvm-stm
文件:IppPrintService.java
/**
* @see javax.print.PrintService#getSupportedAttributeCategories()
*/
public Class[] getSupportedAttributeCategories()
{
Set categories = new HashSet();
// Should only be job template attributes as of section 4.2
if (printerAttr.containsKey(JobPrioritySupported.class))
categories.add(JobPriority.class);
if (printerAttr.containsKey(JobHoldUntilSupported.class))
categories.add(JobHoldUntil.class);
if (printerAttr.containsKey(JobSheetsSupported.class))
categories.add(JobSheets.class);
if (printerAttr.containsKey(MultipleDocumentHandlingSupported.class))
categories.add(MultipleDocumentHandling.class);
if (printerAttr.containsKey(CopiesSupported.class))
categories.add(Copies.class);
if (printerAttr.containsKey(FinishingsSupported.class))
{
// if only none finishing is supported - it does not count as supported
Set set = getPrinterAttributeSet(FinishingsSupported.class);
if (! (set.size() == 1 && set.contains(FinishingsSupported.NONE)))
categories.add(Finishings.class);
}
if (printerAttr.containsKey(PageRangesSupported.class))
categories.add(PageRanges.class);
if (printerAttr.containsKey(SidesSupported.class))
categories.add(Sides.class);
if (printerAttr.containsKey(NumberUpSupported.class))
categories.add(NumberUp.class);
if (printerAttr.containsKey(OrientationRequestedSupported.class))
categories.add(OrientationRequested.class);
if (printerAttr.containsKey(MediaSupported.class))
categories.add(Media.class);
if (printerAttr.containsKey(PrinterResolutionSupported.class))
categories.add(PrinterResolution.class);
if (printerAttr.containsKey(PrintQualitySupported.class))
categories.add(PrintQuality.class);
// Chromaticity, Destination, MediaPrintableArea,
// SheetCollate, PresentationDirection - not IPP attributes
// attributes outside section 4.2
if (printerAttr.containsKey(CompressionSupported.class))
categories.add(Compression.class);
if (printerAttr.containsKey(JobImpressionsSupported.class))
categories.add(JobImpressions.class);
if (printerAttr.containsKey(JobKOctetsSupported.class))
categories.add(JobKOctets.class);
if (printerAttr.containsKey(JobMediaSheetsSupported.class))
categories.add(JobMediaSheets.class);
// always supported as required by IPP specification
categories.add(Fidelity.class);
categories.add(JobName.class);
categories.add(RequestingUserName.class);
return (Class[]) categories.toArray(new Class[categories.size()]);
}
项目:jpexs-decompiler
文件:PDFPrinterJob.java
@Override
public String getUserName() {
return ((TextSyntax) attributes.get(RequestingUserName.class))
.getValue();
}
项目:cn1
文件:PSPrinterJob.java
public String getUserName() {
return attrs.containsKey(RequestingUserName.class)
? ((RequestingUserName)(attrs.get(RequestingUserName.class))).
getValue()
: null;
}
项目:cn1
文件:GetUnsupportedAttributesTest.java
public void testIsAttributeValueSupported() throws Exception {
System.out
.println("============= START GetUnsupportedAttributesTest ================");
PrintService[] services;
DocFlavor[] flavors = new DocFlavor[] { DocFlavor.INPUT_STREAM.GIF,
DocFlavor.INPUT_STREAM.POSTSCRIPT,
DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII };
services = PrintServiceLookup.lookupPrintServices(null, null);
TestUtil.checkServices(services);
if (services.length > 0) {
for (int i = 0, ii = services.length; i < ii; i++) {
System.out.println("----------- " + services[i].getName()
+ "----------");
URI uri = null;
try {
uri = new URI("file:///c:/no/such/dir/print.out");
//uri = File.createTempFile("xxx", null).toURI();
} catch (URISyntaxException e) {
fail();
}
AttributeSet attrs = new HashAttributeSet();
attrs.add(Finishings.EDGE_STITCH);
attrs.add(MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
attrs.add(new Destination(uri));
attrs.add(new DocumentName("Doc X", Locale.US));
attrs.add(new JobName("Job Y", Locale.US));
attrs.add(new RequestingUserName("User Z", Locale.US));
for (int j = 0; j < flavors.length; j++) {
if (services[i].isDocFlavorSupported(flavors[j])) {
AttributeSet aset = services[i]
.getUnsupportedAttributes(flavors[j], attrs);
if (aset == null) {
fail("At least one attribute is unsupported");
}
if (aset != null) {
Attribute[] aarr = aset.toArray();
System.out
.println("Usupported attributes fo DocFlavor "
+ flavors[j]);
for (int k = 0, kk = aarr.length; k < kk; k++) {
System.out.println("\t" + aarr[k]);
}
}
}
}
}
}
System.out
.println("============= END GetUnsupportedAttributesTest ================");
}
项目:cn1
文件:PrinterJobImpl.java
@Override
public String getUserName() {
final RequestingUserName name = (RequestingUserName) attributes
.get(RequestingUserName.class);
return name != null ? name.getValue() : null;
}