updated common code

pull/11/head
Stefan Feuerhahn 7 years ago
parent c0fb912326
commit d0caa66dc4

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850; package com.beanit.openiec61850;
public class HexConverter { public class HexConverter {
@ -89,8 +102,8 @@ public class HexConverter {
public static String toShortHexString(byte[] bytes, int offset, int length) { public static String toShortHexString(byte[] bytes, int offset, int length) {
char[] hexChars = new char[length * 2]; char[] hexChars = new char[length * 2];
for (int j = offset; j < (offset + length); j++) { for (int j = 0; j < length; j++) {
int v = bytes[j] & 0xff; int v = bytes[j + offset] & 0xff;
hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0f]; hexChars[j * 2 + 1] = hexArray[v & 0x0f];
} }

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal; package com.beanit.openiec61850.internal;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public class Action { public class Action {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public final class ActionException extends Exception { public final class ActionException extends Exception {

@ -1,8 +1,21 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public interface ActionListener { public interface ActionListener {
public void actionCalled(String actionKey) throws ActionException, FatalActionException; void actionCalled(String actionKey) throws ActionException;
public void quit(); void quit();
} }

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
import static java.lang.System.exit; import static java.lang.System.exit;
@ -82,11 +95,7 @@ public class ActionProcessor {
return; return;
} }
try { actionListener.actionCalled(actionKey);
actionListener.actionCalled(actionKey);
} catch (ActionException e) {
System.err.println(e.getMessage() + "\n");
}
} }
} catch (Exception e) { } catch (Exception e) {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public abstract class CliParameter { public abstract class CliParameter {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
import java.util.List; import java.util.List;

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public final class CliParseException extends Exception { public final class CliParseException extends Exception {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
import java.util.ArrayList; import java.util.ArrayList;

@ -1,22 +0,0 @@
package com.beanit.openiec61850.internal.cli;
public final class FatalActionException extends Exception {
private static final long serialVersionUID = -8134353678567694515L;
public FatalActionException() {
super();
}
public FatalActionException(String s) {
super(s);
}
public FatalActionException(Throwable cause) {
super(cause);
}
public FatalActionException(String s, Throwable cause) {
super(s, cause);
}
}

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public class FlagCliParameter extends CliParameter { public class FlagCliParameter extends CliParameter {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public class IntCliParameter extends ValueCliParameter { public class IntCliParameter extends ValueCliParameter {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public class LongCliParameter extends ValueCliParameter { public class LongCliParameter extends ValueCliParameter {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
public class StringCliParameter extends ValueCliParameter { public class StringCliParameter extends ValueCliParameter {

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
import java.util.ArrayList; import java.util.ArrayList;

@ -1,3 +1,16 @@
/*
* Copyright 2018 beanit
*
* 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 com.beanit.openiec61850.internal.cli; package com.beanit.openiec61850.internal.cli;
abstract class ValueCliParameter extends CliParameter { abstract class ValueCliParameter extends CliParameter {

Loading…
Cancel
Save