All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.svws_nrw.davapi.util.icalendar.IProperty Maven / Gradle / Ivy

Go to download

Diese Bibliothek enthält die Java-Server-Definition der CalDAV und CardDAV-Schnittstelle für die Schulverwaltungssoftware in NRW

The newest version!
package de.svws_nrw.davapi.util.icalendar;

import jakarta.validation.constraints.NotNull;

/**
 * Interface für Properties von VCalendars bestehend aus Key und Value
 */
public interface IProperty {

	/** colon character */
	char COLON_CHAR = ':';

	/**
	 * getter für den Key des Properties
	 *
	 * @return der Key des Properties
	 */
	String getKey();

	/**
	 * getter für den Value des Properties
	 *
	 * @return der Value des Properties
	 */
	String getValue();

	/**
	 * Statische Methode zum Parsen eines Properties aus einem gegebenen String
	 *
	 * @param string der gegebene String des Properties
	 * @return das geparste Property
	 */
	static IProperty fromString(final String string) {
		int splitIndex = 0;
		final char[] charArray = string.toCharArray();
		int i = 0;
		while (i < charArray.length) {
			final char c = charArray[i];
			if (c == '"') {
				// skip split character for inlined strings
				do {
					i++;
				} while (charArray[i] != '"');
			}
			if (c == COLON_CHAR) {
				splitIndex = i;
				break;
			}
			i++;
		}
		final String propertyKey = string.substring(0, splitIndex);
		final String propertyValue = string.substring(splitIndex + 1);
		return new Property(propertyKey, propertyValue);
	}

	/**
	 * Gibt zurück, ob ein gegebenes IProperty den gegebenen Key und den gegebenen
	 * Value enthält
	 *
	 * @param property das Property, welches geprüft werden soll
	 * @param key      der Key gegen den das Property geprüft werden soll
	 * @param value    der Value gegen den das Property geprüft werden soll
	 * @return ob key und value in dem property enthalten sind
	 */
	static boolean isProperty(final @NotNull IProperty property, final @NotNull String key, final @NotNull String value) {
		return key.equals(property.getKey()) && value.equals(property.getValue());
	}

	/**
	 * serialisiert dieses Property am gegebenen Stringbuffer
	 *
	 * @param sb der Stringbuffer
	 */
	void serialize(StringBuilder sb);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy