Package com.alibaba.citrus.util.templatelite

Examples of com.alibaba.citrus.util.templatelite.Template$Location


    return b.toString();
  }

    public Location provideLocation(Location location, int index, int repetition) {
        if (location.getField() < 0)
            return new Location(location)
                .withField(index)
                .withFieldRepetition(repetition);
        if (location.getComponent() < 0)
            return new Location(location)
                .withComponent(index);
        return new Location(location)
            .withSubcomponent(index);
    }
View Full Code Here


        this.componentName = name.toString();

        URL templateResource = assertNotNull(getClass().getResource(name + ".htm"),
                                             "Could not find template for page component class: %s", className);

        template = new Template(templateResource);
    }
View Full Code Here

        String contentType = defaultIfNull(contentTypes.get(ext), DEFAULT_CONTENT_TYPE);

        if (!template) {
            io(resource.openStream(), request.getOutputStream(contentType), true, true);
        } else {
            Template tpl = new Template(resource);
            PrintWriter out = request.getWriter(contentType);

            // 对于模板文件中,${url:relativeUrl}将被转换成完整的URL
            tpl.accept(new TextWriter<PrintWriter>(out) {
                @SuppressWarnings("unused")
                public void visitUrl(String relativeUrl) {
                    out().print(request.getResourceURL(relativeUrl));
                }
            });
View Full Code Here

            super(out);
            this.value = value;
        }

        private void visitStyledValue(Template[] styledTextTemplates) {
            Template template;

            // 纯文本
            if (value instanceof TextValue) {
                template = styledTextTemplates[0];
                context().put("value", value.getText());

                template.accept(this);
            }

            // raw data
            else if (value instanceof RawValue) {
                template = styledTextTemplates[1];
                context().put("packageName", ((RawValue) value).getRawType().getPackage().getName());
                context().put("className", ClassUtil.getSimpleClassName(((RawValue) value).getRawType()));
                context().put("value", ((RawValue) value).getRawToString());

                template.accept(this);
            }

            // class name
            else if (value instanceof ClassValue) {
                template = styledTextTemplates[2];
                context().put("packageName", ((ClassValue) value).getPackageName());
                context().put("className", ((ClassValue) value).getSimpleName());

                template.accept(this);
            }

            // anchor
            else if (value instanceof AnchorValue) {
                template = styledTextTemplates[3];

                int i = 0;
                for (String name : ((AnchorValue) value).getNames()) {
                    context().put("anchorName", toId(name));
                    context().put("anchorNameDisplay", name);
                    this.withSep = i++ > 0;

                    template.accept(this);
                }
            }

            // ref to anchor
            else if (value instanceof RefValue) {
                template = styledTextTemplates[4];

                int i = 0;
                for (String name : ((RefValue) value).getNames()) {
                    context().put("refName", toId(name));
                    context().put("refNameDisplay", name);
                    this.withSep = i++ > 0;

                    template.accept(this);
                }
            }

            // unknown value
            else {
View Full Code Here

            super(out);
            this.value = value;
        }

        private void visitStyledValue(Template[] styledTextTemplates) {
            Template template;

            // ���ı�
            if (value instanceof TextValue) {
                template = styledTextTemplates[0];
                context().put("value", value.getText());

                template.accept(this);
            }

            // raw data
            else if (value instanceof RawValue) {
                template = styledTextTemplates[1];
                context().put("packageName", ((RawValue) value).getRawType().getPackage().getName());
                context().put("className", ClassUtil.getSimpleClassName(((RawValue) value).getRawType()));
                context().put("value", ((RawValue) value).getRawToString());

                template.accept(this);
            }

            // class name
            else if (value instanceof ClassValue) {
                template = styledTextTemplates[2];
                context().put("packageName", ((ClassValue) value).getPackageName());
                context().put("className", ((ClassValue) value).getSimpleName());

                template.accept(this);
            }

            // anchor
            else if (value instanceof AnchorValue) {
                template = styledTextTemplates[3];

                int i = 0;
                for (String name : ((AnchorValue) value).getNames()) {
                    context().put("anchorName", toId(name));
                    context().put("anchorNameDisplay", name);
                    this.withSep = i++ > 0;

                    template.accept(this);
                }
            }

            // ref to anchor
            else if (value instanceof RefValue) {
                template = styledTextTemplates[4];

                int i = 0;
                for (String name : ((RefValue) value).getNames()) {
                    context().put("refName", toId(name));
                    context().put("refNameDisplay", name);
                    this.withSep = i++ > 0;

                    template.accept(this);
                }
            }

            // unknown value
            else {
View Full Code Here

        this.componentName = name.toString();

        URL templateResource = assertNotNull(getClass().getResource(name + ".htm"),
                "Could not find template for page component class: %s", className);

        template = new Template(templateResource);
    }
View Full Code Here

        String contentType = defaultIfNull(contentTypes.get(ext), DEFAULT_CONTENT_TYPE);

        if (!template) {
            io(resource.openStream(), request.getOutputStream(contentType), true, true);
        } else {
            Template tpl = new Template(resource);
            PrintWriter out = request.getWriter(contentType);

            // ����ģ���ļ��У�${url:relativeUrl}����ת����������URL
            tpl.accept(new TextWriter<PrintWriter>(out) {
                @SuppressWarnings("unused")
                public void visitUrl(String relativeUrl) {
                    out().print(request.getResourceURL(relativeUrl));
                }
            });
View Full Code Here

    GeoTargeting geoTargeting = new GeoTargeting();

    // Include the US, Quebec, Canada, and the B3P Canada postal code.
    // To determine what other geographic criteria exists,
    // run GetGeoTargets.java.
    Location countryLocation = new Location();
    countryLocation.setId(2840L);

    Location regionLocation = new Location();
    regionLocation.setId(20133L);

    Location postalCodeLocation = new Location();
    postalCodeLocation.setId(9000093L);

    geoTargeting.setTargetedLocations(new Location[] {countryLocation, regionLocation,
        postalCodeLocation});

    // Exclude Chicago and the New York metro area.
    // To determine what other geographic criteria exists, run
    // GetGeoTargets.java.
    Location cityLocation = new Location();
    cityLocation.setId(1016367L);

    Location metroLocation = new Location();
    metroLocation.setId(200501L);
    geoTargeting.setExcludedLocations(new Location[] {cityLocation, metroLocation});

    // Exclude domains that are not under the network's control.
    UserDomainTargeting userDomainTargeting = new UserDomainTargeting();
    userDomainTargeting.setDomains(new String[] {"usa.gov"});
View Full Code Here

    GeoTargeting geoTargeting = new GeoTargeting();

    // Include the US, Quebec, Canada, and the B3P Canada postal code.
    // To determine what other geographic criteria exists,
    // run GetGeoTargets.java.
    Location countryLocation = new Location();
    countryLocation.setId(2840L);

    Location regionLocation = new Location();
    regionLocation.setId(20133L);

    Location postalCodeLocation = new Location();
    postalCodeLocation.setId(9000093L);

    geoTargeting.setTargetedLocations(new Location[] {countryLocation, regionLocation,
        postalCodeLocation});

    // Exclude Chicago and the New York metro area.
    // To determine what other geographic criteria exists, run
    // GetGeoTargets.java.
    Location cityLocation = new Location();
    cityLocation.setId(1016367L);

    Location metroLocation = new Location();
    metroLocation.setId(200501L);
    geoTargeting.setExcludedLocations(new Location[] {cityLocation, metroLocation});

    // Exclude domains that are not under the network's control.
    UserDomainTargeting userDomainTargeting = new UserDomainTargeting();
    userDomainTargeting.setDomains(new String[] {"usa.gov"});
View Full Code Here

    GeoTargeting geoTargeting = new GeoTargeting();

    // Include the US, Quebec, Canada, and the B3P Canada postal code.
    // To determine what other geographic criteria exists,
    // run GetGeoTargets.java.
    Location countryLocation = new Location();
    countryLocation.setId(2840L);

    Location regionLocation = new Location();
    regionLocation.setId(20133L);

    Location postalCodeLocation = new Location();
    postalCodeLocation.setId(9000093L);

    geoTargeting.setTargetedLocations(new Location[] {countryLocation, regionLocation,
        postalCodeLocation});

    // Exclude Chicago and the New York metro area.
    // To determine what other geographic criteria exists, run
    // GetGeoTargets.java.
    Location cityLocation = new Location();
    cityLocation.setId(1016367L);

    Location metroLocation = new Location();
    metroLocation.setId(200501L);
    geoTargeting.setExcludedLocations(new Location[] {cityLocation, metroLocation});

    // Exclude domains that are not under the network's control.
    UserDomainTargeting userDomainTargeting = new UserDomainTargeting();
    userDomainTargeting.setDomains(new String[] {"usa.gov"});
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.util.templatelite.Template$Location

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.