mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-04 15:14:49 +00:00
Initial version based on previous work. (Version alpha 7)
This commit is contained in:
63
trunk/libsrc/jpproxy/src/com/jpexs/proxy/Replacement.java
Normal file
63
trunk/libsrc/jpproxy/src/com/jpexs/proxy/Replacement.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.jpexs.proxy;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Replacement of URL with local file
|
||||
*/
|
||||
public class Replacement {
|
||||
|
||||
/**
|
||||
* URL pattern, can contain * wild-cards
|
||||
*/
|
||||
public String urlPattern;
|
||||
/**
|
||||
* Filename to replace content with
|
||||
*/
|
||||
public String targetFile;
|
||||
/**
|
||||
* Date of last accesing this url
|
||||
*/
|
||||
public Calendar lastAccess;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param urlPattern URL pattern, can contain * wild-cards
|
||||
* @param targetFile Filename to replace content with
|
||||
*/
|
||||
public Replacement(String urlPattern, String targetFile) {
|
||||
this.urlPattern = urlPattern;
|
||||
this.targetFile = targetFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when urlPattern matches specified url
|
||||
*
|
||||
* @param url Url to test match
|
||||
* @return True when matches
|
||||
*/
|
||||
public boolean matches(String url) {
|
||||
String pat = Pattern.quote(urlPattern);
|
||||
pat = pat.replace("*", "\\E.*\\Q");
|
||||
return Pattern.matches(pat, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object.
|
||||
*
|
||||
* @return a string representation of the object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
if (lastAccess == null) {
|
||||
return " " + urlPattern;
|
||||
} else {
|
||||
return format.format(lastAccess.getTime()) + " " + urlPattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user