time | Calls | line |
---|
| | 132 | function obj = validateAndAssignLabels(obj,newLabels,dimIndices,fullAssignment,fixDups,fixEmpties,fixIllegal)
|
| | 133 | import matlab.internal.datatypes.isCharString
|
| | 134 | import matlab.internal.datatypes.isCharStrings
|
| | 135 |
|
< 0.001 | 3 | 136 | if ~fullAssignment && isCharString(newLabels) && (fixEmpties || (newLabels ~= ""))
|
| | 137 | % Accept one character vector for (partial) assignment to one name, allow empty character vectors per caller.
|
| | 138 | newLabels = { newLabels };
|
< 0.001 | 3 | 139 | elseif isCharStrings(newLabels,true) && (fixEmpties || ~any((newLabels == ""),'all'))
|
| | 140 | % Accept a cellstr, allow empty character vectors per caller.
|
< 0.001 | 3 | 141 | newLabels = newLabels(:)'; % a row vector, conveniently forces any empty to 0x1
|
| | 142 | else
|
| | 143 | error(message('MATLAB:table:InvalidDimNames'));
|
< 0.001 | 3 | 144 | end
|
| | 145 |
|
< 0.001 | 3 | 146 | if fixEmpties
|
| | 147 | % Fill in empty names if allowed, and make them unique with respect
|
| | 148 | % to the other new names. If not allowed, an error was already thrown.
|
| | 149 | [newLabels,wasEmpty] = fillEmptyNames(newLabels,dimIndices);
|
| | 150 | newLabels = matlab.lang.makeUniqueStrings(newLabels,wasEmpty,namelengthmax);
|
| 3 | 151 | end
|
| | 152 |
|
< 0.001 | 3 | 153 | if fixIllegal
|
| | 154 | newLabels = obj.makeValidName(newLabels,'warn');
|
< 0.001 | 3 | 155 | else
|
< 0.001 | 3 | 156 | if obj.backwardsCompatibility % tables, for now
|
0.001 | 3 | 157 | newLabels = obj.fixLabelsForCompatibility(newLabels);
|
| | 158 | else % timetables
|
| | 159 | newLabels = obj.makeValidName(newLabels,'error');
|
< 0.001 | 3 | 160 | end
|
< 0.001 | 3 | 161 | end
|
| | 162 |
|
< 0.001 | 3 | 163 | if fixDups
|
| | 164 | % Make the new names (in their possibly modified form) unique with respect to
|
| | 165 | % each other and to existing names.
|
| | 166 | allNewLabels = obj.labels; allNewLabels(dimIndices) = newLabels;
|
| | 167 | allNewLabels = matlab.lang.makeUniqueStrings(allNewLabels,dimIndices,namelengthmax);
|
| | 168 | newLabels = allNewLabels(dimIndices);
|
< 0.001 | 3 | 169 | elseif fullAssignment
|
| | 170 | % Check that the whole set of new names is unique
|
0.001 | 3 | 171 | obj.checkDuplicateLabels(newLabels);
|
| | 172 | else
|
| | 173 | % Check that the new names do not duplicate each other or existing names.
|
| | 174 | allNewLabels = obj.labels; allNewLabels(dimIndices) = newLabels;
|
| | 175 | obj.checkDuplicateLabels(newLabels,allNewLabels,dimIndices);
|
< 0.001 | 3 | 176 | end
|
| | 177 |
|
< 0.001 | 3 | 178 | obj = obj.assignLabels(newLabels,fullAssignment,dimIndices);
|
< 0.001 | 3 | 179 | end
|
Other subfunctions in this file are not included in this listing.