Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 73f377613127e440d31aa8b7911a07ab0bcb615f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
 * Copyright (c) 2005, 2006 Erkki Lindpere and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Erkki Lindpere - initial API and implementation
 *******************************************************************************/
package org.eclipse.ecf.internal.provider.vbulletin.identity;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.ecf.internal.bulletinboard.commons.util.IDUtil;

public class ThreadID extends VBID {

	private static final long serialVersionUID = 6005970691318023633L;

	public ThreadID(VBNamespace namespace, URI uri)
			throws URISyntaxException {
		super(namespace, uri);
	}

	public ThreadID(VBNamespace namespace, URL baseURL, long longValue)
			throws URISyntaxException {
		super(namespace, IDUtil.composeURI(baseURL, "showthread.php?t="
				+ longValue));
	}

	public long getLongValue() {
		Matcher m = Pattern.compile("showthread.php\\?(?:.*?)t=([0-9]+)")
				.matcher(uri.toString());
		if (m.find()) {
			return Long.parseLong(m.group(1));
		}
		return -1;
	}
}

Back to the top