This repository was archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathAlchemyAPI_LanguageParams.java
More file actions
60 lines (49 loc) · 1.58 KB
/
Copy pathAlchemyAPI_LanguageParams.java
File metadata and controls
60 lines (49 loc) · 1.58 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.alchemyapi.api;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class AlchemyAPI_LanguageParams extends AlchemyAPI_Params {
public static final String CLEANED_OR_RAW = "cleaned_or_raw";
public static final String CLEANED = "cleaned";
public static final String RAW = "raw";
public static final String CQUERY = "cquery";
public static final String XPATH = "xpath";
private String sourceText;
private String cQuery;
private String xPath;
public String getSourceText() {
return sourceText;
}
public void setSourceText(String sourceText) {
if( !sourceText.equals(AlchemyAPI_LanguageParams.CLEANED_OR_RAW)
&& !sourceText.equals(AlchemyAPI_LanguageParams.CQUERY)
&& !sourceText.equals(AlchemyAPI_LanguageParams.XPATH))
{
throw new RuntimeException("Invalid setting " + sourceText + " for parameter sourceText");
}
this.sourceText = sourceText;
}
public String getCQuery() {
return cQuery;
}
public void setCQuery(String cQuery) {
this.cQuery = cQuery;
}
public String getXPath() {
return xPath;
}
public void setXPath(String xPath) {
this.xPath = xPath;
}
public String getParameterString(){
String retString = super.getParameterString();
try{
if(sourceText!=null) retString+="&sourceText="+sourceText;
if(cQuery!=null) retString+="&cquery="+URLEncoder.encode(cQuery,"UTF-8");
if(xPath!=null) retString+="&xpath="+URLEncoder.encode(xPath,"UTF-8");
}
catch(UnsupportedEncodingException e ){
retString = "";
}
return retString;
}
}