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


Java DocumentName类代码示例

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


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

示例1: write

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:vilie,项目名称:javify,代码行数:34,代码来源:IppRequest.java

示例2: write

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
/**
 * 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());     
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:34,代码来源:IppRequest.java

示例3: getDocName

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
private String getDocName(final Object doc,
                final AttributeSet... attrSets) {
    Attribute name = getAttribute(DocumentName.class, attrSets);

    if (name == null) {
        name = getAttribute(JobName.class, attrSets);
    }

    if ((name == null) && (doc instanceof Component)) {
        Component c = (Component) doc;

        while (c != null) {
            if (c instanceof Frame) {
                if (((Frame) c).getTitle().length() > 0) {
                    return ((Frame) c).getTitle();
                }
            }
            c = c.getParent();
        }
    }

    return name != null ? ((TextSyntax) name).getValue()
                    : WinPrintService.DEFAULT_JOB_NAME.getValue();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:WinPrintJob.java

示例4: getDefaultAttributeValueEx

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:CUPSClient.java

示例5: getSupportedAttributeValuesEx

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:CUPSClient.java

示例6: getSupportedAttributeCategoriesEx

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
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);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:CUPSClient.java

示例7: testIsAttributeValueSupported

import javax.print.attribute.standard.DocumentName; //导入依赖的package包/类
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 ================");
}
 
开发者ID:shannah,项目名称:cn1,代码行数:57,代码来源:GetUnsupportedAttributesTest.java


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