org.apache.felix.inventory.Format Maven / Gradle / Ivy
Show all versions of aem-sdk-api Show documentation
/*
* 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.felix.inventory;
/**
* Java 1.4 compatible enumeration of formats used for inventory printing.
*
* {@link InventoryPrinter} services indicate supported formats listing any of
* these values in their {@link InventoryPrinter#FORMAT} service
* properties.
*
* Requestors of inventory printing indicate the desired output format by
* specifying the respective constant when calling the
* {@link InventoryPrinter#print(java.io.PrintWriter, Format, boolean)} method.
*
* Round-tripping is guaranteed between the {@link #toString()} and
* {@link #valueOf(String)} methods.
*/
public final class Format
{
/**
* Inventory is printed in plain text format.
*/
public static Format TEXT = new Format("TEXT");
/**
* Inventory is printed in HTML format.
*
* Technically the output is expected to be an HTML fragment which is
* intended to be inserted into any block element, such as {@code
},
* within a HTML {@code }.
*/
public static Format HTML = new Format("HTML");
/**
* Inventory is printed in JSON format.
*
* The output is expected to be a valid JSON object. That is, the output
* must start with an opening curly brace ({
) and end with a
* closing curly brace (}
).
*/
public static Format JSON = new Format("JSON");
private final String format;
private Format(final String format)
{
this.format = format;
}
/**
* Converts the given {@code format} string into an instance of
* this class.
*
* @param format The string value to be converted into a {@code Format}.
* @return One of the defined {@code Format} constants or {@code null}.
*/
public static Format valueOf(final String format)
{
if (TEXT.format.equalsIgnoreCase(format))
{
return TEXT;
}
else if (HTML.format.equalsIgnoreCase(format))
{
return HTML;
}
else if (JSON.format.equalsIgnoreCase(format))
{
return JSON;
}
return null;
}
/**
* Returns the string value of this format.
*/
public String toString()
{
return format;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy