Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.xmlcalabash.extensions;
 
Created by IntelliJ IDEA. User: ndw Date: Oct 8, 2008 Time: 7:44:07 AM To change this template use File | Settings | File Templates.
public class GetCookies extends DefaultStep {
    private static final QName _cookies = new QName("","cookies");
    private static final QName _domain = new QName("","domain");
    private static final QName _name = new QName("","name");
    private static final QName _value = new QName("","value");
    private static final QName _path = new QName("","path");
    private static final QName _expires = new QName("","expires");
    private static final QName _version = new QName("""version");
    private static final QName _secure = new QName("","secure");
    private static final QName c_cookies = new QName("c"."cookies");
    private static final QName c_cookie = new QName("c"."cookie");
    private static DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    private WritablePipe result = null;

    
Creates a new instance of Identity
    public GetCookies(XProcRuntime runtimeXAtomicStep step) {
        super(runtime,step);
    }
    public void setOutput(String portWritablePipe pipe) {
         = pipe;
    }
    public void reset() {
        .resetWriter();
    }
    public void run() throws SaxonApiException {
        super.run();
        String cookieKey = getOption().getString();
        TreeWriter tree = new TreeWriter();
        tree.startDocument(.getNode().getBaseURI());
        tree.addStartElement();
        tree.startContent();
        for (Cookie cookie : .getCookies(cookieKey)) {
            tree.addStartElement();
            tree.addAttribute(cookie.getName());
            tree.addAttribute(cookie.getValue());
            tree.addAttribute(cookie.getDomain());
            tree.addAttribute(cookie.getPath());
            //tree.addAttribute(_secure, cookie.getSecure() ? "true" : "false");
            //tree.addAttribute(_version, ""+cookie.getVersion());
            Date date = cookie.getExpiryDate();
            if (date != null) {
                String iso = .format(date);
                // Insert the damn colon in the timezone
                iso = iso.substring(0,22) + ":" + iso.substring(22);
                tree.addAttribute(iso);
                Date today = new Date();
                
            }
            tree.startContent();
            String comment = cookie.getComment();
            if (comment != null) {
                tree.addText(comment);
            }
            tree.addEndElement();
        }
        tree.addEndElement();
        tree.endDocument();
        .write(tree.getResult());
    }
New to GrepCode? Check out our FAQ X