Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright 2011 Google Inc.
 * 
 * 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.
 */

public class Main {
    /**
     * Verify that the basic constraints of a {@link SafeStyles} are met. This
     * method is not a guarantee that the specified css is safe for use in a CSS
     * style attribute. It is a minimal set of assertions to check for common
     * errors.
     * 
     * @param styles the CSS properties string
     * @throws NullPointerException if the css is null
     * @throws AssertionError if the css does not meet the contraints
     */
    static void verifySafeStylesConstraints(String styles) {
        if (styles == null) {
            throw new NullPointerException("css is null");
        }

        // CSS properties must end in a semi-colon or they cannot be safely
        // composed with other properties.
        assert ((styles.trim().length() == 0) || styles.endsWith(";")) : "Invalid CSS Property: '" + styles
                + "'. CSS properties must be an empty string or end with a semi-colon (;).";
        assert !styles.contains("<") && !styles.contains(">") : "Invalid CSS Property: '" + styles
                + "'. CSS should not contain brackets (< or >).";
    }
}