util.java

来自「欢迎使用 FastJsp 开发框架! 编译说明: * 若要生成Api J」· Java 代码 · 共 192 行

JAVA
192
字号
// Copyright 2005-2007 onetsoft.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.onetsoft.fastjsp.util;

import com.onetsoft.fastjsp.ApplicationRuntimeException;
import com.onetsoft.fastjsp.PageModule;
import com.onetsoft.fastjsp.ExceptionHandler;
import com.onetsoft.fastjsp.Link;
import com.onetsoft.fastjsp.request.UploadFile;
import com.onetsoft.fastjsp.request.multipart.MultipartDecoder;
import com.onetsoft.fastjsp.valid.Validator;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;

/**
 * @author <a href="mailto:hgw@onetsoft.com">hgw</a>
 */
public class Util {

    public final static PageModule[] EMPTY_PAGE_MODULES_ARRAY = new PageModule[0];

    public final static PageModule EMPTY_PAGE_MODULE = new PageModule() {
        public int hashCode() {
            return 1;
        }

        public boolean equals(Object obj) {
            PageModule o = (PageModule) obj;
            return o != null && this.getHrefChild().equals(o.getHrefChild());
        }

        public String getHrefChild() {
            return StringUtils.EMPTY;
        }

        public String getPackageChild() {
            return StringUtils.EMPTY;
        }

        public String getTemplateChild() {
            return StringUtils.EMPTY;
        }

        public Map getI18nStrings(Locale locale) {
            return Collections.EMPTY_MAP;
        }

        public Class getDefaultPage() {
            return null;
        }

        public ExceptionHandler getExceptionHandler() {
            throw new UnsupportedOperationException();
        }
    };

    public final static MultipartDecoder EMPTY_DECODER = new MultipartDecoder() {

        private UploadFile[] EMPTY_FILES = new UploadFile[0];

        public HttpServletRequest decode(HttpServletRequest request) throws ApplicationRuntimeException {
            throw new UnsupportedOperationException();
        }

        public UploadFile getFileUpload(String parameterName) {
            return null;
        }

        public UploadFile[] getFileUploads() {
            return EMPTY_FILES;
        }

        public void cleanup() {
            /*ignored*/
        }
    };

    public final static Validator[] EMPTY_VALIDATORS = new Validator[0];

    public final static Link NULL_LINK = new Link() {

        public Link appendAction(String action) {
            throw new UnsupportedOperationException();
        }

        public String getURL() {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, String value) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, String value,int paramPerfered) {
          throw new UnsupportedOperationException();
        }

        public Link append(String param, long value) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, long value, int paramPerfered) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, int value) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, int value, int paramPerfered) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, double value) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, double value, int paramPerfered) {
             throw new UnsupportedOperationException();
        }

        public Link append(String param, boolean value) {
            throw new UnsupportedOperationException();
        }

        public Link append(String param, boolean value, int paramPerfered) {
          throw new UnsupportedOperationException();
        }

        public Link append(Map params) {
            throw new UnsupportedOperationException();
        }

        public Link appendAnchor(String anchorName) {
            throw new UnsupportedOperationException();
        }

        public Object clone() {
            return this;
        }
    };


    public static Reader getReader(InputStream stream, String enc) throws UnsupportedEncodingException {
        return new InputStreamReader(new BufferedInputStream(stream), enc);
    }

/*
public final static IValidationDelegate EMPTY_DELEGATE = new IValidationDelegate() {

    public boolean isError() {
        return false;
    }

    public boolean isError(String field) {
        return false;
    }

    public String getMessage(String field) {
        return StringUtils.EMPTY;
    }

    public String[] getI18nStrings() {
        return StringUtils.EMPTY_ARRAY;
    }

    public void validate() {

    }

    public void executeValidate(ICycle cycle) {
        throw new UnsupportedOperationException();
    }
};*/

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?