mirror of https://github.com/sipwise/jitsi.git
parent
08618c6ab7
commit
7b861b5cf5
@ -1,4 +1,4 @@
|
||||
package net.java.sip.communicator.impl.resources;
|
||||
package net.java.sip.communicator.impl.fileaccess;
|
||||
|
||||
import org.ungoverned.gravity.servicebinder.GenericActivator;
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
Bundle-Activator: net.java.sip.communicator.impl.fileaccess.Activator
|
||||
Bundle-Name: File Access Service Provider
|
||||
Bundle-Description: A bundle that implements the file access package.
|
||||
Bundle-Vendor: sip-communicator.org
|
||||
Bundle-Version: 0.0.1
|
||||
Import-Package: org.ungoverned.gravity.servicebinder,
|
||||
org.osgi.framework,
|
||||
net.java.sip.communicator.service.configuration,
|
||||
net.java.sip.communicator.service.fileaccess,
|
||||
net.java.sip.communicator.impl.fileaccess,
|
||||
org.w3c.dom,
|
||||
org.xml.sax,
|
||||
javax.xml.parsers,
|
||||
org.apache.xml.serializer,
|
||||
javax.xml.transform,
|
||||
javax.xml.transform.dom,
|
||||
javax.xml.transform.stream,
|
||||
net.java.sip.communicator.util,
|
||||
net.java.sip.communicator.util.xml,
|
||||
Export-Package: net.java.sip.communicator.service.fileaccess,
|
||||
net.java.sip.communicator.impl.fileaccess,
|
||||
Metadata-Location: /net/java/sip/communicator/impl/fileaccess/fileaccess.metadata.xml
|
||||
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<bundle>
|
||||
<component class="net.java.sip.communicator.impl.resources.FileAccessServiceImpl">
|
||||
<provides service="net.java.sip.communicator.service.resources.FileAccessService"/>
|
||||
<component class="net.java.sip.communicator.impl.fileaccess.FileAccessServiceImpl">
|
||||
<provides service="net.java.sip.communicator.service.fileaccess.FileAccessService"/>
|
||||
|
||||
<!--
|
||||
One and only one reference to a configuration service is needed.
|
||||
@ -1,22 +0,0 @@
|
||||
Bundle-Activator: net.java.sip.communicator.impl.resources.Activator
|
||||
Bundle-Name: Resources Management Service Provider
|
||||
Bundle-Description: A bundle that implements the resource management package.
|
||||
Bundle-Vendor: sip-communicator.org
|
||||
Bundle-Version: 0.0.1
|
||||
Import-Package: org.ungoverned.gravity.servicebinder,
|
||||
org.osgi.framework,
|
||||
net.java.sip.communicator.service.configuration,
|
||||
net.java.sip.communicator.service.resources,
|
||||
net.java.sip.communicator.impl.resources,
|
||||
org.w3c.dom,
|
||||
org.xml.sax,
|
||||
javax.xml.parsers,
|
||||
org.apache.xml.serializer,
|
||||
javax.xml.transform,
|
||||
javax.xml.transform.dom,
|
||||
javax.xml.transform.stream,
|
||||
net.java.sip.communicator.util,
|
||||
net.java.sip.communicator.util.xml,
|
||||
Export-Package: net.java.sip.communicator.service.resources,
|
||||
net.java.sip.communicator.impl.resources,
|
||||
Metadata-Location: /net/java/sip/communicator/impl/resources/resources.metadata.xml
|
||||
@ -1,124 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* The base class for all enumerated types. One uses this class by extending it
|
||||
* and defining "static final" constants, like this:
|
||||
*
|
||||
* <code>
|
||||
* public class Color extends EnumerationBase {
|
||||
*
|
||||
* public static final Color Red = new Color("Red");
|
||||
* public static final Color Blue = new Color("Blue");
|
||||
* public static final Color Green = new Color("Green");
|
||||
*
|
||||
* protected Color(String description) {
|
||||
* super(description);
|
||||
* }
|
||||
*
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* Note: always compare the enum constants with <code>equals</code>, because
|
||||
* serialization and multiple class loaders can cause alot of hard to trace bugs
|
||||
*
|
||||
* For more information on the issue see
|
||||
*
|
||||
* @link http://www.javaworld.com/javaworld/javatips/jw-javatip122.html and
|
||||
* @link http://www.javaworld.com/javaworld/javatips/jw-javatip133.html
|
||||
*
|
||||
* @author Alexander Pelov
|
||||
*/
|
||||
public abstract class EnumerationBase {
|
||||
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Constructs an enumeration element
|
||||
*
|
||||
* @param description
|
||||
* The description of this element. Should be unique
|
||||
*/
|
||||
protected EnumerationBase(String description) {
|
||||
Assert.assertNonNull(description, "Enumeration description should be non-null");
|
||||
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method searches through all static fields defined in a class
|
||||
* which are of type derived from EnumerationBase and returns the one whose
|
||||
* description matches the desired one. It is the "inverse" of toString.
|
||||
*
|
||||
* Typical usage:
|
||||
* WeekdaysEnumeration monday = (WeekdaysEnumeration)
|
||||
* EnumerationBase.fromString(WeekdaysEnumeration.class, "Monday");
|
||||
*
|
||||
* Note: You should test to see the exact type of the object. A "blind" cast
|
||||
* may cause an exception if the object is of a type superior to the one
|
||||
* you are testing.
|
||||
*
|
||||
* @param clazz The class whose static fields will be tested. The
|
||||
* static fields defined in it and its parents will be tested
|
||||
* for description match.
|
||||
* @param description The desired description to be matched.
|
||||
* @return The field matching the description. Null if no field matches the
|
||||
* description.
|
||||
*/
|
||||
public static EnumerationBase fromString(Class clazz,
|
||||
String description)
|
||||
{
|
||||
if(clazz == null || description == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
EnumerationBase retVal = null;
|
||||
|
||||
Field[] fields = clazz.getFields();
|
||||
|
||||
for(int i = 0; i < fields.length; i++) {
|
||||
if((Modifier.STATIC & fields[i].getModifiers()) != 0 &&
|
||||
EnumerationBase.class.isAssignableFrom(fields[i].getType()))
|
||||
{
|
||||
try {
|
||||
EnumerationBase e = (EnumerationBase)fields[i].get(null);
|
||||
if(e.descriptionEquals(description)) {
|
||||
retVal = e;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof EnumerationBase) {
|
||||
return this.description.equals(((EnumerationBase) obj).description);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean descriptionEquals(String str) {
|
||||
return this.description.equals(str);
|
||||
}
|
||||
|
||||
public boolean descriptionEqualsIgnoreCase(String str) {
|
||||
return this.description.equalsIgnoreCase(str);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,288 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* A tokenizer that takes in account the existence of " and ' and
|
||||
* does skips all delimeters enclosed in those characters.
|
||||
*
|
||||
* Thus the following string:
|
||||
*
|
||||
* <code>This is a "stupid 'hot' dog", boy!</code>
|
||||
*
|
||||
* Parsed created with the default constructor will produce the
|
||||
* following tokens:
|
||||
*
|
||||
* This is a
|
||||
* "stupid 'hot' dog",
|
||||
* boy!
|
||||
*
|
||||
* And the string:
|
||||
* <code>This is a 'smart "hot" dog', boy!</code>
|
||||
*
|
||||
* This is a
|
||||
* 'stupid "hot" dog',
|
||||
* boy!
|
||||
*
|
||||
* @author Alexander Pelov
|
||||
*
|
||||
* TODO: TEST
|
||||
*/
|
||||
public class QuoteTokenizer implements Enumeration {
|
||||
|
||||
/**
|
||||
* Delimeters defined for internal purposes.
|
||||
*/
|
||||
private static final String DELIMS = "'\"";
|
||||
|
||||
/**
|
||||
* The text to be tokenized.
|
||||
*/
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* Delimeters requested by the user.
|
||||
*/
|
||||
private String delims;
|
||||
|
||||
/**
|
||||
* The number of tokens in the text.
|
||||
*/
|
||||
private int tokens = -1;
|
||||
|
||||
/**
|
||||
* Pointer to the current tokenizer position.
|
||||
*/
|
||||
private int currentTokenEnd = -1;
|
||||
|
||||
/**
|
||||
* Return the delimeters?
|
||||
*/
|
||||
private boolean returnDelim;
|
||||
|
||||
/**
|
||||
* Constructs a tokenizer using spaces and tabs as delimeters,
|
||||
* not returning the delimeters as tokens.
|
||||
*
|
||||
* @param text The text to be tokenized
|
||||
*/
|
||||
public QuoteTokenizer(String text) {
|
||||
this(text, " \t");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a tokenizer using the characters specified in delims
|
||||
* as delimeters, not returning the delimeters as tokens.
|
||||
*
|
||||
* @param text The text to be tokenized
|
||||
* @param delims The delimeters in a string
|
||||
*/
|
||||
public QuoteTokenizer(String text, String delims) {
|
||||
this(text, delims, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a tokenizer using the specified delimeters, specifying
|
||||
* if the delimeters should be returned as tokens.
|
||||
*
|
||||
* @param text The text to be tokenized
|
||||
* @param delims The delimeters in a string
|
||||
* @param returnDelim Flag specifying if the delimeters should be returned
|
||||
*/
|
||||
public QuoteTokenizer(String text, String delims, boolean returnDelim) {
|
||||
this.text = text;
|
||||
this.delims = delims;
|
||||
this.returnDelim = returnDelim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of times that this tokenizer's
|
||||
* <code>nextToken</code> method can be called before it
|
||||
* generates an exception. The current position is not advanced.
|
||||
*
|
||||
* @return Returns the number of tokens remaining in the
|
||||
* string using the current delimiter set
|
||||
*/
|
||||
public int countTokens() {
|
||||
// See if the tokens were already count
|
||||
if(this.tokens == -1) {
|
||||
this.tokens = performTokenCount();
|
||||
}
|
||||
|
||||
return this.tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the same value as the <code>hasMoreTokens</code> method.
|
||||
* It exists so that this class can implement the Enumeration interface.
|
||||
*/
|
||||
public boolean hasMoreElements() {
|
||||
return this.hasMoreTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if there are more tokens available from this
|
||||
* tokenizer's string. If this method returns true, then a
|
||||
* subsequent call to nextToken with no argument will
|
||||
* successfully return a token.
|
||||
*
|
||||
* @return Returns true if and only if there is at
|
||||
* least one token in the string after the current position;
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean hasMoreTokens() {
|
||||
return this.currentTokenEnd < this.text.length();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the same value as the nextToken method, except that
|
||||
* its declared return value is Object rather than String.
|
||||
* It exists so that this class can implement the Enumeration interface.
|
||||
*
|
||||
* @return Returns the next token in the string.
|
||||
*
|
||||
* @throws Throws NoSuchElementException - if there are no more
|
||||
* tokens in this tokenizer's string.
|
||||
*/
|
||||
public Object nextElement() {
|
||||
return this.nextToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next token from this string tokenizer.
|
||||
*
|
||||
* @return Returns the next token from this string tokenizer.
|
||||
* @throws Throws NoSuchElementException - if there are no more
|
||||
* tokens in this tokenizer's string.
|
||||
*/
|
||||
public String nextToken() throws NoSuchElementException {
|
||||
if(!this.hasMoreTokens()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
int tokStart = this.getTokenStart(this.currentTokenEnd);
|
||||
int tokEnd = this.getTokenEnd(tokStart);
|
||||
|
||||
this.currentTokenEnd = tokEnd;
|
||||
return this.text.substring(tokStart, tokEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next token in this string tokenizer's string.
|
||||
* First, the set of characters considered to be delimiters
|
||||
* by this StringTokenizer object is changed to be the characters
|
||||
* in the string delim. Then the next token in the string after
|
||||
* the current position is returned. The current position is
|
||||
* advanced beyond the recognized token. The new delimiter set
|
||||
* remains the default after this call.
|
||||
*
|
||||
* @param delims - the new delimeters.
|
||||
* @return Returns the next token, after switching to the
|
||||
* new delimiter set.
|
||||
*
|
||||
* @throws Throws NoSuchElementException - if there are no more
|
||||
* tokens in this tokenizer's string.
|
||||
*/
|
||||
public String nextToken(String delims) {
|
||||
this.delims = delims;
|
||||
this.tokens = -1;
|
||||
|
||||
return this.nextToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the tokenizer.
|
||||
*/
|
||||
public void reset() {
|
||||
this.currentTokenEnd = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts the tokenizer and sets new parameters.
|
||||
*/
|
||||
public void reset(String delims, boolean returnDelim) {
|
||||
this.reset();
|
||||
this.delims = delims;
|
||||
this.returnDelim = returnDelim;
|
||||
this.tokens = -1;
|
||||
}
|
||||
|
||||
|
||||
private int performTokenCount() {
|
||||
// No; Count them
|
||||
int count = 1;
|
||||
|
||||
int tokStart = this.getTokenStart(0);
|
||||
int tokEnd = this.getTokenEnd(tokStart);
|
||||
|
||||
int textLen = this.text.length();
|
||||
while(tokEnd < textLen) {
|
||||
tokStart = this.getTokenStart(tokEnd);
|
||||
tokEnd = this.getTokenEnd(tokStart);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private int getTokenStart(int prevTokenEnd) {
|
||||
int tokenStart = prevTokenEnd;
|
||||
|
||||
if(!this.returnDelim) {
|
||||
int textLen = this.text.length();
|
||||
while(tokenStart < textLen
|
||||
&&
|
||||
this.delims.indexOf(this.text.charAt(tokenStart)) >= 0
|
||||
) {
|
||||
tokenStart++;
|
||||
}
|
||||
}
|
||||
|
||||
return tokenStart;
|
||||
}
|
||||
|
||||
private int getTokenEnd(int tokenStart) {
|
||||
return findNextDelim(tokenStart)+1;
|
||||
}
|
||||
|
||||
private int findNextDelim(int start) {
|
||||
// The end of the token
|
||||
int nextDelim;
|
||||
|
||||
// Mark if a " or ' was met
|
||||
char stringChar = 0;
|
||||
|
||||
int textLen = this.text.length();
|
||||
for(nextDelim = start; nextDelim < textLen; nextDelim++) {
|
||||
char c = this.text.charAt(nextDelim);
|
||||
|
||||
// Have we met a " or ' ?
|
||||
if(stringChar == 0) {
|
||||
// No;
|
||||
if(this.delims.indexOf(c) >= 0) {
|
||||
// Found Delim!! Quit!
|
||||
break;
|
||||
} else if(DELIMS.indexOf(c) >= 0) {
|
||||
stringChar = c;
|
||||
}
|
||||
} else {
|
||||
// Yes;
|
||||
if(c == stringChar) {
|
||||
stringChar = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nextDelim;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue