Package org.apache.harmony.x.print.ipp

Examples of org.apache.harmony.x.print.ipp.IppAttribute


        return attrx.toArray();
    }

    public static IppAttribute getIppByJava(Attribute attr) {
        IppAttribute a = null;
        String aname = getIppAttributeNameByClass(attr.getClass());
        byte vtag;

        if (aname != null) {
            vtag = IppDefs.getAttributeVtag(aname);

            if (vtag != -1) {
                Object o = IppAttributeUtils.getIppValue(attr, vtag);
                if (o != null) {
                    if (o instanceof Integer) {
                        a = new IppAttribute(vtag, aname,
                                ((Integer) o).intValue());
                    } else if (o instanceof String) {
                        a = new IppAttribute(vtag, aname, (String) o);
                    } else if (o instanceof byte[]) {
                        a = new IppAttribute(vtag, aname, (byte[]) o);
                    } else if (o instanceof Vector) {
                        a = new IppAttribute(vtag, aname, (Vector) o);
                    }
                }
            }
        }
View Full Code Here


                    for (int i = 0, ii = gg.size(); i < ii; i++) {
                        IppAttributeGroup g = (IppAttributeGroup) gg.get(i);
                        int ai = g.findAttribute("printer-uri-supported");

                        if (ai >= 0) {
                            IppAttribute a = (IppAttribute) g.get(ai);
                            Vector v = a.getValue();
                            if (v.size() > 0) {
                                ippservices.add(new String((byte[]) v.get(0)));
                            }
                        }
                    }
View Full Code Here

        request = new IppRequest(1, 1, IppOperation.TAG_CUPS_GET_PRINTERS,
                "utf-8", "en-us");
        agroup = request.getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
        va.add("printer-uri-supported".getBytes());
        agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                "requested-attributes", va));

        try {
            cupsuri = new URI(cups);
            c = new IppClient(cupsuri);

            response = c.request(request.getBytes());

            Vector gg = response
                    .getGroupVector(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            if (gg != null) {
                for (int i = 0, ii = gg.size(); i < ii; i++) {
                    IppAttributeGroup g = (IppAttributeGroup) gg.get(i);
                    int ai = g.findAttribute("printer-uri-supported");

                    if (ai >= 0) {
                        IppAttribute a = (IppAttribute) g.get(ai);
                        Vector v = a.getValue();
                        if (v.size() > 0) {
                            ippservices.add(new String((byte[]) v.get(0)));
                        }
                    }
                }
View Full Code Here

                request = new IppRequest(1, 1,
                        IppOperation.TAG_CUPS_GET_DEFAULT, "utf-8", "en-us");
                agroup = request
                        .getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
                va.add("printer-uri-supported".getBytes());
                agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                        "requested-attributes", va));

                response = c.request(request.getBytes());

                IppAttributeGroup g = response
                        .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
                if (g != null) {
                    int ai = g.findAttribute("printer-uri-supported");

                    if (ai >= 0) {
                        IppAttribute a = (IppAttribute) g.get(ai);
                        Vector v = a.getValue();
                        if (v.size() > 0) {
                            serviceName = new String((byte[]) v.get(0));
                            break;
                        }
                    }
                }
            } catch (URISyntaxException e) {
                //e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                //e.printStackTrace();
            }
        }
        if (serviceName != null && !serviceName.equals("")) {
            return serviceName;
        }

        String[] ippp = CUPSPrintServiceProvider.getIppPrintersByProperty();
        for (int i = 0; i < ippp.length; i++) {
            try {
                URI ippuri = new URI(ippp[i]);
                IppClient c = new IppClient(ippuri);
                IppRequest request;
                IppResponse response;
                IppAttributeGroup agroup;
                Vector va = new Vector();

                request = new IppRequest(1, 1,
                        IppOperation.GET_PRINTER_ATTRIBUTES, "utf-8", "en-us");
                agroup = request
                        .getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
                va.add("printer-uri-supported".getBytes());
                agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                        "requested-attributes", va));

                response = c.request(request.getBytes());

                IppAttributeGroup g = response
                        .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
                if (g != null) {
                    int ai = g.findAttribute("printer-uri-supported");

                    if (ai >= 0) {
                        IppAttribute a = (IppAttribute) g.get(ai);
                        Vector v = a.getValue();
                        if (v.size() > 0) {
                            serviceName = new String((byte[]) v.get(0));
                            break;
                        }
                    }
View Full Code Here

    public PrintServiceAttributeSet getAttributes() {
        synchronized (this) {
            try {
                IppResponse response;
                IppAttributeGroup agroup;
                IppAttribute attr;
                Object[] attrx = new Object[0];

                response = printer.requestPrinterDescriptionAttributes();
                agroup = response
                        .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
View Full Code Here

            IppResponse response = printer.requestPrinterAttributes();
            IppAttributeGroup agroup = response
                    .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            String aname;
            Class claz;
            IppAttribute attr;

            if (agroup != null) {
                for (int i = 0, ii = agroup.size(); i < ii; i++) {
                    attr = (IppAttribute) agroup.get(i);
                    aname = new String(attr.getName());
                    if (aname.indexOf("-supported") > 0) {
                        claz = Ipp2Java.getClassByIppAttributeName(aname
                                .substring(0, aname.indexOf("-supported")));
                        if (claz != null) {
                            clazz.add(claz);
View Full Code Here

        }
        try {
            IppResponse response = printer.requestPrinterAttributes();
            IppAttributeGroup agroup = response
                    .getGroup(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            IppAttribute attr;
            String aname;
            int andex;

            if (agroup != null) {
                aname = Ipp2Java.getIppAttributeNameByClass(category);
View Full Code Here

                    "CUPSClient.java: getSupportedAttributeValues(): agroup: "
                            + agroup.toString());
            if (agroup != null) {
                int aind = agroup.findAttribute(aname);
                if (aind >= 0) {
                    IppAttribute attr = (IppAttribute) agroup.get(aind);
                    vals = Ipp2Java.getJavaByIpp(attr);
                }
            }
            doVerbose(1, "CUPSClient.java: getSupportedAttributeValues(): 1");
            // Make right type/value for return
View Full Code Here

                    for (int i = 0, ii = gg.size(); i < ii; i++) {
                        IppAttributeGroup g = (IppAttributeGroup) gg.get(i);
                        int ai = g.findAttribute("printer-uri-supported");

                        if (ai >= 0) {
                            IppAttribute a = (IppAttribute) g.get(ai);
                            Vector v = a.getValue();
                            if (v.size() > 0) {
                                ippservices.add(new String((byte[]) v.get(0)));
                            }
                        }
                    }
View Full Code Here

        request = new IppRequest(1, 1, IppOperation.TAG_CUPS_GET_PRINTERS,
                "utf-8", "en-us");
        agroup = request.getGroup(IppAttributeGroup.TAG_OPERATION_ATTRIBUTES);
        va.add("printer-uri-supported".getBytes());
        agroup.add(new IppAttribute(IppAttribute.TAG_KEYWORD,
                "requested-attributes", va));

        try {
            cupsuri = new URI(cups);
            c = new IppClient(cupsuri);

            response = c.request(request.getBytes());

            Vector gg = response
                    .getGroupVector(IppAttributeGroup.TAG_GET_PRINTER_ATTRIBUTES);
            if (gg != null) {
                for (int i = 0, ii = gg.size(); i < ii; i++) {
                    IppAttributeGroup g = (IppAttributeGroup) gg.get(i);
                    int ai = g.findAttribute("printer-uri-supported");

                    if (ai >= 0) {
                        IppAttribute a = (IppAttribute) g.get(ai);
                        Vector v = a.getValue();
                        if (v.size() > 0) {
                            ippservices.add(new String((byte[]) v.get(0)));
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.harmony.x.print.ipp.IppAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.