From 4982b9614516dde101c3e44c60a612b3bfd8d6fe Mon Sep 17 00:00:00 2001 From: DELL <DELL@WIN-3EOIPEE9ML1> Date: 星期三, 21 二月 2024 16:26:06 +0800 Subject: [PATCH] 新增IEDScout调试工具功能 --- iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/clientgui/databind/UnicodeStringDataBind.java | 126 +++++++++++++++++++++--------------------- 1 files changed, 63 insertions(+), 63 deletions(-) diff --git a/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/clientgui/databind/UnicodeStringDataBind.java b/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/clientgui/databind/UnicodeStringDataBind.java index fc25165..5ffc72a 100644 --- a/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/clientgui/databind/UnicodeStringDataBind.java +++ b/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/clientgui/databind/UnicodeStringDataBind.java @@ -1,63 +1,63 @@ -/* - * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors - * - * 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.openmuc.openiec61850.clientgui.databind; - -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; - -import org.openmuc.openiec61850.BdaType; -import org.openmuc.openiec61850.BdaUnicodeString; - -public class UnicodeStringDataBind extends TextFieldDataBind<BdaUnicodeString> { - - private static final Charset UTF8 = Charset.forName("UTF-8"); - - public UnicodeStringDataBind(BdaUnicodeString data) { - super(data, BdaType.UNICODE_STRING, new Utf8Filter(data.getMaxLength())); - } - - @Override - protected void resetImpl() { - inputField.setText(new String(data.getValue(), UTF8)); - } - - @Override - protected void writeImpl() { - data.setValue(UTF8.encode(inputField.getText()).array()); - } - - private static class Utf8Filter extends AbstractFilter { - private final CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder(); - private final int maxBytes; - - public Utf8Filter(int maxBytes) { - this.maxBytes = maxBytes; - } - - @Override - protected boolean test(String text) { - try { - byte[] codedString = encoder.encode(CharBuffer.wrap(text)).array(); - return codedString.length <= maxBytes; - } catch (CharacterCodingException e) { - return false; - } - } - } -} +/* + * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors + * + * 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.openmuc.openiec61850.clientgui.databind; + +import java.nio.CharBuffer; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + +import org.openmuc.openiec61850.BdaType; +import org.openmuc.openiec61850.BdaUnicodeString; + +public class UnicodeStringDataBind extends TextFieldDataBind<BdaUnicodeString> { + + private static final Charset UTF8 = Charset.forName("UTF-8"); + + public UnicodeStringDataBind(BdaUnicodeString data) { + super(data, BdaType.UNICODE_STRING, new Utf8Filter(data.getMaxLength())); + } + + @Override + protected void resetImpl() { + inputField.setText(new String(data.getValue(), UTF8)); + } + + @Override + protected void writeImpl() { + data.setValue(UTF8.encode(inputField.getText()).array()); + } + + private static class Utf8Filter extends AbstractFilter { + private final CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder(); + private final int maxBytes; + + public Utf8Filter(int maxBytes) { + this.maxBytes = maxBytes; + } + + @Override + protected boolean test(String text) { + try { + byte[] codedString = encoder.encode(CharBuffer.wrap(text)).array(); + return codedString.length <= maxBytes; + } catch (CharacterCodingException e) { + return false; + } + } + } +} -- Gitblit v1.9.1