org.apache.wink.server.internal.providers.entity.html.ExpandableSectionHelper Maven / Gradle / Ivy
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.wink.server.internal.providers.entity.html;
/**
* This class will be used for the default HTML representation. The method
* defines the HTML code that will be used to start and end the expandable tag.
*/
public final class ExpandableSectionHelper {
/**
* private constructor to avoid instantiation.
*/
private ExpandableSectionHelper() {
}
/**
* The method defines the HTML code that will be used to start the
* expandable tag.
*
* @param title the title of the section
* @param id the id of the section
* @param isStateCollapsed the state of the section (true=collapsed,
* false=expanded)
* @return the HTML code of the section header
*/
public static String getFormHeaderHtml(String title, String id, boolean isStateCollapsed) {
StringBuilder stringBuilder = new StringBuilder();
String collapseStr = "-"; //$NON-NLS-1$
String expandStr = "+"; //$NON-NLS-1$
stringBuilder.append("").append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// the section header
stringBuilder
.append("\n") //$NON-NLS-1$
.append("\n") //$NON-NLS-1$
.append("\n") //$NON-NLS-1$
.append("\n") //$NON-NLS-1$
.append("\n") //$NON-NLS-1$
.append("") //$NON-NLS-1$
.append("").append(isStateCollapsed ? expandStr : collapseStr) //$NON-NLS-1$
.append("").append(" \n").append(" ").append(title) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
.append(" \n").append(" ").append("
\n").append(" \n") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
.append(" \n").append("
\n"); //$NON-NLS-1$ //$NON-NLS-2$
// the collapsed/expanded table
stringBuilder.append(" \n"); //$NON-NLS-1$ //$NON-NLS-2$
// collapse if needed
if (isStateCollapsed) {
stringBuilder.append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
return stringBuilder.toString();
}
}