Hades
5 years ago
7 changed files with 104 additions and 2 deletions
@ -0,0 +1,36 @@
|
||||
package com.fr.design.data; |
||||
|
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/4/27 |
||||
*/ |
||||
public abstract class BasicTableDataUtils { |
||||
|
||||
private static final int LEN = 2; |
||||
|
||||
|
||||
public static boolean checkName(String name) { |
||||
if (isInValidName(name)) { |
||||
FineJOptionPane.showMessageDialog(null, |
||||
Toolkit.i18nText("Fine-Design_Basic_DataSet_Rename_Warning", name), |
||||
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
||||
FineJOptionPane.WARNING_MESSAGE); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public static boolean isInValidName(String name) { |
||||
String[] values = name.split("\\."); |
||||
if (values.length == LEN) { |
||||
return (StringUtils.isNotEmpty(values[0]) && StringUtils.isNotEmpty(values[1])) |
||||
|| (StringUtils.isEmpty(values[0]) && StringUtils.isNotEmpty(values[1])); |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.design.data; |
||||
|
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/4/27 |
||||
*/ |
||||
public class BasicTableDataUtilsTest extends TestCase { |
||||
|
||||
@Test |
||||
public void testIsInValidName() { |
||||
|
||||
boolean result1 = BasicTableDataUtils.isInValidName("a.b"); |
||||
boolean result2 = BasicTableDataUtils.isInValidName("a.b.c"); |
||||
boolean result3 = BasicTableDataUtils.isInValidName("a..b"); |
||||
boolean result4 = BasicTableDataUtils.isInValidName("a."); |
||||
boolean result5 = BasicTableDataUtils.isInValidName("a.b."); |
||||
boolean result6 = BasicTableDataUtils.isInValidName("abc"); |
||||
boolean result7 = BasicTableDataUtils.isInValidName(".abc"); |
||||
boolean result8 = BasicTableDataUtils.isInValidName(".ab.c"); |
||||
boolean result9 = BasicTableDataUtils.isInValidName("ab.c."); |
||||
boolean result10 = BasicTableDataUtils.isInValidName(".abc."); |
||||
boolean result11 = BasicTableDataUtils.isInValidName(".ab.c."); |
||||
boolean result12 = BasicTableDataUtils.isInValidName(".."); |
||||
|
||||
Assert.assertTrue(result1); |
||||
Assert.assertFalse(result2); |
||||
Assert.assertFalse(result3); |
||||
Assert.assertFalse(result4); |
||||
Assert.assertTrue(result5); |
||||
Assert.assertFalse(result6); |
||||
Assert.assertTrue(result7); |
||||
Assert.assertFalse(result8); |
||||
Assert.assertTrue(result9); |
||||
Assert.assertTrue(result10); |
||||
Assert.assertFalse(result11); |
||||
Assert.assertFalse(result12); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue