-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add "how to complie pb" to readme.md * update sqlflow.proto and temporary saving * refactor jsqlflow * add test for detecting html * add comments and reduce interface functions
- Loading branch information
Showing
9 changed files
with
437 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
# SQLFlow client for Java Developers | ||
|
||
## Requirements | ||
- Java 8+ | ||
- Java 8+ | ||
|
||
## Build | ||
### Compile protobuf | ||
```shell script | ||
mvn protobuf:compile && mvn protobuf:compile-custom | ||
``` | ||
### Package | ||
```shell script | ||
mvn clean package -q | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2019 The SQLFlow Authors. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.sqlflow.client; | ||
|
||
import java.util.List; | ||
|
||
/** Interface for application callback objects to receive logs and messages from SQLFlow server. */ | ||
public interface MessageHandler { | ||
/** Handle the html format response */ | ||
void handleHTML(String html); | ||
|
||
/** Handle the log */ | ||
void handleText(String text); | ||
|
||
/** EndOfExecution */ | ||
void handleEOE(); | ||
|
||
/** Table header. */ | ||
void handleHeader(List<String> columnNames); | ||
|
||
/** | ||
* Results | ||
* | ||
* <p>TODO(weiguo): shouldn't expose `Any` | ||
*/ | ||
void handleRows(List<com.google.protobuf.Any> rows); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2019 The SQLFlow Authors. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.sqlflow.client.utils; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* Test if a string contains HTML tag. | ||
* | ||
* <p>Thanks https://ideone.com/HakdHo | ||
*/ | ||
public class HTMLDetector { | ||
private static final String TAG_START = | ||
"<\\w+((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[^'\">\\s]+))?)+\\s*|\\s*)>"; | ||
private static final String TAG_END = "</\\w+>"; | ||
private static final String TAG_SELF_CLOSING = | ||
"<\\w+((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[^'\">\\s]+))?)+\\s*|\\s*)/>"; | ||
private static final String HTML_ENTITY = "&[a-zA-Z][a-zA-Z0-9]+;"; | ||
private static final Pattern HTML_PATTERN = | ||
Pattern.compile( | ||
"(" + TAG_START + ".*" + TAG_END + ")|(" + TAG_SELF_CLOSING + ")|(" + HTML_ENTITY + ")", | ||
Pattern.DOTALL); | ||
|
||
public static boolean validate(String str) { | ||
return !StringUtils.isEmpty(str) && HTML_PATTERN.matcher(str).find(); | ||
} | ||
} |
Oops, something went wrong.